Docs: recommend adding redo-ifchange with a lot of targets at a time.
Some people don't know to do this, and their scripts are unnecessarily slow because of it.
This commit is contained in:
parent
2fa8aab191
commit
656c3c583c
2 changed files with 49 additions and 2 deletions
31
README.md
31
README.md
|
|
@ -269,7 +269,7 @@ instead. Since you didn't `redo-ifchange default.od`,
|
|||
changes to default.od won't cause everything to rebuild.
|
||||
|
||||
|
||||
# Can I set my dircolors to highlight .do files?
|
||||
# Can I set my dircolors to highlight .do files in ls output?
|
||||
|
||||
Yes! At first, having a bunch of .do files in each
|
||||
directory feels like a bit of a nuisance, but once you get
|
||||
|
|
@ -518,6 +518,35 @@ It is almost certainly possible to do it much more nicely
|
|||
than I have, so if you do, please send it in!
|
||||
|
||||
|
||||
# Is it better to run redo-ifchange once per dependency or just once?
|
||||
|
||||
The obvious way to write a list of dependencies might be
|
||||
something like this:
|
||||
|
||||
for d in *.c; do
|
||||
redo-ifchange ${d%.c}.o
|
||||
done
|
||||
|
||||
But it turns out that's very non-optimal. First of all, it
|
||||
forces all your dependencies to be built in order
|
||||
(redo-ifchange doesn't return until it has finished
|
||||
building), which makes -j parallelism a lot less useful.
|
||||
And secondly, it forks and execs redo-ifchange over and
|
||||
over, which can waste CPU time unnecessarily.
|
||||
|
||||
A better way is something like this:
|
||||
|
||||
for d in *.c; do
|
||||
echo ${d%.c}.o
|
||||
done |
|
||||
xargs redo-ifchange
|
||||
|
||||
That only runs redo-ifchange once (or maybe a few times, if
|
||||
there are really a *lot* of dependencies and xargs has to
|
||||
split it up), which saves fork/exec time and allows for
|
||||
parallelism.
|
||||
|
||||
|
||||
# If a target didn't change, how do I prevent dependents from being rebuilt?
|
||||
|
||||
For example, running ./configure creates a bunch of files including
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue