63 lines
2.0 KiB
Ruby
63 lines
2.0 KiB
Ruby
class Libphonenumber < Formula
|
|
desc "C++ Phone Number library by Google"
|
|
homepage "https://github.com/google/libphonenumber"
|
|
url "https://github.com/google/libphonenumber/archive/v8.12.8.tar.gz"
|
|
sha256 "878adbd76c5c9c51844a2b5c84509dc805be2d57b3046cda66eaf3cae5cce9e4"
|
|
license "Apache-2.0"
|
|
revision 1
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "23b9fb9a3de144f61cb12a863efbcd5ba95c89135610c6edd1adb3094f58547d" => :catalina
|
|
sha256 "5ff15a48c0cabc52605458f997adbbd174fae1cf98993eeb703628a73e1bbec0" => :mojave
|
|
sha256 "0e36618d3061b695aab28ba9ccefde1c8e4658aedeb141c2392a06a7fdb095c4" => :high_sierra
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "boost"
|
|
depends_on "icu4c"
|
|
depends_on "protobuf"
|
|
depends_on "re2"
|
|
|
|
resource "gtest" do
|
|
url "https://github.com/google/googletest/archive/release-1.10.0.tar.gz"
|
|
sha256 "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb"
|
|
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, "-std=c++11", "test.cpp", "-L#{lib}", "-lphonenumber", "-o", "test"
|
|
system "./test"
|
|
end
|
|
end
|