diff options
| author | ruki <[email protected]> | 2024-02-06 11:04:20 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-02-06 11:04:20 +0800 |
| commit | c2d5a4a059d88134ef426cb58499994ef02508b2 (patch) | |
| tree | 7bb3a5531812a41ac48895a076e1d14e65ea7ea1 /xmake/modules/core | |
| parent | 8c92537300242e1705e522fe0e6a8087fe1f685c (diff) | |
| parent | b74097ad5fa27dd871ef4cdc6e342342eaca6192 (diff) | |
Merge pull request #4704 from xmake-io/cosmocc
Add cosmocc toolchain support
Diffstat (limited to 'xmake/modules/core')
| -rw-r--r-- | xmake/modules/core/tools/ar.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/core/tools/clangxx.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/core/tools/cosmoar.lua | 38 | ||||
| -rw-r--r-- | xmake/modules/core/tools/cosmocc.lua | 59 | ||||
| -rw-r--r-- | xmake/modules/core/tools/cosmocxx.lua | 24 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 13 |
6 files changed, 132 insertions, 9 deletions
diff --git a/xmake/modules/core/tools/ar.lua b/xmake/modules/core/tools/ar.lua index 0496238b4..b302504d8 100644 --- a/xmake/modules/core/tools/ar.lua +++ b/xmake/modules/core/tools/ar.lua @@ -49,7 +49,8 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) end -- link the library file -function link(self, objectfiles, targetkind, targetfile, flags) +function link(self, objectfiles, targetkind, targetfile, flags, opt) + opt = opt or {} os.mkdir(path.directory(targetfile)) -- @note remove the previous archived file first to force recreating a new file @@ -57,7 +58,7 @@ function link(self, objectfiles, targetkind, targetfile, flags) -- link it local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags) - os.runv(program, argv, {envs = self:runenvs()}) + os.runv(program, argv, {envs = self:runenvs(), shell = opt.shell}) end diff --git a/xmake/modules/core/tools/clangxx.lua b/xmake/modules/core/tools/clangxx.lua index d167dcd17..3a35fc562 100644 --- a/xmake/modules/core/tools/clangxx.lua +++ b/xmake/modules/core/tools/clangxx.lua @@ -15,7 +15,7 @@ -- Copyright (C) 2015-present, TBOOX Open Source Group. -- -- @author ruki --- @file clang++.lua +-- @file clangxx.lua -- -- inherit clang diff --git a/xmake/modules/core/tools/cosmoar.lua b/xmake/modules/core/tools/cosmoar.lua new file mode 100644 index 000000000..2ee1741ae --- /dev/null +++ b/xmake/modules/core/tools/cosmoar.lua @@ -0,0 +1,38 @@ +--!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-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file cosmoar.lua +-- + +inherit("ar") + +function init(self) + _super.init(self) +end + +function link(self, objectfiles, targetkind, targetfile, flags, opt) + opt = opt or {} + if is_host("windows") then + targetfile = targetfile:gsub("\\", "/") + local objectfiles_new = {} + for idx, objectfile in ipairs(objectfiles) do + objectfiles_new[idx] = objectfiles[idx]:gsub("\\", "/") + end + objectfiles = objectfiles_new + end + return _super.link(self, objectfiles, targetkind, targetfile, flags, table.join(opt, {shell = true})) +end diff --git a/xmake/modules/core/tools/cosmocc.lua b/xmake/modules/core/tools/cosmocc.lua new file mode 100644 index 000000000..c53f6e1c5 --- /dev/null +++ b/xmake/modules/core/tools/cosmocc.lua @@ -0,0 +1,59 @@ +--!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-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file cosmocc.lua +-- + +-- inherit gcc +inherit("gcc") + +-- init it +function init(self) + _super.init(self) +end + +-- make the strip flag +function nf_strip(self, level) +end + +-- link the target file +function link(self, objectfiles, targetkind, targetfile, flags, opt) + opt = opt or {} + if is_host("windows") then + targetfile = targetfile:gsub("\\", "/") + local objectfiles_new = {} + for idx, objectfile in ipairs(objectfiles) do + objectfiles_new[idx] = objectfiles[idx]:gsub("\\", "/") + end + objectfiles = objectfiles_new + end + return _super.link(self, objectfiles, targetkind, targetfile, flags, table.join(opt, {shell = true})) +end + +-- compile the source file +function compile(self, sourcefile, objectfile, dependinfo, flags, opt) + opt = opt or {} + if is_host("windows") then + sourcefile = sourcefile:gsub("\\", "/") + objectfile = objectfile:gsub("\\", "/") + local target = opt.target + if target then + target:set("policy", "build.ccache", false) + end + end + return _super.compile(self, sourcefile, objectfile, dependinfo, flags, table.join(opt, {shell = true})) +end diff --git a/xmake/modules/core/tools/cosmocxx.lua b/xmake/modules/core/tools/cosmocxx.lua new file mode 100644 index 000000000..4f64ad261 --- /dev/null +++ b/xmake/modules/core/tools/cosmocxx.lua @@ -0,0 +1,24 @@ +--!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-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file cosmocxx.lua +-- + +-- inherit cosmocc +inherit("cosmocc") + + diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index e519b376a..e4e658749 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -519,13 +519,14 @@ end -- maybe we need to use os.vrunv() to show link output when enable verbose information -- @see https://github.com/xmake-io/xmake/discussions/2916 -- -function link(self, objectfiles, targetkind, targetfile, flags) +function link(self, objectfiles, targetkind, targetfile, flags, opt) + opt = opt or {} os.mkdir(path.directory(targetfile)) local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags) if option.get("verbose") then - os.execv(program, argv, {envs = self:runenvs()}) + os.execv(program, argv, {envs = self:runenvs(), shell = opt.shell}) else - os.vrunv(program, argv, {envs = self:runenvs()}) + os.vrunv(program, argv, {envs = self:runenvs(), shell = opt.shell}) end end @@ -705,17 +706,17 @@ function _compile(self, sourcefile, objectfile, compflags, opt) opt = opt or {} local program, argv = compargv(self, sourcefile, objectfile, compflags) local function _compile_fallback() - return os.iorunv(program, argv, {envs = self:runenvs()}) + return os.iorunv(program, argv, {envs = self:runenvs(), shell = opt.shell}) end local cppinfo if distcc_build_client.is_distccjob() and distcc_build_client.singleton():has_freejobs() then cppinfo = distcc_build_client.singleton():compile(program, argv, {envs = self:runenvs(), preprocess = _preprocess, compile = _compile_preprocessed_file, compile_fallback = _compile_fallback, - tool = self, remote = true}) + tool = self, remote = true, shell = opt.shell}) elseif build_cache.is_enabled(opt.target) and build_cache.is_supported(self:kind()) then cppinfo = build_cache.build(program, argv, {envs = self:runenvs(), preprocess = _preprocess, compile = _compile_preprocessed_file, compile_fallback = _compile_fallback, - tool = self}) + tool = self, shell = opt.shell}) end if cppinfo then return cppinfo.outdata, cppinfo.errdata |
