diff options
| author | ruki <[email protected]> | 2021-02-21 18:28:25 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-02-21 18:28:25 +0800 |
| commit | bedd0f49b1abf23fe3f7dc72b1d46bcf1c848cff (patch) | |
| tree | 071cd474b4d6c1db4a8cf9b48492dcb447bf8281 /xmake/modules/private/action/require/impl | |
| parent | 4ef736be23496aac5a68beb3c4f36e94d5c5b3fd (diff) | |
add should_install module
Diffstat (limited to 'xmake/modules/private/action/require/impl')
| -rw-r--r-- | xmake/modules/private/action/require/impl/install_packages.lua | 17 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/utils/should_install.lua | 39 |
2 files changed, 41 insertions, 15 deletions
diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua index 48f159313..7f98c4959 100644 --- a/xmake/modules/private/action/require/impl/install_packages.lua +++ b/xmake/modules/private/action/require/impl/install_packages.lua @@ -31,6 +31,7 @@ import("actions.download", {alias = "action_download"}) import("net.fasturl") import("private.action.require.impl.package") import("private.action.require.impl.register_packages") +import("private.action.require.impl.utils.should_install") -- sort packages urls function _sort_packages_urls(packages) @@ -402,20 +403,6 @@ function _get_package_installdeps(packages) return installdeps end --- should install? -function _should_install(instance) - if instance:parents() then - -- if all the packages that depend on it already exist, then there is no need to install it - for _, parent in pairs(instance:parents()) do - if _should_install(parent) and not parent:exists() then - return true - end - end - else - return not instance:exists() - end -end - -- install packages function main(requires, opt) @@ -451,7 +438,7 @@ function main(requires, opt) local packages_download = {} local packages_unsupported = {} for _, instance in ipairs(packages) do - if _should_install(instance) then + if should_install(instance) then if instance:supported() then if #instance:urls() > 0 then packages_download[tostring(instance)] = instance diff --git a/xmake/modules/private/action/require/impl/utils/should_install.lua b/xmake/modules/private/action/require/impl/utils/should_install.lua new file mode 100644 index 000000000..ca104787f --- /dev/null +++ b/xmake/modules/private/action/require/impl/utils/should_install.lua @@ -0,0 +1,39 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file should_install.lua +-- + + +-- should install? +function _should_install(instance) + if instance:parents() then + -- if all the packages that depend on it already exist, then there is no need to install it + for _, parent in pairs(instance:parents()) do + if _should_install(parent) and not parent:exists() then + return true + end + end + else + return not instance:exists() + end +end + +-- the given package should be install? +function main(instance) + return _should_install(instance) +end |
