summaryrefslogtreecommitdiff
path: root/xmake/plugins/pack/batchcmds.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-07-23 00:41:48 +0800
committerruki <[email protected]>2024-07-23 00:41:48 +0800
commit56ca5adad669d45f400198b0c99a1d20f546970c (patch)
tree4b51a8f0b6fde1388d5a0306c0d91551c60d37df /xmake/plugins/pack/batchcmds.lua
parent7aaf46f34749b39067bf9c70ba08138ec2708497 (diff)
improve to get deplibs
Diffstat (limited to 'xmake/plugins/pack/batchcmds.lua')
-rw-r--r--xmake/plugins/pack/batchcmds.lua26
1 files changed, 21 insertions, 5 deletions
diff --git a/xmake/plugins/pack/batchcmds.lua b/xmake/plugins/pack/batchcmds.lua
index c41efb89d..4017ed175 100644
--- a/xmake/plugins/pack/batchcmds.lua
+++ b/xmake/plugins/pack/batchcmds.lua
@@ -61,6 +61,26 @@ function _get_target_installdir(package, target)
return path.normalize(installdir)
end
+-- we need to get all deplibs, e.g. app -> libfoo.so -> libbar.so ...
+-- @see https://github.com/xmake-io/xmake/issues/5325#issuecomment-2242597732
+function _get_target_package_deplibs(target, depends, libfiles, binaryfile)
+ local deplibs = get_depend_libraries(binaryfile, {plat = target:plat(), arch = target:arch()})
+ local depends_new = hashset.new()
+ for _, deplib in ipairs(deplibs) do
+ local libname = path.filename(deplib)
+ if not depends:has(libname) then
+ depends:insert(libname)
+ depends_new:insert(libname)
+ end
+ end
+ for _, libfile in ipairs(libfiles) do
+ local libname = path.filename(libfile)
+ if depends_new:has(libname) then
+ _get_target_package_deplibs(target, depends, libfiles, libfile)
+ end
+ end
+end
+
function _get_target_package_libfiles(target, opt)
local libfiles = {}
for _, pkg in ipairs(target:orderpkgs(opt)) do
@@ -76,11 +96,7 @@ function _get_target_package_libfiles(target, opt)
-- we can only reserve used libraries
if target:is_binary() or target:is_shared() then
local depends = hashset.new()
- local targetfile = target:targetfile()
- local depend_libraries = get_depend_libraries(targetfile, {plat = target:plat(), arch = target:arch()})
- for _, libfile in ipairs(depend_libraries) do
- depends:insert(path.filename(libfile))
- end
+ _get_target_package_deplibs(target, depends, libfiles, target:targetfile())
table.remove_if(libfiles, function (_, libfile) return not depends:has(path.filename(libfile)) end)
end
return libfiles