Commit graph

636 commits

Author SHA1 Message Date
Dan Willemsen
f42f01b49d Merge "Upgrade to golang protobuf api v2" 2021-07-29 18:29:26 +00:00
Sasha Smundak
7ae80a7044 Build mk2rbc and rbcrun during bootstrap
Bug: 172923994
Test: treehugger
Change-Id: I6b552b40eecbaedd17b39ed5d00ca2a0b0772c81
2021-07-27 10:27:43 -07:00
Dan Willemsen
4591b6496d Upgrade to golang protobuf api v2
Major operations:
 * Fix the go_package entries to be consistent, as the new tool
   complains when it doesn't have a '/'.
 * Regenerate with the new protoc-gen-go tool.
 * github.com/golang/protobuf -> google.golang.org/protobuf
 * proto.[Un]MarshalText -> prototext.[Un]Marshal

Change-Id: Ie1147bd2457fafb66ba555461b3bf14f0561a25d
2021-07-23 11:12:05 -07:00
Liz Kammer
da29c65eb6 Merge "Include bazel-status of build in metrics" 2021-07-15 12:58:04 +00:00
Paul Duffin
fb9a7f99be Support generating sdk snapshots that can be selected by Soong config vars
Allows the builder of an sdk snapshot to specify a Soong config
variable that can be used to control whether the snapshot's prebuilts
are used or not.

Bug: 193523070
Test: m nothing
Change-Id: Ib09500ba61befc1202dff61dc06847c730ba9253
2021-07-14 23:19:53 +01:00
Liz Kammer
ca9cb2e5bd Include bazel-status of build in metrics
Currently within metrics we cannot distinguish between Bazel-involved
configurations:
  Bazel as Ninja vs Ninja as Ninja builds
  Bazel mixed builds vs non-mixed builds

Add these to the build configuration in order to distinguish between and
track them independently.

Test: go soong tests
Test: USE_BAZEL_ANALYSIS=1 m nothing and verify out/soong_metrics
Bug: 193672397
Change-Id: I94ce56c1a98a76d929598d9fe3070df16ffa1376
2021-07-14 17:48:04 -04:00
Spandan Das
3a932550a3 Merge "Add errorHints to stdout when read-only file system errors are detected" 2021-06-30 23:52:19 +00:00
Anton Hansson
17fc5a03da Remove kati marker in soong-only build
Previously we ensured the kati marker exists in kati-enabled builds, but
did not ensure the kati marker didn't exist in non-kati-enabled builds,
resulting in soong thinking kati would run after it when it would not.

Also change the condition to only create the kati_enabled marker if we
don't skip kati or kati ninja.

Bug: 189187214
Test: m nothing && soong_ui --make-mode --soong-only && verify
      kati_enabled marker is gone
Change-Id: If196b194b6aee38e9d4135889a4a4048ee5add82
2021-06-29 15:17:36 +01:00
Spandan Das
0506361a60 Add errorHints to stdout when read-only file system errors are detected
The source tree will eventually be made ReadOnly, and recipes that write
directly to the source tree will fail. Use a pattern-match approach on
the results of stdout/stderr to provide hints to the user in such a
scenario.

If multiple patterns are found in raw output, print error hint
corresponding to first pattern match. first pattern match is chosen
since the failing function will be at the top of the stack, and hence
will be logged first

Test: Wrote a unit test to assert errorhint is added to output.
Wrote an integration test that writes to a file in the source tree
1. When source_tree is RO, the recipe fails and an error hint is printed
to stdout
2. When source tree is RW, the recipe succeeds and no error hint is
printed

Bug: 174726238
Change-Id: Id67b48f8094cdf8a571c239ae469d60464a1e89c
2021-06-29 00:20:21 +00:00
Jingwen Chen
dd9725c177 Fix SOONG_DUMP_JSON_MODULE_GRAPH on a fresh checkout.
This CL adds generateJsonModuleGraph bazelBuildMode and ensures that it
returns Soong early, before Kati and Soong metrics collection begin
(which causes errors, since they're looking for files that Soong in json
dump mode did not write).

Test: TH
Test: rm -rf out && SOONG_DUMP_JSON_MODULE_GRAPH=/tmp/soong.json m nothing

Change-Id: I264eadb3b3b0cd6b6e7a65adc7b39bb1c01ca136
2021-06-24 08:41:19 +00:00
Colin Cross
30e444be67 Add --skip-config flag to soong_ui.bash
--skip-config can be combined with --soong-only to skip creating
soong.variables from Make, allowing a custom soong.varibles.

