diff options
| author | ruki <[email protected]> | 2021-06-30 00:51:28 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-06-30 00:51:28 +0800 |
| commit | 2e9219f0892b88bbe4bbcc1907385b71fca58024 (patch) | |
| tree | f5c39dcc91744d8aba7e5ded87b6bc24d9c70fd1 /xmake/modules/private/action/require/impl/package.lua | |
| parent | 3be2aa8c6aa6bea890c7ab321628e3e8c0fd4850 (diff) | |
improve optional deps
Diffstat (limited to 'xmake/modules/private/action/require/impl/package.lua')
| -rw-r--r-- | xmake/modules/private/action/require/impl/package.lua | 19 |
1 files changed, 19 insertions, 0 deletions
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 |
