xmake.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package("zoe")
  2. set_homepage("https://github.com/winsoft666/zoe")
  3. set_description("C++ File Download Library.")
  4. set_license("MIT")
  5. add_urls("https://github.com/winsoft666/zoe/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/winsoft666/zoe.git")
  7. add_versions("v3.6", "5cae2a51bbac0bfa54aab78a4d2b534a66bea7bc2d72764cfb5bc8e02a751927")
  8. add_deps("cmake", "libcurl")
  9. add_configs("openssl", {description = "Enable openssl support", default = true, type = "boolean"})
  10. if is_plat("windows") then
  11. add_syslinks("ws2_32", "crypt32")
  12. elseif is_plat("linux", "bsd", "cross") then
  13. add_syslinks("pthread")
  14. end
  15. on_load(function (package)
  16. if package:config("openssl") then
  17. package:add("deps", "openssl")
  18. end
  19. if not package:config("shared") and package:is_plat("windows") then
  20. package:add("defines", "ZOE_STATIC")
  21. end
  22. end)
  23. on_install("!bsd and !wasm", function (package)
  24. if package:is_plat("cross", "android") then
  25. if package:is_plat("android") then
  26. local ndk = package:toolchain("ndk")
  27. local ndk_sdkver = ndk:config("ndk_sdkver")
  28. if tonumber(ndk_sdkver) < 24 then
  29. io.replace("src/file_util.cpp", "fseeko64", "fseeko", {plain = true})
  30. io.replace("src/file_util.cpp", "ftello64", "ftello", {plain = true})
  31. end
  32. end
  33. io.replace("src/curl_utils.h", [[#include "curl/curl.h"]], "#include <curl/curl.h>\n#include <pthread.h>", {plain = true})
  34. io.replace("src/slice.cpp", [[std::atomic_fetch_add(&disk_cache_capacity_, data_size);]],
  35. [[std::atomic_fetch_add(&disk_cache_capacity_, static_cast<int64_t>(data_size));]], {plain = true})
  36. end
  37. io.replace("CMakeLists.txt", "set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)", "include(GNUInstallDirs)\nset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})", {plain = true})
  38. io.replace("CMakeLists.txt", [[set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)]], [[set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})]], {plain = true})
  39. io.replace("CMakeLists.txt", [[set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)]], [[set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})]], {plain = true})
  40. local configs = {"-DZOE_BUILD_TESTS=OFF", "-DZOE_USE_STATIC_CRT=OFF"}
  41. table.insert(configs, "-DZOE_BUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  42. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  43. import("package.tools.cmake").install(package, configs)
  44. end)
  45. on_test(function (package)
  46. assert(package:check_cxxsnippets({test = [[
  47. void test() {
  48. zoe::Zoe::GlobalInit();
  49. }
  50. ]]}, {configs = {languages = "c++11"}, includes = "zoe/zoe.h"}))
  51. end)