summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
authorruki <[email protected]>2024-02-06 11:04:20 +0800
committerGitHub <[email protected]>2024-02-06 11:04:20 +0800
commitc2d5a4a059d88134ef426cb58499994ef02508b2 (patch)
tree7bb3a5531812a41ac48895a076e1d14e65ea7ea1 /xmake/core
parent8c92537300242e1705e522fe0e6a8087fe1f685c (diff)
parentb74097ad5fa27dd871ef4cdc6e342342eaca6192 (diff)
Merge pull request #4704 from xmake-io/cosmocc
Add cosmocc toolchain support
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/platform/platform.lua6
-rw-r--r--xmake/core/project/target.lua26
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_program.lua6
3 files changed, 29 insertions, 9 deletions
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua
index f9a8fba77..54ec35747 100644
--- a/xmake/core/platform/platform.lua
+++ b/xmake/core/platform/platform.lua
@@ -552,8 +552,8 @@ function platform.archs(plat, arch)
return platform.get("archs", plat, arch)
end
--- get the format of the given target kind for platform
-function platform.format(targetkind, plat, arch)
+-- get the format of the given kind for platform
+function platform.format(kind, plat, arch)
-- get platform instance
local instance, errors = platform.load(plat, arch)
@@ -564,7 +564,7 @@ function platform.format(targetkind, plat, arch)
-- get formats
local formats = instance:formats()
if formats then
- return formats[targetkind]
+ return formats[kind]
end
end
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index b9266ca35..25685ccb5 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -542,6 +542,23 @@ function _instance:_checked_target()
return checked_target
end
+-- get format
+function _instance:_format(kind)
+ local formats = self._FORMATS
+ if not formats then
+ for _, toolchain_inst in ipairs(self:toolchains()) do
+ formats = toolchain_inst:get("formats")
+ if formats then
+ break
+ end
+ end
+ self._FORMATS = formats
+ end
+ if formats then
+ return formats[kind or self:kind()]
+ end
+end
+
-- clone target, @note we can just call it in after_load()
function _instance:clone()
if not self:_is_loaded() then
@@ -1575,6 +1592,7 @@ function _instance:filename()
local suffixname = self:get("suffixname")
local extension = self:get("extension")
filename = target.filename(self:basename(), targetkind, {
+ format = self:_format(),
plat = self:plat(), arch = self:arch(),
prefixname = prefixname,
suffixname = suffixname,
@@ -1620,6 +1638,7 @@ function _instance:symbolfile()
local suffixname = self:get("suffixname")
local filename = target.filename(self:basename(), "symbol", {
plat = self:plat(), arch = self:arch(),
+ format = self:_format("symbol"),
prefixname = prefixname,
suffixname = suffixname})
assert(filename)
@@ -1924,7 +1943,10 @@ end
-- get object file from source file
function _instance:objectfile(sourcefile)
return self:autogenfile(sourcefile, {rootdir = self:objectdir(),
- filename = target.filename(path.filename(sourcefile), "object", {plat = self:plat(), arch = self:arch()})})
+ filename = target.filename(path.filename(sourcefile), "object", {
+ plat = self:plat(),
+ arch = self:arch(),
+ format = self:_format("object")})})
end
-- get the object files
@@ -2939,8 +2961,6 @@ end
-- get the filename from the given target name and kind
function target.filename(targetname, targetkind, opt)
-
- -- check
opt = opt or {}
assert(targetname and targetkind)
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
index 6b8aeb13a..baa180b4b 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
@@ -47,7 +47,7 @@ function sandbox_lib_detect_find_program._do_check(program, opt)
-- no check script? attempt to run it directly
if not opt.check then
- local ok, errors = os.runv(program, {"--version"}, {envs = opt.envs})
+ local ok, errors = os.runv(program, {"--version"}, {envs = opt.envs, shell = opt.shell})
if not ok and option.get("verbose") and option.get("diagnosis") then
utils.cprint("${color.warning}checkinfo: ${clear dim}" .. errors)
end
@@ -58,9 +58,9 @@ function sandbox_lib_detect_find_program._do_check(program, opt)
local ok = false
local errors = nil
if type(opt.check) == "string" then
- ok, errors = os.runv(program, {opt.check}, {envs = opt.envs})
+ ok, errors = os.runv(program, {opt.check}, {envs = opt.envs, shell = opt.shell})
elseif type(opt.check) == "table" then
- ok, errors = os.runv(program, opt.check, {envs = opt.envs})
+ ok, errors = os.runv(program, opt.check, {envs = opt.envs, shell = opt.shell})
else
ok, errors = sandbox.load(opt.check, program)
end