From c8d424baeb7b93e2a1e900b271bcc09144fdce94 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 11 Dec 2025 23:01:24 +0800 Subject: improve binutils and add cli modules --- xmake/modules/cli/binutils/bin2obj.lua | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 xmake/modules/cli/binutils/bin2obj.lua (limited to 'xmake/modules/cli/binutils/bin2obj.lua') diff --git a/xmake/modules/cli/binutils/bin2obj.lua b/xmake/modules/cli/binutils/bin2obj.lua new file mode 100644 index 000000000..33eb0511e --- /dev/null +++ b/xmake/modules/cli/binutils/bin2obj.lua @@ -0,0 +1,47 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, Xmake Open Source Community. +-- +-- @author ruki +-- @file bin2obj.lua +-- + +-- imports +import("core.base.option") +import("utils.binary.bin2obj") + +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_)."}, + {'a', "arch", "kv", nil, "Set the target architecture."}, + {'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)."}, + {nil, "zeroend", "k", nil, "Append a null terminator ('\\0') at the end of data."} +} + +function main(...) + + -- parse arguments + local argv = {...} + local opt = option.parse(argv, options, "Convert binary file to object file for direct linking." + , "" + , "Usage: xmake l cli.binutils.bin2obj [options]") + + -- do bin2obj + bin2obj.main(opt.binarypath, opt.outputpath, opt) +end -- cgit v1.3.1 From 7b7db07e2cada2ca610a352297aadce993596947 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 11 Dec 2025 23:01:52 +0800 Subject: fix error --- xmake/modules/cli/binutils/bin2c.lua | 7 +++++++ xmake/modules/cli/binutils/bin2obj.lua | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'xmake/modules/cli/binutils/bin2obj.lua') diff --git a/xmake/modules/cli/binutils/bin2c.lua b/xmake/modules/cli/binutils/bin2c.lua index f2b03acdf..423d4f3eb 100644 --- a/xmake/modules/cli/binutils/bin2c.lua +++ b/xmake/modules/cli/binutils/bin2c.lua @@ -37,6 +37,13 @@ function main(...) , "" , "Usage: xmake l cli.binutils.bin2c [options]") + -- check arguments + if not opt.binarypath or not opt.outputpath then + cprint("${bright}Usage: $${clear}xmake l cli.binutils.bin2c [options]") + option.show_options(options, "bin2c") + return + end + -- do bin2c bin2c.main(opt.binarypath, opt.outputpath, opt) end diff --git a/xmake/modules/cli/binutils/bin2obj.lua b/xmake/modules/cli/binutils/bin2obj.lua index 33eb0511e..9024d4b24 100644 --- a/xmake/modules/cli/binutils/bin2obj.lua +++ b/xmake/modules/cli/binutils/bin2obj.lua @@ -42,6 +42,13 @@ function main(...) , "" , "Usage: xmake l cli.binutils.bin2obj [options]") + -- check arguments + if not opt.binarypath or not opt.outputpath then + cprint("${bright}Usage: $${clear}xmake l cli.binutils.bin2obj [options]") + option.show_options(options, "bin2obj") + return + end + -- do bin2obj bin2obj.main(opt.binarypath, opt.outputpath, opt) end -- cgit v1.3.1 From 17a01fd9a3bad40cb41d884bdee8701e8b61ee6f Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 11 Dec 2025 23:02:00 +0800 Subject: format code --- xmake/modules/cli/binutils/bin2c.lua | 2 +- xmake/modules/cli/binutils/bin2obj.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'xmake/modules/cli/binutils/bin2obj.lua') diff --git a/xmake/modules/cli/binutils/bin2c.lua b/xmake/modules/cli/binutils/bin2c.lua index 423d4f3eb..83e0a88c1 100644 --- a/xmake/modules/cli/binutils/bin2c.lua +++ b/xmake/modules/cli/binutils/bin2c.lua @@ -41,7 +41,7 @@ function main(...) if not opt.binarypath or not opt.outputpath then cprint("${bright}Usage: $${clear}xmake l cli.binutils.bin2c [options]") option.show_options(options, "bin2c") - return + return end -- do bin2c diff --git a/xmake/modules/cli/binutils/bin2obj.lua b/xmake/modules/cli/binutils/bin2obj.lua index 9024d4b24..6ee6c2158 100644 --- a/xmake/modules/cli/binutils/bin2obj.lua +++ b/xmake/modules/cli/binutils/bin2obj.lua @@ -46,7 +46,7 @@ function main(...) if not opt.binarypath or not opt.outputpath then cprint("${bright}Usage: $${clear}xmake l cli.binutils.bin2obj [options]") option.show_options(options, "bin2obj") - return + return end -- do bin2obj -- cgit v1.3.1