Test: manual
Change-Id: Iee9bfa4efeed801339e7c3c1e4807709485e701a
2021-06-18 11:26:19 -07:00
Spandan Das
8f99ae6bc0 Bootstrap empty glob file
1. Initialize an empty glob file for .bootstrap/build.ninja. Initializing
in soong_ui (and not soong_build) prevents inadvertently creating the
file inside the source tree
2. Remove soong-build-globs.ninja, which is not used during the build

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
```

Change-Id: Ibe6eeff65ea1ab25136642299e9878d0da1cac42
2021-06-15 17:50:46 +00:00
Anton Hansson
0b55bdb7af Add a soong-only mode to soong-ui
The previous --skip-kati flag could be interpreted as "do not run kati
to re-generate ninja file". Add a more specific flag for the "soong
only" build use-case, where we do not load the kati-generated ninja
files at all.

Bug: 189187214
Test: build/soong/soong_ui.bash \
  --make-mode \
  --soong-only
  --skip-soong-tests \
  TARGET_PRODUCT=mainline_sdk \
  SOONG_ALLOW_MISSING_DEPENDENCIES=true \
  SOONG_SDK_SNAPSHOT_VERSION=unversioned \
  SOONG_SDK_SNAPSHOT_USE_SRCJAR=true \
  out/soong/mainline-sdks/art-module-sdk.zip
Change-Id: I91abbd28af517d4b550ebc6d88fd64947caf9545
Merged-In: I91abbd28af517d4b550ebc6d88fd64947caf9545
(cherry picked from commit 546de4a1f3)
2021-06-07 14:34:40 +01:00
Anton Hansson
5a7861a272 Various cleanup in soong_ui to aid new feature
- Rename the "BuildX" variables to "RunX"
- Remove redundant comments
- Inline all the "what to do" based on config in build.go
- Inline some constants only used in one place

Bug: 189187214
Test: m nothing
Test: build/soong/build_test.bash
Change-Id: I111a69e642212d7938d4971283545e0d9acbb01a
Merged-In: I111a69e642212d7938d4971283545e0d9acbb01a
(cherry picked from commit d274ea9196)
2021-06-07 14:34:40 +01:00
Spandan Das
8e590ea854 Merge "Create Make flags to set source tree as ReadOnly in soong builds" 2021-06-02 19:23:11 +00:00
Spandan Das
a3639e62cd Create Make flags to set source tree as ReadOnly in soong builds
The following two Make vars control RO/RW access to the source tree
1. BUILD_BROKEN_SRC_DIR_IS_WRITABLE
2. BUILD_BROKEN_SRC_DIR_RW_ALLOWLIST

By default, (1) will be truthy.
- this ensures that this CL is a non breaking change across all products
- different products can opt in to set is as "false"

Bug: 174726238
Test: from build/soong dir, ran go test ./ui/build
Change-Id: I4d55ac74f02b2a73194d31506a9010162620b25a
2021-06-01 21:40:49 +00:00
Colin Cross
f3bdbcbea3 Fix propagating EMPTY_NINJA_FILE from multiproduct_kati to minibp
I6dca478f356f56a8aee1e457d71439272351390b replaced calling
build/blueprint/bootstrap.bash with running minibp directly,
but didn't propagate the EMPTY_NINJA_FILE environment variable
to minibp.  Since everything that uses EMPTY_NINJA_FILE is
executed directly from soong_ui now, replace the EMPTY_NINJA_FILE
environment variable with a config bool and pass it to minibp.

Bug: 189148777
Test: build/soong/build_test.bash --dist --incremental --shard-count=300 --shard=1 && du out/multiproduct
Change-Id: I4d64275ce02c5d68948012f71ac4dc3795af9e85
2021-06-01 11:43:55 -07:00
Jingwen Chen
4fabaf52b0 bp2build/b: exit early in GENERATE_BAZEL_FILES=1.
This CL fixes a typo in writeFakeNinjaFile to correctly write
a fake out/soong/build.ninja and its depfile. It also modifies bootstrap
phase to *not* run the main soong build phase (which takes more than a
minute) if GENERATE_BAZEL_FILES=1.

This change has the side effect that `GENERATE_BAZEL_FILES=1 m nothing`
no longer generates the real build.ninja, which is fine because one
shouldn't be using GENERATE_BAZEL_FILES=1 for that anyway (or, use
USE_BAZEL_ANALYSIS=1). This change has no effect on mixed builds.

Time on a change to Soong or any Android.bp files:

Before: bp2build_workspace_marker (~20 seconds) + build.ninja (1 min)
After: bp2build_workspace_marker (~20 seconds)

Time on the second of two consecutive `b build //bionic/...`: 2.070s

