diff options
| -rw-r--r-- | xmake/modules/private/utils/bin2c.lua | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/xmake/modules/private/utils/bin2c.lua b/xmake/modules/private/utils/bin2c.lua index 91ea1eafe..edb89731c 100644 --- a/xmake/modules/private/utils/bin2c.lua +++ b/xmake/modules/private/utils/bin2c.lua @@ -23,9 +23,10 @@ import("core.base.bytes") import("core.base.option") local options = { - {'w', "linewidth", "kv", nil, "Set the line width"}, - {'i', "binarypath", "kv", nil, "Set the binary file path."}, - {'o', "outputpath", "kv", nil, "Set the output file path."} + {'w', "linewidth", "kv", nil, "Set the line width"}, + {'z', "zeroend", "k", true, "Patch zero terminating character"}, + {'i', "binarypath", "kv", nil, "Set the binary file path."}, + {'o', "outputpath", "kv", nil, "Set the output file path."} } function _do_dump(binarydata, outputfile, opt) @@ -84,7 +85,9 @@ function _do_bin2c(binarypath, outputpath, opt) local binarydata = bytes(io.readfile(binarypath, {encoding = "binary"})) local outputfile = io.open(outputpath, 'w') if outputfile then - binarydata = binarydata .. bytes('\0') + if opt.zeroend then + binarydata = binarydata .. bytes('\0') + end _do_dump(binarydata, outputfile, opt) outputfile:close() end @@ -96,6 +99,7 @@ end -- main entry function main(...) + print("sss") -- parse arguments local argv = {...} local opt = option.parse(argv, options, "Print c/c++ code files from the given binary file." |
