summaryrefslogtreecommitdiff
path: root/xmake/modules/private/utils/batchcmds.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-09-04 23:04:43 +0800
committerruki <[email protected]>2025-09-04 22:30:35 +0800
commit9b446fb15e4c91cb6687cf904e4d39f3ce30637d (patch)
treeda572f2a689426fe137ec57278347c88925f8cb9 /xmake/modules/private/utils/batchcmds.lua
parent4d11d90ba502bcd82a72c2ea66b1115897d81c52 (diff)
improve batchcmds:lua
Diffstat (limited to 'xmake/modules/private/utils/batchcmds.lua')
-rw-r--r--xmake/modules/private/utils/batchcmds.lua38
1 files changed, 30 insertions, 8 deletions
diff --git a/xmake/modules/private/utils/batchcmds.lua b/xmake/modules/private/utils/batchcmds.lua
index 544c94c2e..268f34154 100644
--- a/xmake/modules/private/utils/batchcmds.lua
+++ b/xmake/modules/private/utils/batchcmds.lua
@@ -103,9 +103,7 @@ end
-- run command: os.execv
function _runcmd_execv(cmd, opt)
if cmd.program then
- if opt.dryrun then
- print(os.args(table.join(cmd.program, cmd.argv)))
- else
+ if not opt.dryrun then
os.execv(cmd.program, cmd.argv, cmd.opt)
end
end
@@ -115,7 +113,7 @@ end
function _runcmd_vexecv(cmd, opt)
if cmd.program then
if opt.dryrun then
- print(os.args(table.join(cmd.program, cmd.argv)))
+ vprint(os.args(table.join(cmd.program, cmd.argv)))
else
os.vexecv(cmd.program, cmd.argv, cmd.opt)
end
@@ -125,12 +123,30 @@ 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)))
+ if not opt.dryrun then
local runopt = table.clone(cmd.opt) or {}
runopt.arguments = cmd.argv
+ runopt.quiet = true
+ -- 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: vlua
+function _runcmd_vlua(cmd, opt)
+ if cmd.script then
+ vprint(os.args(table.join("xmake", "lua", cmd.script, cmd.argv)))
+ if not opt.dryrun then
+ local runopt = table.clone(cmd.opt) or {}
+ runopt.arguments = cmd.argv
+ if option.get("diagnosis") then
+ runopt.verbose = true
+ runopt.diagnosis = true
+ else
+ runopt.quiet = not option.get("verbose")
+ end
-- it will run in a separate native thread, which will not block other coroutine jobs
runopt.thread = true
run_script(cmd.script, runopt)
@@ -232,6 +248,7 @@ function _runcmd(cmd, opt)
execv = _runcmd_execv,
vexecv = _runcmd_vexecv,
lua = _runcmd_lua,
+ vlua = _runcmd_vlua,
mkdir = _runcmd_mkdir,
rmdir = _runcmd_rmdir,
cd = _runcmd_cd,
@@ -294,6 +311,11 @@ function batchcmds:lua(script, argv, opt)
table.insert(self:cmds(), {kind = "lua", script = script, argv = argv, opt = opt})
end
+-- add command: run lua script file, command or module
+function batchcmds:vlua(script, argv, opt)
+ table.insert(self:cmds(), {kind = "vlua", script = script, argv = argv, opt = opt})
+end
+
-- add command: compiler.compile
function batchcmds:compile(sourcefiles, objectfile, opt)