xmake.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package("cista")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://cista.rocks")
  4. set_description("Cista is a simple, high-performance, zero-copy C++ serialization & reflection library.")
  5. set_license("MIT")
  6. add_urls("https://github.com/felixguendling/cista/archive/refs/tags/$(version).tar.gz",
  7. "https://github.com/felixguendling/cista.git")
  8. add_versions("v0.16", "55832c0e723568bd3abdfd70e7ba4dca777dfaada63f4da74f325f868f95694e")
  9. add_versions("v0.15", "f807d3282f68a74eed94d6e829763244ae22993169ab6ece7fd7c22bd2f08330")
  10. add_versions("v0.14", "9844a55fd3fd35a15614de01ff54e97ad0216d7b3d3952f14bfd6ebd7d6ff58f")
  11. add_deps("cmake")
  12. if on_check then
  13. on_check(function (package)
  14. if package:is_plat("android") then
  15. local ndk = package:toolchain("ndk")
  16. local ndk_sdkver = ndk:config("ndk_sdkver")
  17. assert(ndk_sdkver and tonumber(ndk_sdkver) > 21, "package(cista): need ndk api level > 21 for android")
  18. end
  19. if package:is_plat("windows") and package:is_arch("x86") then
  20. assert(package:version():lt("0.16"), "package(cista): version >= 0.16 does not support windows|x86")
  21. end
  22. end)
  23. end
  24. on_install("windows|x64", "windows|x86", "linux", "macosx", "bsd", "android", "iphoneos", "cross", function (package)
  25. import("package.tools.cmake").install(package, {"-DCISTA_INSTALL=ON"})
  26. end)
  27. on_test(function (package)
  28. assert(package:check_cxxsnippets({test = [[
  29. #include <vector>
  30. #include <cista/serialization.h>
  31. namespace data = cista::raw;
  32. struct my_struct {
  33. int a_{0};
  34. struct inner {
  35. data::string b_;
  36. } j;
  37. };
  38. void test() {
  39. std::vector<unsigned char> buf;
  40. {
  41. my_struct obj{1, {data::string{"test"}}};
  42. buf = cista::serialize(obj);
  43. }
  44. auto deserialized = cista::deserialize<my_struct>(buf);
  45. }
  46. ]]}, {configs = {languages = "c++17"}}))
  47. end)