summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-05-29 16:28:07 +0800
committerruki <[email protected]>2022-05-29 16:28:07 +0800
commitd534e9346890b433de548294204b214e81319c78 (patch)
tree620ffb3f326cd8738997b42f80990114307d7c7a
parenta7b58040a0ecb8b5fe253886c3d852876fe71e1c (diff)
support xmake r -jN
-rw-r--r--xmake/actions/run/main.lua13
-rw-r--r--xmake/actions/run/xmake.lua3
2 files changed, 14 insertions, 2 deletions
diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua
index 153011b73..0b738aab6 100644
--- a/xmake/actions/run/main.lua
+++ b/xmake/actions/run/main.lua
@@ -26,6 +26,7 @@ import("core.base.global")
import("core.project.project")
import("core.platform.platform")
import("devel.debugger")
+import("private.async.runjobs")
import("private.action.run.make_runenvs")
import("private.service.remote_build.action", {alias = "remote_build_action"})
@@ -207,14 +208,24 @@ function main()
if targetname then
_run(project.target(targetname))
else
+ local targets = {}
for _, target in ipairs(project.ordertargets()) do
if target:is_binary() then
local group = target:get("group")
if (target:is_default() and not group_pattern) or option.get("all") or (group_pattern and group and group:match(group_pattern)) then
- _run(target)
+ table.insert(targets, target)
end
end
end
+ local jobs = tonumber(option.get("jobs") or "1")
+ runjobs("run_targets", function (index)
+ local target = targets[index]
+ if target then
+ _run(target)
+ end
+ end, {total = #targets,
+ comax = jobs,
+ isolate = true})
end
-- leave project directory
diff --git a/xmake/actions/run/xmake.lua b/xmake/actions/run/xmake.lua
index 7c5b1086e..dce6724a1 100644
--- a/xmake/actions/run/xmake.lua
+++ b/xmake/actions/run/xmake.lua
@@ -47,11 +47,12 @@ task("run")
"e.g.",
" xmake run -g test",
" xmake run -g test_*",
- " xmake run --group=benchmark/*" }
+ " xmake run --group=benchmark/*" }
, {'w', "workdir", "kv", nil , "Work directory of running targets, default is folder of targetfile",
"e.g.",
" xmake run -w .",
" xmake run --workdir=`pwd`" }
+ , {'j', "jobs", "kv", "1", "Set the number of parallel compilation jobs." }
, {}
, {nil, "target", "v", nil , "The target name. It will run all default targets if this parameter is not specified."
, values = function (complete, opt)