summaryrefslogtreecommitdiff
path: root/xmake/modules/private/action/require/impl/package.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2022-11-17 09:42:05 +0800
committerGitHub <[email protected]>2022-11-17 09:42:05 +0800
commit8c0fe2e25914c2ccf2ede485ea6306a067007cd7 (patch)
tree9c2bad7bf5a7d11d3ef55352096206bb867765c9 /xmake/modules/private/action/require/impl/package.lua
parent6db72d791606f3093d8c593a28464052eae7019c (diff)
parentbaf063548ce4fcbe5fdb7029fa7caac90a9db9b9 (diff)
Merge pull request #3072 from SirLynix/parents_add
Fix package:parents_add overwriting if another instance of the package…
Diffstat (limited to 'xmake/modules/private/action/require/impl/package.lua')
-rw-r--r--xmake/modules/private/action/require/impl/package.lua38
1 files changed, 21 insertions, 17 deletions
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index 450096c1b..2ff51a609 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -904,8 +904,10 @@ function _get_parents_str(package)
local parents = package:parents()
if parents then
local parentnames = {}
- for _, parent in pairs(parents) do
- table.insert(parentnames, parent:displayname())
+ for _, parentpkgs in pairs(parents) do
+ for _, parent in ipairs(parentpkgs) do
+ table.insert(parentnames, parent:displayname())
+ end
end
if #parentnames == 0 then
return
@@ -1062,23 +1064,25 @@ function should_install(package, opt)
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, opt) and not parent:exists() then
- return true
- end
+ for _, parentpkgs in pairs(package:parents()) do
+ for _, parent in ipairs(parentpkgs) do
+ if should_install(parent, opt) 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 not option.get("force") and _must_depend_on(parent, package) then
- -- mark this package as non-optional because parent package need it
- local requireinfo = package:requireinfo()
- if requireinfo.optional then
- requireinfo.optional = nil
+ -- 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 not option.get("force") and _must_depend_on(parent, package) then
+ -- mark this package as non-optional because parent package need it
+ local requireinfo = package:requireinfo()
+ if requireinfo.optional then
+ requireinfo.optional = nil
+ end
+ return true
end
- return true
end
end
else