summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-02-28 00:55:23 +0800
committerruki <[email protected]>2018-02-27 23:32:23 +0800
commit13d694001559a79b5eaaf3c2c24d4f7c45b2bf94 (patch)
tree4b52b6ece8fcce603d85bfeb58e10531ca86c52b
parentf14144e07da1fb856c14eff80255c0a9d50e68b4 (diff)
add nvcc compiler and flags
-rw-r--r--xmake/languages/c++/xmake.lua10
-rw-r--r--xmake/modules/core/tools/nvcc.lua33
-rw-r--r--xmake/modules/detect/tools/find_nvcc.lua58
-rw-r--r--xmake/modules/detect/tools/nvcc/has_flags.lua27
-rw-r--r--xmake/platforms/macosx/check.lua3
5 files changed, 126 insertions, 5 deletions
diff --git a/xmake/languages/c++/xmake.lua b/xmake/languages/c++/xmake.lua
index 34ed07fc8..87a6256bd 100644
--- a/xmake/languages/c++/xmake.lua
+++ b/xmake/languages/c++/xmake.lua
@@ -26,10 +26,10 @@
language("c++")
-- set source file kinds
- set_sourcekinds {cc = ".c", cxx = {".cc", ".cpp", ".cxx"}}
+ set_sourcekinds {cc = ".c", cxx = {".cc", ".cpp", ".cxx"}, cu = ".cu"}
-- set source file flags
- set_sourceflags {cc = {"cflags", "cxflags"}, cxx = {"cxxflags", "cxflags"}}
+ set_sourceflags {cc = {"cflags", "cxflags"}, cxx = {"cxxflags", "cxflags"}, cu = {"cuflags"}}
-- set target kinds
set_targetkinds {binary = "ld", static = "ar", shared = "sh"}
@@ -38,10 +38,10 @@ language("c++")
set_targetflags {binary = "ldflags", static = "arflags", shared = "shflags"}
-- set language kinds
- set_langkinds {c = "cc", cxx = "cxx"}
+ set_langkinds {c = "cc", cxx = "cxx", cu = "cu"}
-- set mixing kinds
- set_mixingkinds("cc", "cxx", "as", "mrc")
+ set_mixingkinds("cc", "cxx", "cu", "as", "mrc")
-- on load
on_load("load")
@@ -150,6 +150,7 @@ language("c++")
{category = "Cross Complation Configuration/Compiler Configuration" }
, {nil, "cc", "kv", nil, "The C Compiler" }
, {nil, "cxx", "kv", nil, "The C++ Compiler" }
+ , {nil, "cu", "kv", nil, "The Cuda Compiler" }
, {category = "Cross Complation Configuration/Linker Configuration" }
, {nil, "ld", "kv", nil, "The Linker" }
@@ -160,6 +161,7 @@ language("c++")
, {nil, "cflags", "kv", nil, "The C Compiler Flags" }
, {nil, "cxflags", "kv", nil, "The C/C++ compiler Flags" }
, {nil, "cxxflags", "kv", nil, "The C++ Compiler Flags" }
+ , {nil, "cuflags", "kv", nil, "The Cuda Compiler Flags" }
, {category = "Cross Complation Configuration/Linker Flags Configuration" }
, {nil, "ldflags", "kv", nil, "The Binary Linker Flags" }
diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua
new file mode 100644
index 000000000..f1a76b60d
--- /dev/null
+++ b/xmake/modules/core/tools/nvcc.lua
@@ -0,0 +1,33 @@
+--!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 nvcc.lua
+--
+
+-- inherit gcc
+inherit("gcc")
+
+-- init it
+function init(self)
+
+ -- init super
+ _super.init(self)
+end
diff --git a/xmake/modules/detect/tools/find_nvcc.lua b/xmake/modules/detect/tools/find_nvcc.lua
new file mode 100644
index 000000000..92b37f6e8
--- /dev/null
+++ b/xmake/modules/detect/tools/find_nvcc.lua
@@ -0,0 +1,58 @@
+--!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_nvcc.lua
+--
+
+-- imports
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find nvcc
+--
+-- @param opt the argument options, .e.g {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local nvcc = find_nvcc()
+-- local nvcc, version = find_nvcc({program = "nvcc", version = true})
+--
+-- @endcode
+--
+function main(opt)
+
+ -- init options
+ opt = opt or {}
+
+ -- find program
+ local program = find_program(opt.program or "nvcc", 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
diff --git a/xmake/modules/detect/tools/nvcc/has_flags.lua b/xmake/modules/detect/tools/nvcc/has_flags.lua
new file mode 100644
index 000000000..291be7f3b
--- /dev/null
+++ b/xmake/modules/detect/tools/nvcc/has_flags.lua
@@ -0,0 +1,27 @@
+--!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 has_flags.lua
+--
+
+-- imports
+inherit("detect.tools.gcc.has_flags")
+
diff --git a/xmake/platforms/macosx/check.lua b/xmake/platforms/macosx/check.lua
index 57aa64144..485284703 100644
--- a/xmake/platforms/macosx/check.lua
+++ b/xmake/platforms/macosx/check.lua
@@ -38,7 +38,7 @@ function _toolchains(config)
-- insert c/c++ tools to toolchains
checker.toolchain_insert(toolchains, "cc", "", "$(env CC)", "the c compiler")
- checker.toolchain_insert(toolchains, "cxx", "", "$(env CXX)", "the linker")
+ checker.toolchain_insert(toolchains, "cxx", "", "$(env CXX)", "the c++ compiler")
checker.toolchain_insert(toolchains, "ld", "", "$(env LD)", "the linker")
checker.toolchain_insert(toolchains, "ld", "", "$(env CXX)", "the linker")
checker.toolchain_insert(toolchains, "ar", "", "$(env AR)", "the static library archiver")
@@ -46,6 +46,7 @@ function _toolchains(config)
checker.toolchain_insert(toolchains, "cc", "xcrun -sdk macosx ", "clang", "the c compiler")
checker.toolchain_insert(toolchains, "cxx", "xcrun -sdk macosx ", "clang", "the c++ compiler")
checker.toolchain_insert(toolchains, "cxx", "xcrun -sdk macosx ", "clang++", "the c++ compiler")
+ checker.toolchain_insert(toolchains, "cu", "", "nvcc", "the cuda compiler")
checker.toolchain_insert(toolchains, "ld", "xcrun -sdk macosx ", "clang++", "the linker")
checker.toolchain_insert(toolchains, "ld", "xcrun -sdk macosx ", "clang", "the linker")
checker.toolchain_insert(toolchains, "ar", "xcrun -sdk macosx ", "ar", "the static library archiver")