homebrew-core/Formula/libphonenumber.rb
2018-08-26 11:53:49 +02:00

64 lines
2.1 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.12.tar.gz"
sha256 "7200c2ba53fcf6bc234ccd70e83079b59090467b239d4f3bbe0cb4a0db5b95c3"
bottle do
cellar :any
sha256 "158182de4399c56f8bd84cbbdfb533053a3d6abaf6bbeb6b27a9b49a6f0a3ef0" => :mojave
sha256 "3c354f7e1b39a8ea72d14cd46d10c4156ad512747a882006dbb3dd6af8fe1868" => :high_sierra
sha256 "e67c934396cc4da6dedd945eae4e3c69301f1fe6e1d9c31a5be1a35d81cf832b" => :sierra
sha256 "e1cfd427b2cd6f9cd6b0305fced7d58a2a964337e34ed47ffe099a3fd0964039" => :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, "-std=c++11", "test.cpp", "-L#{lib}", "-lphonenumber", "-o", "test"
system "./test"
end
end