xmake.lua 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package("libnpy-matajoh")
  2. set_homepage("https://github.com/matajoh/libnpy")
  3. set_description("C++ library for reading and writing of numpy's .npy files")
  4. set_license("MIT")
  5. add_urls("https://github.com/matajoh/libnpy/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/matajoh/libnpy.git")
  7. add_versions("v1.5.3", "27f6ce7136fe9d4bc823b98585e21f5cd8c27b72d634afa9d613cd4101e6aff1")
  8. add_patches("v1.5.3", "patches/v1.5.3/fix.diff", "a1db18e4615ece28b6ef0c7e3befcca8bdd696191b983968843ba69213c1d77f")
  9. add_includedirs("include", "include/npy")
  10. add_deps("cmake")
  11. add_deps("miniz")
  12. on_install(function (package)
  13. os.rm("doc", "src/miniz")
  14. local configs = {}
  15. if package:config("shared") and package:is_plat("windows") then
  16. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  17. end
  18. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  19. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  20. import("package.tools.cmake").install(package, configs)
  21. end)
  22. on_test(function (package)
  23. assert(package:check_cxxsnippets({test = [[
  24. #include <tensor.h>
  25. #include <npy.h>
  26. #include <npz.h>
  27. void test() {
  28. std::vector<size_t> shape({65, 12, 8});
  29. npy::tensor<std::uint8_t> color(shape);
  30. npy::save("color.npy", color);
  31. npy::onpzstream output("test.npz");
  32. }
  33. ]]}, {configs = {languages = "c++17"}}))
  34. end)