xmake.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.0.0", "50e0d7c9cad853c794f9b12aded960dbdcf3ba6baa8bc9896da52fe526cc014e")
  8. add_versions("v1.2.0", "5d8a251ffd708a14f9faf2ea29dae934cb4b29c5473bd2bcf2e3d16eccaeacb7")
  9. add_versions("v1.0.2", "d08a724c1868530b1c0b89ebeaaf2d654f7e6489c968a3dc2255b1f21ddc94e0")
  10. add_versions("v1.0.1", "458d49c1e84063a2e38b40f5dae5ba01e618e7fba29550f9cc01bf10d04ff7a1")
  11. add_versions("v1.0.0", "9ad14357c177f7c038a447996a065995e074eb5447015467687726c5d221b5f4")
  12. add_configs("tools", {description = "Build tools", default = false, type = "boolean"})
  13. add_configs("cmake", {description = "Use cmake build system", default = true, type = "boolean"})
  14. on_load(function (package)
  15. if package:is_plat("windows") and package:config("shared") then
  16. package:config_set("cmake", false)
  17. end
  18. if package:config("cmake") then
  19. package:add("deps", "cmake")
  20. end
  21. end)
  22. on_install(function (package)
  23. if package:config("cmake") then
  24. io.replace("CMakeLists.txt", "STATIC", "", {plain = true})
  25. local configs = {"-DURL_BUILD_TESTS=OFF", "-DUPA_BUILD_TESTS=OFF"}
  26. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  27. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  28. table.insert(configs, "-DUPA_BUILD_TOOLS=" .. (package:config("tools") and "ON" or "OFF"))
  29. import("package.tools.cmake").install(package, configs)
  30. else
  31. io.writefile("xmake.lua", [[
  32. add_rules("mode.debug", "mode.release")
  33. set_languages("c++17")
  34. target("upa_url")
  35. set_kind("$(kind)")
  36. add_files("src/*.cpp")
  37. add_includedirs("include")
  38. add_headerfiles("include/(upa/*.h)")
  39. if is_plat("windows") and is_kind("shared") then
  40. add_rules("utils.symbols.export_all", {export_classes = true})
  41. end
  42. ]])
  43. import("package.tools.xmake").install(package)
  44. end
  45. end)
  46. on_test(function (package)
  47. assert(package:check_cxxsnippets({test = [[
  48. void test() {
  49. upa::url url{"https://xmake.io/"};
  50. }
  51. ]]}, {configs = {languages = "c++17"}, includes = "upa/url.h"}))
  52. end)