A small utility to compare if two files are different, and update the destination only if necessary (eg. to avoid invalidating buildsystem cache).
Basic thing with bash, including support for src being stdin (expressed '-'):
cat src/*.c | ./coc - build/all-sources-as-single-file.c
This illustrates the use of mvrm
mode, that is as mv
,
but removes the source file when there is no change.
tmp=$(mktemp)
gcc -c file.c -o $tmp
./coc $tmp file.o mvrm
(a bit contrived example, as this does not prevent recompilation on next build attempt (source would be kept newer than .o) but at least prevents invalidation of linking the .o together into bigger thing).