Commit graph

92 commits

Author SHA1 Message Date
Lukacs T. Berki
a67610a75f Allow soong_ui to set env vars for soong_build .
This is used to make GODEBUG=asyncpreemptoff=1 only be set in debug mode
so that production is not affected.

Test: Presubmits.
Change-Id: Idb15ad20bb74ba3f896699715e3208c1287a5e82
2022-01-05 10:29:48 +01:00
Lukács T. Berki
1a1ec4b59c Merge "Set GODEBUG=asyncpreemptoff=1 for soong_build." 2022-01-05 09:06:19 +00:00
Lukacs T. Berki
3dab5143bd Allow specifying the pool for soong_build calls.
Test: Presubmits.
Change-Id: Iff0edf595b1868ccdda4ea6391c1057e0f86cd9b
2022-01-04 14:49:54 +01:00
Lukacs T. Berki
635fc35a09 Set GODEBUG=asyncpreemptoff=1 for soong_build.
This makes debugging with Delve much faster, sometimes by an order of
magnitude because Delve does not have to deal with the many SIGURG
signals that are used to stop preempted goroutines this way.

This could in theory result in a performance loss, but running
`rm -f out/soong/build.ninja; time m nothing` five times demonstrated no
change in the execution time.

Test: Presubmits + performance testing as described above.
Change-Id: I438564bcaf70d2a50147cf54cdfac6dcfe925ce5
2022-01-04 12:37:24 +01:00
Jingwen Chen
8e7786a0fd Forward descriptions to primary build invocations.
Test: m nothing bp2build json-module-graph queryview soong_docs
Change-Id: Ic64238dc10a90c923cf5559d1bbbc51fd0922e31
2021-12-06 13:30:18 +00:00
Lukacs T. Berki
6fbc68d41d Move bpglob to outside of the Ninja action graph.
It's in reality built by Microfactory quite early in the build which
takes care of incrementality in bpglob itself.

Test: Presubmits.
Change-Id: I066a6e85f48e9cfec4efd46cb1f615c68b806080
2021-11-10 12:37:55 +01:00
Colin Cross
37d151ff95 Move bpglob out of ToolDir
ToolDir is going to become unstable when switching between KatiEnabled
and Soong-only builds while the duplication between out/soong/host and
out/host is resolved.  bpglob gets executed very early during bootstrap,
before the primary builder has run to update the paths to match the
current configuration.  Move it into SoongOutDir() so that its path
is more stable.

The copy of bpglob in ToolDir is still used when bpglob is used by the
primary builder through bootstrap.GlobFile.

Bug: 204136549
Test: m nothing
Change-Id: Ida51997b6408d7c265f3ba343278e5e2968467d3
2021-11-01 22:54:02 -07:00
Lukacs T. Berki
d9d298c760 Remove UseValidationsForGoTests.
Whenever it was called, it returned true.

Test: Presubmits.
Change-Id: Iabe5a99b8363771d06b200d4641d9ce477ba5b6e
2021-09-08 15:32:52 +02:00
Lukacs T. Berki
9b435b8089 Make cmdline args consistent with what they do.
Test: Presubmits.
Change-Id: I6d5f827e06526a121f915aae57c6f086ba44f21d
2021-09-02 13:29:10 +02:00
Lukacs T. Berki
d782b504e0 Remove the bootstrap.Config class.
It was confusing because there are two concepts with the same name:
thebootstrapping config special-cased in the bootstrap modules /
singletons and the "global" config.

This change folds the first into the second.

A further next step would be to split the Go parts and the Ninja parts
(subninjas + primary builder invocation) apart, but at some point, I
should stop gold-plating this.

Test: Presubmits.
Change-Id: Id341dee664a9d2527535f4f9980e5f0d10139eef
2021-09-02 09:58:45 +02:00
Lukacs T. Berki
ceb3c43f65 Simplify bootstrapping:
- Remove the bootstrap_go_binary module type in favor of
blueprint_go_binary
- Make it so that all the binaries used during bootstrapping are in the
host tool directory so that the bootstrap and main Ninja files are
consistent

Test: Presubmits.

Change-Id: I00744fec0474fbea89db6c0c0338856453138564
2021-09-01 11:55:00 +02:00
Lukacs T. Berki
ce41c169b5 Remove some unnecessary arguments from Blueprint.
What's gone:

