xmake.lua 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package("flux")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://tristanbrindle.com/flux/")
  4. set_description("A C++20 library for sequence-orientated programming")
  5. set_license("BSL-1.0")
  6. add_urls("https://github.com/tcbrindle/flux/archive/refs/tags/$(version).tar.gz",
  7. "https://github.com/tcbrindle/flux.git")
  8. add_versions("v0.4.0", "95e7d9d71c9ee9e89bb24b46ccba77ddfb0a1580630c2faab0b415dacc7c8d56")
  9. add_deps("cmake")
  10. if on_check then
  11. on_check("android", function (package)
  12. local ndk = package:toolchain("ndk")
  13. local ndkver = ndk:config("ndkver")
  14. local ndk_sdkver = ndk:config("ndk_sdkver")
  15. assert(ndkver and tonumber(ndkver) > 22, "package(flux) require ndk version > 22")
  16. assert(ndk_sdkver and tonumber(ndk_sdkver) >= 24, "package(flux) require ndk api >= 24")
  17. end)
  18. on_check("windows", function (package)
  19. local vs_toolset = package:toolchain("msvc"):config("vs_toolset")
  20. if vs_toolset then
  21. local vs_toolset_ver = import("core.base.semver").new(vs_toolset)
  22. local minor = vs_toolset_ver:minor()
  23. assert(minor and minor >= 30, "package(flux) require vs_toolset >= 14.3")
  24. end
  25. end)
  26. end
  27. on_install(function (package)
  28. local configs = {"-DFLUX_BUILD_EXAMPLES=OFF", "-DFLUX_BUILD_TESTS=OFF"}
  29. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  30. import("package.tools.cmake").install(package, configs)
  31. end)
  32. on_test(function (package)
  33. assert(package:check_cxxsnippets({test = [[
  34. #include <flux.hpp>
  35. void test() {
  36. constexpr auto result = flux::from(std::array{1, 2, 3, 4, 5})
  37. .filter(flux::pred::even)
  38. .map([](int i) { return i * 2; })
  39. .sum();
  40. static_assert(result == 12);
  41. }
  42. ]]}, {configs = {languages = "c++20"}}))
  43. end)