xmake.lua 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. -- when adding a new sdk version, please ensure vulkan-headers, vulkan-hpp, vulkan-loader, vulkan-tools, vulkan-validationlayers, vulkan-utility-libraries, spirv-headers, spirv-reflect, spirv-tools, glslang and volk packages are updated simultaneously
  6. add_urls("https://github.com/KhronosGroup/SPIRV-Tools.git")
  7. add_versions("1.2.154+1", "sdk-1.2.154.1")
  8. add_versions("1.2.162+0", "sdk-1.2.162.0")
  9. add_versions("1.2.189+1", "sdk-1.2.189.1")
  10. add_versions("1.3.211+0", "sdk-1.3.211.0")
  11. add_versions("1.3.231+1", "sdk-1.3.231.1")
  12. add_versions("1.3.236+0", "sdk-1.3.236.0")
  13. add_versions("1.3.239+0", "sdk-1.3.239.0")
  14. add_versions("1.3.246+1", "sdk-1.3.246.1")
  15. add_versions("1.3.250+1", "sdk-1.3.250.1")
  16. add_versions("1.3.261+1", "sdk-1.3.261.1")
  17. add_versions("1.3.268+0", "vulkan-sdk-1.3.268.0")
  18. add_versions("1.3.275+0", "vulkan-sdk-1.3.275.0")
  19. add_versions("1.3.280+0", "vulkan-sdk-1.3.280.0")
  20. add_versions("1.3.283+0", "vulkan-sdk-1.3.283.0")
  21. add_versions("1.3.290+0", "vulkan-sdk-1.3.290.0")
  22. add_versions("1.4.309+0", "vulkan-sdk-1.4.309.0")
  23. add_deps("cmake >=3.17.2")
  24. add_deps("python 3.x", {kind = "binary"})
  25. if is_plat("linux") then
  26. add_extsources("apt::spirv-tools", "pacman::spirv-tools")
  27. end
  28. on_load(function (package)
  29. local sdkver = package:version():split("%+")[1]
  30. package:add("deps", "spirv-headers " .. sdkver)
  31. end)
  32. on_fetch("macosx", function (package, opt)
  33. if opt.system then
  34. -- fix missing includedirs when the system library is found on macOS
  35. local result = package:find_package("spirv-tools")
  36. if result and not result.includedirs then
  37. for _, linkdir in ipairs(result.linkdirs) do
  38. if linkdir:startswith("/usr") then
  39. local includedir = path.join(path.directory(linkdir), "include", "spirv-tools")
  40. if os.isdir(includedir) then
  41. includedir = path.directory(includedir)
  42. result.includedirs = result.includedirs or {}
  43. table.insert(result.includedirs, includedir)
  44. end
  45. end
  46. end
  47. end
  48. return result
  49. end
  50. end)
  51. on_install(function (package)
  52. package:addenv("PATH", "bin")
  53. local configs = {"-DSPIRV_SKIP_TESTS=ON", "-DSPIRV_WERROR=OFF"}
  54. -- walkaround for potential conflict with parallel build & debug pdb generation
  55. if package:debug() then
  56. table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
  57. end
  58. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  59. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  60. local spirv = package:dep("spirv-headers")
  61. table.insert(configs, "-DSPIRV-Headers_SOURCE_DIR=" .. spirv:installdir():gsub("\\", "/"))
  62. if package:is_plat("windows") then
  63. import("package.tools.cmake").install(package, configs, {buildir = os.tmpfile() .. ".dir"})
  64. else
  65. import("package.tools.cmake").install(package, configs)
  66. end
  67. package:add("links", "SPIRV-Tools-link", "SPIRV-Tools-reduce", "SPIRV-Tools-opt")
  68. if package:config("shared") then
  69. package:add("links", "SPIRV-Tools-shared")
  70. else
  71. package:add("links", "SPIRV-Tools")
  72. end
  73. end)
  74. on_test(function (package)
  75. if not package:is_cross() then
  76. os.runv("spirv-as --help")
  77. os.runv("spirv-opt --help")
  78. end
  79. assert(package:has_cxxfuncs("spvContextCreate", {configs = {languages = "c++17"}, includes = "spirv-tools/libspirv.hpp"}))
  80. end)