- TopFile (it's always Android.bp)
- GeneratingPrimaryBuilder (we don't make that distinction anymore)

Also rename BuildDir and NinjaBuildDir to SoongOutDir and OutDir,
respectively, to be consistent with the rest of the code.

Test: Presubmits.
Change-Id: I55ecb02a59fe68bf5674395a108181ea7557b21f
2021-08-31 10:58:04 +02:00
Lukacs T. Berki
0459f6b18e Remove Depfiles from bootstrap.Args .
It is not used anymore; Soong assumes that the depfile is just the name
of the output file with a ".d" suffix.

Test: Presubmits.
Change-Id: Ifbf722dcdffc8420e12a032e23ab791a6be5a736
2021-08-27 15:56:00 +02:00
Lukacs T. Berki
5c4abb15e3 Rename BuildDir and NinjaBuildDir.
These are just out/ and out/soong/ and the old names were quite
confusing.

Test: Presubmits.
Merged-In: Idd9ce3c38a259faabcc56f0cd3fdac8b289123b1
Merged-In: I334ab40c668d2a94536f3e63d5f1fa0b401388ac
Change-Id: Ib7c568c6a97701f2240c5e3f0f2ce67397819ac0
2021-08-26 15:08:09 +02:00
Lukacs T. Berki
51b625928d Do not separate .primary and .bootstrap dirs.
This makes it possible to share work between the bootstrap and the main
Ninja file.

As a side fix, remove the reference to $srcDir from moduleSrcDir() since
that is hardwired to "." anyway.

Test: Presubmits.
Change-Id: Ia4a251dd34273ec3e0436ac7a2fbafe4ef46c73f
2021-08-19 16:26:36 +02:00
Lukacs T. Berki
5f0a740fed Do not reference Ninja variables in Makefiles.
installPath was included by androidmk.go in the Soong-generated
Android.mk file, which means that the Ninja variable reference
`$buildDir` passe through Kati, with unpredictable results.

`$buildDir` is still used in a few places, but those are not problematic
because they are not copied to Android.mk (they could probably be
removed, but it's not trivial enough to be done as a drive-by fix)

Test: Presubmits.
Change-Id: I6a5ea8b1679001ff685d263310cb061d3a6a992e
2021-08-19 13:46:22 +02:00
Lukacs T. Berki
016a7dd6ef Delete support for standalone Blueprint.
Now that Blueprint has been merged with Soong, a large amount of code is
unnecessary.

Test: Presubmits.
Change-Id: I8d30d8b80f37fdc6a9db630a1792c57c7d6edb38
2021-08-16 14:09:47 +02:00
Lukacs T. Berki
64ee4262a0 Remove the ability to emit Blueprint docs.
This is not necessary anymore now that Blueprint doesn't have a separate
existence and Soong's documentation generation uses a completely
separate code path.

Test: Presubmits.
Change-Id: Ibc9e57379c5f8ee9a06d90fbe81fac314f01ee92
2021-08-16 13:42:42 +02:00
Lukacs T. Berki
0eb24a7041 Explain why build.ninja is a non-default output.
Test: Only comment change.
Change-Id: I335670b7f3bed0fe34fdb1d625b6e459146cc192
2021-08-16 11:48:51 +02:00
Lukacs T. Berki
d3a0637702 Separate the concept of subninjas and glob files.
This makes the distinction between what the bootstrap .ninja file and
the main .ninja files do clearer: the bootstrap .ninja file includes the
build-globs.ninja file(s) which the main .ninja file writes.

This required removing the "default" statement from said bootstrap
.ninja file: now we can build more than one thing instead of just
build.ninja and thus soong_ui explicitly tells Ninja what to do instead.

On the side, stop catering for the use case where the bootstrap
Blueprint invocation uses globs: Soong's does not and that's our only
use case.

Test: Presubmits.

Change-Id: Icffce31928242cfe9cdab56b290a37598d32a58c
2021-08-16 09:16:09 +02:00
Dan Willemsen
0f0e304d08 Add blueprint_go_packages phony to build all go packages
We have `blueprint_tools` that can build all Go binaries (and run their
associates tests). But if a package is not (yet) used, it won't be
included there. This makes testing the build of new Go packages
difficult.

Test: m blueprint_go_packages
Change-Id: I7a67cf2593fedcf499d40d82c266d3b0d7ebbef2
2021-05-24 11:36:37 -07:00
Lukacs T. Berki
78df853e07 Make it possible to call the primary builder more than once.
This is accomplished by plumbing PrimaryBuilderInvocation in from
bootstrap.Args.

The confusing removal of "primaryBuilderExtraFlags" from documentation
generation is because it used to (erroneously) refer to the func defined
in command.go and its removal apparently doesn't break anything. I
suspect that this code path is dead within Android, but we'll need to
wait until May to remove it.

Test: Presubmits.
Change-Id: I8763579b82bd79d5ee0f233edfd48327282e401c
2021-04-14 10:28:54 +02:00
Lukacs T. Berki
77ef79b7c4 Move primary builder command line computation.
This makes it possible to invoke the primary builder more than once in a
single Ninja file.

This required adding arguments that were hard-wired in the build.ninja
rule to extraArgs and adding a "set of primary builder invocations"
member to bootstrap.Config . The only command line arguments that remain
hard-wired are those which are expected to be relevant to every
invocation of the primary builder.

As a welcome side effect, I was able to remove a number of random
environment variables that were so far special-cased ($SOONG_DELVE,
$SOONG_DELVE_PATH and $SOONG_OUTDIR). I was also able to move writing
the empty stub ninja glob file to command.go from the bowels of the
Blueprint machinery.

In theory, $TOP and $BUILDER could be removed, too, but this would
require hard-coding the value of $TOP into build.ninja and I don't know
what would break if I did that (it's okay to hard-wired $SOONG_DELVE and
$SOONG_DELVE_PATH because those are only used for debugging and
$SOONG_OUTDIR turned out to be superfluous)

Test: Presubmits.
Change-Id: Idbfd9976c4b270bc3e5a8926c8c760a8534596cf
2021-04-12 14:30:47 +02:00
Lukacs T. Berki
07a91f072c Add a flag to compile Go code for debugging.
This makes it possible to debug the primary builder without manually
adding the respective flags to the compilation command lines.

Test: "m nothing", "m nothing" with debugging, then "m nothing" again
Change-Id: I7d403af48528a94e5e0033d9a5c1fa9981100cfd
2021-03-17 15:01:51 +01:00
Lukacs T. Berki
7ea1c168fe Make it possible to call Blueprint from Go.
In addition to the command line interface, a new struct is created that
holds all the information Blueprint needs to do its job.

Test: Presubmits.
Change-Id: I0d6c924e09e069b3c1ae2000722efb52fd561e79
2021-03-17 08:33:21 +01:00
Lukacs T. Berki
5353744f1d Remove global variables from Blueprint.
The end goal of this exercise is to remove all mutable global state so
that multiple Blueprint instances can be run in the same process.

This is done by plumbing the necessary data through the configuration.

Test: Presubmit.
Change-Id: I040a461ae17705258b882b3a44740a4dd5027a2c
2021-03-17 08:06:38 +01:00
Lukács T. Berki
51868f1577 Merge "Fix quoting issues when generating build.ninja ." 2021-03-10 07:03:48 +00:00
Lukacs T. Berki
0bd3de33fd Fix quoting issues when generating build.ninja .
Some of these were introduced in aosp/1610784 and some others were
present since a good while.

Test: Manual: "m nothing"
Change-Id: I7d5cb56ca2d87cb439354fd1b298c3b8d97d665d
2021-03-09 09:32:54 +01:00
Lukacs T. Berki
7d2e60ece7 Use stageDir() to determine the install directory.
In particular, for Go binary modules.

Test: Manual ("m nothing")
Change-Id: I98d184a00f1a48bc68e4b03747331fd449e37de1
2021-03-08 16:48:38 +01:00
Lukacs T. Berki
122b3ee153 Make debugging easier:
- Add the -N -l command line arguments to Microfactory
- Pass the the Delve arguments to the primary builder on the command line

Test: Manual.

Change-Id: I4034f2d48b3e40d9863529053715183dc3dce1f5
2021-03-03 09:15:04 +01:00
Lukacs T. Berki
f802ffcd12 cd / before generating build.ninja .
This is so that soong_build doesn't know the current directory, thereby
avoiding one way to leak information.

Test: Manual.
Change-Id: I976a8663b11d99c5382726487102df10043c5a61
2021-03-03 09:14:22 +01:00
Colin Cross
d2458a23bf Enable variants of bootstrap modules
The primary builder may want to create variants of bootstrap
modules if they need to fit in to the primary builder's dependency
graph.  Enable arbitrary variants of bootstrap modules by only
running the module's actions on the primary variant and then
copying the result to any other variants that exist.

Test: m checkbuild
Change-Id: I24b97771bb11faeacab4079ed8cf69aef59da140
2020-09-09 14:32:42 -07:00
Colin Cross
0cdec99c81 Add flag to use validations for tests
Using validations for tests ensures the tests run without blocking
the critical path.

Change-Id: Icb21a52e96f70d815f7df86882351c13f5575cf5
2020-07-09 14:28:20 -07:00
Colin Cross
f89751462c Revert "Always emit rules for tests and add phony to run them"
This reverts commit 63085f9e7c.

It breaks the blueprint tests, and we aren't use it yet, so revert
it for now.

Change-Id: I1ac81371342285e8d57baf15fe3a223d4140c6cf
2020-06-11 16:23:10 -07:00
Colin Cross
63085f9e7c Always emit rules for tests and add phony to run them
Emit the rules to build blueprint tests even if runGoTests is not
set, and add a phony rule "blueprint_tests" to run them.  This will
allow Soong to stop running the tests at the beginning of every build
but still run them as part of checkbuild or with a manual
`m blueprint_tests`.

Bug: 156428456
Test: m
Test: m blueprint_tests
Change-Id: If293a0757766d3046e78bf230a1825f15adc68fd
2020-05-12 19:20:26 -07:00
Colin Cross
c5fa50e057 Allow primary builder to change working directory
Bug: 146437378
Test: pathtools/fs_test.go
Change-Id: I513ceb9b8b0b4f18223bc34ecad9846fe220709b
2020-01-08 15:54:58 -08:00
Colin Cross
16fec72dfc Move outputs of bootstrap modules in main stage to separate directory
Don't write to $buildDir/.bootstrap in the ninja file generated for
the main stage.

Test: examine main stage build.ninja file
Change-Id: I9c6183c9a434ff11d44cdd4f9844eae192ebfe03
2019-10-17 13:42:34 -07:00
Colin Cross
a2bc585afe Fix compiling binaries with go 1.13
The go compile command in go 1.13 needs -p main instead of
-p $pkgPath when compiling binaries.  This also works for older
go releases.

Also turn on travis for go 1.13.

Change-Id: I45ce185aa44cfa01a7933cc6e52290a85c851641
2019-09-06 14:25:28 -07:00
Colin Cross
0e112a8b97 Revert "Put the primary builder into the console pool"
This reverts commit 8ea996f61d.

Having the primary builder hinders automatic error reporting
by separating the error message from the failure status.
2019-07-18 13:53:43 -07:00
Colin Cross
8ea996f61d Put the primary builder into the console pool
The primary builder should always be running on its own with no
other processes running in parallel, so put it in the console
pool so that it can print to stdout without buffering.

Bug: 80165685
Test: build with print in Soong
Change-Id: If34ecdb5fa18de7e47c4cd6965d551c504850176
2019-06-19 14:39:41 -07:00
Dan Willemsen
dac90d33ca Add --empty-ninja-file for test usecases
In cases that we want to run blueprint-based builds in many
configurations to verify all of the logic works without errors, but
don't care about running the final ninja file, writing it out only
wastes time and disk space. So add a --empty-ninja-file option that
writes out an empty ninja file instead.

Our specific use case (Soong's build_test / multiproduct_kati) runs
Soong several hundred times for different configurations, and the ninja
files are around 1GB, which leads to several hundred gigabytes of disk
writes (and persistent use during incremental generation).

Change-Id: I0198dfb2f744ce22284c05d5214dac2ab5dc9700
2018-10-26 09:57:24 -07:00
Colin Cross
1be9abc109 Add link dependency on test package archive
The test package archive was being picked up through "-L" + testRoot,
but did not have a dependency on it.  If the *_test.go file was
changed but not the implementation then the tests would not be
rerun.

Test: Add t.Fatal() to a *_test.go file and rebuild.
Change-Id: I32b8c7a0fa1d5b76b1242646887fe937e396e318
2018-10-24 13:13:13 -07:00
Colin Cross
0e58dc0176 Add missing dependencies when linking tests
Linking tests needs the same dependencies that linking binaries
got in https://github.com/google/blueprint/pull/222.

Test: m checkbuild
Change-Id: I33330f3184b8c0fd2bc20b48736c20d6edeaea68
2018-10-05 11:12:53 -07:00
Colin Cross
6c92af937e Enable restat for go binaries
Many Android build tools are written in go, and changes to Soong or
Blueprint can cause them to rebuild.  Almost everything in an
Android build is downstream of at least one of these tools, so
they all rebuild too.

Go binaries are static, so their contents will always change if any
of their dependencies change.  Only update output files of go compile
and go link if the contents change, and enable restat for the rules.

Test: m soong_zip && m soong_zip
Test: m soong_zip && touch build/soong/zip/cmd/main.go && m soong_zip
Change-Id: I9267580f644b42b44d43fb0a2674dc5234f127e5
2018-10-02 21:52:50 -07:00
Dan Willemsen
734f20c205 Fix issues found by go vet
Change-Id: If3e20a1f394d757554d6a7da5ed4c41fe194f55f
2018-07-21 13:10:25 -07:00
Dan Willemsen
ab223a512b Run globs during earlier bootstrap phases
Instead of sometimes re-running minibp/the primary builder during the
next phase, run bpglob earlier to check dependencies.

We've run into issues where the environment is slightly different
between bootstrapping phase and the main build phase. It's also a
problem because our primary builder (Soong) exports information used by
another tool (Kati) that runs in between the bootstrapping phases and
the main phase. When Soong would run in the main phase, it could get out
of sync, and would require the build to be run again.

To do this, add a "subninja" include a build-globs.ninja file to each
build.ninja file. The first time, this will be an empty file, but we'll
always run minibp / the primary builder anyway. When the builder runs,
in addition to writing a dependency file, write out the
build-globs.ninja file with the rules to run bpglob.

Since bpglob may need to be run very early, before it would normally be
built, build it with microfactory.

Change-Id: I89fcd849a8729e892f163d40060ab90b5d4dfa5d
2018-07-06 10:39:38 -07:00
Dan Willemsen
20c343b89e Cap the number of cpus for Go compiles
When passing "-c" to the Go compiler, any time this value changes, we'd
force all of the Go compiles to rebuild. This could trigger a
substantial portion of the tree to rebuild (anything that transitive
depends on a Go helper tool).

We're running into issues when moving output directories between
multiple GCE machines with different core counts, but are otherwise
identical. This could also hit users moving/mounting disks between
machines, though changes to other host tools can make an impact too.

On my 48-core machine, I get a ~15% benefit from going from -c 1 to -c
48, but also ~12% benefit from going from -c 1 to -c 8. So this will
still let us scale somewhat, but prevent rebuilds when transitioning
between machines that are more likely building Android.
2018-03-02 15:32:22 -08:00
Dan Willemsen
2d9b59bc20 Store build.ninja deps in .ninja_deps
We're already going to load the .ninja_deps file, so we may as well use
it. These are the only two files in our build that don't.

Test: dump the .ninja_deps file, see the dependencies
2017-12-18 09:14:16 -08:00
Colin Cross
5eb116a46e Move auto-generated docs to main stage
Move the docs to the main stage and make a phony rule to build
them.  This will allow the primaray builder to choose not to
build them so that it can use its own rule instead.

Change-Id: Ib788f74717ccdcd85c2e5b6a581cc744d439341a
2017-12-11 16:31:41 -08:00
Jeff Gaston
c3e2844dfe Support for a custom list of Blueprints files to parse
Bug: 64363847
Test: BLUEPRINT_LIST_FILE=out/.module_paths/Android.bp.list minibp

Change-Id: Id7f8cb1ab3a6684b3f8265d77bb32413957f1c93
2017-10-30 15:00:19 -07:00