diff options
| author | ruki <[email protected]> | 2020-05-20 22:44:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-20 10:25:37 +0800 |
| commit | a5a4b0ac5b9674ac00049cc1f4ff8f11d5268f6b (patch) | |
| tree | 66a5a45701b8c06e05011e6d6b40754c20e47991 | |
| parent | 5627a51d82327a2d694be53d1587e6a10671278c (diff) | |
set standalone toolchain
| -rw-r--r-- | tests/projects/asm/nasm/src/main.S | 1 | ||||
| -rw-r--r-- | xmake/actions/config/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/core/platform/platform.lua | 25 | ||||
| -rw-r--r-- | xmake/core/tool/toolchain.lua | 13 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_fasm.lua | 1 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_nasm.lua | 1 | ||||
| -rw-r--r-- | xmake/platforms/bsd/check.lua | 16 | ||||
| -rw-r--r-- | xmake/platforms/linux/check.lua | 16 | ||||
| -rw-r--r-- | xmake/platforms/macosx/check.lua | 16 | ||||
| -rw-r--r-- | xmake/toolchains/clang/xmake.lua | 3 | ||||
| -rw-r--r-- | xmake/toolchains/cross/xmake.lua | 3 | ||||
| -rw-r--r-- | xmake/toolchains/gcc/xmake.lua | 3 | ||||
| -rw-r--r-- | xmake/toolchains/llvm/xmake.lua | 3 | ||||
| -rw-r--r-- | xmake/toolchains/xcode/xmake.lua | 3 |
14 files changed, 62 insertions, 44 deletions
diff --git a/tests/projects/asm/nasm/src/main.S b/tests/projects/asm/nasm/src/main.S index 5b3a93699..e96a8d2c9 100644 --- a/tests/projects/asm/nasm/src/main.S +++ b/tests/projects/asm/nasm/src/main.S @@ -1,6 +1,5 @@ global _main - section .text _main: diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua index 4953fc718..3b02846d1 100644 --- a/xmake/actions/config/xmake.lua +++ b/xmake/actions/config/xmake.lua @@ -156,7 +156,7 @@ task("config") , " - sdk/bin" , " - sdk/lib" , " - sdk/include" } - , {nil, "toolchain", "kv", nil, "The Cross Toolchain Name" + , {nil, "toolchain", "kv", nil, "The Toolchain Name" , "e.g." , " - llvm" } diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua index 1ca688636..328bcce75 100644 --- a/xmake/core/platform/platform.lua +++ b/xmake/core/platform/platform.lua @@ -107,19 +107,28 @@ end function _instance:toolchains() local toolchains = self._TOOLCHAINS if not toolchains then - local names = {} - if config.get("toolchain") then - table.insert(names, config.get("toolchain")) - elseif self._INFO:get("toolchains") then - table.join2(names, self._INFO:get("toolchains")) - end + + -- get the given toolchain toolchains = {} - for _, name in ipairs(names) do - local toolchain_inst, errors = toolchain.load(name, self:name()) + local toolchain_given = config.get("toolchain") + if toolchain_given then + local toolchain_inst, errors = toolchain.load(toolchain_given, self:name()) if not toolchain_inst then os.raise(errors) end table.insert(toolchains, toolchain_inst) + toolchain_given = toolchain_inst + end + + -- get the platform toolchains + if (not toolchain_given or not toolchain_given:standalone()) and self._INFO:get("toolchains") then + for _, name in ipairs(self._INFO:get("toolchains")) do + local toolchain_inst, errors = toolchain.load(name, self:name()) + if not toolchain_inst then + os.raise(errors) + end + table.insert(toolchains, toolchain_inst) + end end self._TOOLCHAINS = toolchains end diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua index 78da9ea7f..f5d6ada4f 100644 --- a/xmake/core/tool/toolchain.lua +++ b/xmake/core/tool/toolchain.lua @@ -77,6 +77,16 @@ function _instance:get(name) return self._INFO:get(name) end +-- get toolchain kind +function _instance:kind() + return self._INFO:get("kind") +end + +-- is standalone toolchain? +function _instance:standalone() + return self:kind() == "standalone" +end + -- get the program and name of the given tool kind function _instance:tool(toolkind) local toolpathes = self:get("toolsets." .. toolkind) @@ -271,7 +281,8 @@ function toolchain._apis() { values = { - "toolchain.set_bindir" + "toolchain.set_kind" + , "toolchain.set_bindir" , "toolchain.set_sdkdir" } , keyvalues = diff --git a/xmake/modules/detect/tools/find_fasm.lua b/xmake/modules/detect/tools/find_fasm.lua index 5ebf9e699..0b555a406 100644 --- a/xmake/modules/detect/tools/find_fasm.lua +++ b/xmake/modules/detect/tools/find_fasm.lua @@ -39,6 +39,7 @@ function main(opt) -- init options opt = opt or {} + opt.norun = true -- find program local program = find_program(opt.program or "fasm", opt) diff --git a/xmake/modules/detect/tools/find_nasm.lua b/xmake/modules/detect/tools/find_nasm.lua index 40b710d2e..68936502e 100644 --- a/xmake/modules/detect/tools/find_nasm.lua +++ b/xmake/modules/detect/tools/find_nasm.lua @@ -39,6 +39,7 @@ function main(opt) -- init options opt = opt or {} + opt.check = "-v" -- find program local program = find_program(opt.program or "nasm", opt) diff --git a/xmake/platforms/bsd/check.lua b/xmake/platforms/bsd/check.lua index 3cd6b8980..71d2e555c 100644 --- a/xmake/platforms/bsd/check.lua +++ b/xmake/platforms/bsd/check.lua @@ -22,12 +22,6 @@ import("core.project.config") import("private.platform.check_arch") --- is basic toolchain? -function _is_basic_toolchain(toolchain) - local name = toolchain:name() - return name == "clang" or name == "gcc" -end - -- check it function main(platform) @@ -38,16 +32,16 @@ function main(platform) local toolchains = platform:toolchains() local idx = 1 local num = #toolchains - local has_basic = false + local standalone = 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 + -- we need remove other standalone toolchains if standalone toolchain found + if (standalone and toolchain:standalone()) or not toolchain:check() then table.remove(toolchains, idx) num = num - 1 else - if _is_basic_toolchain(toolchain) then - has_basic = true + if toolchain:standalone() then + standalone = true end idx = idx + 1 end diff --git a/xmake/platforms/linux/check.lua b/xmake/platforms/linux/check.lua index a851256e5..71d2e555c 100644 --- a/xmake/platforms/linux/check.lua +++ b/xmake/platforms/linux/check.lua @@ -22,12 +22,6 @@ import("core.project.config") import("private.platform.check_arch") --- is basic toolchain? -function _is_basic_toolchain(toolchain) - local name = toolchain:name() - return name == "cross" or name == "clang" or name == "gcc" -end - -- check it function main(platform) @@ -38,16 +32,16 @@ function main(platform) local toolchains = platform:toolchains() local idx = 1 local num = #toolchains - local has_basic = false + local standalone = 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 + -- we need remove other standalone toolchains if standalone toolchain found + if (standalone and toolchain:standalone()) or not toolchain:check() then table.remove(toolchains, idx) num = num - 1 else - if _is_basic_toolchain(toolchain) then - has_basic = true + if toolchain:standalone() then + standalone = true end idx = idx + 1 end diff --git a/xmake/platforms/macosx/check.lua b/xmake/platforms/macosx/check.lua index 08e04d7d6..b4eb3b73b 100644 --- a/xmake/platforms/macosx/check.lua +++ b/xmake/platforms/macosx/check.lua @@ -22,12 +22,6 @@ 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) @@ -38,16 +32,16 @@ function main(platform) local toolchains = platform:toolchains() local idx = 1 local num = #toolchains - local has_basic = false + local standalone = 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 + -- we need remove other standalone toolchains if standalone toolchain found + if (standalone and toolchain:standalone()) or not toolchain:check() then table.remove(toolchains, idx) num = num - 1 else - if _is_basic_toolchain(toolchain) then - has_basic = true + if toolchain:standalone() then + standalone = true end idx = idx + 1 end diff --git a/xmake/toolchains/clang/xmake.lua b/xmake/toolchains/clang/xmake.lua index 5d495fff5..ca84a94be 100644 --- a/xmake/toolchains/clang/xmake.lua +++ b/xmake/toolchains/clang/xmake.lua @@ -20,6 +20,9 @@ -- define toolchain toolchain("clang") + + -- mark as standalone toolchain + set_kind("standalone") -- set toolsets set_toolsets("cc", "clang") diff --git a/xmake/toolchains/cross/xmake.lua b/xmake/toolchains/cross/xmake.lua index 78be10f98..1cf211646 100644 --- a/xmake/toolchains/cross/xmake.lua +++ b/xmake/toolchains/cross/xmake.lua @@ -20,6 +20,9 @@ -- define toolchain toolchain("cross") + + -- mark as standalone toolchain + set_kind("standalone") -- check toolchain on_check("check") diff --git a/xmake/toolchains/gcc/xmake.lua b/xmake/toolchains/gcc/xmake.lua index ba1ef6989..77f2ef228 100644 --- a/xmake/toolchains/gcc/xmake.lua +++ b/xmake/toolchains/gcc/xmake.lua @@ -20,6 +20,9 @@ -- define toolchain toolchain("gcc") + + -- mark as standalone toolchain + set_kind("standalone") -- set toolsets set_toolsets("cc", "gcc") diff --git a/xmake/toolchains/llvm/xmake.lua b/xmake/toolchains/llvm/xmake.lua index d04234809..4c6c4748b 100644 --- a/xmake/toolchains/llvm/xmake.lua +++ b/xmake/toolchains/llvm/xmake.lua @@ -20,6 +20,9 @@ -- define toolchain toolchain("llvm") + + -- mark as standalone toolchain + set_kind("standalone") -- check toolchain on_check("check") diff --git a/xmake/toolchains/xcode/xmake.lua b/xmake/toolchains/xcode/xmake.lua index aed4a44e9..74462908c 100644 --- a/xmake/toolchains/xcode/xmake.lua +++ b/xmake/toolchains/xcode/xmake.lua @@ -21,6 +21,9 @@ -- define toolchain toolchain("xcode") + -- mark as standalone toolchain + set_kind("standalone") + -- check toolchain on_check("check") |
