Commit graph

57 commits

Author SHA1 Message Date
Dan Willemsen
e27ed543bf Stop setting ASAN_OPTIONS for kati
Kati sets detect_leaks=0 by default now.

Test: unset ASAN_OPTIONS; SANITIZE_HOST=address m nothing
Change-Id: I0cbf04ae9ed40de520abca3fb35c65e7f543682d
2017-08-21 20:54:06 -07:00
Dan Willemsen
99a75cd2a5 Obsolete bootstrap.bash and ./soong wrappers
We can call directly into the blueprint bootstrap.bash using values that
soong_ui has already calculated.

Instead of calling into blueprint.bash, build minibp with microfactory,
and directly run ninja. This allows us to get individual tracing data
from each component.

Test: m -j blueprint_tools
Test: m clean; m -j blueprint_tools
Change-Id: I2239943c9a8a3ad6e1a40fa0dc914421f4b5202c
2017-08-18 10:13:22 -07:00
Jeff Gaston
b64fc1cab5 Run the Finder and make its results available to Kati
The Finder runs roughly 200ms faster than findleaves.py in aosp,
and runs roughly 400ms faster in internal master.

Bug: 64363847
Test: m -j

Change-Id: I62db8dacc90871e913576fe2443021fb1749a483
2017-08-16 14:56:00 -07:00
Jeff Gaston
f1fd45e784 Revert "Revert "Cacheable, multithreaded finder.""
Bug: 62455338
Test: m -j

This reverts commit d1abeb9d98.

Change-Id: I9f73031636157511b5f1c6ce8a205e9bc91669ff
2017-08-10 12:20:30 -07:00
Jeff Gaston
c3f32070dc Merge "Revert "Cacheable, multithreaded finder."" 2017-08-10 01:21:09 +00:00
Jeff Gaston
d1abeb9d98 Revert "Cacheable, multithreaded finder."
This reverts commit b6d161bf16.

Reason for revert: New Build Breakage: aosp-master/sdk_mac @ 4260825

Change-Id: I8bda8c50c5e5c9f84621d11a4c15b168833bcd21
2017-08-10 01:16:34 +00:00
Jeff Gaston
c17e048bad Merge "Cacheable, multithreaded finder." 2017-08-09 22:18:13 +00:00
Jeff Gaston
df4a081292 Move build system documentation
Bug: 62201421

Test: make help
Change-Id: I7d7b448d3f736e171ebfbdceee46eef7de748742
2017-08-09 19:40:01 +00:00
Dan Willemsen
e0879fc3ae Add --skip-make to replace Soong's blueprint wrapper with soong_ui
This way we only have one way to start a build, which always has logging
/ tracing / etc, even if we don't need Kati.

There's two ways to use this:

As a direct replacement for mkdir out; cd out; ../bootstrap.bash;
./soong -- as long as --skip-make is always passed, we'll never run
Kati, and Soong will run outside of it's "make" mode. This preserves
most of the speed, and allows full user control over the Soong
configuration.

A (experimental, dangerous) way to temporarily bypass the product
variable and kati steps of a build. As long as a user is sure that
nothing has changed from the last build, and they know exactly which
Ninja targets they want to build (which may not be the same as the
arguments normally passed to 'm'), this can lead to shorter build
startup times.

Test: rm -rf out; m --skip-make libc
Test: rm -rf out; m libc; m --skip-make libc
Test: rm -rf out; mkdir out; cd out; ../bootstrap.bash; ./soong libc
Test: build/soong/scripts/build-ndk-prebuilts.sh
Change-Id: Ic0f91167b5779dba3f248a379fbaac67a75a946e
2017-08-08 22:49:28 -07:00
Jeff Gaston
b6d161bf16 Cacheable, multithreaded finder.
It can find every Android.bp in internal master in
about 2.5 sec the first time and 0.3 sec subsequent times

Bug: 62455338

Test: m -j blueprint_tools # which runs the unit tests

Test: m -j blueprint_tools && \
  out/soong/host/linux-x86/bin/finder \
    -v
    --db /tmp/mydb \
    --names Android.mk \
    --prune-files .android-out-dir \
    --exclude-dirs .git,.repo \
    . \
    >/tmp/finder-log 2>&1

Change-Id: I5ab2650459a1dae0d5d076faf411ec2d053c743d
2017-08-08 14:19:55 -07:00
Treehugger Robot
98be5836de Merge "Remove java version checks" 2017-07-25 19:55:48 +00:00
Dan Willemsen
05f17764c3 Use a unified ninja builddir
Instead of calling SetNinjaBuildDir, pass it to bootstrap.bash, so that
the bootstrap package can set it consistently during bootstrapping and
normal execution.

