diff options
| author | ruki <[email protected]> | 2024-07-11 22:48:29 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-07-11 22:48:29 +0800 |
| commit | caf06e43fb5931197b18b853462b9f40c6acff84 (patch) | |
| tree | 1e3475506e80c1c0555de77997f6a6fa513476a5 /xmake/modules/utils | |
| parent | b29871ae1036ac77e35c2eb84d32b5fbda314572 (diff) | |
dump deps by objdump
Diffstat (limited to 'xmake/modules/utils')
| -rw-r--r-- | xmake/modules/utils/symbols/depend.lua | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/xmake/modules/utils/symbols/depend.lua b/xmake/modules/utils/symbols/depend.lua index 08381c419..ab317f5d5 100644 --- a/xmake/modules/utils/symbols/depend.lua +++ b/xmake/modules/utils/symbols/depend.lua @@ -55,12 +55,50 @@ function _get_all_depends_by_dumpbin(binaryfile, opt) return depends end +function _get_all_depends_by_objdump(binaryfile, opt) + local depends + local cachekey = "utils.symbols.depend" + local objdump = find_tool("llvm-objdump", {cachekey = cachekey}) or find_tool("objdump", {cachekey = cachekey}) + if objdump then + local binarydir = path.directory(binaryfile) + local result = try { function () return os.iorunv(objdump.program, {"-p", binaryfile}) end } + if result then + for _, line in ipairs(result:split("\n")) do + line = line:trim() + if line:startswith("DLL Name:") then + local filename = line:split(":")[2]:trim() + if filename:endswith(".dll") then + local dependfile + if os.isfile(filename) then + dependfile = line + elseif os.isfile(path.join(binarydir, filename)) then + dependfile = path.join(binarydir, filename) + end + if dependfile then + depends = depends or {} + table.insert(depends, path.absolute(dependfile)) + end + end + end + end + end + end + return depends +end + function main(binaryfile, opt) opt = opt or {} - local depends + local dumpers = { + _get_all_depends_by_objdump + } if is_host("windows") then - depends = _get_all_depends_by_dumpbin(binaryfile, opt) + table.insert(dumpers, _get_all_depends_by_dumpbin) + end + for _, dump in ipairs(dumpers) do + local depends = dump(binaryfile, opt) + if depends then + return depends + end end - return depends end |
