homebrew-core/Formula/jsoncpp.rb
2015-07-16 08:14:34 -07:00

57 lines
1.9 KiB
Ruby

class Jsoncpp < Formula
desc "Library for interacting with JSON"
homepage "https://github.com/open-source-parsers/jsoncpp"
url "https://github.com/open-source-parsers/jsoncpp/archive/0.10.4.tar.gz"
sha256 "87c42cc93d5242f3b81574a47f5003f247a27b5d0130753aaf3d8447666d653e"
bottle do
cellar :any
sha256 "7e41500ac30f3f84145096e1550d31659476d3473b66447c9f7fcd3014517ca7" => :yosemite
sha256 "19e1205cd37336a1a6b0608f47ac33672961dd6ba6d9c8680fea1e2d1fbb1d47" => :mavericks
sha256 "5911263312f4793fd7e5c61d0e25952ee27ba970637323e84805768891617f53" => :mountain_lion
end
depends_on "scons" => :build
def install
gccversion = `g++ -dumpversion`.strip
libs = buildpath/"libs/linux-gcc-#{gccversion}/"
scons "platform=linux-gcc"
system "install_name_tool", "-id", lib/"libjsoncpp.dylib", libs/"libjson_linux-gcc-#{gccversion}_libmt.dylib"
lib.install libs/"libjson_linux-gcc-#{gccversion}_libmt.dylib" => "libjsoncpp.dylib"
lib.install libs/"libjson_linux-gcc-#{gccversion}_libmt.a" =>"libjsoncpp.a"
(include/"jsoncpp").install buildpath/"include/json"
(lib/"pkgconfig/jsoncpp.pc").write <<-EOS.undent
prefix=#{prefix}
exec_prefix=${prefix}
libdir=#{lib}
includedir=#{include}
Name: jsoncpp
Description: API for manipulating JSON
Version: #{version}
URL: https://github.com/open-source-parsers/jsoncpp
Libs: -L${libdir} -ljsoncpp
Cflags: -I${includedir}/jsoncpp/
EOS
end
test do
(testpath/"test.cpp").write <<-EOS.undent
#include <json/json.h>
int main() {
Json::Value root;
Json::Reader reader;
return reader.parse("[1, 2, 3]", root) ? 0: 1;
}
EOS
system ENV.cxx, "test.cpp", "-o", "test",
"-I#{include}/jsoncpp",
"-L#{lib}",
"-ljsoncpp"
system "./test"
end
end