diff options
| author | ruki <[email protected]> | 2024-10-25 00:45:11 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-10-25 00:45:11 +0800 |
| commit | ecf4f21dd34c684e74618c95a4186d889badb5d3 (patch) | |
| tree | 6e72e5d3920283764abd7628c733d9a0ea3848dd | |
| parent | c92b5d009f2421ee3cda1933c5cac519659785f1 (diff) | |
get linewidth
| -rw-r--r-- | core/src/xmake/utils/bin2c.c | 8 | ||||
| -rw-r--r-- | xmake/core/base/utils.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/utils/bin2c.lua | 3 |
3 files changed, 10 insertions, 3 deletions
diff --git a/core/src/xmake/utils/bin2c.c b/core/src/xmake/utils/bin2c.c index 1ce85654c..921793345 100644 --- a/core/src/xmake/utils/bin2c.c +++ b/core/src/xmake/utils/bin2c.c @@ -51,8 +51,16 @@ tb_int_t xm_utils_bin2c(lua_State* lua) tb_char_t const* outputfile = luaL_checkstring(lua, 2); tb_check_return_val(outputfile, 0); + // get line width + tb_int_t linewidth = (tb_int_t)lua_tointeger(lua, 3); + + // no zero end? + tb_bool_t nozeroend = (tb_bool_t)lua_toboolean(lua, 4); + tb_trace_i("binaryfile: %s", binaryfile); tb_trace_i("outputfile: %s", outputfile); + tb_trace_i("linewidth: %d", linewidth); + tb_trace_i("nozeroend: %d", nozeroend); return 0; } diff --git a/xmake/core/base/utils.lua b/xmake/core/base/utils.lua index 2beab7bce..8f1f9a3d0 100644 --- a/xmake/core/base/utils.lua +++ b/xmake/core/base/utils.lua @@ -324,7 +324,7 @@ end -- generate c/c++ code from the binary file function utils.bin2c(binaryfile, outputfile, opt) opt = opt or {} - return utils._bin2c(binaryfile, outputfile, opt.linewidth, opt.nozeroend) + return utils._bin2c(binaryfile, outputfile, opt.linewidth or 0x20, opt.nozeroend or false) end -- return module diff --git a/xmake/modules/private/utils/bin2c.lua b/xmake/modules/private/utils/bin2c.lua index 31b400954..987a478f7 100644 --- a/xmake/modules/private/utils/bin2c.lua +++ b/xmake/modules/private/utils/bin2c.lua @@ -20,7 +20,6 @@ -- imports import("core.base.bytes") -import("core.base.utils") import("core.base.option") local options = { @@ -84,7 +83,7 @@ function _do_bin2c(binarypath, outputpath, opt) -- do dump if utils.bin2c then - utils.bin2c(binarydata, outputpath, opt) + utils.bin2c(binarypath, outputpath, opt) else local binarydata = bytes(io.readfile(binarypath, {encoding = "binary"})) local outputfile = io.open(outputpath, 'w') |
