diff options
Diffstat (limited to 'xmake')
| -rw-r--r-- | xmake/core/base/binutils.lua | 10 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/base/binutils.lua | 10 | ||||
| -rw-r--r-- | xmake/modules/utils/binary/rpath.lua | 8 |
3 files changed, 27 insertions, 1 deletions
diff --git a/xmake/core/base/binutils.lua b/xmake/core/base/binutils.lua index af71e8ae7..5bed5de21 100644 --- a/xmake/core/base/binutils.lua +++ b/xmake/core/base/binutils.lua @@ -31,6 +31,7 @@ binutils._bin2macho = binutils._bin2macho or binutils.bin2macho binutils._bin2elf = binutils._bin2elf or binutils.bin2elf binutils._readsyms = binutils._readsyms or binutils.readsyms binutils._deplibs = binutils._deplibs or binutils.deplibs +binutils._rpath_list = binutils._rpath_list or binutils.rpath_list binutils._extractlib = binutils._extractlib or binutils.extractlib -- generate c/c++ code from the binary file @@ -111,6 +112,15 @@ function binutils.deplibs(binaryfile) end end +-- get rpath list from binary file (auto-detect format: ELF or Mach-O) +function binutils.rpath_list(binaryfile) + if binutils._rpath_list then + return binutils._rpath_list(binaryfile) + else + return nil, "binutils: internal rpath_list not supported!" + end +end + -- extract static library to directory -- Supports AR format (.a) and MSVC lib format (.lib) -- @param libraryfile the static library file path (.a or .lib) diff --git a/xmake/core/sandbox/modules/import/core/base/binutils.lua b/xmake/core/sandbox/modules/import/core/base/binutils.lua index 11f432340..b7b8a1792 100644 --- a/xmake/core/sandbox/modules/import/core/base/binutils.lua +++ b/xmake/core/sandbox/modules/import/core/base/binutils.lua @@ -62,6 +62,16 @@ function sandbox_core_base_binutils.deplibs(binaryfile) end end +-- get rpath list from binary file (auto-detect format: ELF or Mach-O) +function sandbox_core_base_binutils.rpath_list(binaryfile) + local rpaths, errors = binutils.rpath_list(binaryfile) + if rpaths then + return rpaths + else + raise("rpath_list: %s", errors or "unknown errors") + end +end + -- extract static library to directory function sandbox_core_base_binutils.extractlib(libraryfile, outputdir, opt) local ok, errors = binutils.extractlib(libraryfile, outputdir, opt) diff --git a/xmake/modules/utils/binary/rpath.lua b/xmake/modules/utils/binary/rpath.lua index 271ef8939..6152d4d14 100644 --- a/xmake/modules/utils/binary/rpath.lua +++ b/xmake/modules/utils/binary/rpath.lua @@ -20,6 +20,7 @@ -- imports import("core.base.option") +import("core.base.binutils") import("lib.detect.find_tool") function _replace_rpath_vars(rpath, opt) @@ -34,6 +35,10 @@ function _replace_rpath_vars(rpath, opt) return rpath end +function _get_rpath_list_by_binutils(binaryfile, opt) + return binutils.rpath_list(binaryfile) +end + function _get_rpath_list_by_objdump(binaryfile, opt) local list local plat = opt.plat or os.host() @@ -296,7 +301,8 @@ function list(binaryfile, opt) local ops = { _get_rpath_list_by_objdump, _get_rpath_list_by_readelf, - _get_rpath_list_by_patchelf + _get_rpath_list_by_patchelf, + _get_rpath_list_by_binutils } if is_host("macosx") then table.insert(ops, 1, _get_rpath_list_by_otool) |
