diff options
| author | ruki <[email protected]> | 2025-07-26 00:44:04 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-07-26 00:44:04 +0800 |
| commit | 53d106bc017dc2e7db4bdff583ebe863c957ab9f (patch) | |
| tree | 36aa368c8d2c0faec1b8556b45b632fe7280c7e7 /xmake/plugins/pack/batchcmds.lua | |
| parent | 8f3b582019d38f1aa9d774b1c752f9a5f18507fc (diff) | |
improve deplibs
Diffstat (limited to 'xmake/plugins/pack/batchcmds.lua')
| -rw-r--r-- | xmake/plugins/pack/batchcmds.lua | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/xmake/plugins/pack/batchcmds.lua b/xmake/plugins/pack/batchcmds.lua index c768453d0..df0c506e0 100644 --- a/xmake/plugins/pack/batchcmds.lua +++ b/xmake/plugins/pack/batchcmds.lua @@ -62,26 +62,6 @@ 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(binaryfile, depends, libfiles, opt) - local deplibs = get_depend_libraries(binaryfile, {plat = opt.plat, arch = opt.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(libfile, depends, libfiles, opt) - end - end -end - function _get_target_package_libfiles(target, opt) if option.get("nopkgs") then return {} @@ -101,9 +81,16 @@ function _get_target_package_libfiles(target, opt) -- we can only reserve used libraries if project.policy("install.strip_packagelibs") then if target:is_binary() or target:is_shared() or opt.binaryfile then - local depends = hashset.new() - _get_target_package_deplibs(opt.binaryfile or target:targetfile(), depends, libfiles, {plat = target:plat(), arch = target:arch()}) - table.remove_if(libfiles, function (_, libfile) return not depends:has(path.filename(libfile)) 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 + local deplibs = get_depend_libraries(opt.binaryfile or target:targetfile(), {recursive = true, plat = target:plat(), arch = target:arch()}) + if deplibs then + local depends = hashset.new() + for _, deplib in ipairs(deplibs) do + depends:insert(path.filename(deplib)) + end + table.remove_if(libfiles, function (_, libfile) return not depends:has(path.filename(libfile)) end) + end end end return libfiles |
