diff options
| author | ruki <[email protected]> | 2025-07-26 00:54:18 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-07-26 00:54:18 +0800 |
| commit | 67ef64a4a1d823f93029dab849dd0b64702c7b7e (patch) | |
| tree | 358cb1a09c04661072cb2b4fe2f095bbd7c3c813 /xmake/modules/utils/binary/deplibs.lua | |
| parent | 3eb8749861478f3d396d6a4692dcf23e35a237dd (diff) | |
resolve path form path envs
Diffstat (limited to 'xmake/modules/utils/binary/deplibs.lua')
| -rw-r--r-- | xmake/modules/utils/binary/deplibs.lua | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/xmake/modules/utils/binary/deplibs.lua b/xmake/modules/utils/binary/deplibs.lua index b3c1c257d..5ed9108a4 100644 --- a/xmake/modules/utils/binary/deplibs.lua +++ b/xmake/modules/utils/binary/deplibs.lua @@ -236,6 +236,7 @@ end function _resolve_filepath(binaryfile, dependfile, opt) local loaderfile = opt._loaderfile local resolve_hint_paths = opt.resolve_hint_paths + local resolve_search_paths = opt.resolve_search_paths local resolved = false -- resolve path from rpath @@ -301,8 +302,28 @@ function _resolve_filepath(binaryfile, dependfile, opt) end end - -- TODO + -- resolve path from the searth paths + if resolve_search_paths then + for _, searchdir in ipairs(resolve_search_paths) do + local filepath = path.join(searchdir, dependfile) + if os.isfile(filepath) then + dependfile = path.absolute(filepath) + resolved = true + end + end + end + -- resolve path from LD_LIBRARY_PATH, ... + local library_paths = is_host("macosx") and os.getenv("DYLD_LIBRARY_PATH") or os.getenv("LD_LIBRARY_PATH") + if library_paths then + for _, searchdir in ipairs(path.splitenv(library_paths)) do + local filepath = path.join(searchdir, dependfile) + if os.isfile(filepath) then + dependfile = path.absolute(filepath) + resolved = true + end + end + end end dependfile = path.normalize(dependfile) @@ -349,6 +370,7 @@ end -- - recursive: recursively get all sub-dependencies, sorted by topology -- - resolve_path: try to resolve the file full path, e.g. @rpath, @loader_path, $ORIGIN, relative path .. -- - resolve_hint_paths: we can resolve and match path from them +-- - resolve_search_paths: the search library paths, like: LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, ... -- function main(binaryfile, opt) opt = opt or {} |
