diff options
| author | ruki <[email protected]> | 2021-12-05 22:45:19 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-05 22:45:19 +0800 |
| commit | 00aa83d2e17880f3c22bbe36ddf960616103bc2a (patch) | |
| tree | 675656db79be2eb74ee0d08324c5f5c0fd355856 /xmake/modules/private/utils/bin2c.lua | |
| parent | 1032fc64a13221a674ebbfce59542b7a6dd536c7 (diff) | |
Update bin2c.lua
Diffstat (limited to 'xmake/modules/private/utils/bin2c.lua')
| -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." |
