summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-06-30 00:51:28 +0800
committerruki <[email protected]>2021-06-30 00:51:28 +0800
commit2e9219f0892b88bbe4bbcc1907385b71fca58024 (patch)
treef5c39dcc91744d8aba7e5ded87b6bc24d9c70fd1
parent3be2aa8c6aa6bea890c7ab321628e3e8c0fd4850 (diff)
improve optional deps
-rw-r--r--xmake/core/package/package.lua10
-rw-r--r--xmake/modules/private/action/require/impl/install_packages.lua6
-rw-r--r--xmake/modules/private/action/require/impl/package.lua19
3 files changed, 34 insertions, 1 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 76084f392..b1afcaed6 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -578,6 +578,16 @@ function _instance:manifest_save()
manifest.configs = self:configs()
manifest.envs = self:envs()
+ -- save enabled link deps
+ if self:linkdeps() then
+ manifest.linkdeps = {}
+ for _, dep in ipairs(self:linkdeps()) do
+ if dep:exists() then
+ table.insert(manifest.linkdeps, dep:name())
+ end
+ end
+ end
+
-- save variables
local vars = {}
local apis = language.apis()
diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua
index 8e2c50725..fb7647861 100644
--- a/xmake/modules/private/action/require/impl/install_packages.lua
+++ b/xmake/modules/private/action/require/impl/install_packages.lua
@@ -530,7 +530,7 @@ function main(requires, opt)
comax = (option.get("verbose") or option.get("diagnosis")) and 1 or 4,
isolate = true})
- -- register all required root packages to local cache
+ -- register all installed root packages to local cache
register_packages(packages)
-- filter packages
@@ -594,6 +594,10 @@ function main(requires, opt)
-- disable other packages in same group
_disable_other_packages_in_group(packages)
+
+ -- re-register and refresh all root packages to local cache,
+ -- because there may be some missing optional dependencies reinstalled
+ register_packages(packages)
return packages
end
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index d66686482..490c357c2 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -22,6 +22,7 @@
import("core.base.semver")
import("core.base.option")
import("core.base.global")
+import("core.base.hashset")
import("private.utils.progress")
import("core.cache.memcache")
import("core.project.project")
@@ -742,6 +743,15 @@ function _check_package_depconflicts(package)
end
end
+-- must depend on the given package?
+function _must_depend_on(package, dep)
+ local manifest = package:manifest_load()
+ if manifest and manifest.linkdeps then
+ local linkdeps = hashset.from(manifest.linkdeps)
+ return linkdeps:has(dep:name())
+ end
+end
+
-- the cache directory
function cachedir()
return path.join(global.directory(), "cache", "packages")
@@ -767,6 +777,15 @@ function should_install(package)
if should_install(parent) and not parent:exists() then
return true
end
+
+ -- if the existing parent package is already using it,
+ -- then even if it is an optional package, you must make sure to install it
+ --
+ -- @see https://github.com/xmake-io/xmake/issues/1460
+ --
+ if parent:exists() and _must_depend_on(parent, package) then
+ return true
+ end
end
else
return true