xmake.lua 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package("upa-url")
  2. set_homepage("https://upa-url.github.io/docs/")
  3. set_description("An implementation of the WHATWG URL Standard in C++")
  4. set_license("BSD-2-Clause")
  5. add_urls("https://github.com/upa-url/upa/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/upa-url/upa.git", {submodules = false})
  7. add_versions("v2.4.0", "97a7ddf56c8b65e8b54027d01acfb4fe7b2f0f1f16ce5023d12ce5a5539718ff")
  8. add_versions("v2.3.0", "707b487534c1cb2be6bc180249b6c0fd7947758a4bca76754c0afdbda462bdba")
  9. add_versions("v2.2.0", "7b6d5e5774d0264ef2be0782ec3548e191ef113b34983323791a914a00de0d3a")
  10. add_versions("v2.1.0", "4a5edae83dc5c9a2aacfdb4720d6bce3ceff5edfb19213615b1e95a44a7793fe")
  11. add_versions("v2.0.0", "50e0d7c9cad853c794f9b12aded960dbdcf3ba6baa8bc9896da52fe526cc014e")
  12. add_versions("v1.2.0", "5d8a251ffd708a14f9faf2ea29dae934cb4b29c5473bd2bcf2e3d16eccaeacb7")
  13. add_versions("v1.0.2", "d08a724c1868530b1c0b89ebeaaf2d654f7e6489c968a3dc2255b1f21ddc94e0")
  14. add_versions("v1.0.1", "458d49c1e84063a2e38b40f5dae5ba01e618e7fba29550f9cc01bf10d04ff7a1")
  15. add_versions("v1.0.0", "9ad14357c177f7c038a447996a065995e074eb5447015467687726c5d221b5f4")
  16. add_configs("tools", {description = "Build tools", default = false, type = "boolean"})
  17. add_configs("cmake", {description = "Use cmake build system", default = true, type = "boolean"})
  18. on_load(function (package)
  19. if package:is_plat("windows") and package:config("shared") then
  20. package:config_set("cmake", false)
  21. end
  22. if package:config("cmake") then
  23. package:add("deps", "cmake")
  24. end
  25. end)
  26. on_install(function (package)
  27. if package:config("cmake") then
  28. io.replace("CMakeLists.txt", "STATIC", "", {plain = true})
  29. local configs = {"-DURL_BUILD_TESTS=OFF", "-DUPA_BUILD_TESTS=OFF"}
  30. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  31. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  32. table.insert(configs, "-DUPA_BUILD_TOOLS=" .. (package:config("tools") and "ON" or "OFF"))
  33. import("package.tools.cmake").install(package, configs)
  34. else
  35. io.writefile("xmake.lua", [[
  36. add_rules("mode.debug", "mode.release")
  37. set_languages("c++17")
  38. target("upa_url")
  39. set_kind("$(kind)")
  40. add_files("src/*.cpp")
  41. add_includedirs("include")
  42. add_headerfiles("include/(upa/*.h)")
  43. if is_plat("windows") and is_kind("shared") then
  44. add_rules("utils.symbols.export_all", {export_classes = true})
  45. end
  46. ]])
  47. import("package.tools.xmake").install(package)
  48. end
  49. end)
  50. on_test(function (package)
  51. assert(package:check_cxxsnippets({test = [[
  52. void test() {
  53. upa::url url{"https://xmake.io/"};
  54. }
  55. ]]}, {configs = {languages = "c++17"}, includes = "upa/url.h"}))
  56. end)