summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2024-12-01 22:20:21 +0800
committerruki <[email protected]>2024-12-01 22:20:21 +0800
commitdf467da416ce72c90a79eb106673bb0f13ef7197 (patch)
treef55a721eb8ec6c60138e475b214c01af68e072bc /xmake/modules
parentce6f7dbd1350ba83c88c55b7ca170ae97bc54764 (diff)
merge configs
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/private/action/require/impl/package.lua50
1 files changed, 37 insertions, 13 deletions
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index 100a24560..b030f7eec 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -1212,24 +1212,12 @@ function _get_requirepaths(package)
return requirepaths
end
--- get configs key for compatibility
+-- get compatibility key
function _get_package_compatkey(dep)
local key = dep:plat() .. "/" .. dep:arch() .. "/" .. (dep:kind() or "")
if dep:is_system() then
key = key .. "/system"
end
- local configs = dep:requireinfo().configs
- if configs then
- local configs_order = {}
- for k, v in pairs(configs) do
- if type(v) == "table" then
- v = string.serialize(v, {strip = true, indent = false, orderkeys = true})
- end
- table.insert(configs_order, k .. "=" .. tostring(v))
- end
- table.sort(configs_order)
- key = key .. ":" .. string.serialize(configs_order, true)
- end
return key
end
@@ -1298,16 +1286,42 @@ function _check_and_resolve_package_depconflicts_impl(package, name, deps, resol
-- check configs compatibility
local prevkey
+ local configs
local configs_conflict = false
for _, dep in ipairs(deps) do
local key = _get_package_compatkey(dep)
if prevkey then
if prevkey ~= key then
configs_conflict = true
+ break
end
else
prevkey = key
end
+ local depconfigs = dep:requireinfo().configs
+ if configs and depconfigs then
+ for k, v in pairs(depconfigs) do
+ local oldv = configs[k]
+ if oldv ~= nil then
+ local v_key = tostring(v)
+ local oldv_key = tostring(oldv)
+ if type(v) == "table" then
+ v_key = string.serialize(v, {strip = true, indent = false, orderkeys = true})
+ end
+ if type(oldv) == "table" then
+ oldv_key = string.serialize(oldv, {strip = true, indent = false, orderkeys = true})
+ end
+ if v_key ~= oldv_key then
+ configs_conflict = true
+ break
+ end
+ else
+ configs[k] = v
+ end
+ end
+ else
+ configs = depconfigs
+ end
end
if configs_conflict then
print("package(%s): add_deps(%s, ...)", package:name(), name)
@@ -1335,6 +1349,16 @@ function _check_and_resolve_package_depconflicts_impl(package, name, deps, resol
end
end
end
+
+ -- resolve configs
+ if configs then
+ for _, dep in ipairs(deps) do
+ for _, requirepath in ipairs(_get_requirepaths(dep)) do
+ resolvedinfo[requirepath] = resolvedinfo[requirepath] or {}
+ resolvedinfo[requirepath].configs = configs
+ end
+ end
+ end
end
-- check and resolve dependencies conflicts