Commit graph

195 commits

Author SHA1 Message Date
Kevin Dagostino
ad7bcc7b50 Enable parallelCompile since golang is now >= 1.9
Test: m nothing
Change-Id: I38cdd83ca9b17263155433abb65fb4f97b5ec70b
2023-03-03 21:57:29 +00:00
Usta Shrestha
ce85ecb176 cosmetic: readability
Test: run `m nothing` and `m nothing --empty_ninja_file`
Bug: NA
Change-Id: I6fd81667ea2d636139ae38bc36315f8710b72c25
2023-02-23 02:27:26 +00:00
Chris Parsons
58a29728ea Close ninja file descriptor
With this close() missing, especially with large ninja files, soong paid
the runtime cost at arbitrary times during the rest of its execution (or
during process cleanup).

Test: Manual runs of `m nothing` and verifying timing metrics
Change-Id: Ibdfbf7371cfc4c58c485e76f96b8e9b9ad900972
2023-02-08 23:33:56 -05:00
Treehugger Robot
a405cf7f6a Merge changes I516c984b,I2b3354de
* changes:
  comment on how glob files are written
  cosmetic: use map[_]struct{}  for set semantics
2022-12-21 15:44:42 +00:00
Usta Shrestha
f0e02237da comment on how glob files are written
Bug: NA
Test: NA
Change-Id: I516c984b62d07ca7f188b2faef1466c5720b3b22
2022-12-21 01:04:19 -05:00
Sasha Smundak
08343b7a89 bootstrap.Args should contain only relevant command line arguments
Soong/Bazel-specific arguments are now kept in Soong.

Test: treehugger
Change-Id: If37bc6ea60b58173baa981bb5c85bfc90102005c
2022-12-14 10:27:31 -08:00
Spandan Das
c3887c2bbb Merge "Conditional inclusion of blueprint modules" 2022-12-05 23:50:23 +00:00
Spandan Das
ed4af01be6 Conditional inclusion of blueprint modules
This introduces a new `blueprint_package_includes` module type. If
present, other blueprint modules in that file will be analyzed
if and only if the requested include tags are met

example syntax:
```
Android.bp
blueprint_packgage_includes {
  match_all: ["tag1", "tag2", ...],
}

other_module1 {...}
other_module2 {...}
```
other_module1 and other_module2 will not be analyzed unless
tag1,tag2, ... are set

This also adds a new object of type `IncludeTags` to the Context object,
which is a container for these string keys.

Test: In build/blueprint, go test ./
Test: TH

Change-Id: I79de0d7da3224a5b2025c27a5137f39d00c7382e
2022-12-02 01:46:28 +00:00
MarkDacek
99f7962b35 Add bazel-force-enabled-modules.
Test: m nothing
Change-Id: I97d8fcb304f0d039fd7bbd3ea3d01966ae25471f
2022-12-01 20:15:33 +00:00
Colin Cross
1b457a5e10 Add VariableFuncContext argument to VariableFuncs
Add a VariableFuncContext argument to VariableFuncs that implements
GlobWithDeps.  This will allow Soong to use optimized glob dependencies
in VariableFuncs.

Bug: 257079828
Test: no dependencies on directories in build.ninja.d
Change-Id: Iee5fc9c9ae3087662a5d1a3d7323a87462299205
2022-11-04 18:21:31 +00:00
Lukacs T. Berki
0acaefea0d Add order-only inputs for primary builder.
Test: Presubmits.
Change-Id: Iefe729f6874c1154c94d10563fb2fac3dc03049a
2022-10-27 08:05:27 +00:00
MarkDacek
c5e959b244 Add staging mode to soong build.
This is to build bazel targets that are nearing readiness for prod mode.

Bug: 254265047
Test: m nothing
Test: m nothing --bazel-mode-dev
Test: m nothing --bazel-mode-staging
Change-Id: Ie8336ec4ad70c0c9bd6d74f3b0a278c85fd5df2d
2022-10-18 20:35:45 +00:00
usta
71ce3eae12 cosmetic: fail fast on empty module list
also minor refactoring to limit var scopes

Test: m nothing and ensure ninja files are generated
Bug: N/A
Change-Id: If7bdede4e54687955896b03ab11ef771855d2225
2022-09-20 05:15:24 +00:00
usta
83ede83a31 cleanup: remove deprecated module ioutil
Test: m nothing and check bootstrap.ninja and build.ninja file
Bug: N/A
Change-Id: I8c2f2d8cb452955921b2287ec2c621909ebde5e4
2022-09-20 05:13:27 +00:00
Chris Parsons
a034bea7e9 Add bazelmode and bazelmodedev as command args
Test: See attached topic CLs
Change-Id: I7a6290702f6cd721ef5f67e885b3dfc4b98edeb0
2022-08-19 11:35:54 -04:00
Chris Parsons
91f638f692 Support pre-build-action hook in blueprint
This allows for a bazel-invocation hook in mixed builds, which allows
for mixed builds to take place in only a single pass, greatly improving
its performance and complexity.

Test: Conjunction with build/soong CL
Change-Id: If89fb56830b4eb06d3263d6ca6da7b285e7ba315
2022-05-10 13:46:40 -04:00
Chris Parsons
18ebb2318a Add event handling to blueprint for metrics
In conjunction with soong/build changes, this materialized runtime
metrics for various soong_build events.

Test: Manually verified materialized protos for bp2build, mixed builds,
and legacy build.

Change-Id: Ia92403605e3063028dbf6a1ded8449c190b9e63e
2022-03-25 13:15:17 -04:00
Usta Shrestha
62823dcf01 use iota for "enum"
Test: m nothing
Bug: N/A
Change-Id: I9d59796cbf1dc3dc8e1e9fc536b50c1dea3a5f61
2022-01-18 16:51:12 -05:00
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
Trevor Radcliffe
0bf636f3ef Merge "Change bpdoc to separate entries with the same type" 2021-11-05 16:11:23 +00:00
Lukacs T. Berki
f12f1d7d1e Remove the -v argument from bpglob.
Now that we have bootstrapEpoch, it's not necessary anymore.

Test: Presubmits.
Change-Id: If36cf3c8f71c1023003f408b4e799bbbdba6fa27
2021-11-04 11:48:43 +01:00
Trevor Radcliffe
d14f342fa6 Change bpdoc to separate entries with the same type
Presently, entries in the Soong reference docs that
share the same type are condensed into a single entry.
This is very unintuitive, so this change removes that
functionality.

Fixes: 204441523
Test: bpdoc_test.go
Test: build and compare Soong docs
Change-Id: Ic03891a8a7a29b5f7ee58c01b2fa05a0c27e0a2b
2021-11-02 15:59:48 +00: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
Spandan Das
1109cd96b7 bpdocs for struct types created using reflection
struct types defined using reflection have empty PkgPaths(), due to
which they were not added to the generated bpdocs. This CL allows
us to generate bpdocs for such struct types.

For each field in the struct, the algorithm checks the following and
creates a PropertyStruct object accordingly
1. If field is a primitive type (Base condition)
2. If field is another exported struct (Base condition)
3. If field is another struct created using reflection (Recurse)

Test: m soong_docs
Test: java_sdk_library_import before
https://ci.android.com/builds/submitted/7710820/linux/latest/view/java.html#java_sdk_library_import
and after
https://spandandas.users.x20web.corp.google.com/docs/java.html#java_sdk_library_import
Bug: 172797653

Change-Id: I0349e405fd290d427fa0b38a109b4212aace50c6
2021-09-20 22:33:05 +00: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
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