summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-01-18 22:31:41 +0800
committerruki <[email protected]>2022-01-18 22:31:41 +0800
commit4b80511f28926aa82f4d78c3ae2eac6c1a8ac117 (patch)
treefd9d5aa2c1614dbfebbeb4ebcdc9c45149a0c95b
parentb86e3b25723812bdf0c20bc1d3d4075d47b57523 (diff)
add clang-xx toolchains
-rw-r--r--xmake/rules/c++/modules/xmake.lua2
-rw-r--r--xmake/toolchains/clang-12/xmake.lua3
-rw-r--r--xmake/toolchains/clang-13/xmake.lua3
-rw-r--r--xmake/toolchains/clang-14/xmake.lua3
-rw-r--r--xmake/toolchains/clang/xmake.lua28
5 files changed, 29 insertions, 10 deletions
diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua
index c587a3912..12132da54 100644
--- a/xmake/rules/c++/modules/xmake.lua
+++ b/xmake/rules/c++/modules/xmake.lua
@@ -45,6 +45,7 @@ rule("c++.build.modules")
elseif target:has_tool("cxx", "cl") then
import("build_modules.msvc").load_parent(target, opt)
else
+ local _, toolname = target:tool("cxx")
raise("compiler(%s): does not support c++ module!", toolname)
end
end
@@ -57,6 +58,7 @@ rule("c++.build.modules")
elseif target:has_tool("cxx", "cl") then
import("build_modules.msvc").build_with_batchjobs(target, batchjobs, sourcebatch, opt)
else
+ local _, toolname = target:tool("cxx")
raise("compiler(%s): does not support c++ module!", toolname)
end
end, {batch = true})
diff --git a/xmake/toolchains/clang-12/xmake.lua b/xmake/toolchains/clang-12/xmake.lua
new file mode 100644
index 000000000..306d2f5c9
--- /dev/null
+++ b/xmake/toolchains/clang-12/xmake.lua
@@ -0,0 +1,3 @@
+includes(path.join(os.scriptdir(), "../clang/xmake.lua"))
+
+toolchain_clang("12")
diff --git a/xmake/toolchains/clang-13/xmake.lua b/xmake/toolchains/clang-13/xmake.lua
new file mode 100644
index 000000000..ea5094922
--- /dev/null
+++ b/xmake/toolchains/clang-13/xmake.lua
@@ -0,0 +1,3 @@
+includes(path.join(os.scriptdir(), "../clang/xmake.lua"))
+
+toolchain_clang("13")
diff --git a/xmake/toolchains/clang-14/xmake.lua b/xmake/toolchains/clang-14/xmake.lua
new file mode 100644
index 000000000..9af9ac17b
--- /dev/null
+++ b/xmake/toolchains/clang-14/xmake.lua
@@ -0,0 +1,3 @@
+includes(path.join(os.scriptdir(), "../clang/xmake.lua"))
+
+toolchain_clang("14")
diff --git a/xmake/toolchains/clang/xmake.lua b/xmake/toolchains/clang/xmake.lua
index 96d22eac7..3456d7f73 100644
--- a/xmake/toolchains/clang/xmake.lua
+++ b/xmake/toolchains/clang/xmake.lua
@@ -18,25 +18,31 @@
-- @file xmake.lua
--
-toolchain("clang")
+-- define toolchain
+function toolchain_clang(version)
+local suffix = ""
+if version then
+ suffix = suffix .. "-" .. version
+end
+toolchain("clang" .. suffix)
set_homepage("https://clang.llvm.org/")
- set_description("A C language family frontend for LLVM")
+ set_description("A C language family frontend for LLVM" .. (version and (" (" .. version .. ")") or ""))
set_kind("standalone")
- set_toolset("cc", "clang")
- set_toolset("cxx", "clang", "clang++")
- set_toolset("ld", "clang++", "clang")
- set_toolset("sh", "clang++", "clang")
+ set_toolset("cc", "clang" .. suffix)
+ set_toolset("cxx", "clang", "clang++" .. suffix)
+ set_toolset("ld", "clang++", "clang" .. suffix)
+ set_toolset("sh", "clang++", "clang" .. suffix)
set_toolset("ar", "ar")
set_toolset("strip", "strip")
- set_toolset("mm", "clang")
- set_toolset("mxx", "clang", "clang++")
- set_toolset("as", "clang")
+ set_toolset("mm", "clang" .. suffix)
+ set_toolset("mxx", "clang" .. suffix, "clang++" .. suffix)
+ set_toolset("as", "clang" .. suffix)
on_check(function (toolchain)
- return import("lib.detect.find_tool")("clang")
+ return import("lib.detect.find_tool")("clang" .. suffix)
end)
on_load(function (toolchain)
@@ -54,3 +60,5 @@ toolchain("clang")
toolchain:add("shflags", march)
end
end)
+end
+toolchain_clang()