diff options
| author | ruki <[email protected]> | 2025-12-10 00:48:15 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-12-12 09:00:43 +0800 |
| commit | 094b9b26786db5960947819680ccc49985f5ed55 (patch) | |
| tree | d980e4bb569b5ac8b6b0c482b09aaabd4eb63b01 /xmake/core/base/binutils.lua | |
| parent | 245d472158edc782c4ee7ddb6d47be65270c5451 (diff) | |
add binutils extractlib
Diffstat (limited to 'xmake/core/base/binutils.lua')
| -rw-r--r-- | xmake/core/base/binutils.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/xmake/core/base/binutils.lua b/xmake/core/base/binutils.lua index 77b17dc92..ea5d04ba8 100644 --- a/xmake/core/base/binutils.lua +++ b/xmake/core/base/binutils.lua @@ -30,6 +30,7 @@ binutils._bin2coff = binutils._bin2coff or binutils.bin2coff binutils._bin2macho = binutils._bin2macho or binutils.bin2macho binutils._bin2elf = binutils._bin2elf or binutils.bin2elf binutils._readsyms = binutils._readsyms or binutils.readsyms +binutils._extractlib = binutils._extractlib or binutils.extractlib -- generate c/c++ code from the binary file function binutils.bin2c(binaryfile, outputfile, opt) @@ -100,6 +101,24 @@ function binutils.readsyms(binaryfile) 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) +-- @param outputdir the output directory to extract object files +-- @return true on success, false and error message on failure +function binutils.extractlib(libraryfile, outputdir) + if binutils._extractlib then + local ok, errors = binutils._extractlib(libraryfile, outputdir) + if ok then + return true + else + return false, errors or "extractlib: unknown error" + end + else + return false, "extractlib: C implementation not available" + end +end + -- return module return binutils |
