I’m looking to run size
on an ELF file only when it gets recompiled.
So far I’ve got
const elf: *Step.Compile;
// ...
const size_cmd = b.addSystemCommand(&.{"size"});
size_cmd.addArtifactArg(elf);
Of course Zig Build wants to see an output arg to determine that it doesn’t have side-effects and when the output needs to be regenerated.
The usual make/ninja hack of generating a dummy output file with psuedocode:
_ = size_cmd.addPrefixedOutputFileArg(" && touch ", "SIZED");
Technically doesn’t work because it’s not executing as a shell. I think I’d have to write a custom executable to interface between the Run Step, what it thinks its arguments are, the actual system command I want to run just once, and a dummy output for stale-checking.
Any ideas on how to idiomatically handle this use-case? I have a few other uses for this pattern of post-processing: scp binary to server when it changes, program MCU when firmware recompiles, etc.