summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-12-18 15:18:08 +0800
committerGitHub <[email protected]>2022-12-18 15:18:08 +0800
commit4e4f010e7fd1123dcbc272549f3d45f5261bc8a9 (patch)
treeede1d207f878ddb47727cdd037a86b0c6e6a4259
parent66991f330fcfe08630fd2c028f45d7a54b5fd7be (diff)
parent7108528ba8b47cc9388109f1f246e910204ff030 (diff)
Merge pull request #3179 from xmake-io/link
fix link
-rw-r--r--tests/apis/clone_target/test.lua2
-rw-r--r--xmake/core/base/private/instance_deps.lua13
2 files changed, 12 insertions, 3 deletions
diff --git a/tests/apis/clone_target/test.lua b/tests/apis/clone_target/test.lua
index a4a38b0ce..83c0a9546 100644
--- a/tests/apis/clone_target/test.lua
+++ b/tests/apis/clone_target/test.lua
@@ -1,3 +1,3 @@
function main()
- os.exec("xmake")
+ os.exec("xmake -vD")
end
diff --git a/xmake/core/base/private/instance_deps.lua b/xmake/core/base/private/instance_deps.lua
index 535b2d2bb..857e3a2e1 100644
--- a/xmake/core/base/private/instance_deps.lua
+++ b/xmake/core/base/private/instance_deps.lua
@@ -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 plaindeps = table.wrap(instance:get("deps"))
+ local total = #plaindeps
+ for idx, _ in ipairs(plaindeps) 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 = plaindeps[total + 1 - idx]
local depinst = instances[dep]
if depinst then
local depspath_sub
@@ -75,3 +83,4 @@ end
-- return module
return instance_deps
+