summaryrefslogtreecommitdiff
path: root/xmake/modules/utils/binary/deplibs.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-07-26 00:44:04 +0800
committerruki <[email protected]>2025-07-26 00:44:04 +0800
commit53d106bc017dc2e7db4bdff583ebe863c957ab9f (patch)
tree36aa368c8d2c0faec1b8556b45b632fe7280c7e7 /xmake/modules/utils/binary/deplibs.lua
parent8f3b582019d38f1aa9d774b1c752f9a5f18507fc (diff)
improve deplibs
Diffstat (limited to 'xmake/modules/utils/binary/deplibs.lua')
-rw-r--r--xmake/modules/utils/binary/deplibs.lua55
1 files changed, 29 insertions, 26 deletions
diff --git a/xmake/modules/utils/binary/deplibs.lua b/xmake/modules/utils/binary/deplibs.lua
index fdc873b31..b81d644d8 100644
--- a/xmake/modules/utils/binary/deplibs.lua
+++ b/xmake/modules/utils/binary/deplibs.lua
@@ -67,27 +67,29 @@ function _get_depends_by_objdump(binaryfile, opt)
if result then
for _, line in ipairs(result:split("\n")) do
line = line:trim()
- if plat == "windows" or plat == "mingw" then
- if line:startswith("DLL Name:") then
- local filename = line:split(":")[2]:trim()
- if filename:endswith(".dll") then
- depends = depends or {}
- table.insert(depends, filename)
+ if not line:endswith(":") then
+ if plat == "windows" or plat == "mingw" then
+ if line:startswith("DLL Name:") then
+ local filename = line:split(":")[2]:trim()
+ if filename:endswith(".dll") then
+ depends = depends or {}
+ table.insert(depends, filename)
+ end
end
- end
- elseif plat == "macosx" or plat == "iphoneos" or plat == "appletvos" or plat == "watchos" then
- local filename = line:match(".-%.dylib") or line:match(".-%.framework")
- if filename then
- depends = depends or {}
- table.insert(depends, filename)
- end
- else
- if line:startswith("NEEDED") then
- local filename = line:split("%s+")[2]
- if filename and filename:endswith(".so") or filename:find("%.so[%.%d+]+$") then
+ elseif plat == "macosx" or plat == "iphoneos" or plat == "appletvos" or plat == "watchos" then
+ local filename = line:match(".-%.dylib") or line:match(".-%.framework")
+ if filename then
depends = depends or {}
table.insert(depends, filename)
end
+ else
+ if line:startswith("NEEDED") then
+ local filename = line:split("%s+")[2]
+ if filename and filename:endswith(".so") or filename:find("%.so[%.%d+]+$") then
+ depends = depends or {}
+ table.insert(depends, filename)
+ end
+ end
end
end
end
@@ -195,10 +197,13 @@ function _get_depends_by_otool(binaryfile, opt)
local result = try { function () return os.iorunv(otool.program, {"-L", binaryfile}) end }
if result then
for _, line in ipairs(result:split("\n")) do
- local filename = line:match(".-%.dylib") or line:match(".-%.framework")
- if filename then
- depends = depends or {}
- table.insert(depends, filename:trim())
+ line = line:trim()
+ if not line:endswith(":") then
+ local filename = line:match(".-%.dylib") or line:match(".-%.framework")
+ if filename then
+ depends = depends or {}
+ table.insert(depends, filename:trim())
+ end
end
end
end
@@ -240,18 +245,18 @@ function _resolve_filepath(binaryfile, dependfile, opt)
for _, rpath in ipairs(rpathlist) do
local filepath = dependfile:replace("@rpath/", rpath .. "/", {plain = true})
if os.isfile(filepath) then
- dependfile = filepath
+ dependfile = path.absolute(filepath)
break
elseif filepath:startswith("@loader_path/") then
filepath = filepath:replace("@loader_path/", path.directory(loaderfile) .. "/", {plain = true})
if os.isfile(filepath) then
- dependfile = filepath
+ dependfile = path.absolute(filepath)
break
end
elseif filepath:startswith("$ORIGIN/") then
filepath = filepath:replace("$ORIGIN/", path.directory(loaderfile) .. "/", {plain = true})
if os.isfile(filepath) then
- dependfile = filepath
+ dependfile = path.absolute(filepath)
break
end
end
@@ -304,8 +309,6 @@ end
--
function main(binaryfile, opt)
opt = opt or {}
- --opt.recursive = true
- --opt.resolve_path = true
if opt.resolve_path then
opt._loaderfile = binaryfile
end