summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-03-30 00:56:15 +0800
committerruki <[email protected]>2024-03-30 00:56:15 +0800
commite9ded8fe9241b33bebd4902424ac4e0278386a36 (patch)
tree7b12b41d2dc1ab9cef123d4ffc93c7fa4fe3b61f
parent50dbca64847f4ac58bf889c158f4a726dfd02cc1 (diff)
improve to inherit links for object #4887
-rw-r--r--xmake/rules/utils/inherit_links/inherit_links.lua31
1 files changed, 15 insertions, 16 deletions
diff --git a/xmake/rules/utils/inherit_links/inherit_links.lua b/xmake/rules/utils/inherit_links/inherit_links.lua
index 2bfd3076f..b40800756 100644
--- a/xmake/rules/utils/inherit_links/inherit_links.lua
+++ b/xmake/rules/utils/inherit_links/inherit_links.lua
@@ -65,9 +65,8 @@ function main(target)
return
end
- -- export links and linkdirs
- local targetkind = target:kind()
- if targetkind == "shared" or targetkind == "static" then
+ -- export target links and linkdirs
+ if target:is_shared() or target:is_static() then
local targetfile = target:targetfile()
-- rust maybe will disable inherit links, only inherit linkdirs
@@ -86,26 +85,26 @@ function main(target)
-- we need to add includedirs to support import modules for golang
_add_export_value(target, "includedirs", path.directory(targetfile))
end
+ end
- -- we export all links and linkdirs in self/packages/options to the parent target by default
- --
- -- @note we only export links for static target,
- -- and we need to pass `{public = true}` to add_packages/add_links/... to export it if want to export links for shared target
- --
- if target:data("inherit.links.exportlinks") ~= false then
- if targetkind == "static" then
- for _, name in ipairs({"rpathdirs", "frameworkdirs", "frameworks", "linkdirs", "links", "syslinks", "ldflags", "shflags"}) do
- local values = _get_values_from_target(target, name)
- if values and #values > 0 then
- _add_export_values(target, name, values)
- end
+ -- we export all links and linkdirs in self/packages/options to the parent target by default
+ --
+ -- @note we only export links for static target,
+ -- and we need to pass `{public = true}` to add_packages/add_links/... to export it if want to export links for shared target
+ --
+ if target:data("inherit.links.exportlinks") ~= false then
+ if target:is_static() or target:is_object() then
+ for _, name in ipairs({"rpathdirs", "frameworkdirs", "frameworks", "linkdirs", "links", "syslinks", "ldflags", "shflags"}) do
+ local values = _get_values_from_target(target, name)
+ if values and #values > 0 then
+ _add_export_values(target, name, values)
end
end
end
end
-- export rpathdirs for all shared library
- if targetkind == "binary" then
+ if target:is_binary() then
local targetdir = target:targetdir()
for _, dep in ipairs(target:orderdeps({inherit = true})) do
if dep:kind() == "shared" then