xmake.lua 2.3 KB

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