diff options
| author | ruki <[email protected]> | 2018-02-28 22:34:23 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-02-28 09:26:21 +0800 |
| commit | e69e78bddc912b935990382671a3317bd9830073 (patch) | |
| tree | 38e0bb133471cb81dbe4fbd4d723d89937038628 | |
| parent | 13d694001559a79b5eaaf3c2c24d4f7c45b2bf94 (diff) | |
find cuda sdk toolchains
| -rw-r--r-- | xmake/modules/detect/sdks/find_cuda_toolchains.lua | 89 | ||||
| -rw-r--r-- | xmake/modules/detect/sdks/find_ndk_toolchains.lua | 20 | ||||
| -rw-r--r-- | xmake/platforms/iphoneos/xmake.lua | 8 | ||||
| -rw-r--r-- | xmake/platforms/macosx/xmake.lua | 11 | ||||
| -rw-r--r-- | xmake/platforms/watchos/xmake.lua | 8 |
5 files changed, 114 insertions, 22 deletions
diff --git a/xmake/modules/detect/sdks/find_cuda_toolchains.lua b/xmake/modules/detect/sdks/find_cuda_toolchains.lua new file mode 100644 index 000000000..0d84f69b7 --- /dev/null +++ b/xmake/modules/detect/sdks/find_cuda_toolchains.lua @@ -0,0 +1,89 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you 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 - 2018, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_cuda_toolchains.lua +-- + +-- imports +import("lib.detect.find_file") + +-- find cuda sdk directory +function _find_cudadir() + + -- init the search directories + local pathes = {} + if os.host() == "macosx" then + table.insert(pathes, "/Developer/NVIDIA/CUDA**/bin") + elseif os.host() == "windows" then + else + table.insert(pathes, "/usr/local/cuda/bin") + end + + -- attempt to find nvcc + local nvcc = find_file("nvcc", pathes) + if nvcc then + return path.directory(path.directory(nvcc)) + end +end + +-- find cuda sdk toolchains +-- +-- @param cudadir the cuda directory +-- @param opt the argument options +-- +-- @return the cuda sdk toolchains. .e.g {cudadir = ..., bindir = .., linkdirs = ..., includedirs = ..., .. } +-- +-- @code +-- +-- local toolchains = find_cuda_toolchains("/Developer/NVIDIA/CUDA-9.1") +-- +-- @endcode +-- +function main(cudadir, opt) + + -- init arguments + opt = opt or {} + + -- find cuda directory + if not cudadir or not os.isdir(cudadir) then + cudadir = _find_cudadir() + end + + -- not found? + if not cudadir or not os.isdir(cudadir) then + return {} + end + + -- get the bin directory + local bindir = path.join(cudadir, "bin") + if not os.isfile(path.join(bindir, "nvcc")) then + return {} + end + + -- get linkdirs + local linkdirs = {path.join(cudadir, "lib")} + + -- get includedirs + local includedirs = {path.join(cudadir, "include")} + + -- get toolchains + return {cudadir = cudadir, bindir = bindir, linkdirs = linkdirs, includedirs = includedirs} +end diff --git a/xmake/modules/detect/sdks/find_ndk_toolchains.lua b/xmake/modules/detect/sdks/find_ndk_toolchains.lua index 904306a68..235466661 100644 --- a/xmake/modules/detect/sdks/find_ndk_toolchains.lua +++ b/xmake/modules/detect/sdks/find_ndk_toolchains.lua @@ -19,7 +19,7 @@ -- Copyright (C) 2015 - 2018, TBOOX Open Source Group. -- -- @author ruki --- @file find_ndk_toolchains.lua +-- @file find_toolchains.lua -- -- imports @@ -27,7 +27,7 @@ import("core.project.config") -- find ndk toolchains -- --- @param ndk_dir the ndk directory +-- @param ndkdir the ndk directory -- @param opt the argument options -- .e.g {arch = "[armv5te|armv6|armv7-a|armv8-a|arm64-v8a]"} -- @@ -35,18 +35,18 @@ import("core.project.config") -- -- @code -- --- local ndk_toolchains = find_ndk_toolchains("/xxx/android-ndk-r10e") --- local ndk_toolchains = find_ndk_toolchains("/xxx/android-ndk-r10e", {arch = "arm64-v8a"}) +-- local toolchains = find_toolchains("/xxx/android-ndk-r10e") +-- local toolchains = find_toolchains("/xxx/android-ndk-r10e", {arch = "arm64-v8a"}) -- -- @endcode -- -function main(ndk_dir, opt) +function main(ndkdir, opt) -- init arguments opt = opt or {} -- get ndk directory - if not ndk_dir or not os.isdir(ndk_dir) then + if not ndkdir or not os.isdir(ndkdir) then return {} end @@ -60,14 +60,14 @@ function main(ndk_dir, opt) local cross = ifelse(arm64, "aarch64-linux-android-", "arm-linux-androideabi-") -- save the toolchains directory - local ndk_toolchains = {} - for _, bindir in ipairs(os.dirs(path.join(ndk_dir, "toolchains", cross .. "**", "prebuilt/*/bin"))) do + local toolchains = {} + for _, bindir in ipairs(os.dirs(path.join(ndkdir, "toolchains", cross .. "**", "prebuilt/*/bin"))) do local binfiles = os.files(path.join(bindir, cross .. "*")) if binfiles and #binfiles > 0 then - table.insert(ndk_toolchains, {bin = bindir, cross = cross}) + table.insert(toolchains, {bin = bindir, cross = cross}) end end -- ok? - return ndk_toolchains + return toolchains end diff --git a/xmake/platforms/iphoneos/xmake.lua b/xmake/platforms/iphoneos/xmake.lua index 549cf4fac..05ee387db 100644 --- a/xmake/platforms/iphoneos/xmake.lua +++ b/xmake/platforms/iphoneos/xmake.lua @@ -48,9 +48,9 @@ platform("iphoneos") config = { {category = "XCode SDK Configuration" } - , {nil, "xcode_dir", "kv", "auto", "the xcode application directory" } - , {nil, "xcode_sdkver", "kv", "auto", "the sdk version for xcode" } - , {nil, "target_minver", "kv", "auto", "the target minimal version" } + , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } + , {nil, "xcode_sdkver", "kv", "auto", "The SDK Version for Xcode" } + , {nil, "target_minver", "kv", "auto", "The Target Minimal Version" } , {} , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" } , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" } @@ -60,7 +60,7 @@ platform("iphoneos") , global = { {} - , {nil, "xcode_dir", "kv", "auto", "the xcode application directory" } + , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } , {} , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" } , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" } diff --git a/xmake/platforms/macosx/xmake.lua b/xmake/platforms/macosx/xmake.lua index 80b3bf64a..b32419750 100644 --- a/xmake/platforms/macosx/xmake.lua +++ b/xmake/platforms/macosx/xmake.lua @@ -51,15 +51,18 @@ platform("macosx") config = { {category = "XCode SDK Configuration" } - , {nil, "xcode_dir", "kv", "auto", "the xcode application directory" } - , {nil, "xcode_sdkver", "kv", "auto", "the sdk version for xcode" } - , {nil, "target_minver", "kv", "auto", "the target minimal version" } + , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } + , {nil, "xcode_sdkver", "kv", "auto", "The SDK Version for Xcode" } + , {nil, "target_minver", "kv", "auto", "The Target Minimal Version" } + , {category = "Cuda SDK Configuration" } + , {nil, "cuda_dir", "kv", "auto", "The Cuda SDK Directory" } } , global = { {} - , {nil, "xcode_dir", "kv", "auto", "the xcode application directory" } + , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } + , {nil, "cuda_dir", "kv", "auto", "The Cuda SDK Directory" } } } diff --git a/xmake/platforms/watchos/xmake.lua b/xmake/platforms/watchos/xmake.lua index 850c5eaab..97df8f893 100644 --- a/xmake/platforms/watchos/xmake.lua +++ b/xmake/platforms/watchos/xmake.lua @@ -48,9 +48,9 @@ platform("watchos") config = { {category = "XCode SDK Configuration" } - , {nil, "xcode_dir", "kv", "auto", "the xcode application directory" } - , {nil, "xcode_sdkver", "kv", "auto", "the sdk version for xcode" } - , {nil, "target_minver", "kv", "auto", "the target minimal version" } + , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } + , {nil, "xcode_sdkver", "kv", "auto", "The SDK Version for Xcode" } + , {nil, "target_minver", "kv", "auto", "The Target Minimal Version" } , { } , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" } , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" } @@ -60,7 +60,7 @@ platform("watchos") , global = { { } - , {nil, "xcode_dir", "kv", "auto", "the xcode application directory" } + , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } , { } , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" } , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" } |
