summaryrefslogtreecommitdiff
path: root/xmake/core/tool/builder.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-09-28 23:11:18 +0800
committerruki <[email protected]>2023-09-28 23:11:18 +0800
commitca1eba2d96ed24fd2070b45de35c42ce3b37b066 (patch)
treeaab939deefcce6901d6add8fd4a38239bdd6b76e /xmake/core/tool/builder.lua
parent2aa8a4a793f3a7281487d6bc8334f975fa6bd26d (diff)
remove linkgroups from links
Diffstat (limited to 'xmake/core/tool/builder.lua')
-rw-r--r--xmake/core/tool/builder.lua34
1 files changed, 27 insertions, 7 deletions
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua
index 9c44c2c71..f867304b1 100644
--- a/xmake/core/tool/builder.lua
+++ b/xmake/core/tool/builder.lua
@@ -441,33 +441,48 @@ end
function builder:_sort_links_of_items(target, items)
local sortlinks = false
local makegroups = false
- local linkorders = target:get("linkorders")
- if linkorders and type(linkorders) == "table" and #linkorders > 1 then
+ local linkorders = table.wrap(target:get("linkorders"))
+ if #linkorders > 0 then
sortlinks = true
end
- local linkgroups = target:get("linkgroups")
- if linkgroups and type(linkgroups) == "table" and #linkgroups > 1 then
+ local linkgroups = table.wrap(target:get("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
- utils.dump(linkorders)
-- get all links
local links = {}
+ local linkgroups_map = {}
local link_mapper
local framework_mapper
+ local linkgroup_mapper
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
- table.insert(links, value)
+ if not linkgroups_set:has(value) then
+ table.insert(links, value)
+ end
link_mapper = item.mapper
removed = true
elseif name == "frameworks" then
table.insert(links, "framework::" .. value)
framework_mapper = item.mapper
removed = true
+ elseif name == "linkgroups" then
+ local key = tostring(value)
+ table.insert(links, "linkgroup::" .. key)
+ linkgroups_map[key] = value
+ linkgroup_mapper = item.mapper
+ removed = true
end
end
return removed
@@ -476,6 +491,7 @@ function builder:_sort_links_of_items(target, items)
end
-- sort sublinks
+ --[[
if sortlinks then
local linkorders_set = hashset.from(linkorders)
local sublinks = {}
@@ -500,7 +516,7 @@ function builder:_sort_links_of_items(target, items)
end
end
end
- end
+ end]]
-- re-generate links to items list
if sortlinks or makegroups then
@@ -508,6 +524,10 @@ function builder:_sort_links_of_items(target, items)
if link:startswith("framework::") then
link = link:sub(12)
table.insert(items, {name = "frameworks", values = table.wrap(link), check = false, multival = false, mapper = framework_mapper})
+ elseif link:startswith("linkgroup::") then
+ local key = link:sub(12)
+ local value = linkgroups_map[key]
+ table.insert(items, {name = "linkgroups", values = table.wrap(value), check = false, multival = false, mapper = linkgroup_mapper})
else
table.insert(items, {name = "links", values = table.wrap(link), check = false, multival = false, mapper = link_mapper})
end