class Libphonenumber < Formula desc "C++ Phone Number library by Google" homepage "https://github.com/googlei18n/libphonenumber" url "https://github.com/googlei18n/libphonenumber/archive/v8.1.0.tar.gz" sha256 "ec7caa880508859da6ff0df0cd28b935abb5ae1477112eeee3f1f19eea46da4b" bottle do cellar :any sha256 "fed7ab3c60febb180192980c59cdc1b6371f6c0f1f070facb7c69fecf21f3a35" => :sierra sha256 "adf608aa55b1602f7b3c58794a382f77786e164edd6a7fe7ef6395941ae8bd37" => :el_capitan sha256 "1be75fc7518d69266fc1641062824d6bca0630de1338bddbeee81c7d2e569140" => :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://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/googletest/gtest-1.7.0.zip" sha256 "247ca18dd83f53deb1328be17e4b1be31514cedfc1e3424f672bf11fd7e0d60d" end def install (buildpath/"gtest").install resource("gtest") cd "gtest" do system "cmake", ".", *std_cmake_args system "make" end args = std_cmake_args + %W[ -DGTEST_INCLUDE_DIR:PATH=#{buildpath}/gtest/include -DGTEST_LIB:PATH=#{buildpath}/gtest/libgtest.a -DGTEST_SOURCE_DIR:PATH=#{buildpath}/gtest/src ] system "cmake", "cpp", *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