Skip to content

Commit

Permalink
fix link order #3177 #3144
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Dec 18, 2022
1 parent 47f6392 commit 62ca3cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions xmake/core/base/private/instance_deps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,19 @@ local table = require("base/table")
--
-- a.deps = b
-- b.deps = c
-- foo.deps = a d
--
-- orderdeps: c -> b -> a
-- orderdeps: c -> b -> d -> a -> foo
--
-- if they're target, their links order is reverse(orderdeps), e.g. foo-> a -> d -> b -> c
--
function instance_deps.load_deps(instance, instances, deps, orderdeps, depspath)
for _, dep in ipairs(table.wrap(instance:get("deps"))) do
local deps = table.wrap(instance:get("deps"))
local total = #deps
for idx, _ in ipairs(deps) do
-- we reverse to get the flat dependencies in order to ensure the correct linking order
-- @see https://github.com/xmake-io/xmake/issues/3144
local dep = deps[total + 1 - idx]
local depinst = instances[dep]
if depinst then
local depspath_sub
Expand Down
4 changes: 3 additions & 1 deletion xmake/core/project/target.lua
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,9 @@ end
function _instance:get_from_deps(name, opt)
local values = {}
local orderdeps = self:orderdeps()
for _, dep in ipairs(orderdeps) do
local total = #orderdeps
for idx, _ in ipairs(orderdeps) do
local dep = orderdeps[total + 1 - idx]
local depinherit = self:extraconf("deps", dep:name(), "inherit")
if depinherit == nil or depinherit then
table.join2(values, dep:get(name, opt))
Expand Down

0 comments on commit 62ca3cf

Please sign in to comment.