Test: TH
Test: Soong integration tests
Change-Id: I43720641815994caba97b8d165d7c3fc254cbd06
2021-05-25 03:42:38 +00:00
Treehugger Robot
3078f3bddc Merge "Add SOONG_SDK_SNAPSHOT_VERSION support" 2021-05-24 17:58:17 +00:00
Rupert Shuttleworth
c29cace414 In the finder, keep track of BUILD files instead of only BUILD.bazel files.
Test: TH
Change-Id: I95bf638ff1f71849a885d22326c5c527a3d00947
2021-05-18 08:40:24 -04:00
Paul Duffin
43f7bf0efd Add SOONG_SDK_SNAPSHOT_VERSION support
SOONG_SDK_SNAPSHOT_VERSION=current will generate unversioned and
versioned prebuilts and a versioned snapshot module. This is the
default behavior. The zip file containing the generated snapshot will
be <sdk name>-current.zip.

SOONG_SDK_SNAPSHOT_VERSION=unversioned will generate unversioned
prebuilts only and the zip file containing the generated snapshot will
be <sdk name>.zip.

SOONG_SDK_SNAPSHOT_VERSION=<number> will generate versioned prebuilts
and a versioned snapshot module only. The zip file containing the
generated snapshot will be <sdk name>-<number>.zip.

Bug: 157884619
Test: m nothing
      m SOONG_SDK_SNAPSHOT_VERSION=current art-module-sdk
      - check that the generated Android.bp file has not changed
        from the default.
      m SOONG_SDK_SNAPSHOT_VERSION=none art-module-sdk
      - check that the generated Android.bp file does not contain
        versioned modules.
      m SOONG_SDK_SNAPSHOT_VERSION=2 art-module-sdk
      - check that the generated Android.bp file only contains
        version 2 of each module.
Change-Id: I087e9d7d3ad110508a3d6a39bca50cbb46b3ce82
2021-05-12 22:14:32 +01:00
Colin Cross
f7bcd42a4a Clean symbols directory during installclean
Installclean is used in some build server builds when switching between
different TARGET_BUILD_APPS, remove the symbols directory so it doesn't
accumulate old symbols files.

Bug: 186507256
Test: m && m installclean && m
Change-Id: I316703cd0985ee555959a6dcdb39d5a702ab0332
2021-04-28 16:52:52 -07:00
Peter Collingbourne
19947656df Merge "Don't print RBE stats if ANDROID_QUIET_BUILD is set." 2021-04-26 19:47:58 +00:00
Peter Collingbourne
f4d9bd2c4d Don't print RBE stats if ANDROID_QUIET_BUILD is set.
Change-Id: I3823f44fb25f90955f0b42326032fea30683b069
2021-04-20 21:03:02 -07:00
Chris Parsons
ec1a3dc6f8 Subsume INTEGRATED_BP2BUILD into other env modes
This refactors bazel-build mode determination logic in soong_ui so it's
clearer which of three possible modes are being used in a given
invocation (NO_BAZEL, GENERATE_BUILD_FILES, or MIXED_BUILDS).

Test: bootstrap tests
Change-Id: I41d2baebf8d560c2cc42db8daa8b936101d453e3
2021-04-20 19:25:48 -04:00
Lukacs T. Berki
d518e1a407 Make bp2build be more correct.
It now handles adding .bp files and changing globs.

In order to do this, depfiles are now written separately from RunBlueprint.

This is necessary due to the confluence of a number of seemingly
unrelated factors:

1. The glob filelist dependencies are discovered in globSingleton
2. Singletons need to be registered because otherwise singleton module
   types panic
3. Singletons don't work because they require mutators bp2build does not
   run

Due to (1), we would need to run the glob singleton. However, due to (2)
and (3), we can't run singletons and have to run Blueprint with
StopBeforeGeneratingBuildActions, which is when the build actions
writing glob files would be generated. So what happens is:

1. When bp2build is run, the glob singleton is disabled
2. At the end of bp2build, the list of glob files is artifically added
   to the depfile of the workspace marker file
3. When build.ninja is generated, the Ninja file containing the glob
   list file is written by the now-active glob singleton

Test: Presubmits.
Change-Id: I3c5898d8c57c554a93520276c64a952afc912dbe
2021-04-15 13:06:16 +02:00
Lukacs T. Berki
f8e2428c5d Allow running bp2build as part of a regular build.
This is done by setting the INTEGRATED_BP2BUILD environment variable
when invoking the build.

