diff options
| author | ruki <[email protected]> | 2023-02-21 23:14:18 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-02-21 23:14:18 +0800 |
| commit | 09eb965760daaa301c40910b6dfe61f1ba832cc1 (patch) | |
| tree | d8d1b7be2a8e4a0dabfcd3316dad36f6e34509d4 | |
| parent | eec6de9e8b6456aa13b588ecce47af07fcfba965 (diff) | |
on build failure
| -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}) |