Bug: 63720725
Test: m -j nothing
Test: mkdir o; ../bootstrap.bash; ./soong
Change-Id: Ica88d2d5f1461b5be49bfe6316c6ec4ef4d89d49
2017-07-24 15:58:20 -07:00
Colin Cross
3f837b9d90 Remove java version checks
The build now uses a prebuilt javac binary distributed with the
source, checking the host java version is no longer required.

Reapplies Ieef83481d0e6d68371bbd8a422f870ffe2bbb428 after updating
some more manifests to include the prebuilts.

Test: m -j checkbuild
Bug: 62956999
Change-Id: I774dbb75c8ae2ff1a990423a3827c77886e44779
(cherry picked from commit c6f07f00da)
2017-07-20 15:14:43 +00:00
Colin Cross
6650414087 Revert "Remove java version checks"
This reverts commit c6f07f00da.

Change-Id: Ibcb52ce2aecf20ac741ed9beec27c2b4b07f8b66
2017-07-19 22:42:59 +00:00
Colin Cross
c6f07f00da Remove java version checks
The build now uses a prebuilt javac binary distributed with the
source, checking the host java version is no longer required.

Test: m -j checkbuild
Bug: 62956999
Change-Id: Ieef83481d0e6d68371bbd8a422f870ffe2bbb428
2017-07-14 14:01:29 -07:00
Dan Willemsen
cae59bc29d Add microfactory tracing
Test: m clean; load out/build.trace.gz in chrome://tracing
Test: m -j nothing; load again
Change-Id: I67d4e006a4bdde593b54c20d6d93a48278fe696d
2017-07-13 15:09:44 -07:00
Dan Willemsen
c40e10bd6b Drop make flags in soong_ui
MAKELEVEL and MAKEFLAGS were are both unset by makeparallel when invoked
from Make. In preparation for removing the Make wrapper (and
makeparallel), strip them in soong_ui as well.

Add MFLAGS for completeness.

