diff options
| -rw-r--r-- | xmake/actions/build/main.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua index 27b2419da..50e84dc93 100644 --- a/xmake/actions/build/main.lua +++ b/xmake/actions/build/main.lua @@ -109,6 +109,25 @@ function _do_build(targetname, group_pattern) end end +-- on exit +function _on_exit(ok, errors) + + -- since we call it in both os.atexit and catch block, + -- we need to avoid duplicate execution. + local handled = false + local exited = _g.exited + if not exited then + exited = true + handled = true + _g.exited = exited + end + + -- we just handle the build failure + if handled and not ok then + print("build failed") + end +end + -- main function main() @@ -144,6 +163,9 @@ function main() -- clean up temporary files once a day cleaner.cleanup() + -- register exit callbacks + os.atexit(_on_exit) + try { function () @@ -163,6 +185,10 @@ function main() { function (errors) + -- maybe it's unreachable when building fails, so we need also os.atexit() + -- @see https://github.com/xmake-io/xmake/issues/3401 + _on_exit(false, errors) + -- do rules after building _do_project_rules("build_after", {errors = errors}) |
