diff options
| author | ruki <[email protected]> | 2021-02-21 19:12:01 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-02-21 19:12:01 +0800 |
| commit | e53e7a33d47b36ddff4b6ec1ed2a64413760ead6 (patch) | |
| tree | 4fd1c7525a702813d5bcd074d20703b76d7b76a6 | |
| parent | 3de14fa6738d4cb9f2bf5b0fc6e635776f82d407 (diff) | |
move should_install script
4 files changed, 20 insertions, 46 deletions
diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua index 7f98c4959..036f2ac2d 100644 --- a/xmake/modules/private/action/require/impl/install_packages.lua +++ b/xmake/modules/private/action/require/impl/install_packages.lua @@ -31,7 +31,6 @@ 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) @@ -438,7 +437,7 @@ function main(requires, opt) local packages_download = {} local packages_unsupported = {} for _, instance in ipairs(packages) do - if should_install(instance) then + if package.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/package.lua b/xmake/modules/private/action/require/impl/package.lua index abfa91e7b..f31400625 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -578,6 +578,23 @@ function _load_package(packagename, requireinfo, opt) return package end +-- this package should be install? +function should_install(package) + if package:exists() then + return false + end + if package:parents() then + -- if all the packages that depend on it already exist, then there is no need to install it + for _, parent in pairs(package:parents()) do + if _should_install(parent) and not parent:exists() then + return true + end + end + else + return true + end +end + -- load all required packages function _load_packages(requires, opt) diff --git a/xmake/modules/private/action/require/impl/utils/should_install.lua b/xmake/modules/private/action/require/impl/utils/should_install.lua deleted file mode 100644 index fe1b0d834..000000000 --- a/xmake/modules/private/action/require/impl/utils/should_install.lua +++ /dev/null @@ -1,42 +0,0 @@ ---!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:exists() then - return false - end - 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 true - end -end - --- the given package should be install? -function main(instance) - return _should_install(instance) -end diff --git a/xmake/modules/private/action/require/install.lua b/xmake/modules/private/action/require/install.lua index fb8a210ba..6e6a3ad2b 100644 --- a/xmake/modules/private/action/require/install.lua +++ b/xmake/modules/private/action/require/install.lua @@ -22,11 +22,11 @@ import("core.base.option") import("core.base.task") import("lib.detect.find_tool") +import("private.action.require.impl.package") import("private.action.require.impl.repository") import("private.action.require.impl.environment") import("private.action.require.impl.install_packages") import("private.action.require.impl.utils.get_requires") -import("private.action.require.impl.utils.should_install") -- check missing packages function _check_missing_packages(packages) @@ -35,7 +35,7 @@ function _check_missing_packages(packages) local packages_missing = {} local optional_missing = {} for _, instance in ipairs(packages) do - if should_install(instance) then + if package.should_install(instance) then if instance:optional() then optional_missing[instance:name()] = instance else |
