diff options
| author | ruki <[email protected]> | 2025-12-07 11:36:02 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-12-07 17:15:59 +0800 |
| commit | 1ef6dddad4c6a3a2e3b3b79667e7f4568f7cfda0 (patch) | |
| tree | 7dd959bba3f618f2cc32e229e46b65d4cee4c2da /xmake | |
| parent | cae5b0a17dc7d0eb5599c0d5a92fab69d39983d5 (diff) | |
improve minos and sdkver
Diffstat (limited to 'xmake')
| -rw-r--r-- | xmake/core/sandbox/modules/utils.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/private/utils/bin2obj.lua | 18 | ||||
| -rw-r--r-- | xmake/rules/utils/bin2obj/xmake.lua | 20 |
3 files changed, 33 insertions, 9 deletions
diff --git a/xmake/core/sandbox/modules/utils.lua b/xmake/core/sandbox/modules/utils.lua index b6dfedd45..b3453cb92 100644 --- a/xmake/core/sandbox/modules/utils.lua +++ b/xmake/core/sandbox/modules/utils.lua @@ -170,8 +170,8 @@ end -- generate Mach-O object file from the binary file if utils.bin2macho then - function sandbox_utils.bin2macho(binaryfile, outputfile, symbol_prefix, plat, arch, basename) - local ok, errors = utils.bin2macho(binaryfile, outputfile, symbol_prefix, plat, arch, basename) + function sandbox_utils.bin2macho(binaryfile, outputfile, symbol_prefix, plat, arch, basename, target_minver, xcode_sdkver) + local ok, errors = utils.bin2macho(binaryfile, outputfile, symbol_prefix, plat, arch, basename, target_minver, xcode_sdkver) if not ok then os.raise(errors) end diff --git a/xmake/modules/private/utils/bin2obj.lua b/xmake/modules/private/utils/bin2obj.lua index a27f5c5dc..a41c919fe 100644 --- a/xmake/modules/private/utils/bin2obj.lua +++ b/xmake/modules/private/utils/bin2obj.lua @@ -25,14 +25,16 @@ local options = { {'i', "binarypath", "kv", nil, "Set the binary file path."}, {'o', "outputpath", "kv", nil, "Set the output object file path."}, {'f', "format", "kv", nil, "Set the object file format (coff, elf, macho)."}, - {nil, "symbol-prefix", "kv", nil, "Set the symbol prefix (default: _binary_)."}, + {nil, "symbol_prefix", "kv", nil, "Set the symbol prefix (default: _binary_)."}, {'a', "arch", "kv", nil, "Set the target architecture."}, - {'p', "plat", "kv", nil, "Set the target platform (macosx, iphoneos, etc.)."} + {'p', "plat", "kv", nil, "Set the target platform (macosx, iphoneos, etc.)."}, + {nil, "target_minver", "kv", nil, "Set the target minimum version (e.g., 10.0, 18.2)."}, + {nil, "xcode_sdkver", "kv", nil, "Set the Xcode SDK version (e.g., 10.0, 18.2)."} } function _do_bin2obj_coff(binarypath, outputpath, opt) -- get symbol prefix - local symbol_prefix = opt["symbol-prefix"] or "_binary_" + local symbol_prefix = opt.symbol_prefix or "_binary_" -- get architecture (default: x86_64) local arch = opt.arch or "x86_64" @@ -65,7 +67,7 @@ end function _do_bin2obj_macho(binarypath, outputpath, opt) -- get symbol prefix - local symbol_prefix = opt["symbol-prefix"] or "_binary_" + local symbol_prefix = opt.symbol_prefix or "_binary_" -- get platform (default: macosx) local plat = opt.plat or "macosx" @@ -73,6 +75,12 @@ function _do_bin2obj_macho(binarypath, outputpath, opt) -- get architecture (default: x86_64) local arch = opt.arch or "x86_64" + -- get target minimum version (default: nil, will use default 10.0.0 in C) + local target_minver = opt.target_minver + + -- get xcode sdk version (default: nil, will use default 10.0.0 in C) + local xcode_sdkver = opt.xcode_sdkver + -- get filename from binary path (with extension, dots replaced with underscores) local filename = path.filename(binarypath) -- replace dots with underscores for symbol name (e.g., data.bin -> data_bin) @@ -83,7 +91,7 @@ function _do_bin2obj_macho(binarypath, outputpath, opt) -- do dump if utils.bin2macho then - utils.bin2macho(binarypath, outputpath, symbol_prefix, plat, arch, basename) + utils.bin2macho(binarypath, outputpath, symbol_prefix, plat, arch, basename, target_minver, xcode_sdkver) else raise("bin2obj: utils.bin2macho not available (C implementation not compiled)") end diff --git a/xmake/rules/utils/bin2obj/xmake.lua b/xmake/rules/utils/bin2obj/xmake.lua index def3f56e8..1f8e6e0b2 100644 --- a/xmake/rules/utils/bin2obj/xmake.lua +++ b/xmake/rules/utils/bin2obj/xmake.lua @@ -53,6 +53,17 @@ rule("utils.bin2obj") -- get platform local plat = target:plat() + -- get target_minver and xcode_sdkver from xcode toolchain (if available) + local target_minver = nil + local xcode_sdkver = nil + if format == "macho" then + local toolchain = target:toolchain("xcode") + if toolchain then + target_minver = toolchain:config("target_minver") + xcode_sdkver = toolchain:config("xcode_sdkver") + end + end + -- convert binary file to object file local argv = { "-i", path(sourcefile_bin), @@ -62,8 +73,13 @@ rule("utils.bin2obj") "-p", plat } if symbol_prefix ~= "_binary_" then - table.insert(argv, "--symbol-prefix") - table.insert(argv, symbol_prefix) + table.insert(argv, "--symbol_prefix=" .. symbol_prefix) + end + if target_minver then + table.insert(argv, "--target_minver=" .. target_minver) + end + if xcode_sdkver then + table.insert(argv, "--xcode_sdkver=" .. xcode_sdkver) end batchcmds:vlua("private.utils.bin2obj", argv) |
