diff options
| author | ruki <[email protected]> | 2025-12-09 22:34:36 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-12-09 22:34:36 +0800 |
| commit | 5931e48282914758fd7c4eeaf9ca05a16521692b (patch) | |
| tree | f06ffda22f2675a3e08979503b4bff1de0e08e0f /xmake/core/base/binutils.lua | |
| parent | 102507b96dab0403592c07c8760644f08ed66dff (diff) | |
fix compile error
Diffstat (limited to 'xmake/core/base/binutils.lua')
| -rw-r--r-- | xmake/core/base/binutils.lua | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/xmake/core/base/binutils.lua b/xmake/core/base/binutils.lua index 995f0d0a7..77b17dc92 100644 --- a/xmake/core/base/binutils.lua +++ b/xmake/core/base/binutils.lua @@ -21,6 +21,9 @@ -- define module local binutils = binutils or {} +-- load modules +local os = require("base/os") + -- save original interfaces binutils._bin2c = binutils._bin2c or binutils.bin2c binutils._bin2coff = binutils._bin2coff or binutils.bin2coff @@ -55,7 +58,15 @@ function binutils.bin2obj(binaryfile, outputfile, opt) opt = opt or {} local format = opt.format if not format then - return nil, "bin2obj: format is required (coff, elf, or macho)" + -- auto-detect format based on host platform + local host = os.host() + if host == "windows" or host == "mingw" or host == "msys" or host == "cygwin" then + format = "coff" + elseif host == "macosx" or host == "iphoneos" or host == "watchos" or host == "appletvos" then + format = "macho" + else + format = "elf" + end end format = format:lower() |
