Skip to content

Commit

Permalink
prepare to sort package links
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Oct 26, 2023
1 parent ab8ceb9 commit ee9a61f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
1 change: 0 additions & 1 deletion xmake/core/package/package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
54 changes: 51 additions & 3 deletions xmake/modules/package/manager/xmake/find_package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ee9a61f

Please sign in to comment.