72 lines
2.3 KiB
Ruby
72 lines
2.3 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.8.8.tar.gz"
|
|
sha256 "ef39c4f38c80eaec5655aa7708df8103915730bd1dd11e03eaa7efb5ddc8dece"
|
|
revision 1
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "23761cbbaca28a92e4f61e106af7394f2a0fc317b01fa08e69636fc9e645424d" => :high_sierra
|
|
sha256 "3aa8b02ae49aed546b3fd919a73f4db30fc1721ecf22d521e3677a77624c916b" => :sierra
|
|
sha256 "3559b3efa01cc7f8827c0fbd5adffd69b0ddf0722744e793689d1553ad5f9522" => :el_capitan
|
|
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
|
|
|
|
needs :cxx11
|
|
|
|
# Upstream PR from 2 Dec 2017 "Only use lib64 directory on Linux"
|
|
# See https://github.com/googlei18n/libphonenumber/issues/2044
|
|
patch do
|
|
url "https://github.com/googlei18n/libphonenumber/pull/2045.patch?full_index=1"
|
|
sha256 "4d47d0f92c994ca74e3bbbf020064b2d249d0b01f93bf6f5d82736eb9ed3aa43"
|
|
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 <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
|