diff options
| author | ruki <[email protected]> | 2022-09-08 00:51:05 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-09-08 00:51:05 +0800 |
| commit | 72384b987dc3565a1f37f7e5728db7dd5846394d (patch) | |
| tree | 330a2f2926e91903f817edf065017adcc619a09b | |
| parent | 96d2662955aae226e3ff5705ed5f7e2ac98da6d9 (diff) | |
add package.strict_compatibility
| -rw-r--r-- | xmake/core/project/policy.lua | 10 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/package.lua | 46 |
2 files changed, 33 insertions, 23 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index b746f6853..c58b60cbb 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -71,10 +71,14 @@ function policy.policies() ["package.include_external_headers"] = {description = "Use includes as external headers.", type = "boolean"}, -- inherit the configs from the external command arguments, e.g. toolchains, `xmake f --toolchain=` ["package.inherit_external_configs"] = {description = "Inherit the configs from the external command arguments.", default = true, type = "boolean"}, - -- set strict compatibility for package dependencies - -- if true, then any updates to linked dependencies, such as buildhash changes due to version changes, + -- set strict compatibility for package and it's all child packages + -- if true, then any updates to this package, such as buildhash changes due to version changes, + -- will force all installed child packages to be recompiled and installed, @see https://github.com/xmake-io/xmake/issues/2719 + ["package.strict_compatibility"] = {description = "Set strict compatibility for package and it's all child packages.", type = "boolean"}, + -- set strict compatibility for package and it's all library dependencies + -- 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 dependencies.", type = "boolean"}, + ["package.librarydeps.strict_compatibility"] = {description = "Set strict compatibility for package and it's all library dependencies.", type = "boolean"} } policy._POLICIES = policies end diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index 26f608e3d..e7be7e21b 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -956,44 +956,50 @@ function _compatible_with_previous_librarydeps(package, opt) return true end + -- has been checked? + local compatible_checked = package:data("librarydeps.compatible_checked") + if compatible_checked then + return + end + -- check strict compatibility for librarydeps? local strict_compatibility = project.policy("package.librarydeps.strict_compatibility") if strict_compatibility == nil then strict_compatibility = package:policy("package.librarydeps.strict_compatibility") end - if not strict_compatibility then - return true - end - -- has been checked? - local compatible_checked = package:data("librarydeps.compatible_checked") - if compatible_checked then - return + -- compute the buildhash for current librarydeps + local depnames = hashset.new() + local depinfos_curr = {} + for _, dep in ipairs(package:librarydeps()) do + if strict_compatibility or dep:policy("package.strict_compatibility") then + depinfos_curr[dep:name()] = { + version = dep:version_str(), + buildhash = dep:buildhash() + } + depnames:insert(dep:name()) + end end -- compute the buildhash for previous librarydeps local depinfos_prev = {} - local depnames = hashset.new() local manifest = package:manifest_load() if manifest and manifest.librarydeps then local deps = manifest.deps or {} for _, depname in ipairs(manifest.librarydeps) do - local depinfo = deps[depname] - if depinfo and depinfo.buildhash then - depinfos_prev[depname] = depinfo - depnames:insert(depname) + if strict_compatibility or (package:dep(depname) and package:dep(depname):policy("package.strict_compatibility")) then + local depinfo = deps[depname] + if depinfo and depinfo.buildhash then + depinfos_prev[depname] = depinfo + depnames:insert(depname) + end end end end - -- compute the buildhash for current librarydeps - local depinfos_curr = {} - for _, dep in ipairs(package:librarydeps()) do - depinfos_curr[dep:name()] = { - version = dep:version_str(), - buildhash = dep:buildhash() - } - depnames:insert(dep:name()) + -- no any dependencies + if depnames:empty() then + return true end -- is compatible? |
