class Libphonenumber < Formula desc "C++ Phone Number library by Google" homepage "https://github.com/google/libphonenumber" url "https://github.com/google/libphonenumber/archive/v8.10.22.tar.gz" sha256 "1d43a94502c875cb44f9bd464c5898bca6db9a54e18288892921e985268a3fb4" bottle do cellar :any sha256 "02a7480553852b3e66e73252b77f42cff6d36ef6640595ef86c0bd729e77770c" => :catalina sha256 "7814613669b4ef858e276d1c8151fa622c6abff8ee91706b8080e3e6f1e43471" => :mojave sha256 "47ff666ce7a2c2aa6370d24d72c62634d4e2cfcc128931c8f3a47096ca114d2b" => :high_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