From 66eb03baa99faea83dca67ff3cbb762ffc8d25dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sat, 25 Dec 2021 10:24:50 +0100 Subject: [PATCH] Add mingw support to glslang, spirv-headers and spirv-tools (#791) * Add mingw support to glslang, spirv-headers and spirv-tools * Fix glslang and spirv-tools tests * Add MinGW support to spirv-cross and spirv-reflect --- packages/g/glslang/xmake.lua | 8 ++++---- packages/s/spirv-cross/xmake.lua | 6 ++++-- packages/s/spirv-headers/xmake.lua | 2 +- packages/s/spirv-reflect/xmake.lua | 2 +- packages/s/spirv-tools/xmake.lua | 8 +++++--- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/g/glslang/xmake.lua b/packages/g/glslang/xmake.lua index 7dde64cd7..4b2f870ae 100644 --- a/packages/g/glslang/xmake.lua +++ b/packages/g/glslang/xmake.lua @@ -29,7 +29,7 @@ package("glslang") end end) - on_install("linux", "windows", "macosx", function (package) + on_install("linux", "windows", "macosx", "mingw", function (package) package:addenv("PATH", "bin") io.replace("CMakeLists.txt", "ENABLE_OPT OFF", "ENABLE_OPT ON") io.replace("StandAlone/CMakeLists.txt", "target_link_libraries(glslangValidator ${LIBRARIES})", [[ @@ -52,10 +52,10 @@ package("glslang") end) on_test(function (package) - os.vrun("glslangValidator --version") + if not package:is_plat("mingw") or is_subhost("msys") then + os.vrun("glslangValidator --version") + end if not package:config("binaryonly") then assert(package:has_cxxfuncs("ShInitialize", {configs = {languages = "c++11"}, includes = "glslang/Public/ShaderLang.h"})) end end) - - diff --git a/packages/s/spirv-cross/xmake.lua b/packages/s/spirv-cross/xmake.lua index 493d6f7f1..792471c71 100644 --- a/packages/s/spirv-cross/xmake.lua +++ b/packages/s/spirv-cross/xmake.lua @@ -12,7 +12,7 @@ package("spirv-cross") add_deps("cmake") add_links("spirv-cross-c", "spirv-cross-cpp", "spirv-cross-reflect", "spirv-cross-msl", "spirv-cross-util", "spirv-cross-hlsl", "spirv-cross-glsl", "spirv-cross-core") - on_install("windows", "linux", "macosx", function (package) + on_install("windows", "linux", "macosx", "mingw", function (package) local configs = {"-DSPIRV_CROSS_ENABLE_TESTS=OFF"} if package:config("shared") then table.insert(configs, "-DSPIRV_CROSS_SHARED=ON") @@ -24,6 +24,8 @@ package("spirv-cross") end) on_test(function (package) - os.vrun("spirv-cross --help") + if not package:is_plat("mingw") or is_subhost("msys") then + os.vrun("spirv-cross --help") + end assert(package:has_cfuncs("spvc_get_version", {includes = "spirv_cross/spirv_cross_c.h"})) end) diff --git a/packages/s/spirv-headers/xmake.lua b/packages/s/spirv-headers/xmake.lua index c1a1d305b..92ab75880 100644 --- a/packages/s/spirv-headers/xmake.lua +++ b/packages/s/spirv-headers/xmake.lua @@ -13,7 +13,7 @@ package("spirv-headers") add_deps("cmake") - on_install("linux", "windows", "macosx", function (package) + on_install(function (package) import("package.tools.cmake").install(package, {"-DSPIRV_HEADERS_SKIP_EXAMPLES=ON"}) end) diff --git a/packages/s/spirv-reflect/xmake.lua b/packages/s/spirv-reflect/xmake.lua index b12a3938e..c282656a1 100644 --- a/packages/s/spirv-reflect/xmake.lua +++ b/packages/s/spirv-reflect/xmake.lua @@ -11,7 +11,7 @@ package("spirv-reflect") add_deps("spirv-headers") - on_install("windows", "linux", "macosx", function (package) + on_install("windows", "linux", "macosx", "mingw", function (package) io.gsub("spirv_reflect.h", "#include \"%.%/include%/spirv%/unified1%/spirv.h\"", "#include \"spirv/unified1/spirv.h\"") io.writefile("xmake.lua", [[ add_rules("mode.debug", "mode.release") diff --git a/packages/s/spirv-tools/xmake.lua b/packages/s/spirv-tools/xmake.lua index 4c22f607e..7bf718732 100644 --- a/packages/s/spirv-tools/xmake.lua +++ b/packages/s/spirv-tools/xmake.lua @@ -38,7 +38,7 @@ package("spirv-tools") end end) - on_install("linux", "windows", "macosx", function (package) + on_install("linux", "windows", "macosx", "mingw", function (package) package:addenv("PATH", "bin") local configs = {"-DSPIRV_SKIP_TESTS=ON"} table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) @@ -59,7 +59,9 @@ package("spirv-tools") end) on_test(function (package) - os.runv("spirv-as --help") - os.runv("spirv-opt --help") + if not package:is_plat("mingw") or is_subhost("msys") then + os.runv("spirv-as --help") + os.runv("spirv-opt --help") + end assert(package:has_cxxfuncs("spvContextCreate", {configs = {languages = "c++11"}, includes = "spirv-tools/libspirv.hpp"})) end)