summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-02-21 18:00:43 +0800
committerruki <[email protected]>2021-02-21 18:00:43 +0800
commit7994b41cc05c77ceb7c26594b68e9dff9ac626c3 (patch)
tree969e302966276ef98895a78b5881ac69f6628526
parentd6cfe92e5692251e31c95be50af0a3cd0f0817ed (diff)
improve to install packages
-rw-r--r--xmake/modules/private/action/require/impl/install_packages.lua16
-rw-r--r--xmake/modules/private/action/require/install.lua16
2 files changed, 30 insertions, 2 deletions
diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua
index b7adf5400..08b54a80d 100644
--- a/xmake/modules/private/action/require/impl/install_packages.lua
+++ b/xmake/modules/private/action/require/impl/install_packages.lua
@@ -402,6 +402,20 @@ 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 ipairs(instance:parents()) do
+ if not parent:exists() then
+ return true
+ end
+ end
+ else
+ return not instance:exists()
+ end
+end
+
-- install packages
function main(requires, opt)
@@ -437,7 +451,7 @@ function main(requires, opt)
local packages_download = {}
local packages_unsupported = {}
for _, instance in ipairs(packages) do
- if not instance:exists() 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/install.lua b/xmake/modules/private/action/require/install.lua
index 5750f4b0e..b93bc02fe 100644
--- a/xmake/modules/private/action/require/install.lua
+++ b/xmake/modules/private/action/require/install.lua
@@ -27,6 +27,20 @@ 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 ipairs(instance:parents()) do
+ if not parent:exists() then
+ return true
+ end
+ end
+ else
+ return not instance:exists()
+ end
+end
+
-- check missing packages
function _check_missing_packages(packages)
@@ -34,7 +48,7 @@ function _check_missing_packages(packages)
local packages_missing = {}
local optional_missing = {}
for _, instance in ipairs(packages) do
- if not instance:exists() then
+ if _should_install(instance) then
if instance:optional() then
optional_missing[instance:name()] = instance
else