Even though the name of the marker file insinuates that a Bazel
workspace is already created, this is not the case yet.

An issue that remains is that a .d file is not written for the marker
file so it won't be rebuilt if a .bp file changes. Fixing this requires
delicate surgery because writing the .d file is the result of delicate
interplay between Soong and Blueprint.

There are also a number of semi-related fixes:

- The name of soong.environment.{used,available} is now on the command
  line of soong_build (soong_docs is still special cased because its
  command line in the Ninja file is taken from the os.Args of
  soong_build so it's not trivial to remove the --{available,used}_env
  from it
- bp2build writes a separate soong.environment.used file
- I had to call SetAllowMissingDependencies() separately when creating
  the android.Context for bp2build so that bp2build runs in the
  integration tests (it was not obvious how not to do this)
- Fixed a number of integration tests where a command with an expected
  exit code of 1 was used as the last one in a test case, thereby
  breaking the test suite

Test: Presubmits.
Change-Id: Ibeb61c26022cf801dcb98505b4039151b3409873
2021-04-15 08:46:07 +02:00
Lukacs T. Berki
745380ce23 Remove the dependency on a number of env vars.
This is so that the way soong_build is invoked is simpler, which is in
turn useful so that it can be invoked multiple times within a single
build, which in turn will be used to invoke bp2build routinely (as
opposed to manually when needed)

Test: Presubmits.
Change-Id: Iddaebb05ff7bcedc0db8273192bb31284b739920
2021-04-12 12:07:44 +02:00
Rupert Shuttleworth
bf94d2fdba Allow Bazel actions to see the SHELL variable.
Test: TH
Change-Id: I97ffe7ad84dfb8d58d0e6d022f73d97a73778129
2021-04-02 20:09:51 +00:00
Kousik Kumar
2081052592 Print the output from RBE bootstrap shutdown
The output from bootstrap would contain the a one-line summary of RBE
download / upload stats.

Bug: b/183007125
Change-Id: I90082a8433504e40bbf92992c3c8d1d656c49429
2021-03-21 22:39:04 -04:00
Kousik Kumar
47665870d7 Merge "Allowlist RBE_num_retries_if_mismatched variable" 2021-03-18 19:13:29 +00:00
Kousik Kumar
c3a22d8ebd Allowlist RBE_num_retries_if_mismatched variable
This variable tells reproxy the number of times an action that
mismatches between local and remote-executions should be run remotely to
determine if the action is inherently non-deterministic.
An action is considered non-deterministic if the number of unique output
digests we get from the remote-run is > 1.

Bug: b/178842439
Change-Id: I0d50eed29b801be67a7ede9b25ce7f4535980f05
2021-03-17 14:22:05 -04:00
Lukacs T. Berki
5f6cb1d6d3 Compile soong_build for debugging if needed.
That is, when SOONG_DELVE= is set.

Test: "m nothing; SOONG_DELVE=port m nothing; m nothing"
Change-Id: I16bd4e54e81b93202573935df134d413feea9bb2
2021-03-17 15:03:14 +01:00
Lukacs T. Berki
d7ce8402d8 Remove GeneratingPrimaryBuilder().
It's replaced with a flag in bootstrap.Args .

Test: "m nothing" (presubmits take a full workday these days)
Change-Id: Ia0bfa2091013e389890e583c559006077806af99
2021-03-17 14:08:50 +01:00
Lukacs T. Berki
d1e3f1ff08 Embed minibp into soong_ui.
This requires linking Blueprint into soong_ui. It lets us avoid the
complicated dance of Ninja files and shell scripts: now the information
as to how soong_build is built is passed directly to Blueprint using a
struct that contains all the information the command line arguments used
to contain.

The ability to run Blueprint from the command line is kept (for now).

Some variables in bootstrap/command.go needed public accessor functions
because soong_build reads them. This will be disentangled by moving the
flag parsing to soong_build.

The presence of the flag definitions in Blueprint means that soong_ui
now also accepts them. This is not a problem in practice because they
are ignored and because soong_ui itself is hidden behind a few layers of
shell scripts.

Test: Presubmits + the new bootstrap_test.sh .
Change-Id: I6dca478f356f56a8aee1e457d71439272351390b
2021-03-17 08:35:52 +01:00
Lukacs T. Berki
21d5c7aaa9 Hard-wire the path to xcrun as /usr/bin/xcrun.
This lets us not leak $PATH to soong_build. It was only needed for
Darwin tests anyway.

Test: Will ask jingwen@ who has a Mac.
Change-Id: I4647e41275b323fe6283580f8f92718c6229f23e
2021-03-11 08:52:39 +01:00
Lukács T. Berki
2373e597ea Merge "Fix the environment of soong_build:" 2021-03-11 07:09:24 +00:00
Colin Cross
75a38ba791 Merge "Revert "Skip old file cleanup for non-full builds."" 2021-03-10 22:53:43 +00:00
Lukacs T. Berki
b4ced9d886 Fix the environment of soong_build:
- Incorporate BAZEL_* variables in soong.environment.available
- Set SOONG_DELVE when requested

Test: Manual.
Change-Id: I3ac675f4876220b788cc48d288b402ac6016c37b
2021-03-10 15:43:06 +01:00
Lukacs T. Berki
73ab928daa Make $PATH available when building soong_build.
This is exclusively used by tests so it's awful, but Darwin builds are
currently broken so let's unbreak them first then start thinking.

Test: "m nothing" on Linux (I don't have access to a mac OS machine)
Change-Id: I1ea9ca71a5aff36a3454282a4c87ad368138baaa
2021-03-10 11:02:39 +01:00
Colin Cross
41ad6b632f Revert "Skip old file cleanup for non-full builds."
This reverts commit 6e49493dac.

FULL_BUILD is not set during the config stage, so this never calls
cleanOldInstalledFiles.

Bug: 168105598
Bug: 182008128
Test: manual
Change-Id: I58a54f167763cdb77b3c1bd4f18f519fcaf8751a
2021-03-09 12:04:17 -08:00
Lukacs T. Berki
b14ad7b5dc Run Ninja in a clean environment.
This sandboxes Soong's tests better.

Setting "TOP" is slightly ugly, but doing it properly would conflict
with aosp/1609218.

Test: Manual ("m nothing")
Change-Id: Ie3d3cd17f116a5fe0ad25c670fc5ed9c33f8123b
2021-03-09 10:43:57 +01:00
Lukacs T. Berki
7d613bfe2c Make it possible to debug soong_ui.
This works by setting the SOONG_UI_DELVE= environment variable to the
port on which soong_ui should accept a Delve connection on.

This is achieved by reusing the Delve execution logic between soong_ui
and soong_build.

Test: Manual.
Change-Id: Id2c1d4b6faac1a4a3918c91030ce2239f7daf54f
2021-03-08 08:27:58 +01:00
Paul Duffin
5e85c665d0 Do not ignore error when writing environment file
Test: m nothing
Change-Id: I4281e22ae10a649b51b9fbed7f8c1554f18885b9
2021-03-05 17:46:29 +00:00
Lukács T. Berki
ddebd2c82a Merge "cd to / before running soong_build ." 2021-03-04 07:07:02 +00:00
Petri Gynther
ac22956dcb Rename vendor-ramdisk to vendor_ramdisk
Rename to get consistent ramdisk directory naming in
out/target/product/<name>:
  debug_ramdisk
  ramdisk
  vendor_debug_ramdisk
  vendor_ramdisk

Test: build and inspect out/target/product/<name>
Change-Id: Ib86e6509bd910e8c95bcb6e3f7bb639ebbfe3758
2021-03-03 00:15:54 -08:00
Lukacs T. Berki
7690c09953 cd to / before running soong_build .
This lets one avoid any decisions as to when to chdir there during its
execution and leads to better sandboxing because the pwd doesn't leak to
init() functions anymore.

Test: Manual.
Change-Id: I1560da8ed3a621249426f9e8908aa890c21e13ba
2021-03-03 09:14:22 +01:00
Colin Cross
fdf28ca403 Merge changes I3e6bc9b5,If9f8fb10
* changes:
  Disable TestSendLog on the buildbots
  Remove global state from VNDK apexes
2021-03-03 01:45:02 +00:00
Colin Cross
6cb1128b54 Disable TestSendLog on the buildbots
TestSendLog sometimes hangs on the buildbot, although it has never
been reproduced locally.  The cause appears to be a unix domain
packet that was sent but never received.  Skip the test in short
mode for now, which will leave it manually runnable but not run
it as part of the build.

Fixes: 120596545
Test: m nothing
Change-Id: I3e6bc9b5f1d9c15dc9a7294d98cbd917d0637c44
2021-03-02 12:26:14 -08:00
Lukacs T. Berki
3243aa51eb Move environment staleness check to soong_ui.
Also delete the now-unnecessary soong_env binary.

Test: Manually. Also checked what happens when a used environment
variable changes.

Change-Id: Ib393e7f444e94819198c6cce4bcd8719d9fd9441
2021-03-02 09:32:49 +01:00