|REDO(1)||General Commands Manual||REDO(1)|
redo - rebuild target files when source files have changed
redo [option] [target]...
redo is a tool for building files and for rebuilding them if any of their dependencies have changed. The build rules are contained in files with the extension .do that are called dofiles. Usually, dofiles are shell scripts executed by sh(1).
redo uses a simple algorithm to find dofiles: First it looks for the filename of the target with the suffix .do, then it looks for filenames consisting of default plus the target's filename extension plus .do, recursively removing the last component of the target's filename extension.
For example, if redo is asked to build a file called example.x.y.z, it will look for dofiles with the following filenames to build the file:
redo considers the first existing file found this way the dofile for the target and executes it. If redo is not given a target, it builds a target named all. If redo can not find a dofile for a target, it exits with a status code indicating failure.
redo passes three arguments to a dofile that is executed:
- is the name of the target.
- is the basename of the target, i.e. the name of the target minus leading directory components and extensions. Note that the extension is determined from the dofile: A file example.a.b.c that is built with a dofile default.b.c.do will be considered to have the extension b.c, so $2 will be set to example.a.
- is the name of a temporary file which replaces the target atomically after the dofile has exited successfully. Instead of writing to $3, a dofile can also write to standard output.
If the current target should be rebuilt if other files change, this can be declared with redo-ifchange(1): When redo-ifchange(1) is executed from a dofile, redo builds the targets given to redo-ifchange(1) and will rebuild the current target on the next invocation of redo if any of the targets given to redo-ifchange(1) have changed since the last build.
If the current target should be rebuilt if a file that does not exist at the time of the build exists, this can be declared with redo-ifcreate(1): When redo-ifcreate(1) is executed from a dofile, redo will rebuild the current target on the next invocation of redo if any of the targets given to redo-ifcreate(1) exist.
If the current target should be rebuilt if the output of a command changes, this can be declared with redo-stamp(1): When redo-stamp(1) is executed from a dofile and given data on standard input, redo will rebuild the current target on the next invocation of redo if the the output of the command that piped data to it changes.
If the current target should always be rebuilt, this can be declared with redo-always(1): When redo-always(1) is executed from a dofile, redo will rebuild the current target on the next invocation of redo.
If the -d or --debug option is given, redo prints information about all dependency checks.
If the -h or --help option is given, redo prints a short notice about its command line options.
If the -j or --jobs option is given followed by an integer, an invocation of redo(1) or redo-ifchange(1) with multiple arguments builds targets in parallel. The integer argument specifies the maximum number of targets allowed to be built in parallel. Targets are locked, so if targets built in parallel share a dependency, redo(1) only builds it once, unless the dependency dofile uses redo-always(1) to rebuild every time, or the dependency becomes out of date during a build in some other way.
If the --version option is given, redo prints version information and exits.
If the -x or --xtrace option is given, redo prints commands inside dofiles as they are executed.
- makes redo search for a dofile called all.do, which it executes to build the target all. Usually, executing all.do will yield no output on standard output and redo will not create a file called all.
- redo example.x.y.z
- makes redo search for dofiles called example.x.y.z.do, default.x.y.z.do, default.x.y.do, default.x.do, default.do. redo executes the first file that exists to build example.x.y.z.
redo was designed by D. J. Bernstein and implemented multiple times by Alan Grosskurth, Avery Pennarun, Jonathan de Boyne Pollard and Nils Dagsson Moskopp.
- Rebuilding target files when source files have changed ⟨URL: http://cr.yp.to/redo.html ⟩ by D. J. Bernstein
- Purely top-down software rebuilding ⟨URL: http://grosskurth.ca/papers/mmath-thesis.pdf ⟩ by Alan Grosskurth
- redo: a top-down software build system ⟨URL: https://github.com/apenwarr/redo#readme ⟩ by Avery Pennarun
- Introduction to redo ⟨URL: http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/introduction-to-redo.html ⟩ by Jonathan de Boyne Pollard
- Redo implementation in Bourne Shell ⟨URL: http://news.dieweltistgarnichtso.net/bin/redo-sh.html ⟩ by Nils Dagsson Moskopp
redo and this man page were written by Nils Dagsson Moskopp.
Copyright © 2014-2016 Nils Dagsson Moskopp. License AGPLv3+: GNU Affero GPL version 3 or later http://www.gnu.org/licenses/agpl-3.0.html. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
This implementation of redo may break if the target filename contains a tab or newline.