summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/actions/build/target_utils.lua4
-rw-r--r--xmake/core/base/graph.lua11
-rw-r--r--xmake/modules/async/jobgraph.lua4
3 files changed, 16 insertions, 3 deletions
diff --git a/xmake/actions/build/target_utils.lua b/xmake/actions/build/target_utils.lua
index 6a29f2e78..74c57a2c9 100644
--- a/xmake/actions/build/target_utils.lua
+++ b/xmake/actions/build/target_utils.lua
@@ -37,7 +37,7 @@ function _add_jobs_for_target(jobgraph, target, opt)
-- add after_xxx jobs for target
local job_kind = opt.job_kind
local job_after = target:fullname() .. "/after_" .. job_kind
- --[[
+ -- TODO we should remove root job, use group instead of it
jobgraph:add(job_after, function (index, total, opt)
local progress = opt.progress
local script_aftername = job_kind .. "_after"
@@ -59,7 +59,7 @@ function _add_jobs_for_target(jobgraph, target, opt)
end
end
end
- end)]]
+ end)
end
-- add jobs for the given target and deps
diff --git a/xmake/core/base/graph.lua b/xmake/core/base/graph.lua
index 658b71e73..43b43ce3c 100644
--- a/xmake/core/base/graph.lua
+++ b/xmake/core/base/graph.lua
@@ -94,6 +94,17 @@ function graph:has_vertex(v)
return table.contains(self:vertices(), v)
end
+-- add an isolated without edges
+function graph:add_vertex(v)
+ if not self:has_vertex(v) then
+ table.insert(self._vertices, v)
+ self._adjacent_edges[v] = {}
+ end
+
+ -- reset partial topological sort state since graph structure changed
+ self._partial_topo_dirty = true
+end
+
-- remove the given vertex?
function graph:remove_vertex(v)
local contains = false
diff --git a/xmake/modules/async/jobgraph.lua b/xmake/modules/async/jobgraph.lua
index 3767cfe73..d737c7348 100644
--- a/xmake/modules/async/jobgraph.lua
+++ b/xmake/modules/async/jobgraph.lua
@@ -70,10 +70,12 @@ end
--
function jobgraph:add(name, run, opt)
opt = opt or {}
+ local dag = self._dag
local jobs = self._jobs
if not jobs[name] then
local job = {name = name, run = run, opt = opt}
jobs[name] = job
+ dag:add_vertex(job)
self._size = self._size + 1
if opt.groups then
@@ -91,9 +93,9 @@ end
-- remove a given job
function jobgraph:remove(name)
+ local dag = self._dag
local jobs = self._jobs
local job = jobs[name]
- local dag = self._dag
if job then
assert(self._size > 0)
jobs[name] = nil