diff options
Diffstat (limited to 'xmake/rules/utils/bin2c')
| -rw-r--r-- | xmake/rules/utils/bin2c/utils.lua | 12 | ||||
| -rw-r--r-- | xmake/rules/utils/bin2c/xmake.lua | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/xmake/rules/utils/bin2c/utils.lua b/xmake/rules/utils/bin2c/utils.lua index 405c2ed62..b5bf7638b 100644 --- a/xmake/rules/utils/bin2c/utils.lua +++ b/xmake/rules/utils/bin2c/utils.lua @@ -36,6 +36,7 @@ function generate_headerfile(target, batchcmds, binaryfile, opt) opt = opt or {} local rulename = opt.rulename or "utils.bin2c" local progress = opt.progress + local fileconfig = target:fileconfig(binaryfile) -- get header directory and file local headerdir = opt.headerdir @@ -52,6 +53,16 @@ function generate_headerfile(target, batchcmds, binaryfile, opt) -- add includedirs target:add("includedirs", headerdir) + -- transform binary data first + -- @see https://github.com/xmake-io/xmake/issues/7513 + local transform = opt.transform or (fileconfig and fileconfig.transform) or target:extraconf("rules", rulename, "transform") + if transform then + batchcmds:show_progress(progress, "${color.build.object}transforming.bin2obj %s", binaryfile) + local transformed_file = target:autogenfile(binaryfile .. ".transformed") + batchcmds:call(transform, {binaryfile, transformed_file}, {target = target}) + binaryfile = transformed_file + end + -- add commands if progress then batchcmds:show_progress(progress, "${color.build.object}generating.bin2c %s", binaryfile) @@ -69,7 +80,6 @@ function generate_headerfile(target, batchcmds, binaryfile, opt) end -- get nozeroend/zeroend (check file-level config first, then rule-level config, then opt) - local fileconfig = target:fileconfig(binaryfile) local nozeroend = nil if fileconfig then if fileconfig.nozeroend ~= nil then diff --git a/xmake/rules/utils/bin2c/xmake.lua b/xmake/rules/utils/bin2c/xmake.lua index 9f6338758..0d2745b60 100644 --- a/xmake/rules/utils/bin2c/xmake.lua +++ b/xmake/rules/utils/bin2c/xmake.lua @@ -33,7 +33,7 @@ rule("utils.bin2c") -- generate header file local headerfile = bin2c_utils.generate_headerfile(target, batchcmds, sourcefile_bin, { - progress = opt.progress + progress = opt.progress, }) -- add deps |
