Skip to content

Commit

Permalink
get linewidth
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Oct 24, 2024
1 parent c92b5d0 commit ecf4f21
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
8 changes: 8 additions & 0 deletions core/src/xmake/utils/bin2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion xmake/core/base/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions xmake/modules/private/utils/bin2c.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

-- imports
import("core.base.bytes")
import("core.base.utils")
import("core.base.option")

local options = {
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit ecf4f21

Please sign in to comment.