class Libphonenumber < Formula desc "C++ Phone Number library by Google" homepage "https://github.com/googlei18n/libphonenumber" url "https://github.com/googlei18n/libphonenumber/archive/v8.5.0.tar.gz" sha256 "73b9348ac90fc05f2acea5cfc167ba8aacf4d5b6c4234caf65be90024ec7d5e1" bottle do cellar :any sha256 "321f2730aa8cf3d5230aedb30d4e5fe9ea770cb6a5da06a5502f63adc55b1973" => :sierra sha256 "4a2cde5213ddc1f0d4f9432dfbba410f8cc7303632f2bb701cf6674dbace00c5" => :el_capitan sha256 "09bb0e9b45c2198b188598c8c4df6e83dc8a1a3b93a397a6b24aab2c55bfe1bd" => :yosemite end depends_on "cmake" => :build depends_on :java => "1.7+" depends_on "icu4c" depends_on "protobuf" depends_on "boost" depends_on "re2" resource "gtest" do url "https://github.com/google/googletest/archive/release-1.8.0.tar.gz" sha256 "58a6f4277ca2bc8565222b3bbd58a177609e9c488e8a72649359ba51450db7d8" end def install (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.undent #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, "test.cpp", "-L#{lib}", "-lphonenumber", "-o", "test" system "./test" end end