Skip to content

Commit

Permalink
fix runtime configs #4477
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Jan 27, 2024
1 parent 97ebae3 commit cf61b2b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 4 additions & 2 deletions xmake/core/package/package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1454,8 +1454,9 @@ function _instance:configs()
configs = {}
local requireinfo = self:requireinfo()
local configs_required = requireinfo and requireinfo.configs or {}
local configs_overrided = requireinfo and requireinfo.configs_overrided or {}
for _, name in ipairs(table.wrap(configs_defined)) do
local value = configs_required[name]
local value = configs_overrided[name] or configs_required[name]
if value == nil then
value = self:extraconf("configs", name, "default")
-- support for the deprecated vs_runtime in add_configs
Expand Down Expand Up @@ -1493,10 +1494,11 @@ function _instance:_configs_for_buildhash()
configs = {}
local requireinfo = self:requireinfo()
local configs_required = requireinfo and requireinfo.configs or {}
local configs_overrided = requireinfo and requireinfo.configs_overrided or {}
local ignored_configs_for_buildhash = hashset.from(requireinfo and requireinfo.ignored_configs_for_buildhash or {})
for _, name in ipairs(table.wrap(configs_defined)) do
if not ignored_configs_for_buildhash:has(name) then
local value = configs_required[name]
local value = configs_overrided[name] or configs_required[name]
if value == nil then
value = self:extraconf("configs", name, "default")
-- support for the deprecated vs_runtime in add_configs
Expand Down
12 changes: 10 additions & 2 deletions xmake/modules/private/action/require/impl/package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,15 @@ function _select_package_runtimes(package)
end
end
-- we need update runtimes for buildhash, configs ...
--
-- we use configs_overrided to override configs in configs and buildhash,
-- but we shouldn't modify requireinfo.configs directly as it affects the package cache key
--
-- @see https://github.com/xmake-io/xmake/issues/4477#issuecomment-1913185727
local requireinfo = package:requireinfo()
if requireinfo and requireinfo.configs then
requireinfo.configs.runtimes = #runtimes_current > 0 and table.concat(runtimes_current, ",") or nil
if requireinfo then
requireinfo.configs_overrided = requireinfo.configs_overrided or {}
requireinfo.configs_overrided.runtimes = #runtimes_current > 0 and table.concat(runtimes_current, ",") or nil
end
end
end
Expand Down Expand Up @@ -1266,8 +1272,10 @@ function get_configs_str(package)
table.insert(configs, requireinfo.kind)
end
local ignored_configs_for_buildhash = hashset.from(requireinfo.ignored_configs_for_buildhash or {})
local configs_overrided = requireinfo.configs_overrided or {}
for k, v in pairs(requireinfo.configs) do
if not ignored_configs_for_buildhash:has(k) then
v = configs_overrided[k] or v
if type(v) == "boolean" then
table.insert(configs, k .. ":" .. (v and "y" or "n"))
else
Expand Down

0 comments on commit cf61b2b

Please sign in to comment.