diff options
| author | ruki <[email protected]> | 2024-01-23 23:07:54 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-01-25 12:09:58 +0800 |
| commit | 5b7ead17c49b68f8cfd6ca5325f5ccfe1b3e82cc (patch) | |
| tree | 04f976d30336b08578f4e5b570c4271998544cca | |
| parent | eeb0f80823bfd4fdd45a9d9a4eede7f407905fea (diff) | |
limit runtimes
| -rw-r--r-- | xmake/core/package/package.lua | 24 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 22 |
2 files changed, 37 insertions, 9 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 69d2b234d..f6b3e2f4c 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -1136,7 +1136,21 @@ function _instance:runtimes() if runtimes == nil then runtimes = self:config("runtimes") if runtimes then - runtimes = table.unwrap(runtimes:split(",", {plain = true})) + local runtimes_supported = hashset.new() + for _, toolchain_inst in ipairs(self:toolchains()) do + if toolchain_inst:is_standalone() and toolchain_inst:get("runtimes") then + for _, runtime in ipairs(table.wrap(toolchain_inst:get("runtimes"))) do + runtimes_supported:insert(runtime) + end + end + end + local runtimes_current = {} + for _, runtime in ipairs(table.wrap(runtimes:split(",", {plain = true}))) do + if runtimes_supported:has(runtime) then + table.insert(runtimes_current, runtime) + end + end + runtimes = table.unwrap(runtimes_current) end runtimes = runtimes or false self:_memcache():set("runtimes", runtimes) @@ -1146,10 +1160,10 @@ end -- has the given runtime for the current toolchains? function _instance:has_runtime(...) - local runtimes_set = self._RUNTIMES_SET + local runtimes_set = self:_memcache():get("runtimes_set") if runtimes_set == nil then runtimes_set = hashset.from(table.wrap(self:runtimes())) - self._RUNTIMES_SET = runtimes_set + self:_memcache():set("runtimes_set", runtimes_set) end for _, v in ipairs(table.pack(...)) do if runtimes_set:has(v) then @@ -1160,7 +1174,7 @@ end -- get the given toolchain function _instance:toolchain(name) - local toolchains_map = self._TOOLCHAINS_MAP + local toolchains_map = self:_memcache():get("toolchains_map") if toolchains_map == nil then toolchains_map = {} local toolchains = self:toolchains() @@ -1169,7 +1183,7 @@ function _instance:toolchain(name) toolchains_map[toolchain_inst:name()] = toolchain_inst end end - self._TOOLCHAINS_MAP = toolchains_map + self:_memcache():set("toolchains_map", toolchains_map) end return toolchains_map[name] end diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 6d6fe66d5..b5fe3b35b 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -2385,8 +2385,22 @@ function _instance:runtimes() local runtimes = self:_memcache():get("runtimes") if runtimes == nil then runtimes = self:get("runtimes") - if runtimes and #runtimes > 0 then - runtimes = table.unwrap(runtimes) + if runtimes then + local runtimes_supported = hashset.new() + for _, toolchain_inst in ipairs(self:toolchains()) do + if toolchain_inst:is_standalone() and toolchain_inst:get("runtimes") then + for _, runtime in ipairs(table.wrap(toolchain_inst:get("runtimes"))) do + runtimes_supported:insert(runtime) + end + end + end + local runtimes_current = {} + for _, runtime in ipairs(table.wrap(runtimes)) do + if runtimes_supported:has(runtime) then + table.insert(runtimes_current, runtime) + end + end + runtimes = table.unwrap(runtimes_current) end runtimes = runtimes or false self:_memcache():set("runtimes", runtimes) @@ -2396,10 +2410,10 @@ end -- has the given runtime for the current toolchains? function _instance:has_runtime(...) - local runtimes_set = self._RUNTIMES_SET + local runtimes_set = self:_memcache():get("runtimes_set") if runtimes_set == nil then runtimes_set = hashset.from(table.wrap(self:runtimes())) - self._RUNTIMES_SET = runtimes_set + self:_memcache():set("runtimes_set", runtimes_set) end for _, v in ipairs(table.pack(...)) do if runtimes_set:has(v) then |
