diff options
| author | ruki <[email protected]> | 2022-10-10 22:37:39 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-10-10 22:37:39 +0800 |
| commit | a9e8492bcc68823067d805a7ee666e99c08ad02f (patch) | |
| tree | 9bff8e4f5d3f0a77a4df0eb508584c952a057e89 | |
| parent | 4eab4583144dd0319c33431a557a06905c811ef5 (diff) | |
add package.install_always policy
| -rw-r--r-- | tests/projects/c/library_with_cmakelists/xmake.lua | 1 | ||||
| -rw-r--r-- | xmake/core/project/policy.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/package.lua | 8 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/install.lua | 2 |
4 files changed, 10 insertions, 3 deletions
diff --git a/tests/projects/c/library_with_cmakelists/xmake.lua b/tests/projects/c/library_with_cmakelists/xmake.lua index e5646c372..057aea584 100644 --- a/tests/projects/c/library_with_cmakelists/xmake.lua +++ b/tests/projects/c/library_with_cmakelists/xmake.lua @@ -3,6 +3,7 @@ add_rules("mode.debug", "mode.release") package("foo") add_deps("cmake") set_sourcedir(path.join(os.scriptdir(), "foo")) + set_policy("package.install_always", true) on_install(function (package) local configs = {} table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index f3c29ff54..8148a37e2 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -67,6 +67,8 @@ function policy.policies() ["package.fetch_only"] = {description = "Only fetch packages on system.", type = "boolean"}, -- only install packages from remote ["package.install_only"] = {description = "Only install packages from remote.", type = "boolean"}, + -- always install packages every time + ["package.install_always"] = {description = "Always install packages every time.", type = "boolean"}, -- use includes as external header files? e.g. -isystem .. ["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=` diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index 71f75d418..0608a3960 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -949,9 +949,9 @@ end -- @see https://github.com/xmake-io/xmake/issues/2719 function _compatible_with_previous_librarydeps(package, opt) - -- skip to check compatibility? + -- skip to check compatibility if installation has been finished opt = opt or {} - if opt.check_compatibility == false then + if opt.install_finished then return true end @@ -1036,9 +1036,13 @@ end -- this package should be install? function should_install(package, opt) + opt = opt or {} if package:is_template() then return false end + if not opt.install_finished and package:policy("package.install_always") then + return true + end if package:exists() and _compatible_with_previous_librarydeps(package, opt) then return false end diff --git a/xmake/modules/private/action/require/install.lua b/xmake/modules/private/action/require/install.lua index f6d02717e..ee5e56f95 100644 --- a/xmake/modules/private/action/require/install.lua +++ b/xmake/modules/private/action/require/install.lua @@ -35,7 +35,7 @@ function _check_missing_packages(packages) local packages_missing = {} local optional_missing = {} for _, instance in ipairs(packages) do - if package.should_install(instance, {check_compatibility = false}) or (instance:is_fetchonly() and not instance:exists()) then + if package.should_install(instance, {install_finished = true}) or (instance:is_fetchonly() and not instance:exists()) then if instance:is_optional() then optional_missing[instance:name()] = instance else |
