summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxq114 <[email protected]>2022-09-05 23:12:10 +0800
committerxq114 <[email protected]>2022-09-05 23:12:10 +0800
commitfbdcc61009d3dbf37720babcb044d161077f7e16 (patch)
treef10f77c4204262e01745fc9ebd68f6af67b8d777
parent80d10b758c80eb49fc46f1aab57c013baf278ed5 (diff)
improve arch detection
-rw-r--r--xmake/modules/detect/packages/find_vulkansdk.lua4
-rw-r--r--xmake/modules/detect/sdks/find_vulkansdk.lua15
2 files changed, 11 insertions, 8 deletions
diff --git a/xmake/modules/detect/packages/find_vulkansdk.lua b/xmake/modules/detect/packages/find_vulkansdk.lua
index efce6adeb..451a9c8ac 100644
--- a/xmake/modules/detect/packages/find_vulkansdk.lua
+++ b/xmake/modules/detect/packages/find_vulkansdk.lua
@@ -28,6 +28,6 @@ import("detect.sdks.find_vulkansdk")
-- @return see the return value of find_package()
--
function main(opt)
-
- return find_vulkansdk()
+ opt = opt or {}
+ return find_vulkansdk({arch = opt.arch})
end
diff --git a/xmake/modules/detect/sdks/find_vulkansdk.lua b/xmake/modules/detect/sdks/find_vulkansdk.lua
index 5cea9dce4..ad47c2be7 100644
--- a/xmake/modules/detect/sdks/find_vulkansdk.lua
+++ b/xmake/modules/detect/sdks/find_vulkansdk.lua
@@ -19,13 +19,14 @@
--
-- imports
+import("core.project.config")
import("lib.detect.find_file")
import("lib.detect.find_path")
import("lib.detect.find_library")
import("lib.detect.find_programver")
-- find vulkan sdk info executable
-function _find_vkinfo()
+function _find_vkinfo(opt)
-- init search paths
local paths =
@@ -35,9 +36,10 @@ function _find_vkinfo()
}
-- find vulkan sdk info
+ local arch = opt.arch or config.arch() or os.arch()
local vkinfo
if is_host("windows") then
- if is_arch("x86") then
+ if arch == "x86" then
vkinfo = find_file("vulkaninfoSDK.exe", paths, {suffixes = {"bin32"}})
else
vkinfo = find_file("vulkaninfoSDK.exe", paths, {suffixes = {"bin"}})
@@ -58,7 +60,8 @@ end
function main(opt)
-- find vkinfo
- local vkinfo = _find_vkinfo()
+ opt = opt or {}
+ local vkinfo = _find_vkinfo(opt)
if not vkinfo then
-- not found?
return
@@ -69,13 +72,14 @@ function main(opt)
local apiver = find_programver(vkinfo, {command = "--summary", parse = "Vulkan Instance Version: (%d+%.%d+%.%d+)"})
-- initialize result
+ local arch = opt.arch or config.arch() or os.arch()
local result = {sdkdir = sdkdir, apiversion = apiver, links = {}, linkdirs = {}, includedirs = {}}
- local binsuffix = ((is_host("windows") and is_arch("x86")) and "bin32" or "bin")
+ local binsuffix = ((is_host("windows") and arch == "x86") and "bin32" or "bin")
result.bindir = path.join(result.sdkdir, binsuffix)
-- find library
local libname = (is_host("windows") and "vulkan-1" or "vulkan")
- local libsuffix = ((is_host("windows") and is_arch("x86")) and "lib32" or "lib")
+ local libsuffix = ((is_host("windows") and arch == "x86") and "lib32" or "lib")
local linkinfo = find_library(libname, sdkdir, {suffixes = libsuffix})
if linkinfo then
table.insert(result.linkdirs, linkinfo.linkdir)
@@ -95,6 +99,5 @@ function main(opt)
end
-- return
- print(result)
return result
end