Test: m -j
Change-Id: I029f9464d11b432e979b32ede360450f4facb038
2017-07-11 15:23:55 -07:00
Dan Willemsen
091525e15c Parse environment options from the command line
Make supports specifying all types of variables on the command line
(using =, :=, +=, and other variable references. When running soong_ui
through make/makeparallel these all effectively become environment
variables.

So in preparation to remove the Make wrapper, support a simplified form
of this syntax, roughly equivalent to what the shell supports if
specified before the command (<NAME>=<VALUE>).

Test: m -j blueprint_tools
Change-Id: I08fa2b86710f282e619b0cc324a3e5bbaf62d26e
2017-07-11 15:23:51 -07:00
Dan Willemsen
9b58749f30 Support more ways to pass -j/-k
In preparation to remove Make/makeparallel from soong_ui startup, we
need to preserve compatibility with the different ways that make
supports the -j option.

Nothing changes unless Make/makeparallel is removed from the startup.
Once that is removed, not specifying a -j value will be equivalent to
'-j' instead of '-j1', like Ninja. A value will also be supported when
specifying -k, like Ninja (though specifying it alone will be equivalent
to '-k 0').

Test: m -j blueprint_tools
Change-Id: I9d5d59bedd4f6e5cca76bdb4cd47e0b5b7d523f0
2017-07-11 14:51:26 -07:00
Dan Willemsen
418420e49d Turn find emulator warnings into errors
Test: build/soong/build_test.bash (multiproduct_kati)
Change-Id: Ieb65a457c8c1ed4bff44a01aa2cc11203172ba9b
Merged-In: Ieb65a457c8c1ed4bff44a01aa2cc11203172ba9b
Merged-In: I70b696525a90c64cc05ad4caa1c3647d57ec9e9e
(cherry picked from commit dc5b70f97c)
(cherry picked from commit e8a25d5577)
(cherry picked from commit 14b3f7f12b)
2017-06-21 12:44:18 -07:00
Jeff Gaston
a6697e8b7f Only check for ninja stuckness after it's been running for a bit
Bug: 62580037
Test: rm -rf out && m -j showcommands | grep "ninja may be stuck" || echo ok

Change-Id: I8ff1bd216b5f8349ce9e06e5465a9f8d0663f8c0
2017-06-13 14:15:02 -07:00
Jeff Gaston
efc1b412f1 Have Soong try to enforce that genrules declare all their outputs.
This causes Soong to put the outputs of each genrule into a temporary
location and copy the declared outputs back to the output directory.
This gets the process closer to having an actual sandbox.

Bug: 35562758
Test: make

Change-Id: I8048fbf1a3899a86fb99d71b60669b6633b07b3e
2017-06-09 17:57:18 +00:00
Jeff Gaston
809cc6f58a Run 'pstree' if ninja_log hasn't updated recently
This doesn't catch all the possible causes of timeouts,
(like if Ninja is only partially stuck or if Kati is stuck)
but it should clarify some causes of stuckness

Bug: 62065855
Test: m -j showcommands NINJA_HEARTBEAT_INTERVAL=500ms
Change-Id: I73a792ae91873b19d7b336166a2d47f37c549906
2017-06-06 16:33:51 -07:00
Dan Willemsen
a18660d366 Have installclean remove android-info.txt again
I removed *.txt from the installclean list yesterday, but it turns out
that android-info.txt being removed was the only thing triggering
system.prop to be rebuilt on the incremental build servers. So continue
android-info.txt so that the version information in system.prop is
correct.

I'll follow this up with a more complicated change to make the
system.prop generation depend on the build number/versions more
directly, but that's a more complicated change since we need to change
how the build number file is written.

Bug: 62252890
Test: m ...intermediates/system.prop; m installclean; m ...intermediates/system.prop
Change-Id: I25dd8ddd99f7b2c927a8cbfb7f1aca1dd3e82a82
2017-06-01 22:49:47 +00:00
Dan Willemsen
e427a40356 Stop installcleaning $PRODUCT_OUT/*.{ini,txt,xlb}
For *.ini/*.txt files we should be recreating them as the instructions
change, so we shouldn't need to remove them. The biggest reason to
remove them is that the auto-installclean was removing
$PRODUCT_OUT/build_fingerprint.txt just after Kati wrote it out, causing
the fingerprint to be blank on builds where the auto installclean code
ran.

There's no reference to xlb in our tree, and it's been around since the
beginning of git history, so remove it.

Bug: 62224537
Test: lunch aosp_arm-eng; m nothing;
      lunch aosp_arm-userdebug; m -j nothing;
      check out/target/product/generic/build_fingerprint.txt
Change-Id: Id391af5c7d95ea78e4e68fae294d8295fccb1964
2017-05-31 17:26:34 -07:00
Dan Willemsen
977fd8f1fa Merge "Support Make rewriting APP-*" 2017-05-26 19:51:56 +00:00
Tobias Thierer
9847add454 Merge "Allow version 9 toolchains for EXPERIMENTAL_USE_OPENJDK9" 2017-05-26 12:08:38 +00:00
Tobias Thierer
849bb6bf99 Allow version 9 toolchains for EXPERIMENTAL_USE_OPENJDK9
By default, the Android build enforces an OpenJDK 8 toolchain,
whose name contains the strings "openjdk" and "1.8".

After this CL, the check can be changed to enforce a toolchain
name starting with "9" and without the need for "openjdk" having
to occur in the name.

This experimental new check can be enabled by running:
  export EXPERIMENTAL_USE_OPENJDK9=true
To switch back to the standard check, run:
  unset EXPERIMENTAL_USE_OPENJDK9

Test: make ANDROID_COMPILE_WITH_JACK=false checkbuild tests \
      && make checkbuild tests
      (with OpenJDK 8u45 toolchain on the PATH)
Test: make EXPERIMENTAL_USE_OPENJDK9=true \
      ANDROID_COMPILE_WITH_JACK=false checkbuild
      (with jdk 9-ea+170 toolchain on the PATH)
Bug: 38177295

Change-Id: I75de3e23fe0b7f41eb6dd3f55dadd3fa3c3383bd
2017-05-26 12:45:25 +01:00
Dan Willemsen
04a16c7dcf Support Make rewriting APP-*
Test: ALLOW_MISSING_DEPENDENCIES=true m -j APP-Calculator
Change-Id: If5a0b60a0dbc615b6f47ea222616f8d34950ba0c
2017-05-25 22:18:57 -07:00
Jeff Gaston
3615fe8665 Revert "Revert "Disallow multiple build executions in parallel""
Bug: 36698966
Test: m -j & m -j # (run two builds at once)

This reverts commit be9cd1192b.

Change-Id: Ia15c0bf156a6de54da054eab8134f36bae0823ca
2017-05-24 13:22:19 -07:00
Tobias Thierer
442b7e6dc9 Merge "Drop build support for LEGACY_USE_JAVA7." 2017-05-24 10:24:53 +00:00
Tobias Thierer
8b4319c3aa Drop build support for LEGACY_USE_JAVA7.
This flag allowed for building with an OpenJDK 7 toolchain. It was
used for build bot builds that now work with an OpenJDK 8 toolchain.
Hence, this feature is no longer required. This CL drops it.

Bug: 27583810
Test: Treehugger build succeeds.
Change-Id: Iba9cf12cff2597fa70aa9999e8a6bda190f29f3c
2017-05-23 14:20:03 +01:00
Dan Willemsen
f052f78b40 Move dataclean and installclean to soong_ui
This speeds things up a little bit, but the major win is that we don't
need to recursively call into the build during the auto installclean.

Test: m -j installclean
Test: m -j dataclean
Change-Id: I09ded8dbd8a2015c7848bc0042dfd3adad1b31c9
2017-05-18 15:48:25 -07:00
Jeff Gaston
be9cd1192b Revert "Disallow multiple build executions in parallel"
This reverts commit 7db68be5e1.

Reason for revert: postsubmit build encountered a failure

Change-Id: I3c7304114f712d78f79afb1b9d84dc2eadcbc876
2017-05-18 00:34:48 +00:00
Jeff Gaston
7db68be5e1 Disallow multiple build executions in parallel
Bug: 36698966
Test: run two 'make -j' executions in parallel in each of two terminals

Change-Id: Ief91391fe1f0fdbf9655cc0ba1298e353396d705
2017-05-16 17:47:09 -07:00
Treehugger Robot
e121bbbb3b Merge changes I9512642d,I6548889c,I8db5198f
* changes:
  Add build_test.sh, split common parts of soong_ui.bash
  Allow specifying a build variant
  Improve multiproduct_kati output
2017-05-16 19:45:08 +00:00
Dan Willemsen
02781d59bb Move auto installclean to soong_ui
This way kati won't need to be run as often (either initially, or when
switching products with the same device).

Bug: 35970961
Test: m clean; m -j blueprint_tools; m -j blueprint_tools; m -j blueprint_tools
Test: lunch aosp_arm-eng; m -j blueprint_tools; lunch full-eng; m -j blueprint_tools; <repeat>
Change-Id: Ie9fca3c8f1dd412459ea47c7090c7c5fdb0bcf6e
2017-05-15 16:26:21 -07:00
Dan Willemsen
db8457cfec Move version checking from Make into soong_ui
When kati keeps state around, it has to regenerate the ninja file every
time the state is changed. So move the java version checking into
soong_ui, where we can parallelize it with other operations instead of
only checking it occasionally.

Bug: 35970961
Test: Put java7 in PATH, m -j
Test: Put java8-google in PATH, m -j
Test: Put a space in TOP, m -j
Test: OUT_DIR=<case-preserving fs> m -j
Test: OUT_DIR=<path with space> m -j
Test: DIST_DIR=<path with sapce> m -j
Change-Id: I3245c8dd6d856240d17d54cb05d593dc9df71a27
2017-05-15 16:21:33 -07:00
Dan Willemsen
a4e43a77d8 Improve multiproduct_kati output
It now uses the same output style as ninja, overwriting status lines in
smart terminals.

Test: multiproduct_kati
Test: multiproduct_kati | cat
Change-Id: I8db5198ffdc5ebc5503241ac492379753d92978e
2017-05-15 15:24:10 -07:00
Dan Willemsen
0b73b4bc37 Move clean/clobber to soong_ui
So that we don't have to load up all the makefile state just to remove
the output directory.

Starting from a completely empty out directory:
 kati:    16s
 soong_ui: 2.0s

From a minimal out directory (m -j blueprint_tools):
 kati:     3.8s
 soong_ui: 0.4s

Test: m -j clean
Test: m -j clobber
Change-Id: Ibeec6fbfa29387750342a752a55336caca4b3992
2017-05-15 14:46:04 -07:00
Dan Willemsen
02f3add3a3 Clean OUT_DIR
Otherwise Make and soong_ui disagree about where the soong.variables
file should be. For example, when "OUT_DIR=out/":

Error dumping make vars: Failed to parse make line: "make: Nothing to be done for `out/soong/soong.variables'."

We would need to pass out//soong/soong.variables into make, since it
doesn't attempt to match clean/unclean paths.

Bug: 37553659
Test: OUT_DIR=out/ m -j
Change-Id: Iebeea4868b96b11e8b08735f272e22be5db1d701
2017-05-12 21:12:13 +00:00
Dan Willemsen
a3e6c520ac Always run asan ckati on the build servers
We're seeing some rare crashes that appear to be stack overflows. To get
better debugging, use the asan version of ckati when 'dist' is
specified.

Bug: 36182021
Test: m -j
Test: m -j dist
Test: make -j dist (w/o lunch)
Change-Id: Ic3a5590974bfd718bf1929355d344b5933ac1d4f
2017-05-05 16:59:10 -07:00
Dan Willemsen
269a8c78e7 Add exec.Cmd wrapper for logging / sandboxing
Wrap os/exec.Cmd to use our Context and Config interfaces for automatic
logging and error handling. It also simplifies environment modification
based on the Config's environment.

This also adds sandboxing on Macs using sandbox-exec. A simple profile
is provided that only logs on violations, though multiproduct_kati on
AOSP has no violations. This isn't applied to ninja, only make / soong /
kati to start with. I measured <5% time increase in reading all
makefiles, and no noticable difference when kati doesn't regenerate.

I'd like to spin up a process to dump violation logs into our log file,
but the log reporting changed over the range of Mac versions that we
support, so that's going to be more complicated. Opening Console.app
works in all cases if you're local -- just search/filter for sandbox.

Linux sandboxing will be implemented later -- the sandbox definition is
opaque enough to support a different implementation.

Test: multiproduct_kati on AOSP master on Mac
Change-Id: I7046229333d0dcc8f426a493e0f7380828879f17
2017-05-05 16:25:40 -07:00
Dan Willemsen
f173d595c2 Support ASAN for ckati and ninja
I missed this when converting to soong_ui.

Test: m -j blueprint_tools (check soong.log)
Test: SANITIZE_HOST=address m -j blueprint_tools
Change-Id: I01eb567db6848dc36dd679557291a4e600a63bba
2017-04-27 14:33:24 -07:00
Dan Willemsen
68a09854a4 Blacklist DISPLAY / GREP_OPTIONS
We keep having makefiles reading $DISPLAY, and GREP_OPTIONS with
--color=always has caused problems with shell commands in the past.

Bug: 37333696
Test: GREP_OPTIONS="--color=always" m -j
Test: DISPLAY=test m -j (modify an Android.mk to check DISPLAY)
Change-Id: Iafab37d61ecde5c6fdb35a05f18709abc17e8554
2017-04-18 14:02:38 -07:00
Yoshisato Yanagisawa
13fd3ff296 Export JAVAC_WRAPPER environment.
To allow to inject a wrapper program for compiling java code, let
me allow soong to export JAVAC_WRAPPER.

Test: Set JAVAC_WRAPPER and ANDROID_COMPILE_WITH_JACK=false envs,
Test: and make -j 32

Change-Id: Ib77fe00bd781f8f4ddf965c5e7905eab466a057a
2017-04-05 11:35:24 +09:00
Dan Willemsen
0c3919e996 Fix OUT_DIR_COMMON_BASE with soong_ui
Currently, Kati is the only one that is respecting OUT_DIR_COMMON_BASE,
causing the build to fail when ninja tries to match up the Soong and
Kati ninja files.

The soong_ui.bash script change is necessary to move the microfactory
built outputs to the correct location.

The config.go change takes care of setting OUT_DIR in the environment of
every subprocess, so that we could remove the OUT_DIR_COMMON_BASE
handling from Make once the USE_SOONG_UI=false path goes away.

Bug: 35929763
Test: m -j blueprint_tools
Test: OUT_DIR=... m -j blueprint_tools
Test: OUT_DIR_COMMON_BASE=... m -j blueprint_tools
Change-Id: I4184f2b4392d32c5bea51e51162a48df0e5c90d5
2017-03-02 19:42:21 -08:00
Dan Willemsen
c38d366d78 Updates for the new ckati drop
We can start removing out directories again in multiproduct_kati, since
the opendir bug has been fixed.

Add --color_warnings to the Kati command line. Since this is different
from Make, take this opportunity to reorder the command line to make
more sense. This wasn't done before because kati forces a regen whenever
the command line changes.

Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I5ad03359fbc16db482722946202297c1ae0f2b90
2017-02-24 10:53:23 -08:00
Treehugger Robot
fd96d2421a Merge "Improve signal handling in soong_ui" 2017-02-22 20:29:53 +00:00
Dan Willemsen
9af5fb9ac8 Improve signal handling in soong_ui
Bug: 35214134
Test: ctrl-C during build
Test: add for{} to hang soong_ui in multiple places, ensure it exits
Change-Id: Ic71eedd4b1814ab2f3c441ae61a97570eda4fe16
2017-02-22 10:44:19 -08:00