63 lines
2 KiB
Ruby
63 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.9.0.tar.gz"
|
|
sha256 "15a09cfe903e43ef2da903503bbd9bafeb06ae19b1eeaf81e3cfbaa69c103c56"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "e2416ad3812380317b1c2ffe560e1376bf7f6ac396214f820199a8ea5a29ea6b" => :high_sierra
|
|
sha256 "a2a701ccf61e3663f1d95dea1463c67ff00b89f6af5423d3c8ca2ef84ffdeecb" => :sierra
|
|
sha256 "011ce29734512dca4f14e4e52f43d5454eca2b70f117505e9d6b9160cc4d448f" => :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
|
|
|
|
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
|