xmake.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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("v1.0.2", "d08a724c1868530b1c0b89ebeaaf2d654f7e6489c968a3dc2255b1f21ddc94e0")
  8. add_versions("v1.0.1", "458d49c1e84063a2e38b40f5dae5ba01e618e7fba29550f9cc01bf10d04ff7a1")
  9. add_versions("v1.0.0", "9ad14357c177f7c038a447996a065995e074eb5447015467687726c5d221b5f4")
  10. add_configs("tools", {description = "Build tools", default = false, type = "boolean"})
  11. add_deps("cmake")
  12. on_install(function (package)
  13. if package:is_plat("windows") and package:config("shared") then
  14. io.writefile("xmake.lua", [[
  15. add_rules("mode.debug", "mode.release")
  16. set_languages("c++11")
  17. target("upa_url")
  18. set_kind("$(kind)")
  19. add_files("src/*.cpp")
  20. add_includedirs("include")
  21. add_headerfiles("include/(upa/*.h)")
  22. if is_plat("windows") and is_kind("shared") then
  23. add_rules("utils.symbols.export_all", {export_classes = true})
  24. end
  25. ]])
  26. import("package.tools.xmake").install(package)
  27. else
  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. end
  35. end)
  36. on_test(function (package)
  37. assert(package:check_cxxsnippets({test = [[
  38. void test() {
  39. upa::url url{"https://xmake.io/"};
  40. }
  41. ]]}, {configs = {languages = "c++11"}, includes = "upa/url.h"}))
  42. end)