xmake.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package("hyprwayland-scanner")
  2. set_kind("binary")
  3. set_homepage("https://github.com/hyprwm/hyprwayland-scanner")
  4. set_description("A Hyprland implementation of wayland-scanner, in and for C++.")
  5. set_license("BSD-3-Clause")
  6. add_urls("https://github.com/hyprwm/hyprwayland-scanner/archive/refs/tags/$(version).tar.gz",
  7. "https://github.com/hyprwm/hyprwayland-scanner.git")
  8. add_versions("v0.4.4", "ac73f626019f8d819ff79a5fca06ce4768ce8a3bded6f48c404445f3afaa25ac")
  9. if is_plat("linux") then
  10. add_extsources("pacman::hyprwayland-scanner", "apt::hyprwayland-scanner")
  11. end
  12. add_deps("pugixml")
  13. if on_check then
  14. on_check(function (package)
  15. assert(package:check_cxxsnippets({test = [[
  16. #include <format>
  17. void test() {
  18. auto f = std::format("Hello, {}!", "world");
  19. }
  20. ]]}, {configs = {languages = "c++23"}}), "package(hyprwayland-scanner) requires c++23")
  21. end)
  22. end
  23. on_install(function (package)
  24. local version = try { function() return io.readfile("VERSION"):trim() end }
  25. version = version or (package:version() and package:version_str():gsub("^v", ""))
  26. version = version or "0.0.0"
  27. io.replace("src/main.cpp", "SCANNER_VERSION", '"' .. version .. '"', {plain = true})
  28. if package:is_debug() then
  29. io.replace("src/main.cpp", "HYPRLAND_DEBUG", "1", {plain = true})
  30. end
  31. io.writefile("xmake.lua", [[
  32. add_rules("mode.debug", "mode.release")
  33. add_requires("pugixml")
  34. set_languages("c++23")
  35. target("hyprwayland-scanner")
  36. set_kind("binary")
  37. add_files("src/main.cpp")
  38. add_packages("pugixml")
  39. ]])
  40. import("package.tools.xmake").install(package)
  41. end)
  42. on_test(function (package)
  43. os.vrunv("hyprwayland-scanner" .. (package:is_plat("windows") and ".exe" or ""), {"--version"})
  44. end)