summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/modules/private/action/require/impl/install_packages.lua17
-rw-r--r--xmake/modules/private/action/require/impl/utils/should_install.lua39
-rw-r--r--xmake/modules/private/action/require/install.lua17
3 files changed, 43 insertions, 30 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
diff --git a/xmake/modules/private/action/require/install.lua b/xmake/modules/private/action/require/install.lua
index 5477d999d..fb8a210ba 100644
--- a/xmake/modules/private/action/require/install.lua
+++ b/xmake/modules/private/action/require/install.lua
@@ -26,20 +26,7 @@ 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")
-
--- 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
+import("private.action.require.impl.utils.should_install")
-- check missing packages
function _check_missing_packages(packages)
@@ -48,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 should_install(instance) then
if instance:optional() then
optional_missing[instance:name()] = instance
else