diff options
| author | ruki <[email protected]> | 2023-10-27 00:50:53 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-10-27 00:50:53 +0800 |
| commit | ee9a61fdad8d0755b600864092de468a7d2b2364 (patch) | |
| tree | 0d7f4b8d041c44ce3d77e6d5bd5a95bf50f1da1f | |
| parent | ab8ceb9f7a8d8faad35d0cf823a7c3395a23eb96 (diff) | |
prepare to sort package links
| -rw-r--r-- | xmake/core/package/package.lua | 1 | ||||
| -rw-r--r-- | xmake/modules/package/manager/xmake/find_package.lua | 54 |
2 files changed, 51 insertions, 4 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index d9ab55566..187f5e2dd 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -1736,7 +1736,6 @@ function _instance:find_package(name, opt) mode = self:mode(), plat = self:plat(), arch = self:arch(), - linkorders = self:get("linkorders"), configs = table.join(self:configs(), opt.configs), components = self:components_orderlist(), components_extsources = opt.components_extsources, diff --git a/xmake/modules/package/manager/xmake/find_package.lua b/xmake/modules/package/manager/xmake/find_package.lua index d672f98b4..c3c09902b 100644 --- a/xmake/modules/package/manager/xmake/find_package.lua +++ b/xmake/modules/package/manager/xmake/find_package.lua @@ -20,6 +20,7 @@ -- imports import("core.base.global") +import("core.base.graph") import("core.project.config") import("core.project.option") import("core.project.target") @@ -43,8 +44,55 @@ function _deduplicate_values(values) end -- sort links -function _sort_links(result, opt) +function _sort_links(result) + print("sork_links") print(result) + + local sortlinks = false + local makegroups = false + local linkorders = table.wrap(result.linkorders) + if #linkorders > 0 then + sortlinks = true + end + local linkgroups = table.wrap(result.linkgroups) + local linkgroups_set = hashset.new() + if #linkgroups > 0 then + makegroups = true + for _, linkgroup in ipairs(linkgroups) do + for _, link in ipairs(linkgroup) do + linkgroups_set:insert(link) + end + end + end + + -- get all links + --[[ + local links = {} + local linkgroups_map = {} + if sortlinks or makegroups then + table.remove_if(items, function (_, item) + local name = item.name + local removed = false + for _, value in ipairs(item.values) do + if name == "links" or name == "syslinks" then + if not linkgroups_set:has(value) then + table.insert(links, value) + end + removed = true + elseif name == "frameworks" then + table.insert(links, "framework::" .. value) + removed = true + elseif name == "linkgroups" then + --local key = extra and extra.name or tostring(value) + table.insert(links, "linkgroup::" .. key) + linkgroups_map[key] = value + removed = true + end + end + return removed + end) + links = table.reverse_unique(links) + end]] end -- find package from the repository (maybe only include and no links) @@ -236,8 +284,8 @@ function _find_package_from_repo(name, opt) end -- sort links - if opt.linkorders or result.linkgroups then - _sort_links(result, opt) + if result.linkorders or result.linkgroups then + _sort_links(result) end -- deduplicate result |
