Re: ANN: AOSP builds with ninja

13,189 views
Skip to first unread message

Dave Smith

unread,
Oct 28, 2015, 4:47:22 PM10/28/15
to android-...@googlegroups.com, Colin Cross
Colin -

Is Ninja also used at all in the 6.0.0_r1 build branches? The build times on those branches also seem to be considerably faster over previous versions.

-- 
Dave Smith, PE
@devunwired

On October 28, 2015 at 2:43:51 PM, Colin Cross (ccr...@android.com) wrote:

AOSP master platform builds now build with ninja instead of GNU make.
The build/core makefiles and Android.mk files are read by kati
(https://github.com/google/kati/blob/master/README.md), which will
interpret them and write out a $OUT_DIR/build_$(TARGET_PRODUCT).ninja
file, and then the execution of the build rules will be handled by
ninja (https://martine.github.io/ninja/).

Building with kati and ninja provides some immediate benefits:
1. Faster startup time for new builds. Running kati and then ninja
results in builds starting about 25% faster than GNU make.
2. Much faster incremental builds. kati caches the mtimes of files
and directories it read, what environment variables it used, etc., and
only re-reads all the makefiles if something has changed. This
includes globs like $(call all-files-under). Incremental builds with
a warm disk cache will start within 5 seconds.
3. Better build command output. Ninja buffers the output of each
command and prints it without mixing output from multiple commands,
meaning error messages will be printed as a group after a build
failure, and not mixed with other concurrent build output. Ninja also
prints a configurable status line that defaults to printing the
percentage of build commands that have been run, the number that have
been run, and the number that need to run, giving a reasonable
approximation of the progress through the build.
4. Incremental builds should be more reliable. Ninja considers
outputs whose command line has changed to be dirty, which will catch
changes to global cflags, etc. and rebuild anything that has changed.

The use of ninja should be transparent, it is wrapped by the top level
Makefile, so all make-based commands should continue to work.

These changes are a precursor to a much larger change that will
replace all the Android.mk files with data files using a format that
provides much better error checking, even faster builds, and 100%
reliable incremental builds.

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platfo...@googlegroups.com.
To post to this group, send email to android-...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/d/optout.

Colin Cross

unread,
Oct 28, 2015, 4:48:42 PM10/28/15
to android-...@googlegroups.com

Colin Cross

unread,
Oct 28, 2015, 4:53:52 PM10/28/15
to Dave Smith, android-...@googlegroups.com
No, android-6.0.0_r1 and marshmallow-dev do not have ninja, only master.

Ying Wang

unread,
Oct 28, 2015, 11:50:32 PM10/28/15
to android-...@googlegroups.com, Colin Cross
On Wed, Oct 28, 2015 at 1:47 PM, Dave Smith <dasmi...@gmail.com> wrote:
Colin -

Is Ninja also used at all in the 6.0.0_r1 build branches? The build times on those branches also seem to be considerably faster over previous versions.
That's  mostly due to the fact we  dropped building from soruce for libwebviewchromium.so.
See android/mnc-dev/external/chromium-webview/README .

Dmitry Blotsky

unread,
Nov 4, 2015, 8:30:30 PM11/4/15
to android-platform
These changes are a precursor to a much larger change that will 
replace all the Android.mk files with data files using a format that 
provides much better error checking, even faster builds, and 100% 
reliable incremental builds. 

Are you referring to the ninja format, or to something else?

Kindly,
Dmitry

Colin Cross

unread,
Nov 4, 2015, 8:54:07 PM11/4/15
to android-...@googlegroups.com
On Wed, Nov 4, 2015 at 4:29 PM, Dmitry Blotsky <dmitry....@gmail.com> wrote:
> These changes are a precursor to a much larger change that will
> replace all the Android.mk files with data files using a format that
> provides much better error checking, even faster builds, and 100%
> reliable incremental builds.
>
> Are you referring to the ninja format, or to something else?

Android.mk files will be replaced with Blueprints files. For an
in-progress example, see
https://android.googlesource.com/platform/bionic/+/master/libc/Android.bp.

killmind zhang

unread,
Nov 10, 2015, 4:37:24 PM11/10/15
to android-platform
Is there any tool that can help the conversion from Android.mk to blueprints files?

在 2015年11月5日星期四 UTC+8上午9:54:07,Colin Cross写道:

Colin Cross

unread,
Nov 10, 2015, 5:01:09 PM11/10/15
to android-...@googlegroups.com
Yes, although it is still in progress and hasn't been updated in a
while since we haven't been working on the bulk conversion of
Android.mk files yet. The source is at
https://android.googlesource.com/platform/build/soong/+/master/androidmk/

Dave Smith

unread,
Nov 11, 2015, 12:15:08 AM11/11/15
to android-...@googlegroups.com, Colin Cross
I’m a bit confused now, with each iteration of this discussion a new tool seems to pop up. From looking at them, there’s some overlap that I’m having trouble working out. Here’s what I think I understand:

Kati (https://android.googlesource.com/platform/build/kati/) — Reads Android.mk files —> Generates build.ninja
Blueprint (https://android.googlesource.com/platform/build/blueprint/) — Reads Blueprint files —> Generates build.ninja
Soong (https://android.googlesource.com/platform/build/soong/) — Reads both Android.mk + Blueprint files? —> Generates build.ninja

How do these things fit together? Are there more pieces to the puzzle?

Thanks in advance.
Cheers,

Colin Cross

unread,
Nov 11, 2015, 2:15:56 PM11/11/15
to Dave Smith, android-...@googlegroups.com
Blueprint and Soong work together to read Blueprints files and
generate a build.ninja file. Blueprint is a framework to implement
your own build logic in a high level langauge (Go). It reads
Blueprints files and writes build.ninja files, but all the logic to
determine what build rules to put in the build.ninja file is delegated
to custom build logic, which for Android is Soong.

There will be more documentation and announcements for Blueprint/Soong
when they become relevant.

Dave Smith

unread,
Nov 11, 2015, 2:23:39 PM11/11/15
to Colin Cross, android-...@googlegroups.com
Got it—thanks for the clarification.
So then kati is just a stop-gap to allow Ninja builds while the other two are in progress? It will eventually be irrelevant?

Cheers,
-- 
Dave Smith, PE
@devunwired

Colin Cross

unread,
Nov 11, 2015, 2:24:14 PM11/11/15
to Dave Smith, android-...@googlegroups.com
Yes, kati will be removed once we no longer need legacy support for
any makefiles.

William Roberts

unread,
Jul 4, 2016, 11:17:26 AM7/4/16
to android-platform, dasmi...@gmail.com
Does anyone know of documentation or an example that chnaged LOCAL_GENERATED_SOURCES into a Blueprint format?

Notably I am working on: https://android-review.googlesource.com/#/c/214416 and now have a conflict I am looking to resolve.

Thanks,
Bill
 

arden jay

unread,
Jul 6, 2017, 10:09:44 AM7/6/17
to android-...@googlegroups.com
Hi,

Run with Ninja ( android-7.1.1_r13), is it normal?
1. mm -B won't recompile if no source file is changed?
2. mm won't show the new lib built out now (Previously, it will show, Install: xxx.so)

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platform+unsubscribe@googlegroups.com.
To post to this group, send email to android-platform@googlegroups.com.



--
cheers,
jay

Colin Cross

unread,
Jul 6, 2017, 1:37:20 PM7/6/17
to android-...@googlegroups.com
The equivalent behavior to mm -B is not supported in ninja. If you
want to rebuild everything, you can rm out/.ninja_log. If you want to
rebuild just one directory, touch all the source files in that
directory.

Ninja uses smart output when running in a terminal, which overwrites
the status message with the next message. Try mm | cat to show all
the messages, or mm showcommands to see the actual command that was
run.
>> email to android-platfo...@googlegroups.com.
>> To post to this group, send email to android-...@googlegroups.com.
>> Visit this group at http://groups.google.com/group/android-platform.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> cheers,
> jay
>
> --
> You received this message because you are subscribed to the Google Groups
> "android-platform" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-platfo...@googlegroups.com.
> To post to this group, send email to android-...@googlegroups.com.
> Visit this group at https://groups.google.com/group/android-platform.
Reply all
Reply to author
Forward
0 new messages