diff options
| author | ruki <[email protected]> | 2024-02-06 00:54:21 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-02-06 00:54:21 +0800 |
| commit | b5aa7bfa552889527db96a45a4cef91559f7aede (patch) | |
| tree | c624ff938262eabaac9a7e6beebbbed42e42a6e2 | |
| parent | 8fa5433f3f8136c627dd594f1249edf175896cd8 (diff) | |
fix toolchain format
| -rw-r--r-- | xmake/core/platform/platform.lua | 6 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 26 | ||||
| -rw-r--r-- | xmake/toolchains/cosmocc/xmake.lua | 5 |
3 files changed, 31 insertions, 6 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/toolchains/cosmocc/xmake.lua b/xmake/toolchains/cosmocc/xmake.lua index f09eb836b..56788e902 100644 --- a/xmake/toolchains/cosmocc/xmake.lua +++ b/xmake/toolchains/cosmocc/xmake.lua @@ -23,6 +23,11 @@ toolchain("cosmocc") set_homepage("https://github.com/jart/cosmopolitan") set_description("build-once run-anywhere c library") + set_formats("static", "lib$(name).a") + set_formats("object", "$(name).o") + set_formats("binary", "$(name).com") + set_formats("symbol", "$(name).sym") + set_toolset("cc", "cosmocc") set_toolset("cxx", "cosmocc", "cosmoc++") set_toolset("cpp", "cosmocc -E") |
