xmake.lua 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package("spirv-tools")
  2. set_homepage("https://github.com/KhronosGroup/SPIRV-Tools/")
  3. set_description("SPIR-V Tools")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/KhronosGroup/SPIRV-Tools/archive/$(version).tar.gz",
  6. "https://github.com/KhronosGroup/SPIRV-Tools.git")
  7. add_versions("v2020.5", "947ee994ba416380bd7ccc1c6377ac28a4802a55ca81ccc06796c28e84c00b71")
  8. add_versions("v2020.6", "de2392682df8def7ac666a2a320cd475751badf4790b01c7391b7644ecb550a3")
  9. add_versions("v2021.3", "b6b4194121ee8084c62b20f8d574c32f766e4e9237dfe60b0658b316d19c6b13")
  10. add_versions("v2021.4", "d68de260708dda785d109ff1ceeecde2d2ab71142fa5bf59061bb9f47dd3bb2c")
  11. add_versions("v2022.2", "909fc7e68049dca611ca2d57828883a86f503b0353ff78bc594eddc65eb882b9")
  12. add_versions("v2022.4", "a156215a2d7c6c5b267933ed691877a9a66f07d75970da33ce9ad627a71389d7")
  13. add_versions("v2023.1", "f3d8245aeb89f098c01dddaa566f9c0f2aab4a3d62a9020afaeb676b5e7e64d4")
  14. add_patches("v2020.5", "https://github.com/KhronosGroup/SPIRV-Tools/commit/a1d38174b1f7d2651c718ae661886d606cb50a32.patch", "2811faeef3ad53a83e409c8ef9879badcf9dc04fc3d98dbead7313514b819933")
  15. add_deps("cmake", "spirv-headers")
  16. add_deps("python 3.x", {kind = "binary"})
  17. if is_plat("linux") then
  18. add_extsources("apt::spirv-tools", "pacman::spirv-tools")
  19. end
  20. on_fetch("macosx", function (package, opt)
  21. if opt.system then
  22. -- fix missing includedirs when the system library is found on macOS
  23. local result = package:find_package("spirv-tools")
  24. if result and not result.includedirs then
  25. for _, linkdir in ipairs(result.linkdirs) do
  26. if linkdir:startswith("/usr") then
  27. local includedir = path.join(path.directory(linkdir), "include", "spirv-tools")
  28. if os.isdir(includedir) then
  29. includedir = path.directory(includedir)
  30. result.includedirs = result.includedirs or {}
  31. table.insert(result.includedirs, includedir)
  32. end
  33. end
  34. end
  35. end
  36. return result
  37. end
  38. end)
  39. on_install(function (package)
  40. package:addenv("PATH", "bin")
  41. local configs = {"-DSPIRV_SKIP_TESTS=ON", "-DSPIRV_WERROR=OFF"}
  42. -- walkaround for potential conflict with parallel build & debug pdb generation
  43. if package:debug() then
  44. table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
  45. end
  46. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  47. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  48. local spirv = package:dep("spirv-headers")
  49. table.insert(configs, "-DSPIRV-Headers_SOURCE_DIR=" .. spirv:installdir():gsub("\\", "/"))
  50. if package:is_plat("windows") then
  51. import("package.tools.cmake").install(package, configs, {buildir = os.tmpfile() .. ".dir"})
  52. else
  53. import("package.tools.cmake").install(package, configs)
  54. end
  55. package:add("links", "SPIRV-Tools-link", "SPIRV-Tools-reduce", "SPIRV-Tools-opt")
  56. if package:config("shared") then
  57. package:add("links", "SPIRV-Tools-shared")
  58. else
  59. package:add("links", "SPIRV-Tools")
  60. end
  61. end)
  62. on_test(function (package)
  63. if not package:is_cross() then
  64. os.runv("spirv-as --help")
  65. os.runv("spirv-opt --help")
  66. end
  67. assert(package:has_cxxfuncs("spvContextCreate", {configs = {languages = "c++11"}, includes = "spirv-tools/libspirv.hpp"}))
  68. end)