homebrew-core/Formula/libphonenumber.rb
2017-07-06 06:29:53 -07:00

60 lines
2 KiB
Ruby

class Libphonenumber < Formula
desc "C++ Phone Number library by Google"
homepage "https://github.com/googlei18n/libphonenumber"
url "https://github.com/googlei18n/libphonenumber/archive/v8.6.0.tar.gz"
sha256 "64b706cd5c5784c7b9ca764ab8fb8370696ad5490200a25074bf6a61de5da631"
bottle do
cellar :any
sha256 "515e3aaa2a5eea8b6690bbc772adcd7fd8a1a3b2a3e04932663fea18bf90ec7f" => :sierra
sha256 "e6d9d4270adcd4f2e4883119111fdf29a9986f5e286c646a7620b50c8e0b1468" => :el_capitan
sha256 "591ed242b4e7fcc0c639666466e73e9dff1e62485de92780a569bf72374f84ce" => :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 <phonenumbers/phonenumberutil.h>
#include <phonenumbers/phonenumber.pb.h>
#include <iostream>
#include <string>
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