summaryrefslogtreecommitdiff
path: root/xmake/modules/private/utils/batchcmds.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-09-04 22:57:52 +0800
committerruki <[email protected]>2025-09-04 22:30:35 +0800
commit4d11d90ba502bcd82a72c2ea66b1115897d81c52 (patch)
tree7475b62c335f4c4028a0e7f36e5f4073b61151fd /xmake/modules/private/utils/batchcmds.lua
parent15c0177361f6a6b488ab6937d088f4a0a711a086 (diff)
improve bin2c
Diffstat (limited to 'xmake/modules/private/utils/batchcmds.lua')
-rw-r--r--xmake/modules/private/utils/batchcmds.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/xmake/modules/private/utils/batchcmds.lua b/xmake/modules/private/utils/batchcmds.lua
index 944507397..544c94c2e 100644
--- a/xmake/modules/private/utils/batchcmds.lua
+++ b/xmake/modules/private/utils/batchcmds.lua
@@ -28,6 +28,7 @@ import("core.theme.theme")
import("core.tool.linker")
import("core.tool.compiler")
import("core.language.language")
+import("utils.run_script")
import("utils.progress", {alias = "progress_utils"})
import("utils.binary.rpath", {alias = "rpath_utils"})
@@ -121,6 +122,22 @@ function _runcmd_vexecv(cmd, opt)
end
end
+-- run command: lua
+function _runcmd_lua(cmd, opt)
+ if cmd.script then
+ if opt.dryrun then
+ print(os.args(table.join("xmake", "lua", cmd.script, cmd.argv)))
+ else
+ vprint(os.args(table.join("xmake", "lua", cmd.script, cmd.argv)))
+ local runopt = table.clone(cmd.opt) or {}
+ runopt.arguments = cmd.argv
+ -- it will run in a separate native thread, which will not block other coroutine jobs
+ runopt.thread = true
+ run_script(cmd.script, runopt)
+ end
+ end
+end
+
-- run command: os.mkdir
function _runcmd_mkdir(cmd, opt)
local dir = cmd.dir
@@ -214,6 +231,7 @@ function _runcmd(cmd, opt)
vrunv = _runcmd_vrunv,
execv = _runcmd_execv,
vexecv = _runcmd_vexecv,
+ lua = _runcmd_lua,
mkdir = _runcmd_mkdir,
rmdir = _runcmd_rmdir,
cd = _runcmd_cd,
@@ -271,6 +289,11 @@ function batchcmds:vexecv(program, argv, opt)
table.insert(self:cmds(), {kind = "vexecv", program = program, argv = argv, opt = opt})
end
+-- add command: run lua script file, command or module
+function batchcmds:lua(script, argv, opt)
+ table.insert(self:cmds(), {kind = "lua", script = script, argv = argv, opt = opt})
+end
+
-- add command: compiler.compile
function batchcmds:compile(sourcefiles, objectfile, opt)