diff options
| author | ruki <[email protected]> | 2022-11-17 22:39:53 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-11-17 22:39:53 +0800 |
| commit | 6eda4ea531300a72984127253c0b79beefd96f56 (patch) | |
| tree | 2e6220833d0fc9e9c7b155536939a92a77e3fa1c /xmake/core/package/package.lua | |
| parent | 8c0fe2e25914c2ccf2ede485ea6306a067007cd7 (diff) | |
improve package parents
Diffstat (limited to 'xmake/core/package/package.lua')
| -rw-r--r-- | xmake/core/package/package.lua | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 57f7c1b78..e82691534 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -384,20 +384,39 @@ function _instance:librarydeps() end -- get parents -function _instance:parents() - return self._PARENTS +function _instance:parents(packagename) + local parents = self._PARENTS + if parents then + if packagename then + return parents[packagename] + else + local results = self._PARENTS_PLAIN + if not results then + results = {} + for _, parentpkgs in pairs(parents) do + table.join2(results, parentpkgs) + end + results = table.unique(results) + self._PARENTS_PLAIN = results + end + return results + end + end end -- add parents function _instance:parents_add(...) self._PARENTS = self._PARENTS or {} for _, parent in ipairs({...}) do + -- maybe multiple parents will depend on it + -- @see https://github.com/xmake-io/xmake/issues/3065 local parentpkgs = self._PARENTS[parent:name()] if not parentpkgs then parentpkgs = {} self._PARENTS[parent:name()] = parentpkgs end table.insert(parentpkgs, parent) + self._PARENTS_PLAIN = nil end end |
