xmake.lua 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package("rapidjson")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/Tencent/rapidjson")
  4. set_description("RapidJSON is a JSON parser and generator for C++.")
  5. set_license("MIT")
  6. set_urls("https://github.com/Tencent/rapidjson/archive/refs/tags/$(version).zip",
  7. "https://github.com/Tencent/rapidjson.git", {submodules = false})
  8. add_versions("2025.02.05", "24b5e7a8b27f42fa16b96fc70aade9106cf7102f")
  9. add_versions("2024.08.16", "7c73dd7de7c4f14379b781418c6e947ad464c818")
  10. add_versions("2023.12.6", "6089180ecb704cb2b136777798fa1be303618975")
  11. add_versions("2022.7.20", "27c3a8dc0e2c9218fe94986d249a12b5ed838f1d")
  12. add_versions("v1.1.0", "8e00c38829d6785a2dfb951bb87c6974fa07dfe488aa5b25deec4b8bc0f6a3ab")
  13. -- This commit is used in arrow 7.0.0 https://github.com/apache/arrow/blob/release-7.0.0/cpp/thirdparty/versions.txt#L80
  14. add_versions("v1.1.0-arrow", "1a803826f1197b5e30703afe4b9c0e7dd48074f5")
  15. add_configs("cmake", {description = "Use cmake build system", default = true, type = "boolean"})
  16. on_load(function (package)
  17. if package:config("cmake") then
  18. package:add("deps", "cmake")
  19. end
  20. if package:is_plat("windows") and package:is_arch("arm.*") then
  21. package:add("defines", "RAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN")
  22. end
  23. end)
  24. on_install(function (package)
  25. if package:config("cmake") then
  26. local configs = {
  27. "-DRAPIDJSON_BUILD_DOC=OFF",
  28. "-DRAPIDJSON_BUILD_EXAMPLES=OFF",
  29. "-DRAPIDJSON_BUILD_TESTS=OFF",
  30. }
  31. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  32. import("package.tools.cmake").install(package, configs)
  33. else
  34. os.cp("include/*", package:installdir("include"))
  35. end
  36. end)
  37. on_test(function (package)
  38. assert(package:check_cxxsnippets({test = [[
  39. void test()
  40. {
  41. const char* json = "{\"project\":\"rapidjson\",\"stars\":10}";
  42. rapidjson::Document d;
  43. d.Parse(json);
  44. rapidjson::StringBuffer buffer;
  45. rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
  46. d.Accept(writer);
  47. }
  48. ]]}, {configs = {languages = "c++11"}, includes = { "rapidjson/document.h", "rapidjson/stringbuffer.h", "rapidjson/writer.h"} }))
  49. end)