summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2023-10-29 11:18:32 +0800
committerruki <[email protected]>2023-10-29 11:18:32 +0800
commitd61d953b43fca1d3e68122036df4ef40277177ae (patch)
treee508f996c68db8e426190fbb94a275dea9585a3e /xmake/modules
parenta5ed7b6144d1a6318e25e044dc60a391a317470b (diff)
fix catch build fails
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/async/runjobs.lua27
1 files changed, 20 insertions, 7 deletions
diff --git a/xmake/modules/async/runjobs.lua b/xmake/modules/async/runjobs.lua
index 98ad63747..88f8d552f 100644
--- a/xmake/modules/async/runjobs.lua
+++ b/xmake/modules/async/runjobs.lua
@@ -158,6 +158,8 @@ function main(name, jobs, opt)
local priority_prev = 0
local priority_curr = 0
local job_pending = nil
+ local abort = false
+ local abort_errors
while index < total do
scheduler.co_group_begin(group_name, function (co_group)
local freemax = comax - #co_group
@@ -218,6 +220,9 @@ function main(name, jobs, opt)
try
{
function()
+ if stop then
+ return
+ end
if distcc then
local co_running = scheduler.co_running()
if co_running then
@@ -247,13 +252,11 @@ function main(name, jobs, opt)
progress_helper:stop()
end
- -- do exit callback
- if opt.on_exit then
- opt.on_exit(errors)
+ -- we need re-throw this errors outside scheduler
+ abort = true
+ if abort_errors == nil then
+ abort_errors = errors
end
-
- -- re-throw this errors and abort scheduler
- raise(errors)
end
}
}
@@ -293,6 +296,16 @@ function main(name, jobs, opt)
-- do exit callback
if opt.on_exit then
- opt.on_exit()
+ opt.on_exit(abort_errors)
+ end
+
+ -- re-throw abort errors
+ --
+ -- @note we cannot throw it in coroutine,
+ -- because his causes a direct exit from the entire runloop and
+ -- a quick escape from nested try-catch blocks and coroutines groups.
+ -- so we can not catch runjobs errors, e.g. build fails
+ if abort then
+ raise(abort_errors)
end
end