summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
authorruki <[email protected]>2024-12-04 13:48:01 +0800
committerGitHub <[email protected]>2024-12-04 13:48:01 +0800
commitded88ac6e855f8d1bb07657766ec249688cb526a (patch)
tree825580a1918d754e0f34bccb4dffd57472c1fcb4 /xmake/core
parent6c09c81a3fa14619459168f0fe814431011d4cc8 (diff)
parentcd93b9aa6fd61bccc5b91bf6a3e01b8d00e4a106 (diff)
Merge pull request #5923 from xmake-io/deps
Solve the package configs conflict
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/project/policy.lua8
-rw-r--r--xmake/core/project/project.lua36
2 files changed, 43 insertions, 1 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua
index 3f7915b84..46b16e256 100644
--- a/xmake/core/project/policy.lua
+++ b/xmake/core/project/policy.lua
@@ -136,8 +136,14 @@ function policy.policies()
-- if true, then any updates to library dependencies, such as buildhash changes due to version changes,
-- will force the installed packages to be recompiled and installed. @see https://github.com/xmake-io/xmake/issues/2719
["package.librarydeps.strict_compatibility"] = {description = "Set strict compatibility for package and it's all library dependencies.", type = "boolean"},
+ -- Resolve package dependencies conflict automatically
+ -- @see https://github.com/xmake-io/xmake/issues/5745
+ ["package.resolve_depconflict"] = {description = "Automatically resolve package dependencies conflict.", default = true, type = "boolean"},
+ -- Synchronize add_requires configuration in toplevel to all package dependencies for this package
+ -- @see https://github.com/xmake-io/xmake/issues/5745
+ ["package.sync_requires_to_deps"] = {description = "Synchronize requires configuration to all package dependencies.", default = false, type = "boolean"},
-- Automatically passes dependency configuration for inner xmake package
- -- https://github.com/xmake-io/xmake/issues/3952
+ -- @see https://github.com/xmake-io/xmake/issues/3952
["package.xmake.pass_depconfs"] = {description = "Automatically passes dependency configuration for inner xmake package", default = true, type = "boolean"},
-- It will force cmake package use ninja for build
["package.cmake_generator.ninja"] = {description = "Set cmake package use ninja for build", type = "boolean"},
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 6c896dde5..77793d3e5 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -1030,6 +1030,42 @@ function project.requireconfs_str()
project.requires_str()
local requireconfs_str = project._memcache():get("requireconfs_str")
local requireconfs_extra = project._memcache():get("requireconfs_extra")
+ -- synchronize requires configuration to all package dependencies.
+ -- @see https://github.com/xmake-io/xmake/issues/5745#issuecomment-2513951471
+ if project.policy("package.sync_requires_to_deps") then
+ local requires_str = project._memcache():get("requires_str")
+ local requires_extra = project._memcache():get("requires_extra")
+ local sync_requires_to_deps = project._memcache():get("package.sync_requires_to_deps")
+ if requires_str and not sync_requires_to_deps then
+ requires_extra = requires_extra and table.wrap(requires_extra) or {}
+ requireconfs_str = requireconfs_str and table.wrap(requireconfs_str) or {}
+ requireconfs_extra = requireconfs_extra and table.wrap(requireconfs_extra) or {}
+ for _, require_str in ipairs(table.wrap(requires_str)) do
+ if not require_str:find("::", 1, true) then
+ local splitinfo = require_str:split("%s")
+ local packagename = splitinfo[1]
+ local packageversion = splitinfo[2]
+ local requireconf_str = "**." .. packagename
+ local requireconf_extra = table.clone(requires_extra[require_str])
+ if requireconf_extra then
+ requireconf_extra.configs = table.clone(requireconf_extra.configs) or {}
+ end
+ if packageversion then
+ requireconf_extra = requireconf_extra or {configs = {}}
+ requireconf_extra.configs.version = packageversion
+ end
+ if requireconf_extra then
+ requireconf_extra.override = true
+ table.insert(requireconfs_str, requireconf_str)
+ requireconfs_extra[requireconf_str] = requireconf_extra
+ end
+ end
+ end
+ project._memcache():set("requireconfs_str", requireconfs_str)
+ project._memcache():set("requireconfs_extra", requireconfs_extra)
+ project._memcache():set("package.sync_requires_to_deps", true)
+ end
+ end
return requireconfs_str, requireconfs_extra
end