diff options
| author | Arthur LAURENT <[email protected]> | 2025-11-02 18:08:17 +0100 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2025-11-02 18:08:17 +0100 |
| commit | ffd3dd3885359c969d36d3ea963e011c50dc854d (patch) | |
| tree | 353cb2b3b29a5e7b9d345928733f75785116617b | |
| parent | 6bb310b029f7adb13709d73655b635649b7c5814 (diff) | |
fix(target) cache compiler by sourcekind instead of global cache for target
| -rw-r--r-- | xmake/core/project/target.lua | 10 | ||||
| -rw-r--r-- | xmake/rules/swift/xmake.lua | 3 |
2 files changed, 6 insertions, 7 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 3f9e7b813..6547a4a6c 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -1065,17 +1065,17 @@ end -- get the target compiler function _instance:compiler(sourcekind) - local compilerinst = self:_memcache():get("compiler") + if not sourcekind then + os.raise("please pass sourcekind to the first argument of target:compiler(), e.g. cc, cxx, as") + end + local compilerinst = self:_memcache():get("compiler_" .. sourcekind) if not compilerinst then - if not sourcekind then - os.raise("please pass sourcekind to the first argument of target:compiler(), e.g. cc, cxx, as") - end local instance, errors = compiler.load(sourcekind, self) if not instance then os.raise(errors) end compilerinst = instance - self:_memcache():set("compiler", compilerinst) + self:_memcache():set("compiler_" .. sourcekind, compilerinst) end return compilerinst end diff --git a/xmake/rules/swift/xmake.lua b/xmake/rules/swift/xmake.lua index 6a96c7b31..46b225db9 100644 --- a/xmake/rules/swift/xmake.lua +++ b/xmake/rules/swift/xmake.lua @@ -95,8 +95,7 @@ rule("swift.interop") end local mode = target:data("swift.interop") - -- local sc = target:compiler("sc") - local sc = import("core.tool.compiler").load("sc") + local sc = target:compiler("sc") assert(sc, "No swift compiler found!") local outdir = target:data("swift.interop.outdir") if not os.isdir(outdir) then os.mkdir(outdir) end |
