diff options
| author | Michael Forney <mforney@mforney.org> | 2016-10-29 13:28:03 -0700 |
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2016-10-30 13:44:58 -0700 |
| commit | 92751409f7e9c403cbfeb503cc494279c712c9ab (patch) | |
| tree | 3ed7108ac6f7115218bbaa3b8d444f3be81ccf7c /ninja.rc | |
| parent | dd45ede13ab186614e6db9d0c65c9b16858167f6 (diff) | |
Provide mechanism to track library dependencies
Now, ar/lib rules can list static libraries or other .d files. These (as well as
the target library) are written to a file called $lib.d. link/exe rules can list
these .d files, causing them to be flattened into an RSP file and appear on the
command line as @$rsp.
The rule to generate the dependency list files depends on the libraries they
contain, so they also act as a stamp file for the dependencies. This gives us
dependency management for free.
Diffstat (limited to 'ninja.rc')
| -rw-r--r-- | ninja.rc | 26 |
1 files changed, 22 insertions, 4 deletions
@@ -74,24 +74,42 @@ fn cc { } fn link { - out='$outdir'/$1 objs=() { + out='$outdir'/$1 objs=() deps=() { shift for(obj in $*) { if(! ~ $obj '$'*) obj='$outdir'/$obj - objs=($objs $obj) + switch($obj) { + case *.d + deps=($deps $obj) + case * + objs=($objs $obj) + } + } + if(! ~ $#deps 0) { + build $out.rsp awk $deps '|' scripts/rsp.awk ; with expr '-f scripts/rsp.awk' + objs=($objs '|' $out.rsp) } build $out link $objs + if(! ~ $#deps 0) + with ldlibs @$out.rsp + status=() } } fn ar { - out='$outdir'/$1 objs=() { + out='$outdir'/$1 objs=() deps=() { shift for(obj in $*) { if(! ~ $obj '$'*) obj='$outdir'/$obj - objs=($objs $obj) + switch($obj) { + case *.[ad] + deps=($deps $obj) + case * + objs=($objs $obj) + } } build $out ar $objs + build $out.d lines $out $deps } } |
