diff options
| author | ruki <[email protected]> | 2024-12-03 23:46:51 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-12-03 23:46:51 +0800 |
| commit | ac7a4a527990ad2e0d2d034971ce7699818d8b61 (patch) | |
| tree | 7ada805782f43bc8bf1c5187a380a02884829bc0 | |
| parent | d2ac413d4cac84cdd15e1f28393967d4ae2efa70 (diff) | |
add policy
| -rw-r--r-- | xmake/core/project/policy.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/package.lua | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index 1eb28130f..af8fb20e4 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -143,6 +143,8 @@ function policy.policies() ["package.cmake_generator.ninja"] = {description = "Set cmake package use ninja for build", type = "boolean"}, -- Enable msbuild MultiToolTask ["package.msbuild.multi_tool_task"] = {description = "Enable msbuild MultiToolTask.", default = false, type = "boolean"}, + -- Resolve package dependencies conflict automatically + ["package.resolve_depconflict"] = {description = "Automatically resolve package dependencies conflict.", default = true, type = "boolean"}, -- Stop to test on the first failure ["test.stop_on_first_failure"] = {description = "Stop to test on the first failure", default = false, type = "boolean"}, -- Return zero as exit code on failure diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index 9a79475e3..e3700af9d 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -1223,6 +1223,28 @@ function _get_package_compatkey(dep) if dep:is_system() then key = key .. "/system" end + local resolve_depconflict = project.policy("package.resolve_depconflict") + if resolve_depconflict == nil then + resolve_depconflict = dep:policy("package.resolve_depconflict") + end + if resolve_depconflict == false then + if dep:version_str() then + key = key .. "/" .. dep:version_str() + 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 + + end return key end |
