cjson 1.7.12 (new formula)
Closes #40582. Signed-off-by: FX Coudert <fxcoudert@gmail.com>
This commit is contained in:
parent
6117f79e3d
commit
80544fa95b
1 changed files with 37 additions and 0 deletions
37
Formula/cjson.rb
Normal file
37
Formula/cjson.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
class Cjson < Formula
|
||||
desc "Ultralightweight JSON parser in ANSI C"
|
||||
homepage "https://github.com/DaveGamble/cJSON"
|
||||
url "https://github.com/DaveGamble/cJSON/archive/v1.7.12.tar.gz"
|
||||
sha256 "760687665ab41a5cff9c40b1053c19572bcdaadef1194e5cba1b5e6f824686e7"
|
||||
|
||||
depends_on "cmake" => :build
|
||||
|
||||
def install
|
||||
system "cmake", "-DENABLE_CJSON_UTILS=On", "-DENABLE_CJSON_TEST=Off", ".",
|
||||
*std_cmake_args
|
||||
system "make", "install"
|
||||
end
|
||||
|
||||
test do
|
||||
(testpath/"test.c").write <<~EOS
|
||||
#include <cjson/cJSON.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char *s = "{\\"key\\":\\"value\\"}";
|
||||
cJSON *json = cJSON_Parse(s);
|
||||
if (!json) {
|
||||
return 1;
|
||||
}
|
||||
cJSON *item = cJSON_GetObjectItem(json, "key");
|
||||
if (!item) {
|
||||
return 1;
|
||||
}
|
||||
cJSON_Delete(json);
|
||||
return 0;
|
||||
}
|
||||
EOS
|
||||
system ENV.cc, "-L#{lib}", "-lcjson", "test.c", "-o", "test"
|
||||
system "./test"
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue