diff options
| author | xq114 <[email protected]> | 2022-10-08 23:08:00 +0800 |
|---|---|---|
| committer | xq114 <[email protected]> | 2022-10-08 23:08:00 +0800 |
| commit | cc683eea50cc9fde6b3158d89f71da25ab851c1a (patch) | |
| tree | c4fb548c1e75b2755028a63eabbfdbace259e101 | |
| parent | be29799887aa5b05900a1e5dc4cb3a1bbfb6b1c5 (diff) | |
make vulkaninfo optional
| -rw-r--r-- | xmake/modules/detect/sdks/find_vulkansdk.lua | 73 |
1 files changed, 30 insertions, 43 deletions
diff --git a/xmake/modules/detect/sdks/find_vulkansdk.lua b/xmake/modules/detect/sdks/find_vulkansdk.lua index ad47c2be7..298548564 100644 --- a/xmake/modules/detect/sdks/find_vulkansdk.lua +++ b/xmake/modules/detect/sdks/find_vulkansdk.lua @@ -25,32 +25,6 @@ import("lib.detect.find_path") import("lib.detect.find_library") import("lib.detect.find_programver") --- find vulkan sdk info executable -function _find_vkinfo(opt) - - -- init search paths - local paths = - { - "$(env VK_SDK_PATH)", - "$(env VULKAN_SDK)" - } - - -- find vulkan sdk info - local arch = opt.arch or config.arch() or os.arch() - local vkinfo - if is_host("windows") then - if arch == "x86" then - vkinfo = find_file("vulkaninfoSDK.exe", paths, {suffixes = {"bin32"}}) - else - vkinfo = find_file("vulkaninfoSDK.exe", paths, {suffixes = {"bin"}}) - end - elseif is_host("linux") then - vkinfo = find_file("vulkaninfo", paths, {suffixes = {"bin"}}) - end - - return vkinfo -end - -- find vulkansdk -- -- @param opt the package options. e.g. see the options of find_package() @@ -59,29 +33,26 @@ end -- function main(opt) - -- find vkinfo + -- init option opt = opt or {} - local vkinfo = _find_vkinfo(opt) - if not vkinfo then - -- not found? - return - end - local sdkdir = path.directory(path.directory(vkinfo)) - -- find api version - local apiver = find_programver(vkinfo, {command = "--summary", parse = "Vulkan Instance Version: (%d+%.%d+%.%d+)"}) - - -- initialize result + -- init search configs + local paths = + { + "$(env VK_SDK_PATH)", + "$(env VULKAN_SDK)" + } 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 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 arch == "x86") and "lib32" or "lib") - local linkinfo = find_library(libname, sdkdir, {suffixes = libsuffix}) + + -- find library + local result = {links = {}, linkdirs = {}, includedirs = {}} + local linkinfo = find_library(libname, paths, {suffixes = {libsuffix}}) if linkinfo then + result.sdkdir = path.directory(linkinfo.linkdir) + result.bindir = path.join(result.sdkdir, binsuffix) table.insert(result.linkdirs, linkinfo.linkdir) table.insert(result.links, libname) else @@ -90,7 +61,7 @@ function main(opt) end -- find headers - local incdir = find_path(path.join("vulkan", "vulkan.h"), sdkdir, {suffixes = {"include"}}) + local incdir = find_path(path.join("vulkan", "vulkan.h"), paths, {suffixes = {"include"}}) if incdir then table.insert(result.includedirs, incdir) else @@ -98,6 +69,22 @@ function main(opt) return end + -- find api version + local vkinfo + if is_host("windows") then + if arch == "x86" then + vkinfo = find_file("vulkaninfoSDK.exe", paths, {suffixes = {"bin32"}}) + else + vkinfo = find_file("vulkaninfoSDK.exe", paths, {suffixes = {"bin"}}) + end + elseif is_host("linux") then + vkinfo = find_file("vulkaninfo", paths, {suffixes = {"bin"}}) + end + if vkinfo then + local apiver = find_programver(vkinfo, {command = "--summary", parse = "Vulkan Instance Version: (%d+%.%d+%.%d+)"}) + result.apiversion = apiver + end + -- return return result end |
