diff options
| author | ruki <[email protected]> | 2023-09-27 23:44:42 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-09-27 23:44:42 +0800 |
| commit | 524b0a1dc0c70e924c21637edd85ae9dd4139527 (patch) | |
| tree | 3e9dbd40ab55e35fab15f30231441bb511d4210d | |
| parent | da714a6b9bad1fb0608445bcb48c079bf0202ea8 (diff) | |
sort links
| -rw-r--r-- | xmake/core/tool/builder.lua | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua index ee5fa5972..03be08c34 100644 --- a/xmake/core/tool/builder.lua +++ b/xmake/core/tool/builder.lua @@ -28,6 +28,7 @@ local utils = require("base/utils") local table = require("base/table") local string = require("base/string") local option = require("base/option") +local hashset = require("base/hashset") local tool = require("tool/tool") local config = require("project/config") local sandbox = require("sandbox/sandbox") @@ -439,7 +440,9 @@ end -- sort links of items function builder:_sort_links_of_items(target, items) local linkorders = target:get("linkorders") - if linkorders then + if linkorders and type(linkorders) == "table" and #linkorders > 1 then + + -- get all links local links = {} local link_mapper local framework_mapper @@ -459,7 +462,33 @@ function builder:_sort_links_of_items(target, items) end return removed end) - utils.dump(links) + links = table.reverse_unique(links) + + -- sort sublinks + local linkorders_set = hashset.from(linkorders) + local sublinks = {} + for _, link in ipairs(links) do + if linkorders_set:has(link) then + table.insert(sublinks, link) + end + end + if #sublinks > 0 then + local sublinks_set = hashset.from(sublinks) + local sublinks_order = {} + for _, link in ipairs(linkorders) do + if sublinks_set:has(link) then + table.insert(sublinks_order, link) + end + end + local sublinks_idx = 1 + for idx, link in ipairs(links) do + if sublinks_set:has(link) then + links[idx] = sublinks_order[sublinks_idx] + sublinks_idx = sublinks_idx + 1 + end + end + end + -- re-generate links to items list for _, link in ipairs(links) do if link:startswith("framework::") then link = link:sub(12) @@ -468,7 +497,6 @@ function builder:_sort_links_of_items(target, items) table.insert(items, {name = "links", values = table.wrap(link), check = false, multival = false, mapper = link_mapper}) end end - utils.dump(links) end end |
