summaryrefslogtreecommitdiff
path: root/xmake/modules/async/jobgraph.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-03-22 00:23:09 +0800
committerruki <[email protected]>2025-04-08 15:31:55 +0800
commita260aa4d879b459aeaf3526816f1bc474485f508 (patch)
treec46b24f23351f6bfb5787867c95060ad8915c8b1 /xmake/modules/async/jobgraph.lua
parent172dbb827ab0efb3c32ebcac823ce866c18b2dd8 (diff)
add group
Diffstat (limited to 'xmake/modules/async/jobgraph.lua')
-rw-r--r--xmake/modules/async/jobgraph.lua21
1 files changed, 14 insertions, 7 deletions
diff --git a/xmake/modules/async/jobgraph.lua b/xmake/modules/async/jobgraph.lua
index 9994ac1f3..ee3a6f274 100644
--- a/xmake/modules/async/jobgraph.lua
+++ b/xmake/modules/async/jobgraph.lua
@@ -26,7 +26,7 @@ import("core.base.hashset")
-- define module
local jobqueue = jobqueue or object {_init = {"_jobgraph", "_dag"}}
-local jobgraph = jobgraph or object {_init = {"_name", "_jobs", "_size", "_dag"}}
+local jobgraph = jobgraph or object {_init = {"_name", "_jobs", "_size", "_dag", "_groups"}}
-- remove the finished job
function jobqueue:remove(job)
@@ -60,7 +60,7 @@ end
--
-- @param name the job name
-- @param run the job run command/script
--- @param opt the job options
+-- @param opt the job options, e.g. {group = "xxx"}
--
function jobgraph:add(name, run, opt)
local jobs = self._jobs
@@ -68,6 +68,16 @@ function jobgraph:add(name, run, opt)
local job = {name = name, run = run, opt = opt}
jobs[name] = job
self._size = self._size + 1
+
+ local group_name = opt.group
+ if group_name then
+ local groups = self._groups[group_name]
+ if not groups then
+ groups = {}
+ self._groups[group_name] = groups
+ end
+ table.insert(groups, job)
+ end
end
end
@@ -98,11 +108,8 @@ function jobgraph:add_deps(...)
end
prev = curr
end
-end
-
--- add jog group
-function jobgraph:add_group(name, callback)
-- TODO
+ -- add groups jobs
end
-- build a job queue
@@ -134,5 +141,5 @@ end
-- new a jobgraph
function new(name)
- return jobgraph {name, {}, 0, graph.new(true)}
+ return jobgraph {name, {}, 0, graph.new(true), {}}
end