summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-09-06 07:39:03 +0800
committerGitHub <[email protected]>2022-09-06 07:39:03 +0800
commitad0112c31cf46fa7e42ba79efdc60c14dafd6416 (patch)
treebcb3f99e1bc9847d8d2f17a758e760a1359d7de2
parentf7ea3d7c6c599c4132d3ffcb6fec26bf1f461d0b (diff)
parentfbdcc61009d3dbf37720babcb044d161077f7e16 (diff)
Merge pull request #2780 from xq114/dev
move find_vulkansdk to sdk detection
-rw-r--r--xmake/modules/detect/packages/find_vulkansdk.lua32
-rw-r--r--xmake/modules/detect/sdks/find_vulkansdk.lua103
-rw-r--r--xmake/rules/python/xmake.lua2
3 files changed, 107 insertions, 30 deletions
diff --git a/xmake/modules/detect/packages/find_vulkansdk.lua b/xmake/modules/detect/packages/find_vulkansdk.lua
index 902fdd498..451a9c8ac 100644
--- a/xmake/modules/detect/packages/find_vulkansdk.lua
+++ b/xmake/modules/detect/packages/find_vulkansdk.lua
@@ -19,8 +19,7 @@
--
-- imports
-import("lib.detect.find_path")
-import("lib.detect.find_library")
+import("detect.sdks.find_vulkansdk")
-- find vulkansdk
--
@@ -29,31 +28,6 @@ import("lib.detect.find_library")
-- @return see the return value of find_package()
--
function main(opt)
-
- -- init search paths
- local paths =
- {
- "$(env VK_SDK_PATH)",
- "$(env VULKAN_SDK)"
- }
-
- -- find library
- local result = {links = {}, linkdirs = {}, includedirs = {}}
- local libname = (opt.plat == "windows" and "vulkan-1" or "vulkan")
- local libsuffix = ((opt.plat == "windows" and opt.arch == "x86") and "lib32" or "lib")
- local binsuffix = ((opt.plat == "windows" and opt.arch == "x86") and "bin32" or "bin")
- 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
- -- not found?
- return
- end
-
- -- find include
- table.insert(result.includedirs, find_path(path.join("vulkan", "vulkan.h"), paths, {suffixes = "include"}))
- return result
+ 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
new file mode 100644
index 000000000..ad47c2be7
--- /dev/null
+++ b/xmake/modules/detect/sdks/find_vulkansdk.lua
@@ -0,0 +1,103 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author xq114
+-- @file find_vulkansdk.lua
+--
+
+-- 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(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()
+--
+-- @return see the return value of find_package()
+--
+function main(opt)
+
+ -- find vkinfo
+ 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
+ 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})
+ if linkinfo then
+ table.insert(result.linkdirs, linkinfo.linkdir)
+ table.insert(result.links, libname)
+ else
+ -- not found?
+ return
+ end
+
+ -- find headers
+ local incdir = find_path(path.join("vulkan", "vulkan.h"), sdkdir, {suffixes = {"include"}})
+ if incdir then
+ table.insert(result.includedirs, incdir)
+ else
+ -- not found?
+ return
+ end
+
+ -- return
+ return result
+end
diff --git a/xmake/rules/python/xmake.lua b/xmake/rules/python/xmake.lua
index da54ead22..20c30c6b5 100644
--- a/xmake/rules/python/xmake.lua
+++ b/xmake/rules/python/xmake.lua
@@ -36,7 +36,7 @@ rule("python.library")
end
end
else
- if target:is_plat("windows") then
+ if target:is_plat("windows", "mingw") then
target:set("extension", ".pyd")
else
target:set("extension", ".so")