diff options
| author | ruki <[email protected]> | 2025-09-05 12:15:58 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-09-05 12:15:58 +0800 |
| commit | 9f6d91af31ffc4bbbc0d04533786a0954afee2bf (patch) | |
| tree | f30814d17a5bd000fe4e1a2186b3301c99123f0a /xmake/modules/private/utils/batchcmds.lua | |
| parent | 1738f7b9d1a336791216c6874c44d386f74cfda4 (diff) | |
| parent | ca139f4b270b402fb13652193057ca8dffe6fd4d (diff) | |
Merge pull request #6765 from xmake-io/thread
Improve bin2c to use native thread
Diffstat (limited to 'xmake/modules/private/utils/batchcmds.lua')
| -rw-r--r-- | xmake/modules/private/utils/batchcmds.lua | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/xmake/modules/private/utils/batchcmds.lua b/xmake/modules/private/utils/batchcmds.lua index 944507397..268f34154 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"}) @@ -102,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 @@ -114,13 +113,47 @@ 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 end end +-- run command: lua +function _runcmd_lua(cmd, opt) + if cmd.script then + 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) + end + end +end + -- run command: os.mkdir function _runcmd_mkdir(cmd, opt) local dir = cmd.dir @@ -214,6 +247,8 @@ function _runcmd(cmd, opt) vrunv = _runcmd_vrunv, execv = _runcmd_execv, vexecv = _runcmd_vexecv, + lua = _runcmd_lua, + vlua = _runcmd_vlua, mkdir = _runcmd_mkdir, rmdir = _runcmd_rmdir, cd = _runcmd_cd, @@ -271,6 +306,16 @@ 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: 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) |
