summaryrefslogtreecommitdiff
path: root/xmake/rules/utils/bin2c
diff options
context:
space:
mode:
authorruki <[email protected]>2021-08-05 00:35:38 +0800
committerruki <[email protected]>2021-08-05 00:35:38 +0800
commit376aaf2b9432b2da255c4aaabcbc8c84d2372c4c (patch)
treedfc6c82445dd54b18e0f664892af72001c7c5cc6 /xmake/rules/utils/bin2c
parentb700ce5f896f1a3edfadafb4c188d1f147ea4ac7 (diff)
improve bin2c rule
Diffstat (limited to 'xmake/rules/utils/bin2c')
-rw-r--r--xmake/rules/utils/bin2c/xmake.lua19
1 files changed, 9 insertions, 10 deletions
diff --git a/xmake/rules/utils/bin2c/xmake.lua b/xmake/rules/utils/bin2c/xmake.lua
index 658bf113a..12db55192 100644
--- a/xmake/rules/utils/bin2c/xmake.lua
+++ b/xmake/rules/utils/bin2c/xmake.lua
@@ -20,23 +20,22 @@
rule("utils.bin2c")
set_extensions(".bin")
- on_load(function (target)
- local headerdir = path.join(target:autogendir(), "rules", "c++", "bin2c")
- if not os.isfile(headerdir) then
- os.mkdir(headerdir)
- end
- target:add("includedirs", headerdir)
- end)
before_buildcmd_file(function (target, batchcmds, sourcefile_bin, opt)
-- get header file
local headerdir = path.join(target:autogendir(), "rules", "c++", "bin2c")
- local headerfile = path.join(headerdir, (sourcefile_bin:gsub("%.", "_")) .. ".h")
+ local headerfile = path.join(headerdir, path.filename(sourcefile_bin) .. ".h")
+ target:add("includedirs", headerdir)
-- add commands
- batchcmds:show_progress(opt.progress, "${color.build.object}generating.header %s", sourcefile_bin)
+ batchcmds:show_progress(opt.progress, "${color.build.object}generating.bin2c %s", sourcefile_bin)
batchcmds:mkdir(headerdir)
- local argv = {"-i", sourcefile_bin, "-o", headerfile, "-w", "32"}
+ local argv = {"lua", "private.utils.bin2c", "-i", sourcefile_bin, "-o", headerfile}
+ local linewidth = target:extraconf("rules", "utils.bin2c", "linewidth")
+ if linewidth then
+ table.insert(argv, "-w")
+ table.insert(argv, tostring(linewidth))
+ end
batchcmds:vrunv(os.programfile(), argv)
-- add deps