class Libphonenumber < Formula desc "C++ Phone Number library by Google" homepage "https://github.com/googlei18n/libphonenumber" url "https://github.com/googlei18n/libphonenumber/archive/v8.10.7.tar.gz" sha256 "82119009a192259a71792969de74fa014be09d5667681373ef6443c80f87aa64" bottle do cellar :any sha256 "e535f7e0d8fb4ed6d92cded7092eda7f7d028879b417ee5b286f0e9bbfa2cbad" => :mojave sha256 "a31f53d539757bbe0a6a088a25f6aa6944e5997955d994a3bd5e4b56e9e24e5c" => :high_sierra sha256 "59f537e43ba4a5020087515fcf4928e1955169c15e84636c781301b904ee41bd" => :sierra end depends_on "cmake" => :build depends_on "boost" depends_on "icu4c" depends_on :java => "1.7+" depends_on "protobuf" depends_on "re2" resource "gtest" do url "https://github.com/google/googletest/archive/release-1.8.1.tar.gz" sha256 "9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c" end def install ENV.cxx11 (buildpath/"gtest").install resource("gtest") system "cmake", "cpp", "-DGTEST_SOURCE_DIR=gtest/googletest", "-DGTEST_INCLUDE_DIR=gtest/googletest/include", *std_cmake_args system "make", "install" end test do (testpath/"test.cpp").write <<~EOS #include #include #include #include using namespace i18n::phonenumbers; int main() { PhoneNumberUtil *phone_util_ = PhoneNumberUtil::GetInstance(); PhoneNumber test_number; string formatted_number; test_number.set_country_code(1); test_number.set_national_number(6502530000ULL); phone_util_->Format(test_number, PhoneNumberUtil::E164, &formatted_number); if (formatted_number == "+16502530000") { return 0; } else { return 1; } } EOS system ENV.cxx, "-std=c++11", "test.cpp", "-L#{lib}", "-lphonenumber", "-o", "test" system "./test" end end