71 lines
2.2 KiB
Ruby
71 lines
2.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.0.1.tar.gz"
|
|
sha256 "77f9824c1195f846f0e27cc7b94da7f79ec635f5343fb57afe661b73374b6260"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "5c8dd8c6e6097fcccd2a9d78100d270205f332f01f16070e8bae238787d3d052" => :sierra
|
|
sha256 "0003e281d01b11276aa49c98685c9e62d93fcb63d44273bad5f9d01711769a05" => :el_capitan
|
|
sha256 "3cd9aecad79549168d1c3591ad546fe6284020ab5d1052bfa1fa9067ebbd1e83" => :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 <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
|