From 3c2ca2356818dffe8c6b70e2fcf6f799a47927f2 Mon Sep 17 00:00:00 2001 From: xq114 <1140735506@qq.com> Date: Mon, 5 Apr 2021 10:58:21 +0800 Subject: add find_bash.lua --- xmake/modules/detect/tools/find_bash.lua | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 xmake/modules/detect/tools/find_bash.lua (limited to 'xmake') diff --git a/xmake/modules/detect/tools/find_bash.lua b/xmake/modules/detect/tools/find_bash.lua new file mode 100644 index 000000000..0c1322ad2 --- /dev/null +++ b/xmake/modules/detect/tools/find_bash.lua @@ -0,0 +1,61 @@ +--!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_bash.lua +-- + +-- imports +import("lib.detect.find_tool") +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find bash +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local bash = find_bash() +-- local bash, version = find_bash({version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find bash from git for windows + if is_host("windows") then + opt.paths = opt.paths or {} + table.insert(opt.paths, "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\GitForWindows;InstallPath)\\bin") + end + + -- find program + local program = find_program(opt.program or "bash", opt) + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, opt) + end + + -- ok? + return program, version +end -- cgit v1.3.1 From 7fc0928774fb5d4e022d85e77fea8f3c29426a80 Mon Sep 17 00:00:00 2001 From: xq114 <1140735506@qq.com> Date: Mon, 5 Apr 2021 11:05:17 +0800 Subject: add find_vulkansdk.lua --- xmake/modules/detect/packages/find_mkl.lua | 4 +- xmake/modules/detect/packages/find_nvtx.lua | 26 +++++++++- xmake/modules/detect/packages/find_vulkansdk.lua | 61 ++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 xmake/modules/detect/packages/find_vulkansdk.lua (limited to 'xmake') diff --git a/xmake/modules/detect/packages/find_mkl.lua b/xmake/modules/detect/packages/find_mkl.lua index cefa0356a..05e9f5c92 100644 --- a/xmake/modules/detect/packages/find_mkl.lua +++ b/xmake/modules/detect/packages/find_mkl.lua @@ -43,7 +43,7 @@ function main(opt) } -- find library - local result = {links = {}, linkdirs = {}, includedirs = {}} + local result = {links = {}, linkdirs = {}, includedirs = {}, threading = ""} local linkinfo = find_library("mkl_core", paths, {suffixes = path.join("lib", rdir)}) if not linkinfo then -- not found? @@ -61,8 +61,10 @@ function main(opt) if tbb_res then table.join2(result.linkdirs, tbb_res.linkdirs) table.join2(result.links, {"mkl_tbb_thread", "mkl_core", "tbb"}) + result.threading = "tbb" else table.join2(result.links, {"mkl_sequential", "mkl_core"}) + result.threading = "seq" end -- find include diff --git a/xmake/modules/detect/packages/find_nvtx.lua b/xmake/modules/detect/packages/find_nvtx.lua index 83f999ded..2b6dd26f6 100644 --- a/xmake/modules/detect/packages/find_nvtx.lua +++ b/xmake/modules/detect/packages/find_nvtx.lua @@ -21,6 +21,7 @@ -- imports import("lib.detect.find_path") import("lib.detect.find_library") +import("detect.sdks.find_cuda") -- find nvtx -- @@ -29,8 +30,7 @@ import("lib.detect.find_library") -- @return see the return value of find_package() -- function main(opt) - - -- for windows platform + if opt.plat == "windows" then -- init bits @@ -62,5 +62,27 @@ function main(opt) -- ok return result + else + + -- find cuda + local cuda = find_cuda() + if cuda then + local result = {links = {}, linkdirs = {}, includedirs = {}} + + -- find library + local linkinfo = find_library("nvToolsExt", cuda.linkdirs) + if linkinfo then + table.insert(result.links, "nvToolsExt") + table.insert(result.linkdirs, linkinfo.linkdir) + else + return + end + table.join2(result.includedirs, cuda.includedirs) + + -- ok + return result + else + return + end end end diff --git a/xmake/modules/detect/packages/find_vulkansdk.lua b/xmake/modules/detect/packages/find_vulkansdk.lua new file mode 100644 index 000000000..6e0a542a0 --- /dev/null +++ b/xmake/modules/detect/packages/find_vulkansdk.lua @@ -0,0 +1,61 @@ +--!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("lib.detect.find_path") +import("lib.detect.find_library") + +-- 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) + + -- 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"})) + + -- ok + return result +end -- cgit v1.3.1