xmake.lua 2.1 KB

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