52 lines
1.8 KiB
Ruby
52 lines
1.8 KiB
Ruby
class Gflags < Formula
|
|
desc "Library for processing command-line flags"
|
|
homepage "https://gflags.github.io/gflags/"
|
|
url "https://github.com/gflags/gflags/archive/v2.2.2.tar.gz"
|
|
sha256 "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "82fe53e7e195d7a2c72243c357c8f3120eb8fa79b06e9a1c0928849b7cf60260" => :mojave
|
|
sha256 "51a508dc83e6213a1726509c0fc1761e5b7a79b220f4c86f8ace660799caaec8" => :high_sierra
|
|
sha256 "44b0ad9e8d8ce61431d959b1c6197e121f8369acc777a8010aabce2adb8eb4db" => :sierra
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
|
|
def install
|
|
mkdir "buildroot" do
|
|
system "cmake", "..", *std_cmake_args, "-DBUILD_SHARED_LIBS=ON"
|
|
system "make", "install"
|
|
end
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.cpp").write <<~EOS
|
|
#include <iostream>
|
|
#include "gflags/gflags.h"
|
|
|
|
DEFINE_bool(verbose, false, "Display program name before message");
|
|
DEFINE_string(message, "Hello world!", "Message to print");
|
|
|
|
static bool IsNonEmptyMessage(const char *flagname, const std::string &value)
|
|
{
|
|
return value[0] != '\0';
|
|
}
|
|
DEFINE_validator(message, &IsNonEmptyMessage);
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
gflags::SetUsageMessage("some usage message");
|
|
gflags::SetVersionString("1.0.0");
|
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
|
if (FLAGS_verbose) std::cout << gflags::ProgramInvocationShortName() << ": ";
|
|
std::cout << FLAGS_message;
|
|
gflags::ShutDownCommandLineFlags();
|
|
return 0;
|
|
}
|
|
EOS
|
|
system ENV.cxx, "-L#{lib}", "-lgflags", "test.cpp", "-o", "test"
|
|
assert_match "Hello world!", shell_output("./test")
|
|
assert_match "Foo bar!", shell_output("./test --message='Foo bar!'")
|
|
end
|
|
end
|