From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
---
cmd/hare/build/queue.ha | 13 ++++++++++---
cmd/hare/build/types.ha | 1 +
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/cmd/hare/build/queue.ha b/cmd/hare/build/queue.ha
index 973f9350..82731164 100644
--- a/cmd/hare/build/queue.ha
+++ b/cmd/hare/build/queue.ha
@@ -125,7 +125,6 @@ fn run_task(ctx: *context, jobs: *[]job, t: *task) (bool | error) = {
io::trunc(lock, 0)?;
let args = get_args(ctx, tmp, flags, t);
- defer strings::freeall(args);
path::set(&buf, out)?;
write_args(ctx, path::push_ext(&buf, "txt")?, args, t)?;
@@ -179,6 +178,7 @@ fn run_task(ctx: *context, jobs: *[]job, t: *task) (bool | error) = {
pid = exec::start(&cmd)?,
task = t,
lock = lock,
+ args = args,
});
return true;
};
@@ -199,6 +199,7 @@ fn await_task(ctx: *context, jobs: *[]job) (size | void | error) = {
assert(i < len(jobs), "Unknown PID returned from waitany");
let j = jobs[i];
let t = j.task;
+ defer strings::freeall(j.args);
static delete(jobs[i]);
let out = get_cache(ctx, t.idx, t.kind)?;
@@ -222,8 +223,14 @@ fn await_task(ctx: *context, jobs: *[]job) (size | void | error) = {
if (ctx.mode == output::DEFAULT) {
fmt::errorln()?;
};
- fmt::fatal(ctx.mods[t.idx].name, ctx.cmds[t.kind],
- exec::exitstr(e));
+
+ fmt::errorf("Failed {} job ({}), command: {} ",
+ ctx.mods[t.idx].name, exec::exitstr(e), ctx.cmds[t.kind])?;
+ for (let i = 0z; i < len(j.args); i += 1) {
+ fmt::error(" ")?;
+ shlex::quote(os::stderr, j.args[i])?;
+ };
+ fmt::fatal();
};
cleanup_task(ctx, t)?;
diff --git a/cmd/hare/build/types.ha b/cmd/hare/build/types.ha
index 43470df5..2748ed67 100644
--- a/cmd/hare/build/types.ha
+++ b/cmd/hare/build/types.ha
@@ -51,6 +51,7 @@ export type job = struct {
// fd to be closed once the job has finished, in order to release the
// [[io::lock]] on it
lock: io::file,
+ args: []str,
};
export type output = enum {
--
2.41.0