From 968d7dc6f05661c381a49e965f56f397cdbb7868 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 5 Feb 2024 23:53:22 +0800 Subject: find cosmocc --- xmake/modules/core/tools/clangxx.lua | 2 +- xmake/modules/core/tools/cosmocc.lua | 32 ++++++++++++++++++++++++++++++++ xmake/modules/core/tools/cosmocxx.lua | 24 ++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 xmake/modules/core/tools/cosmocc.lua create mode 100644 xmake/modules/core/tools/cosmocxx.lua (limited to 'xmake/modules/core') 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/cosmocc.lua b/xmake/modules/core/tools/cosmocc.lua new file mode 100644 index 000000000..978b03395 --- /dev/null +++ b/xmake/modules/core/tools/cosmocc.lua @@ -0,0 +1,32 @@ +--!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 + 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") + + -- cgit v1.3.1 From 62f498ded882ce0f43bc7ee287d91c59827a5fa2 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 5 Feb 2024 23:54:08 +0800 Subject: impl cosmocc tool --- xmake/modules/core/tools/cosmocc.lua | 4 -- xmake/modules/detect/tools/cosmocc/has_flags.lua | 23 ++++++++++++ xmake/modules/detect/tools/cosmocxx/has_flags.lua | 23 ++++++++++++ xmake/modules/detect/tools/find_cosmocxx.lua | 45 +++++++++++++++++++++++ 4 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 xmake/modules/detect/tools/cosmocc/has_flags.lua create mode 100644 xmake/modules/detect/tools/cosmocxx/has_flags.lua create mode 100644 xmake/modules/detect/tools/find_cosmocxx.lua (limited to 'xmake/modules/core') diff --git a/xmake/modules/core/tools/cosmocc.lua b/xmake/modules/core/tools/cosmocc.lua index 978b03395..003634995 100644 --- a/xmake/modules/core/tools/cosmocc.lua +++ b/xmake/modules/core/tools/cosmocc.lua @@ -26,7 +26,3 @@ function init(self) _super.init(self) end --- make the strip flag -function nf_strip(self, level) -end - diff --git a/xmake/modules/detect/tools/cosmocc/has_flags.lua b/xmake/modules/detect/tools/cosmocc/has_flags.lua new file mode 100644 index 000000000..6464e10b6 --- /dev/null +++ b/xmake/modules/detect/tools/cosmocc/has_flags.lua @@ -0,0 +1,23 @@ +--!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 has_flags.lua +-- + +-- imports +inherit("detect.tools.gcc.has_flags") + diff --git a/xmake/modules/detect/tools/cosmocxx/has_flags.lua b/xmake/modules/detect/tools/cosmocxx/has_flags.lua new file mode 100644 index 000000000..6464e10b6 --- /dev/null +++ b/xmake/modules/detect/tools/cosmocxx/has_flags.lua @@ -0,0 +1,23 @@ +--!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 has_flags.lua +-- + +-- imports +inherit("detect.tools.gcc.has_flags") + diff --git a/xmake/modules/detect/tools/find_cosmocxx.lua b/xmake/modules/detect/tools/find_cosmocxx.lua new file mode 100644 index 000000000..c9a06fb0d --- /dev/null +++ b/xmake/modules/detect/tools/find_cosmocxx.lua @@ -0,0 +1,45 @@ +--!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 find_cosmocxx.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find cosmocxx +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local cosmocxx = find_cosmocxx() +-- +-- @endcode +-- +function main(opt) + opt = opt or {} + local program = find_program(opt.program or "cosmoc++", opt) + local version = nil + if program and opt and opt.version then + version = find_programver(program, opt) + end + return program, version +end -- cgit v1.3.1 From 7da1f4565975341780560026fe0e28a51091ce70 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 5 Feb 2024 23:54:11 +0800 Subject: disable strip --- xmake/modules/core/tools/cosmocc.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'xmake/modules/core') diff --git a/xmake/modules/core/tools/cosmocc.lua b/xmake/modules/core/tools/cosmocc.lua index 003634995..978b03395 100644 --- a/xmake/modules/core/tools/cosmocc.lua +++ b/xmake/modules/core/tools/cosmocc.lua @@ -26,3 +26,7 @@ function init(self) _super.init(self) end +-- make the strip flag +function nf_strip(self, level) +end + -- cgit v1.3.1 From b78f608ae74c5c0398e9160891fc6bbef08e358f Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 5 Feb 2024 23:56:46 +0800 Subject: pass shell to cosmocc --- xmake/modules/core/tools/cosmocc.lua | 9 +++++++++ xmake/modules/core/tools/gcc.lua | 9 +++++---- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'xmake/modules/core') diff --git a/xmake/modules/core/tools/cosmocc.lua b/xmake/modules/core/tools/cosmocc.lua index 978b03395..c412d287b 100644 --- a/xmake/modules/core/tools/cosmocc.lua +++ b/xmake/modules/core/tools/cosmocc.lua @@ -30,3 +30,12 @@ end function nf_strip(self, level) end +-- link the target file +function link(self, objectfiles, targetkind, targetfile, flags, opt) + 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) + return _super.compile(self, sourcefile, objectfile, dependinfo, flags, table.join(opt, {shell = true})) +end diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index e519b376a..d5ae314b7 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,7 +706,7 @@ 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 -- cgit v1.3.1 From 1dd66f29e0923d994fc37fcee2db328367c46e7b Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 6 Feb 2024 22:32:37 +0800 Subject: pass shell --- xmake/modules/core/tools/gcc.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xmake/modules/core') diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index d5ae314b7..e4e658749 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -712,11 +712,11 @@ function _compile(self, sourcefile, objectfile, compflags, opt) 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 -- cgit v1.3.1 From 7dd4614a455be4d24ef6d8796f053f250bf92c39 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 6 Feb 2024 22:35:17 +0800 Subject: fix windows files path --- xmake/modules/core/tools/cosmocc.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'xmake/modules/core') diff --git a/xmake/modules/core/tools/cosmocc.lua b/xmake/modules/core/tools/cosmocc.lua index c412d287b..68b531a2a 100644 --- a/xmake/modules/core/tools/cosmocc.lua +++ b/xmake/modules/core/tools/cosmocc.lua @@ -32,10 +32,22 @@ end -- link the target file function link(self, objectfiles, targetkind, targetfile, flags, opt) + 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) + if is_host("windows") then + sourcefile = sourcefile:gsub("\\", "/") + objectfile = objectfile:gsub("\\", "/") + end return _super.compile(self, sourcefile, objectfile, dependinfo, flags, table.join(opt, {shell = true})) end -- cgit v1.3.1 From 61de5394ae8d322c0f1f89e1ee322d8adaaa07d8 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 6 Feb 2024 22:37:12 +0800 Subject: disable ccache for windows --- xmake/modules/core/tools/cosmocc.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'xmake/modules/core') diff --git a/xmake/modules/core/tools/cosmocc.lua b/xmake/modules/core/tools/cosmocc.lua index 68b531a2a..60f25a3f0 100644 --- a/xmake/modules/core/tools/cosmocc.lua +++ b/xmake/modules/core/tools/cosmocc.lua @@ -45,9 +45,14 @@ 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 -- cgit v1.3.1 From 78a1a52f425010571eda84ab1cefeb11d78c20c8 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 6 Feb 2024 22:44:21 +0800 Subject: add cosmoar support --- tests/projects/c/cosmocc/console/src/main.c | 6 +++ tests/projects/c/cosmocc/console/test.lua | 8 ++++ tests/projects/c/cosmocc/console/xmake.lua | 9 +++++ tests/projects/c/cosmocc/src/main.c | 6 --- tests/projects/c/cosmocc/static_library/src/foo.c | 5 +++ tests/projects/c/cosmocc/static_library/src/foo.h | 2 + tests/projects/c/cosmocc/static_library/src/main.c | 7 ++++ tests/projects/c/cosmocc/static_library/xmake.lua | 15 ++++++++ tests/projects/c/cosmocc/test.lua | 8 ---- tests/projects/c/cosmocc/xmake.lua | 9 ----- xmake/modules/core/tools/ar.lua | 5 ++- xmake/modules/core/tools/cosmoar.lua | 38 +++++++++++++++++++ xmake/modules/core/tools/cosmocc.lua | 1 + xmake/modules/detect/tools/find_cosmoar.lua | 44 ++++++++++++++++++++++ xmake/modules/detect/tools/find_cosmocc.lua | 6 +-- 15 files changed, 141 insertions(+), 28 deletions(-) create mode 100644 tests/projects/c/cosmocc/console/src/main.c create mode 100644 tests/projects/c/cosmocc/console/test.lua create mode 100644 tests/projects/c/cosmocc/console/xmake.lua delete mode 100644 tests/projects/c/cosmocc/src/main.c create mode 100644 tests/projects/c/cosmocc/static_library/src/foo.c create mode 100644 tests/projects/c/cosmocc/static_library/src/foo.h create mode 100644 tests/projects/c/cosmocc/static_library/src/main.c create mode 100644 tests/projects/c/cosmocc/static_library/xmake.lua delete mode 100644 tests/projects/c/cosmocc/test.lua delete mode 100644 tests/projects/c/cosmocc/xmake.lua create mode 100644 xmake/modules/core/tools/cosmoar.lua create mode 100644 xmake/modules/detect/tools/find_cosmoar.lua (limited to 'xmake/modules/core') diff --git a/tests/projects/c/cosmocc/console/src/main.c b/tests/projects/c/cosmocc/console/src/main.c new file mode 100644 index 000000000..a1ce06b81 --- /dev/null +++ b/tests/projects/c/cosmocc/console/src/main.c @@ -0,0 +1,6 @@ +#include + +int main(int argc, char** argv) { + printf("hello world\n"); + return 0; +} diff --git a/tests/projects/c/cosmocc/console/test.lua b/tests/projects/c/cosmocc/console/test.lua new file mode 100644 index 000000000..d6ef2e8da --- /dev/null +++ b/tests/projects/c/cosmocc/console/test.lua @@ -0,0 +1,8 @@ +function main(t) + if is_subhost("msys", "cygwin") then + os.exec("xmake f -y -p windows -vD") + os.exec("xmake -vD") + elseif is_host("macosx", "linux") then + os.exec("xmake -y -vD") + end +end diff --git a/tests/projects/c/cosmocc/console/xmake.lua b/tests/projects/c/cosmocc/console/xmake.lua new file mode 100644 index 000000000..babd520a2 --- /dev/null +++ b/tests/projects/c/cosmocc/console/xmake.lua @@ -0,0 +1,9 @@ +add_rules("mode.debug", "mode.release") + +add_requires("cosmocc") + +target("test") + set_kind("binary") + add_files("src/*.c") + set_toolchains("@cosmocc") + diff --git a/tests/projects/c/cosmocc/src/main.c b/tests/projects/c/cosmocc/src/main.c deleted file mode 100644 index a1ce06b81..000000000 --- a/tests/projects/c/cosmocc/src/main.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main(int argc, char** argv) { - printf("hello world\n"); - return 0; -} diff --git a/tests/projects/c/cosmocc/static_library/src/foo.c b/tests/projects/c/cosmocc/static_library/src/foo.c new file mode 100644 index 000000000..1a1fb3425 --- /dev/null +++ b/tests/projects/c/cosmocc/static_library/src/foo.c @@ -0,0 +1,5 @@ +#include "foo.h" + +int add(int a, int b) { + return a + b; +} diff --git a/tests/projects/c/cosmocc/static_library/src/foo.h b/tests/projects/c/cosmocc/static_library/src/foo.h new file mode 100644 index 000000000..16d451cbb --- /dev/null +++ b/tests/projects/c/cosmocc/static_library/src/foo.h @@ -0,0 +1,2 @@ +int add(int a, int b); + diff --git a/tests/projects/c/cosmocc/static_library/src/main.c b/tests/projects/c/cosmocc/static_library/src/main.c new file mode 100644 index 000000000..a4c769408 --- /dev/null +++ b/tests/projects/c/cosmocc/static_library/src/main.c @@ -0,0 +1,7 @@ +#include "foo.h" +#include + +int main(int argc, char** argv) { + printf("add(1, 2) = %d\n", add(1, 2)); + return 0; +} diff --git a/tests/projects/c/cosmocc/static_library/xmake.lua b/tests/projects/c/cosmocc/static_library/xmake.lua new file mode 100644 index 000000000..73d0a681d --- /dev/null +++ b/tests/projects/c/cosmocc/static_library/xmake.lua @@ -0,0 +1,15 @@ +add_rules("mode.release", "mode.debug") + +add_requires("cosmocc") +set_toolchains("@cosmocc") + +target("foo") + set_kind("static") + add_files("src/foo.c") + +target("demo") + set_kind("binary") + add_deps("foo") + add_files("src/main.c") + + diff --git a/tests/projects/c/cosmocc/test.lua b/tests/projects/c/cosmocc/test.lua deleted file mode 100644 index d6ef2e8da..000000000 --- a/tests/projects/c/cosmocc/test.lua +++ /dev/null @@ -1,8 +0,0 @@ -function main(t) - if is_subhost("msys", "cygwin") then - os.exec("xmake f -y -p windows -vD") - os.exec("xmake -vD") - elseif is_host("macosx", "linux") then - os.exec("xmake -y -vD") - end -end diff --git a/tests/projects/c/cosmocc/xmake.lua b/tests/projects/c/cosmocc/xmake.lua deleted file mode 100644 index babd520a2..000000000 --- a/tests/projects/c/cosmocc/xmake.lua +++ /dev/null @@ -1,9 +0,0 @@ -add_rules("mode.debug", "mode.release") - -add_requires("cosmocc") - -target("test") - set_kind("binary") - add_files("src/*.c") - set_toolchains("@cosmocc") - 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/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 index 60f25a3f0..c53f6e1c5 100644 --- a/xmake/modules/core/tools/cosmocc.lua +++ b/xmake/modules/core/tools/cosmocc.lua @@ -32,6 +32,7 @@ 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 = {} diff --git a/xmake/modules/detect/tools/find_cosmoar.lua b/xmake/modules/detect/tools/find_cosmoar.lua new file mode 100644 index 000000000..01c9232ce --- /dev/null +++ b/xmake/modules/detect/tools/find_cosmoar.lua @@ -0,0 +1,44 @@ +--!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 find_cosmoar.lua +-- + +-- imports +import("lib.detect.find_program") + +-- find ar +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local ar = find_cosmoar() +-- +-- @endcode +-- +function main(opt) + opt = opt or {} + opt.shell = true + local program = find_program(opt.program or "cosmoar", opt) + if program and is_host("windows") then + program = program:gsub("\\", "/") + end + return program +end diff --git a/xmake/modules/detect/tools/find_cosmocc.lua b/xmake/modules/detect/tools/find_cosmocc.lua index 102c45284..964b564c8 100644 --- a/xmake/modules/detect/tools/find_cosmocc.lua +++ b/xmake/modules/detect/tools/find_cosmocc.lua @@ -38,12 +38,12 @@ function main(opt) opt = opt or {} opt.shell = true local program = find_program(opt.program or "cosmocc", opt) + if program and is_host("windows") then + program = program:gsub("\\", "/") + end local version = nil if program and opt and opt.version then version = find_programver(program, opt) end - if program and is_host("windows") then - program = program:gsub("\\", "/") - end return program, version end -- cgit v1.3.1