summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpportunityLiu <[email protected]>2019-07-16 23:25:53 +0800
committerOpportunityLiu <[email protected]>2019-07-17 08:45:36 +0800
commit887d97e20023e347fb8920d792aa5024b3d8203b (patch)
tree5e7115966fe9e9a2493a870e70738be313c71781
parent54386754982c5580e9d351484eabd45ebfd20c48 (diff)
add find cuda tools
-rw-r--r--xmake/modules/detect/tools/find_cudagdb.lua39
-rw-r--r--xmake/modules/detect/tools/find_cudamemcheck.lua39
-rw-r--r--xmake/modules/detect/tools/find_nvcc.lua38
-rw-r--r--xmake/modules/private/detect/find_cudatool.lua75
4 files changed, 155 insertions, 36 deletions
diff --git a/xmake/modules/detect/tools/find_cudagdb.lua b/xmake/modules/detect/tools/find_cudagdb.lua
new file mode 100644
index 000000000..15d501ba4
--- /dev/null
+++ b/xmake/modules/detect/tools/find_cudagdb.lua
@@ -0,0 +1,39 @@
+--!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 - 2019, TBOOX Open Source Group.
+--
+-- @author OpportunityLiu
+-- @file find_cudagdb.lua
+--
+
+-- imports
+import("private.detect.find_cudatool")
+
+-- find cudagdb
+--
+-- @param opt the argument options, .e.g {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local cudagdb = find_cudagdb()
+-- local cudagdb, version = find_cudagdb({program = "cuda-gdb", version = true})
+--
+-- @endcode
+--
+function main(opt)
+ return find_cudatool("cuda-gdb", "(%d+%.?%d*%.?%d*.-)%s+release", opt)
+end
diff --git a/xmake/modules/detect/tools/find_cudamemcheck.lua b/xmake/modules/detect/tools/find_cudamemcheck.lua
new file mode 100644
index 000000000..4c7de7469
--- /dev/null
+++ b/xmake/modules/detect/tools/find_cudamemcheck.lua
@@ -0,0 +1,39 @@
+--!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 - 2019, TBOOX Open Source Group.
+--
+-- @author OpportunityLiu
+-- @file find_cudamemcheck.lua
+--
+
+-- imports
+import("private.detect.find_cudatool")
+
+-- find cudamemcheck
+--
+-- @param opt the argument options, .e.g {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local cudamemcheck = find_cudamemcheck()
+-- local cudamemcheck, version = find_cudamemcheck({program = "cuda-memcheck", version = true})
+--
+-- @endcode
+--
+function main(opt)
+ return find_cudatool("cuda-memcheck", "version (%d+%.?%d*%.?%d*.-)", opt)
+end
diff --git a/xmake/modules/detect/tools/find_nvcc.lua b/xmake/modules/detect/tools/find_nvcc.lua
index ce98c9a60..68db9fef5 100644
--- a/xmake/modules/detect/tools/find_nvcc.lua
+++ b/xmake/modules/detect/tools/find_nvcc.lua
@@ -19,10 +19,7 @@
--
-- imports
-import("core.project.config")
-import("lib.detect.find_program")
-import("lib.detect.find_programver")
-import("detect.sdks.find_cuda")
+import("private.detect.find_cudatool")
-- find nvcc
--
@@ -38,36 +35,5 @@ import("detect.sdks.find_cuda")
-- @endcode
--
function main(opt)
-
- -- init options
- opt = opt or {}
- opt.parse = opt.parse or "V(%d+%.?%d*%.?%d*.-)%s"
-
- -- find program
- local program = nil
- if opt.program then
- program = find_program(opt.program, opt)
- end
-
- -- not found? attempt to find program from cuda toolchains
- if not program then
- local toolchains = find_cuda()
- if toolchains and toolchains.bindir then
- program = find_program(path.join(toolchains.bindir, "nvcc"), opt)
- end
- end
-
- -- not found? attempt to find program from PATH
- if not program then
- program = find_program("nvcc", opt)
- end
-
- -- find program version
- local version = nil
- if program and opt.version then
- version = find_programver(program, opt)
- end
-
- -- ok?
- return program, version
+ return find_cudatool("nvcc", "V(%d+%.?%d*%.?%d*.-)%s", opt)
end
diff --git a/xmake/modules/private/detect/find_cudatool.lua b/xmake/modules/private/detect/find_cudatool.lua
new file mode 100644
index 000000000..0583e3a6b
--- /dev/null
+++ b/xmake/modules/private/detect/find_cudatool.lua
@@ -0,0 +1,75 @@
+--!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 - 2019, TBOOX Open Source Group.
+--
+-- @author OpportunityLiu
+-- @file find_cudatool.lua
+--
+
+-- imports
+import("core.project.config")
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+import("detect.sdks.find_cuda")
+
+-- find cuda tool
+--
+-- @param toolname name of cuda tool, .e.g "nvcc"
+-- parse default pattern for version string
+-- opt the argument options, .e.g {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local nvcc = find_cudatool("nvcc", "V(%d+%.?%d*%.?%d*.-)%s")
+-- local nvcc, version = find_cudatool("nvcc", "V(%d+%.?%d*%.?%d*.-)%s", {program = "nvcc", version = true})
+--
+-- @endcode
+--
+function main(toolname, parse, opt)
+
+ -- init options
+ opt = opt or {}
+ opt.parse = opt.parse or parse
+
+ -- find program
+ local program = nil
+ if opt.program then
+ program = find_program(opt.program, opt)
+ end
+
+ -- not found? attempt to find program from cuda toolchains
+ if not program then
+ local toolchains = find_cuda()
+ if toolchains and toolchains.bindir then
+ program = find_program(path.join(toolchains.bindir, toolname), opt)
+ end
+ end
+
+ -- not found? attempt to find program from PATH
+ if not program then
+ program = find_program(toolname, opt)
+ end
+
+ -- find program version
+ local version = nil
+ if program and opt.version then
+ version = find_programver(program, opt)
+ end
+
+ -- ok?
+ return program, version
+end