xmake.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package("swxjson")
  2. set_homepage("https://github.com/swxlion/swxJson")
  3. set_description("A easy to use & convenient JSON library for C++11.")
  4. set_license("MIT")
  5. add_urls("https://github.com/swxlion/swxJson/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/swxlion/swxJson.git")
  7. add_versions("v1.0.9", "672c9362a13a53628469e2d7bb5cc6c976e1fa52c730ae95945c9509b0263f01")
  8. add_patches("v1.0.9", "patches/fix.diff", "99eb96c1b51ad2a216289d6011ddc980cb7f55be941e4f531584c12ace712738")
  9. on_install(function (package)
  10. io.writefile("xmake.lua", [[
  11. add_rules("mode.release", "mode.debug")
  12. target("swxjson")
  13. set_languages("c++11")
  14. set_kind("$(kind)")
  15. add_files("src/*.cpp")
  16. add_headerfiles("src/(*.h)")
  17. if is_plat("windows") and is_kind("shared") then
  18. add_rules("utils.symbols.export_all", {export_classes = true})
  19. end
  20. ]])
  21. import("package.tools.xmake").install(package)
  22. end)
  23. on_test(function (package)
  24. assert(package:check_cxxsnippets({test = [[
  25. #include <swxJson.h>
  26. using namespace swxJson;
  27. void test() {
  28. const std::string dictDemo = R"({"strDict":{"123":"aa", "456":"bb", "789":"cc"}, "intDict":{"aa":1, "bb":2, "cc":3, "dd":4, "ee":5}})";
  29. JsonPtr json = Json::parse(dictDemo.c_str());
  30. }
  31. ]]}, {configs = {languages = "c++11"}}))
  32. end)