diff options
| author | ruki <[email protected]> | 2020-05-18 23:54:35 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-18 17:27:33 +0800 |
| commit | 694bff5b15ada2850b21ce0588d6963654ab0dc2 (patch) | |
| tree | 057dcd4017814a2ffa071ae55ddf8aeaab57848e | |
| parent | fb7bc83c06972744d6f2c5139b5bc079e06b7b11 (diff) | |
add clang/gcc toolchains
| -rw-r--r-- | xmake/core/tool/toolchain.lua | 2 | ||||
| -rw-r--r-- | xmake/platforms/macosx/check.lua | 21 | ||||
| -rw-r--r-- | xmake/platforms/macosx/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/toolchains/clang/xmake.lua | 39 | ||||
| -rw-r--r-- | xmake/toolchains/gcc/xmake.lua | 39 |
5 files changed, 99 insertions, 4 deletions
diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua index e79a32b22..8f524b623 100644 --- a/xmake/core/tool/toolchain.lua +++ b/xmake/core/tool/toolchain.lua @@ -296,7 +296,7 @@ function toolchain.load(name, plat) end -- get cache key - local cachekey = plat .. "_" .. (config.get("arch") or os.arch()) + local cachekey = name .. "_" .. plat .. "_" .. (config.get("arch") or os.arch()) -- get it directly from cache dirst toolchain._TOOLCHAINS = toolchain._TOOLCHAINS or {} diff --git a/xmake/platforms/macosx/check.lua b/xmake/platforms/macosx/check.lua index df2f072ec..08e04d7d6 100644 --- a/xmake/platforms/macosx/check.lua +++ b/xmake/platforms/macosx/check.lua @@ -22,6 +22,12 @@ import("core.project.config") import("private.platform.check_arch") +-- is basic toolchain? +function _is_basic_toolchain(toolchain) + local name = toolchain:name() + return name == "xcode" or name == "clang" or name == "gcc" +end + -- check it function main(platform) @@ -30,9 +36,20 @@ function main(platform) -- check toolchains local toolchains = platform:toolchains() - for idx, toolchain in irpairs(toolchains) do - if not toolchain:check() then + local idx = 1 + local num = #toolchains + local has_basic = false + while idx <= num do + local toolchain = toolchains[idx] + -- we need remove other same basic toolchains if basic toolchain found + if (has_basic and _is_basic_toolchain(toolchain)) or not toolchain:check() then table.remove(toolchains, idx) + num = num - 1 + else + if _is_basic_toolchain(toolchain) then + has_basic = true + end + idx = idx + 1 end end assert(#toolchains > 0, "toolchains not found!") diff --git a/xmake/platforms/macosx/xmake.lua b/xmake/platforms/macosx/xmake.lua index 9fd14a82f..4cd22a2fd 100644 --- a/xmake/platforms/macosx/xmake.lua +++ b/xmake/platforms/macosx/xmake.lua @@ -41,7 +41,7 @@ platform("macosx") -- set toolchains -- set_toolchains("custom", "xcode", "clang", "gcc", "dlang", "rust", "go", "cuda") - set_toolchains("xcode") + set_toolchains("xcode", "clang", "gcc") -- set menu set_menu { diff --git a/xmake/toolchains/clang/xmake.lua b/xmake/toolchains/clang/xmake.lua new file mode 100644 index 000000000..d4c1c3798 --- /dev/null +++ b/xmake/toolchains/clang/xmake.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-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +-- define toolchain +toolchain("clang") + + -- set toolsets + set_toolsets("cc", "clang") + set_toolsets("cxx", "clang", "clang++") + set_toolsets("ld", "clang++", "clang") + set_toolsets("sh", "clang++", "clang") + set_toolsets("ar", "ar") + set_toolsets("ex", "ex") + set_toolsets("strip", "strip") + set_toolsets("mm", "clang") + set_toolsets("mxx", "clang", "clang++") + set_toolsets("as", "clang") + + -- check toolchain + on_check(function (toolchain) + return import("lib.detect.find_tool")("clang") + end) diff --git a/xmake/toolchains/gcc/xmake.lua b/xmake/toolchains/gcc/xmake.lua new file mode 100644 index 000000000..08bb2d062 --- /dev/null +++ b/xmake/toolchains/gcc/xmake.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-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +-- define toolchain +toolchain("gcc") + + -- set toolsets + set_toolsets("cc", "gcc") + set_toolsets("cxx", "gcc", "g++") + set_toolsets("ld", "g++", "gcc") + set_toolsets("sh", "g++", "gcc") + set_toolsets("ar", "ar") + set_toolsets("ex", "ex") + set_toolsets("strip", "strip") + set_toolsets("mm", "gcc") + set_toolsets("mxx", "gcc", "g++") + set_toolsets("as", "gcc") + + -- check toolchain + on_check(function (toolchain) + return import("lib.detect.find_tool")("gcc") + end) |
