Commit graph

166 commits

Author SHA1 Message Date
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
5d5ed5fc6b Remove PrimaryBuilderExtraFlags and cull Args.
PrimaryBuilderExtra flags was only used from soong_ui and has nothing to
do with Blueprint files or modules and Args contained a lot of members
that were likewise only used for plumbing withing soong_ui or for
command line processing for soong_build.

Test: Presubmits.
Change-Id: Ibf009e446b4044309a331592a88a4aa86b4801e3
2021-09-08 09:35:56 +02:00
Lukacs T. Berki
70d6564d7d Prefix file names with ctx.SrcDir() in docgen.
This is because docgen will be called from the bootstrap Ninja file with
cwd == /.

Side cleanup: remove an unused template.

Test: Presubmits.
Change-Id: Ia5ff10247becbabc7a76c21f4ed05d654a7b20c3
2021-09-08 09:34:56 +02:00
Lukacs T. Berki
a9768e1ad7 Pass StopBefore as an argument to RunBlueprint.
Its value is a function of the call site, so it doesn't make a lot of
sense to plumb it through the configuration.

Test: Presubmits.
Change-Id: I5081650818664f283ebc5dc04daef90c26759353
2021-09-07 18:12:29 +02:00
Lukacs T. Berki
f99e89c147 Remove ConfigRemoveAbandonedFilesUnder.
It was not implemented by anyone.

Test: Presubmits.
Change-Id: I8b98620c0ef9c1f242fe7fc0a7d810f2af15d042
2021-09-06 11:35:28 +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
008b6ea661 Do not do glob-related things in RunBlueprint().
From now on, the responsibility of writing build-globs.ninja and adding
the glob list files to build.ninja.d will be the responsibility of
whoever calls Blueprint.

It's nicer this way because the bootstrap Blueprint invocation does not
need globs and Blueprint can be invoked multiple times from the
soong_build binary depending on what it does.

Regrettably, the little Blueprint invocation that generates
build-globs.ninja still requires a reference to a BootstrapConfig
because GlobRule references ${buildDir}.

Side cleanup: remove Args.DocFile, which was unused.

Test: Presubmits.
Change-Id: I37586966e3d6b7557a490ed1ae81ec596ec66ee5
2021-08-19 08:16:19 +02:00
Lukacs T. Berki
6ec924c12b Remove Srcdir() from BootstrapConfig.
It was always ".".

Test: Presubmits.
Change-Id: I0612b9b07233659adc708b9710db9aec6e24f224
2021-08-16 17:04:50 +02:00
Lukacs T. Berki
980c1f0c72 Remove global variables in command.go .
There used to be two:
- The absolute source directory is now threaded through the code instead
- The command line arguments are moved to soong_build

Test: Presubmits.

Change-Id: Ie09de1a2862ec4ced2c7385198300359f805127d
2021-08-16 15:28:04 +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
Jingwen Chen
8979d4c54c Expose build-globs.ninja write function to android/soong.
This enables bp2build to write its own build-globs.ninja file.

Test: soong integration tests
Fixes: 193650250
Change-Id: Icb35f3cf3c30929dab1b2c2e9b244321be30f967
2021-08-12 10:13:44 +00:00
Spandan Das
3a495910ad Delete creation of empty glob file
An empty glob file would be created inside the source tree if
soong_build is invoked directly (instead of via soong_ui). This logic is
now moved to soong/ui/build to prevent this behavior

Bug: 187194795
Test: Ran the following command locally for the target
art-target-arm:git_master-art
```
. ./build/envsetup.sh && lunch armv8-eng &&
art/tools/buildbot-build.sh --target
```
Before change glob file is created in $TOP/.bootstrap
After change glob file is created in $TOP/out/soong/.bootstrap

Change-Id: I6745996c940d790d1f1f387ca08aafc6a8a669df
2021-06-15 17:57:03 +00: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
Colin Cross
9021eef07b Merge "Speed up globs with sharding" 2021-04-20 16:16:40 +00:00
Lukács T. Berki
d04dcc89f4 Merge "Remove the extraNinjaFileDeps arg of RunBlueprint." 2021-04-19 06:46:52 +00:00
Lukács T. Berki
8308aab95e Merge "Use the correct build dir." 2021-04-19 06:46:16 +00:00
Colin Cross
2523698c12 Speed up globs with sharding
There are a few cases that force all globs to be rerun at the beginning
of the build (changes to bpglob or dependencies, second build after a
clean build).  The number of globs has gotten high enough that rerunning
them all can have significant overhead to start bpglob for each one.

Replace the per-glob bpglob invocations with sharded invocations using
1024 hash buckets.

