From eba6f6ef131e4545e0f91643e11e9aecfcd372e9 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 4 Nov 2020 22:41:26 +0800 Subject: [PATCH] fix jsoncpp --- packages/c/cmake/xmake.lua | 2 +- packages/j/jsoncpp/xmake.lua | 85 +++++++++++++++++------------------- 2 files changed, 40 insertions(+), 47 deletions(-) diff --git a/packages/c/cmake/xmake.lua b/packages/c/cmake/xmake.lua index d8f4d39ec..ab009b1b8 100644 --- a/packages/c/cmake/xmake.lua +++ b/packages/c/cmake/xmake.lua @@ -13,7 +13,7 @@ package("cmake") add_versions("3.11.4", "2b5eb705f036b1906a5e0bce996e9cd56d43d73bdee8318ece3e5ce31657b812") add_versions("3.15.4", "adfbf611d21daa83b9bf6d85ab06a455e481b63a38d6e1270d563b03d4e5f829") add_versions("3.18.4", "9d27049660474cf134ab46fa0e0db771b263313fcb8ba82ee8b2d1a1a62f8f20") - elseif is_host("linux") and is_arch("x86_64") then + elseif is_host("linux") and os.arch() == "x86_64" then add_urls("https://cmake.org/files/v$(version)-Linux-x86_64.tar.gz", {version = function (version) return table.concat(table.slice((version):split('%.'), 1, 2), '.') .. "/cmake-" .. version end}) diff --git a/packages/j/jsoncpp/xmake.lua b/packages/j/jsoncpp/xmake.lua index 0c378a7a9..9cf38a8d9 100644 --- a/packages/j/jsoncpp/xmake.lua +++ b/packages/j/jsoncpp/xmake.lua @@ -1,54 +1,47 @@ package("jsoncpp") -set_homepage("https://github.com/open-source-parsers/jsoncpp/wiki") -set_description("A C++ library for interacting with JSON.") + set_homepage("https://github.com/open-source-parsers/jsoncpp/wiki") + set_description("A C++ library for interacting with JSON.") -set_urls("https://github.com/open-source-parsers/jsoncpp/archive/$(version).zip") + set_urls("https://github.com/open-source-parsers/jsoncpp/archive/$(version).zip") -add_versions("1.9.4", "6da6cdc026fe042599d9fce7b06ff2c128e8dd6b8b751fca91eb022bce310880") + add_versions("1.9.4", "6da6cdc026fe042599d9fce7b06ff2c128e8dd6b8b751fca91eb022bce310880") -add_includedirs("include") -add_deps("cmake") -on_install("linux", "macosx", function(package) - local configs = {} - table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) - table.insert(configs, "-DDBUILD_STATIC_LIBS=" .. (package:config("static") and "ON" or "OFF")) - table.insert(configs, "-DDCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) - import("package.tools.cmake").install(package, configs) -end) + add_deps("cmake") -on_test(function(package) + on_install("linux", "macosx", "android", "iphoneos", "windows", "mingw", "cross", function(package) + local configs = {"-DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF", "-DJSONCPP_WITH_TESTS=OFF"} + table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) + table.insert(configs, "-DBUILD_STATIC_LIBS=" .. (package:config("static") and "ON" or "OFF")) + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) + import("package.tools.cmake").install(package, configs) + end) - assert(package:check_cxxsnippets({ - test = [[ - #include - #include - static void test() { - const std::string rawJson = R"({"Age": 20, "Name": "colin"})"; - const auto rawJsonLength = static_cast(rawJson.length()); - constexpr bool shouldUseOldWay = false; - JSONCPP_STRING err; - Json::Value root; - - if (shouldUseOldWay) { - Json::Reader reader; - reader.parse(rawJson, root); - } else { - Json::CharReaderBuilder builder; - const std::unique_ptr reader(builder.newCharReader()); - if (!reader->parse(rawJson.c_str(), rawJson.c_str() + rawJsonLength, &root, - &err)) ; + on_test(function(package) + assert(package:check_cxxsnippets({ + test = [[ + #include + #include + static void test() { + const std::string rawJson = R"({"Age": 20, "Name": "colin"})"; + const auto rawJsonLength = static_cast(rawJson.length()); + constexpr bool shouldUseOldWay = false; + JSONCPP_STRING err; + Json::Value root; + if (shouldUseOldWay) { + Json::Reader reader; + reader.parse(rawJson, root); + } else { + Json::CharReaderBuilder builder; + const std::unique_ptr reader(builder.newCharReader()); + if (!reader->parse(rawJson.c_str(), rawJson.c_str() + rawJsonLength, &root, + &err)) ; + } + const std::string name = root["Name"].asString(); + const int age = root["Age"].asInt(); + assert(name == "colin"); + assert(age == 20); } - const std::string name = root["Name"].asString(); - const int age = root["Age"].asInt(); - assert(name == "colin"); - assert(age == 20); - } - ]] - }, { - configs = { - languages = "c++11" - }, - includes = "json/json.h" - })) -end) + ]] + }, {configs = {languages = "c++11"}, includes = "json/json.h"})) + end)