summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-11-29 00:53:22 +0800
committerruki <[email protected]>2024-11-29 00:53:22 +0800
commit202fb01a8cae37a4168e75c1abbe1ae9b6cdd688 (patch)
treed99e215018e311d2db727c1cf634717aeaf13923
parent36953ccf16f9765746471b47aca5b2611270b274 (diff)
get conflict packages
-rw-r--r--tests/projects/package/compatibility/deps_with_version/xmake.lua2
-rw-r--r--xmake/modules/private/action/require/impl/package.lua32
2 files changed, 29 insertions, 5 deletions
diff --git a/tests/projects/package/compatibility/deps_with_version/xmake.lua b/tests/projects/package/compatibility/deps_with_version/xmake.lua
index 895b57d3b..e937c1384 100644
--- a/tests/projects/package/compatibility/deps_with_version/xmake.lua
+++ b/tests/projects/package/compatibility/deps_with_version/xmake.lua
@@ -4,7 +4,7 @@ package("foo")
package_end()
package("bar")
- add_deps("zlib")
+ add_deps("zlib 1.2.x")
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 cea24ba10..0e4513a98 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -1176,7 +1176,13 @@ function _get_parents_str(package)
end
end
--- check dependencies conflicts
+-- check and resolve package conflicts
+function _check_and_resolve_package_conflicts(package1, package2)
+ print(package1:version_str(), package2:version_str())
+ print(package1:requireinfo(), package2:requireinfo())
+end
+
+-- check and resolve dependencies conflicts
--
-- It exists conflict for dependent packages for each root packages? resolve it first
-- e.g.
@@ -1190,8 +1196,8 @@ end
-- Of course, conflicts caused by `add_packages("foo", "ddd")`
-- cannot be detected at present and can only be resolved by the user
--
-function _check_package_depconflicts(package)
- print("_check_package_depconflicts ..")
+function _check_and_resolve_package_depconflicts(package)
+ print("_check_and_resole_package_depconflicts ..")
--[[
local packagekeys = {}
for _, dep in ipairs(package:librarydeps()) do
@@ -1203,6 +1209,24 @@ function _check_package_depconflicts(package)
packagekeys[dep:name()] = key
end
end]]
+ local same_packages = {}
+ for _, dep in ipairs(package:librarydeps()) do
+ local packages = same_packages[dep:name()]
+ if packages == nil then
+ packages = {}
+ same_packages[dep:name()] = packages
+ end
+ table.insert(packages, dep)
+ end
+ for name, packages in pairs(same_packages) do
+ if #packages > 1 then
+ for i = 1, #packages do
+ for j = i + 1, #packages do
+ _check_and_resolve_package_conflicts(packages[i], packages[j])
+ end
+ end
+ end
+ end
end
-- must depend on the given package?
@@ -1449,7 +1473,7 @@ function load_packages(requires, opt)
local packages = {}
for _, package in ipairs((_load_packages(requires, opt))) do
if package:is_toplevel() then
- _check_package_depconflicts(package)
+ _check_and_resolve_package_depconflicts(package)
end
local key = _get_packagekey(package:name(), package:requireinfo())
if not unique[key] then