summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-09-05 22:38:22 +0800
committerruki <[email protected]>2019-09-05 09:50:17 +0800
commitcd8458c4f16a8e22f688934162c97784b8b33297 (patch)
treeb3dd096cf71bb91a20b53c6d7193e81d1048117e
parentb01c414e9cbd34c22b7c33361d71f18dab7dec7f (diff)
fix dependent package links
-rw-r--r--xmake/core/tool/builder.lua71
1 files changed, 37 insertions, 34 deletions
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua
index ba6f3bcf2..f9cd6fe3d 100644
--- a/xmake/core/tool/builder.lua
+++ b/xmake/core/tool/builder.lua
@@ -117,61 +117,59 @@ function builder:_inherit_links_from_targetdeps(results, target, flagname)
-- for all target deps
local orderdeps = target:orderdeps()
local total = #orderdeps
+ local deplinks = {}
for idx, _ in ipairs(orderdeps) do
-- reverse deps order for links
local dep = orderdeps[total + 1 - idx]
- -- is static or shared target library? link it
+ -- the dependent target is static or shared library? inherit it's links
local depkind = dep:targetkind()
local targetkind = target:targetkind()
local depinherit = target:extraconf("deps", dep:name(), "inherit")
if (depkind == "static" or depkind == "shared" or depkind == "object") and (depinherit == nil or depinherit) then
- if (flagname == "links" or flagname == "syslinks") and (targetkind == "binary" or targetkind == "shared") then
+ if targetkind == "binary" or targetkind == "shared" then
+ if flagname == "links" or flagname == "syslinks" then
- -- add dependent link
- if depkind ~= "object" then
- table.insert(results, dep:basename())
- end
+ -- add dependent link
+ if depkind ~= "object" and flagname == "links" then
+ table.insert(results, dep:basename())
+ end
- -- inherit links from the depdent target
- self:_add_values_from_target(results, dep, flagname)
+ -- inherit links from the depdent target
+ self:_add_values_from_target(deplinks, dep, flagname)
- elseif flagname == "linkdirs" and (targetkind == "binary" or targetkind == "shared") then
+ elseif flagname == "linkdirs" then
- -- add dependent linkdirs
- if depkind ~= "object" then
- table.insert(results, path.directory(dep:targetfile()))
- end
+ -- add dependent linkdirs
+ if depkind ~= "object" then
+ table.insert(results, path.directory(dep:targetfile()))
+ end
- -- inherit linkdirs from the depdent target
- self:_add_values_from_target(results, dep, flagname)
+ -- inherit linkdirs from the depdent target
+ self:_add_values_from_target(results, dep, flagname)
- elseif flagname == "rpathdirs" and (targetkind == "binary" or targetkind == "shared") then
+ elseif flagname == "rpathdirs" then
- -- add dependent rpathdirs
- if depkind ~= "object" then
- local rpathdir = "@loader_path"
- local subdir = path.relative(path.directory(dep:targetfile()), path.directory(target:targetfile()))
- if subdir and subdir ~= '.' then
- rpathdir = path.join(rpathdir, subdir)
+ -- add dependent rpathdirs
+ if depkind ~= "object" then
+ local rpathdir = "@loader_path"
+ local subdir = path.relative(path.directory(dep:targetfile()), path.directory(target:targetfile()))
+ if subdir and subdir ~= '.' then
+ rpathdir = path.join(rpathdir, subdir)
+ end
+ table.insert(results, rpathdir)
end
- table.insert(results, rpathdir)
end
+ -- TODO deprecated
elseif flagname == "includedirs" then
- -- TODO add dependent headerdir (deprecated)
+ -- add dependent headerdir
if dep:get("headers") and os.isdir(dep:headerdir()) then
table.insert(results, dep:headerdir())
end
- -- add dependent header directories
- local headerdirs = dep:get("headerdirs")
- if headerdirs then
- table.join2(results, headerdirs)
- end
-
-- add dependent configheader directory
local configheader = dep:configheader()
if configheader and os.isfile(configheader) then
@@ -180,6 +178,11 @@ function builder:_inherit_links_from_targetdeps(results, target, flagname)
end
end
end
+
+ -- @note we need ensure add option and package links after all dependent targets
+ if #deplinks > 0 then
+ table.join2(results, deplinks)
+ end
end
-- inherit flags (only for public/interface) from target deps
@@ -231,9 +234,9 @@ end
-- add values from target options
function builder:_add_values_from_targetopts(values, target, name)
- for _, opt in ipairs(target:orderopts()) do
- table.join2(values, table.wrap(opt:get(name)))
- end
+ for _, opt in ipairs(target:orderopts()) do
+ table.join2(values, table.wrap(opt:get(name)))
+ end
end
-- add values from target packages
@@ -410,7 +413,7 @@ function builder:_add_flags_from_language(flags, target, getters)
-- is target? get flagvalues of the attached options and packages
local results = {}
if target:type() == "target" then
- self:_add_values_from_targetopts(results, target, name)
+ self:_add_values_from_targetopts(results, target, name)
self:_add_values_from_targetpkgs(results, target, name)
-- is option? get flagvalues of option with given flagname