Bug: 159845846
Test: glob_test.go
Test: m nothing && m nothing
Test: build/soong/bootstrap_test.sh
Change-Id: Ife1f7a03c8f6b25d1be01531425d8dc2c76d1ea0
2021-04-15 11:04:11 -07:00
Colin Cross
45222ec3ca Merge "Version bpglob command line arguments" 2021-04-15 16:42:08 +00:00
Lukacs T. Berki
f646afb52f Use the correct build dir.
Args.BuildDir was accidentally hard-wired to "." in one of my previous
changes, and since Blueprint is not really independent of Soong anymore,
it's probably better to fix it in a way that doesn't involve putting
back the almost-but-not-completely redundant "-b" command line argument
to the primary builder invocation.

Test: Presubmits.
Change-Id: I76d064a99be16cd812cb47a6c448fe44b51893dc
2021-04-15 15:46:35 +02:00
Lukacs T. Berki
f4d43ac0d7 Remove the extraNinjaFileDeps arg of RunBlueprint.
The only thing that was done with it was to append it to the list of
dependencies returned, which can just as well be done by the caller.

Test: Presubmits.
Change-Id: Ibedf024de411a5881f19ed0c137a91b0898f1269
2021-04-15 15:05:26 +02:00
Colin Cross
7e6f6b7932 Version bpglob command line arguments
bpglob is executed through the rules in build-globs.ninja to determine
whether soong_build needs to rerun.  That means when the arguments
accepted by bpglob change it will be called with the old arguments,
then soong_build will rerun and update build-globs.ninja with the new
arguments.

To avoid having to maintain backwards compatibility with old arguments
across the transition, a version argument is used to detect the
transition in order to stop parsing arguments, touch the output file
and exit immediately.  The version number in
pathtools.BPGlobArgumentVersion should be manually incremented when
the bpglob argument format changes.

If the version argument is not passed then a version mismatch is assumed.

Bug: 159845846
Test: build/soong/tests/bootstrap_test.sh
Change-Id: Id6742c7acc51af8d0d224d51e47bddea78e6e363
2021-04-14 09:28:22 -07:00
Lukacs T. Berki
98e0efb9a4 Make Blueprint better callable from Go:
- Make the parsed command line arguments accessible from other packages
- Separate writing the depfile from writing the Ninja file
- Extract a method to compute the name of the file list file for globs

Test: Presubmits.
Change-Id: I4d0daf0f3776a9336da305be0108ebf70a314776
2021-04-14 13:47:52 +02: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
Colin Cross
5ce0d78363 Merge "Make Glob return a GlobResult" 2021-04-13 17:01:39 +00: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
Colin Cross
67c99255cc Make Glob return a GlobResult
Replace the individual matches and deps return values with a GlobResult
struct.  Use the GlobResult to create the file list file in GlobWithDepFile
(used by bpglob) and in the glob singleton, as the generated files must
match exactly so that soong_build is not rerun.

Bug: 159845846
Test: glob_test.go
Change-Id: I2159cc9d85f388073198eac7456e5bf43e813096
2021-04-08 11:03:17 -07:00
Lukacs T. Berki
a9ec69433d Add an accessor function for the output Ninja file.
Test: Presubmits.
Change-Id: I505dfbbf7f87c6ea6bce71f7ae4ef8ca750d066d
2021-03-24 10:57:13 +01:00
Lukacs T. Berki
a4c074bc25 Add comment about what -N -l does.
This was added in aosp/1642084 and I forgot to address a comment.

Test: "m nothing".
Change-Id: I0fd2f2e8eeaa5b316cf19c3b426f708f2587e60f
2021-03-18 10:03:39 +01: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
b3b9cb6ccc Remove the GeneratingPrimaryBuilder() method.
It's replaced with a flag in bootstrap.Args. It's a little bit ugly that
bootstrap.Main also gained a new Boolean flag in the process. The plan
is to delete that method in favor of directly calling RunBlueprint().

Test: "m nothing" (presubmits take a full workday these days)
Change-Id: Iae3421ae517a90570259b6278f18c3614bb1bb73
2021-03-17 14:08:47 +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
c8b9e55289 Increase ninja file writer buffer
Increase the ninja file writer buffer from the default 4k to 16MB.

Test: m checkbuild
Change-Id: Ieb2c82218517b98469ef93f1ea4dd04b5651f7d1
2021-01-21 22:02:30 -08:00
Colin Cross
0335e0900d Use io.StringWriter in ninjaWriter
ninjaWriter repeatedly called io.WriteString() on its writer, which
does a type assertion every time.  Replace its io.Writer with an
io.StringWriter and call WriteString on it directly.

Test: ninja_writer_test.go
Change-Id: Ie073d996a319190242bf6a00af07a13a60d078b5
2021-01-21 22:02:30 -08:00
Colin Cross
7ceeeaf364 Remove unnecessary depFile parameter from GlobFile
GlobRule uses $out.d for the dep file, it doesn't need an extra
parameter.

Test: glob_test.go
Change-Id: Ie753a119c3602c325450909f0240f6eeef9ef243
2020-11-10 12:24:17 -08:00