diff options
| author | ruki <[email protected]> | 2019-07-14 21:34:56 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-07-14 21:36:10 +0800 |
| commit | 893445dd37a571a7f33370b0970f046f30054b29 (patch) | |
| tree | 9b420494048bfd9325030a2a518eabd466b1b84f | |
| parent | 6061930a5c24f9b1ba717a9a39dafda02e8a802a (diff) | |
delay detect cuda
| -rw-r--r-- | xmake/modules/core/tools/nvcc.lua | 3 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/find_cudadevices.lua | 1 | ||||
| -rw-r--r-- | xmake/modules/private/platform/check_cuda.lua | 32 | ||||
| -rw-r--r-- | xmake/platforms/linux/config.lua | 10 | ||||
| -rw-r--r-- | xmake/platforms/macosx/config.lua | 10 | ||||
| -rw-r--r-- | xmake/platforms/windows/config.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/cuda/env/xmake.lua | 19 | ||||
| -rw-r--r-- | xmake/rules/cuda/gencodes/xmake.lua | 5 |
8 files changed, 20 insertions, 64 deletions
diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua index 274d72a54..856e5c47c 100644 --- a/xmake/modules/core/tools/nvcc.lua +++ b/xmake/modules/core/tools/nvcc.lua @@ -22,6 +22,7 @@ import("core.base.option") import("core.project.config") import("core.project.project") +import("core.platform.platform") import("core.language.language") import("detect.tools.find_ccache") import("private.tools.nvcc.parse_deps") @@ -35,7 +36,7 @@ function init(self) end -- add -ccbin - local cu_ccbin = get_config("cu-ccbin") + local cu_ccbin = platform.tool("cu-ccbin") if cu_ccbin then self:add("cuflags", "-ccbin=" .. os.args(cu_ccbin)) end diff --git a/xmake/modules/lib/detect/find_cudadevices.lua b/xmake/modules/lib/detect/find_cudadevices.lua index 8e2a1ae64..cb5781847 100644 --- a/xmake/modules/lib/detect/find_cudadevices.lua +++ b/xmake/modules/lib/detect/find_cudadevices.lua @@ -24,7 +24,6 @@ import("core.platform.platform") import("core.project.config") import("lib.detect.cache") import("lib.detect.find_tool") -import("detect.sdks.find_cuda") -- a magic string to filter output local _PRINT_SUFFIX = "<find_cudadevices>" diff --git a/xmake/modules/private/platform/check_cuda.lua b/xmake/modules/private/platform/check_cuda.lua deleted file mode 100644 index ba86fbb01..000000000 --- a/xmake/modules/private/platform/check_cuda.lua +++ /dev/null @@ -1,32 +0,0 @@ ---!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 ruki --- @file check_cuda.lua --- - --- imports -import("core.base.option") -import("detect.sdks.find_cuda") - --- check the cuda sdk toolchains -function main(config) - local cuda = find_cuda(config.get("cuda"), {verbose = true}) - if cuda then - config.set("cuda", cuda.sdkdir, {force = true, readonly = true}) - end -end - diff --git a/xmake/platforms/linux/config.lua b/xmake/platforms/linux/config.lua index c86144804..1ee407a28 100644 --- a/xmake/platforms/linux/config.lua +++ b/xmake/platforms/linux/config.lua @@ -24,7 +24,6 @@ import("core.base.singleton") import("detect.sdks.find_cross_toolchain") import("private.platform.toolchain") import("private.platform.check_arch") -import("private.platform.check_cuda") import("private.platform.check_toolchain") -- check the architecture @@ -168,15 +167,6 @@ function main(platform, name) -- check arch _check_arch() - - -- check cuda - check_cuda(config) - - -- check cu-ccbin after checking arch - if config.get("cuda") then - local toolchains = singleton.get("linux.toolchains", _toolchains) - check_toolchain(config, "cu-ccbin", toolchains["cu-ccbin"]) - end end end diff --git a/xmake/platforms/macosx/config.lua b/xmake/platforms/macosx/config.lua index 3db232687..0cb66fb68 100644 --- a/xmake/platforms/macosx/config.lua +++ b/xmake/platforms/macosx/config.lua @@ -23,7 +23,6 @@ import("core.project.config") import("core.base.singleton") import("private.platform.toolchain") import("private.platform.check_arch") -import("private.platform.check_cuda") import("private.platform.check_xcode") import("private.platform.check_toolchain") @@ -152,15 +151,6 @@ function main(platform, name) -- check xcode check_xcode(config, true) - - -- check cuda - check_cuda(config) - - -- check cu-ccbin after checking arch - if config.get("cuda") then - local toolchains = singleton.get("macosx.toolchains." .. (config.get("arch") or os.arch()), _toolchains) - check_toolchain(config, "cu-ccbin", toolchains["cu-ccbin"]) - end end end diff --git a/xmake/platforms/windows/config.lua b/xmake/platforms/windows/config.lua index 1ba24cb65..dc647f065 100644 --- a/xmake/platforms/windows/config.lua +++ b/xmake/platforms/windows/config.lua @@ -24,7 +24,6 @@ import("core.base.singleton") import("core.platform.environment") import("private.platform.toolchain") import("private.platform.check_arch") -import("private.platform.check_cuda") import("private.platform.check_vstudio") import("private.platform.check_toolchain") @@ -132,9 +131,6 @@ function main(platform, name) -- check vstudio check_vstudio(config) - - -- check cuda - check_cuda(config) end end diff --git a/xmake/rules/cuda/env/xmake.lua b/xmake/rules/cuda/env/xmake.lua index a151f7fcb..d14ebaa75 100644 --- a/xmake/rules/cuda/env/xmake.lua +++ b/xmake/rules/cuda/env/xmake.lua @@ -20,13 +20,26 @@ -- define rule: environment rule("cuda.env") - after_load(function (target) + + before_load(function (target) -- imports import("detect.sdks.find_cuda") - -- get cuda sdk + -- find cuda sdk first local cuda = assert(find_cuda(nil, {verbose = true}), "Cuda SDK not found!") + if cuda then + target:data_set("cuda", cuda) + end + end) + + after_load(function (target) + + -- imports + import("core.platform.platform") + + -- get cuda sdk + local cuda = assert(target:data("cuda"), "Cuda SDK not found!") -- add arch if is_arch("i386", "x86") then @@ -38,7 +51,7 @@ rule("cuda.env") end -- add ccbin - local cu_ccbin = get_config("cu-ccbin") + local cu_ccbin = platform.tool("cu-ccbin") if cu_ccbin then target:add("culdflags", "-ccbin=" .. os.args(cu_ccbin), {force = true}) end diff --git a/xmake/rules/cuda/gencodes/xmake.lua b/xmake/rules/cuda/gencodes/xmake.lua index 785b60d30..d1a1dc277 100644 --- a/xmake/rules/cuda/gencodes/xmake.lua +++ b/xmake/rules/cuda/gencodes/xmake.lua @@ -36,6 +36,7 @@ rule("cuda.gencodes") -- before_load(function (target) + -- imports import("core.platform.platform") import("lib.detect.find_cudadevices") import("core.base.hashset") @@ -126,9 +127,7 @@ rule("cuda.gencodes") nvcc_flags = '-gencode arch=compute_' .. v_arch .. ',code=[sm_' .. table.concat(r_archs, ',sm_') .. ']' end - return { - clang = clang_flags - , nvcc = nvcc_flags } + return { clang = clang_flags, nvcc = nvcc_flags } end local cugencodes = table.wrap(target:get("cugencodes")) |
