commit | b78d16f5c3f5cb2c5eb859ed4e14b54bbb02b7fc | [log] [tgz] |
---|---|---|
author | Dan Willemsen <dwillemsen@google.com> | Wed Aug 09 16:51:34 2017 -0700 |
committer | Dan Willemsen <dwillemsen@google.com> | Wed Aug 09 17:21:43 2017 -0700 |
tree | a8c1e341f40f0dd78ebccf1ca5f681154db6b508 | |
parent | 18ff00f914e7058cd51b4de8480b4a1c5263a39d [diff] |
Support Ninja implicit outputs Add .KATI_IMPLICIT_OUTPUTS target-specific variable to add extra implicit outputs to the build line in the ninja file. This doesn't actually affect the node graph within Kati, but combined with --gen_all_targets should be usable. This allows us to properly define the build graph in ninja when one rule creates multiple files. There are a number of ways that people attempt to do this in make, all of which have problems: a b: touch a b Define multiple outputs with the same rule. This looks correct to most people, but actually runs the rule multiple times -- once for every output file. Most of the time this works, but runs into very strange concurrency issues when the two rules happen to run at the same time. a: touch a b Only define one of the files in the graph. Then users need to depend on a file that they don't use, and the unlisted file won't be noticed if it's updated separately (or even removed). b: a a: touch a b Define dependencies between the multiple files. This doesn't actually know how to update `b` if `b` is older than `a`, or doesn't exist. b: a touch b a: touch a b A variant of the previous approach, which can "fix" the timestamp if the original rule happened to create `b` before `a`. This can be even more dangerous, since it may create / update `b` improperly. But since ninja supports a graph where there can be multiple outputs from a single edge, with this patch we can write: a: .KATI_IMPLICIT_OUTPUTS := b a: touch a b which translates to: rule rule1 command = touch a b build a | b: rule1 This ninja will allow users to depend on either `a` or `b`, and the rule will be run (once) as appropriate. Change-Id: Ieb9ced7eb4d212b0aa4de5ceb1deb9ba48ada132
kati is an experimental GNU make clone. The main goal of this tool is to speed-up incremental build of Android.
Currently, kati does not offer a faster build by itself. It instead converts your Makefile to a ninja file.
Now AOSP has kati and ninja, so all you have to do is
% export USE_NINJA=true
All Android's build commands (m, mmm, mmma, etc.) should just work.
Set up kati:
% cd ~/src % git clone https://github.com/google/kati % cd kati % make
Build Android:
% cd <android-directory> % source build/envsetup.sh % lunch <your-choice> % ~/src/kati/m2n --kati_stats # Use --goma if you are a Googler. % ./ninja.sh
You need ninja in your $PATH.
% ./ninja.sh -t clean
Note ./ninja.sh passes all parameters to ninja.
For example, the following is equivalent to "make cts":
% ./ninja.sh cts
Or, if you know the path you want, you can do:
% ./ninja.sh out/host/linux-x86/bin/adb