summaryrefslogtreecommitdiff
path: root/xmake/core/package/package.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-01-23 23:07:54 +0800
committerruki <[email protected]>2024-01-25 12:09:58 +0800
commit5b7ead17c49b68f8cfd6ca5325f5ccfe1b3e82cc (patch)
tree04f976d30336b08578f4e5b570c4271998544cca /xmake/core/package/package.lua
parenteeb0f80823bfd4fdd45a9d9a4eede7f407905fea (diff)
limit runtimes
Diffstat (limited to 'xmake/core/package/package.lua')
-rw-r--r--xmake/core/package/package.lua24
1 files changed, 19 insertions, 5 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