xmake.lua 3.6 KB

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