blob: eabf6cfaea6241457d39e8da606ae85bf6aa3f5b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
require "formula"
class Jsoncpp < Formula
homepage "https://github.com/open-source-parsers/jsoncpp"
url "https://github.com/open-source-parsers/jsoncpp/archive/svn-release-0.6.0-rc2.tar.gz"
sha1 "6cc51ed1f31e742637a512201b585e0bc4e06980"
bottle do
cellar :any
sha1 "701adf90e494bfabf0bc54b9d3628fb125bd1244" => :yosemite
sha1 "c6cd33fe89d9b91c1864dc7e8158a507199c1454" => :mavericks
sha1 "d315e5fab004b81e068a624c37fb0afc6b4318b2" => :mountain_lion
end
depends_on "scons" => :build
patch :p1 do
# use the usual environment variables for the compilation flags
url "https://github.com/open-source-parsers/jsoncpp/pull/55.patch"
sha1 "d2e985a0877fc811acfb34f62713a35ba4742452"
end
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
|