summaryrefslogtreecommitdiff
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
parentce6f7dbd1350ba83c88c55b7ca170ae97bc54764 (diff)
merge configs
-rw-r--r--tests/projects/package/compatibility/deps_with_version/xmake.lua4
-rw-r--r--xmake/modules/private/action/require/impl/package.lua50
2 files changed, 39 insertions, 15 deletions
diff --git a/tests/projects/package/compatibility/deps_with_version/xmake.lua b/tests/projects/package/compatibility/deps_with_version/xmake.lua
index 1ceb5f3a1..89a388cb1 100644
--- a/tests/projects/package/compatibility/deps_with_version/xmake.lua
+++ b/tests/projects/package/compatibility/deps_with_version/xmake.lua
@@ -7,14 +7,14 @@ package_end()
package("bar")
add_deps("zlib 1.2.x")
-- add_deps("libpng dev")
--- add_deps("libpng", {configs = {debug = true}})
+ add_deps("libpng", {configs = {shared = false}})
set_policy("package.install_locally", true)
on_install(function () end)
package_end()
package("zoo")
-- add_deps("libpng master")
--- add_deps("libpng", {configs = {shared = true}})
+ add_deps("libpng", {configs = {shared = true}})
set_policy("package.install_locally", true)
on_install(function () end)
package_end()
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