Commit graph

654 commits

Author SHA1 Message Date
LaMont Jones
52a7243387 Add --multitree-build flag
Add a flag that enables logic specific to multitree-build builds.

Bug: b/266730267
Test: treehugger, manual
Change-Id: Ia6f392525faa9d66bb6e0692b2a2e9c3b8493b0d
2023-03-15 23:08:34 +00:00
Jeongik Cha
58fa5a3f36 Merge "Add critical path infomation into metrics" 2023-03-15 03:40:11 +00:00
Jeongik Cha
28c1fe5bc8 Add critical path infomation into metrics
To improve build efficiency, the metrics for critical path and
parallelism ratio is necessary. That information has been included in
soong.log, so added it into metrics as well.

Bug: 271526845
Test: build and check if metrics pb has critical path info
Change-Id: I14e1a78c13d400b792d3b05df18604da48759ade
2023-03-14 17:59:22 +09:00
Spandan Das
98cb85624c Generate a BUILD file for every Android.bp file in api_bp2build
workspace.

This is necessary to solve bazel package boundary issues where the api
file might exist in a different directory

Test: m api_bp2build && build/bazel/bin/bazel build --config=android
--config=api_bp2build //build/orchestrator/apis:system
Test: multitree_build system/nothing (in multitree)

Change-Id: Id64085d65a1943bdb394ea80c875db96ca373839
2023-03-09 23:15:34 +00:00
Jingwen Chen
cf9e2c8b23 Don't create bp2build_all_srcs filegroups in queryview.
These are not necessary for queryview and can lead to inaccurate query results.

Test: m queryview; grep bp2build_all_srcs
Change-Id: Ifaf65b4ec5828718c2becb39b4507cf033ea4546
2023-03-08 13:32:35 +00:00
Jason Wu
074c8c3b61 Merge "Upload soong_build_metrics when user builds" 2023-03-02 20:42:00 +00:00
Chris Parsons
9402ca881c Add a persistent bazel server between builds
This feature is toggled on with USE_PERSISTENT_BAZEL, which is off by
default. Those that opt-in will have a bazel server running between
builds (with a 3hr default TTL) which will greatly improve analysis on
subsequent builds. (As Bazel maintains a cache of analysis results).

Bug: 266983462
Test: Manual `m nothing` runs (timing with and without the feature)
Test: New integration test
Test: Presubmits
Change-Id: I3af4948baa0c490e9b87c48ffdbe9f67732586c7
2023-03-01 23:30:19 -05:00
Jason Wu
d125440aff Upload soong_build_metrics when user builds
Test: m nothing and check the events in database
Bug: 269751664
Change-Id: Ic07a6e1797b11f5413d7ecd78969dec64e9eeac9
2023-03-01 20:26:30 -05:00
Cole Faust
81f170f6bc Disable RBE in multiproduct_kati
RBE has signifigant performance overhead during
analysis time, in theory to reduce execution time.
But multiproduct_kati only tests analysis, and does
not run any execution, so RBE is just slowing us
down.

Bug: 229863781
Bug: 265603584
Test: time ./build/soong/build_test.bash  --products aosp_arm64 on stage_aosp_master
Change-Id: Icbb2f001fee03a75bad37c14d08a203be20ac6cf
2023-02-17 11:36:35 -08:00
Cole Faust
aafdf54f70 Merge "Export apex_available_baseline to soong_injection" 2023-02-09 18:39:27 +00:00
Cole Faust
9e384e2e6b Export apex_available_baseline to soong_injection
So that it can be used in the bazel implementation.

Bug: 268006095
Test: m nothing, check that it's in out/soong/soong_injection
Change-Id: I1520dd874076dee7fa083648d0790b060d658e5a
2023-02-08 17:43:09 -08:00
Jason Wu
51d0ad7c30 Upload soong_metrics when mixed build fails
Test:  `m --bazel-mode-dev` and intentionally break the build.
We can see soong_metrics in the output directory and metrics_uploader
executed.

Bug: 268228148
Change-Id: I79e3b11468fca446673ebf752697a99eaff01b0f
2023-02-08 18:13:43 -05:00
Usta (Tsering) Shrestha
3a49e9a068 Merge "reduce forest generation to be incremental" 2023-02-08 18:46:16 +00:00
Jason Wu
7796b11726 Temporary fix to make soong_metrics files get uploaded
Test: ```m nothing``` and verify the data in local builds table
Bug: 268228148

Change-Id: Idb4b5305f19cf4a69a60896555357623a1ce4532
2023-02-08 01:34:20 +00:00
Usta (Tsering) Shrestha
c4c07b12b6 reduce forest generation to be incremental
Previously, symlink forest generation involved removing the entire
symlink forest and recreating it from scratch. With this change,
a) symlinks which need not change are untouched,
b) symlinks pointing to the wrong location are fixed, and
c) symlinks which should no longer exist are removed.

On AOSP on my local machine, this reduces the symlink forest generation
step from 2.5s to 1.1s clean, and 0.6s when a single file is added to
a source directory.

Bug: 257528847
Test: m bp2build, touch `fakefile` under the forest, remove a file
from the source tree, rerun m bp2build. Manually verify the new forest
does not retain the link to the deleted source file, and that fakefile
no longer exists in the forest.

Change-Id: I481371ae487e9419af6a3a4370c552578b07d650
2023-02-07 06:23:43 +00:00
Cole Faust
5c503d1c43 Precompile python sources
This signifigantly improves the startup time of soong-built
python binaries. For example, running
`m apexer && time out/host/linux-x86/bin/apexer` gives
0.734s before this cl, and 0.094s after.

Fixes: 259718110
Test: Presubmits
Change-Id: Ib19e83e2c60c39a849525be117279c318de3afa7
2023-01-27 15:43:38 -08:00
MarkDacek
00e3152aca Write bazel metrics file from soong.
Test: b build libcore:all
Change-Id: I372d48a9c7132bc57ecc1a8ba06eb098d28cbad7
2023-01-25 22:43:14 +00:00
Usta (Tsering) Shrestha
5c1b0ba692 Merge "metrics: count symlink/mkdir in symlink forest" 2023-01-13 04:01:55 +00:00
Usta Shrestha
da15c61add metrics: count symlink/mkdir in symlink forest
Bug: 260029212
Test: inspect out/bp2build_metrics.pb
Change-Id: Ia84c095a8d7b129cca629256b6c626c726cbfab1
2023-01-12 14:52:56 -05:00
Cole Faust
2b4bc2fddb Merge "Increase ram usage estimate in multiproduct_kati" 2023-01-12 17:33:57 +00:00
Cole Faust
36b259f1e9 Increase ram usage estimate in multiproduct_kati
multiproduct_kati assumed each build would take ~30GB of RAM,
but it seems it's closer to 40GB now.

The current build_test builds use 7 jobs, so this would bring
us down to 5, which should still keep us under the 6 hour
build time limit as currently these tests are at ~3 hours.

Bug: 262629589
Test: Presubmits
Change-Id: I51af364cc602a3bf7ba85fd8f92c4dd57585abbd
2023-01-11 15:06:50 -08:00
Spandan Das
255648c6d5 Create a smoke test for api_bp2build workspace
This test builds an "empty" filegroup. Running it can be useful to
verify that the api_bp2build workspace has been setup correctly.

Test: TH
Change-Id: I78639a2dcdeb659b2d6fdf6abc85d85c4fb697bf
2023-01-11 03:21:18 +00:00
Spandan Das
83e787e837 Add a new CreateSoongInjectionDirFiles function
- This is a wrapper function for all files in soong_injection directory.
This should prevent an error in the workspace generated for
api_bp2build.
- Rename the existing CreateSoongInjectionFiles fn and make it package
  private to prevent confusion

(The subsequent CL in this stack should contain a smoke test for
api_bp2build)

Test: b build //:empty --config=api_bp2build --config=android
Test: TH
Change-Id: Iddb0aa1aff2f709826edd587aa99fccddf80f08f
2023-01-11 03:21:00 +00:00
Cole Faust
b85d1a15cc Bp2build support for multiple product configs
Create a
build/bazel/product_config/generated/products/<product_name>/BUILD
file that contains the platform definitions needed for
a particular product. Currently we just create it for the
current lunch target, but the idea is that eventually when
all product config is in starlark, all the products will
have their platform definitions in the tree at once.

Bug: 249685973
Test: Presubmits
Change-Id: I08c82ff28dcf62f09d3b1d2e3186a6b961e12f6e
2023-01-05 12:49:14 -08:00
Usta (Tsering) Shrestha
253171b016 Merge "Use comma not pipe in switch-case" 2023-01-04 15:43:57 +00:00
Usta Shrestha
7fae695336 Use comma not pipe in switch-case
brings down time to complete by 40%

Bug: NA
Test: m queryview and m soong_docs
Change-Id: I3681e2f5015fc1f5cabaf0462d4d52a4fe9db56c
2023-01-03 21:24:18 +00:00
MarkDacek
6614d9cba3 Add upload-only mode and manual build-started-time flag.
This involved refactoring much of the main method in soong_ui/main.

Test: b build libcore:all
Test: use the build-time started flag and verify via printf that
it's the same across upload.go and metrics.SetBuildDateTimestamp()

Change-Id: Id7fe256337e8ee6c40542eba662c0eadb38e9674
2022-12-22 20:13:56 +00:00
Jason Wu
1c6ca94935 Merge "Delete Stale Metrics Files" 2022-12-20 15:56:21 +00:00
Jason Wu
cc166a77bd Delete Stale Metrics Files
Test: Run `m --bazle-mode-dev nothing` again  after `m --bazel-mode-dev nothing`.
bp2build_metrics.pb no longer exists, the rest metrics files
have the timestamp of the latest creation time.

Bug: 256617990
Change-Id: I869d1b9c3abcb517744e66b21e5c12d6b5b1e97b
2022-12-19 21:16:50 +00:00
Sasha Smundak
1845f42085 Simplify soong_build top-level code
* `android.Context` holds `android.Config`, so provide an accessor to it
  and avoid passing them separately to a lot of functions.
* factor common code in `readBazelPaths`/`getExistingBazelRelatedFiles`
  into `readFileLines`
* refactor check-error-and-quit into `maybeQuit`
* use switch instead of if-elseif-... where appropriate
* rearrange the code in `runApiBp2build`, `runSymlinkForestCreation`

Test: treehugger
Change-Id: I639929c21ec4999cdfd737c07136f32df2d488bc
2022-12-16 11:03:17 -08:00
Sasha Smundak
af5ca926be Keep all Soong command line arguments in a single structure
Define a structure android.CmdArgs and keep all soong_build command line
arguments used to build a configuration in it. Some of them related to BazelMode
were previously kept in Blueprint's bootstrap.Args where they do not belong.
This simplifies the code and lays the gound work for future simplifying changes.

Test: treehugger
Change-Id: I995871f4e6b0e95cc9df65696ad2020df221d8c8
2022-12-16 11:02:12 -08:00
Jason Wu
f0ec631046 Upload soong_build_metrics
Test: m nothing
Test: m --bazel-mode-dev
Test: Verified soong_build_metrics is available in local metrics tables from builds that include this CL

Bug: 257537925
Change-Id: Ic5419ecb203c9b62457e1c553d592ba593a9bfff
2022-12-09 11:48:26 -05:00
Mark Dacek
a366e48bc3 Merge "Add skip-metrics-upload flag to soong_ui." 2022-12-07 19:18:12 +00:00
MarkDacek
d0e7cd3d96 Add skip-metrics-upload flag to soong_ui.
Bug: b/261203925
Test: m libcore --skip-metrics-upload
Change-Id: I0b10027a0f359e682116c2ebb884808c65430dd0
2022-12-07 19:12:02 +00:00
Treehugger Robot
a0206f3d29 Merge "Create soong_injection files in ReadWrite mode" 2022-12-07 17:17:12 +00:00
Spandan Das
067210f70d Create soong_injection files in ReadWrite mode
The synthetic soong_injection workspace is shared between api_bp2build
(used in API export) and bp2build (used in API domain analysis which
runs mixed builds by default). The former creates them in ReadOnly mode,
but the latter creates them in ReadWrite mode (to allow users to
edit/experiment). To prevent errors in the end-to-end builds in
multittree, make api_bp2build create these files in ReadWrite mode as
well.

Test: mulittree_build locally
Change-Id: I8766d88951a3b625739e4dc12d468450ad7322ea
2022-12-07 01:25:03 +00:00
Spandan Das
c576383336 Create a new product variable to gate blueprint files
Users can use this feature by
1. Setting PRODUCT_INCLUDE_TAGS += <val> in their product mk files
2. Set
```
blueprint_packge_includes {
  match_al: ["<val>"],
}

other_module_type {name: foo}
other_module_type {name: bar}
```

bar and foo will be included if and only if <val> is set

Test: Unit tests in blueprint
Test: TH

Change-Id: I32eed4e3b5ac47fb565c62d13d8881fa984c86f4
2022-12-05 19:15:06 +00:00
MarkDacek
d06db5dd5b Add command line flag for extra bazel-built modules
Test: m libcore --bazel-mode-staging --bazel-force-enabled-modules=libcore and find out/bazel/ -name libcore*

Change-Id: I065696d06ce07e05300a41e133867a6e7a891b5e
2022-12-02 21:16:11 +00:00
Usta (Tsering) Shrestha
93b2a9b99f metric namespace for symlink_forest
Change-Id: Ifaa734a222bf37bccc3a74724f597f2d55200d6b
Test: run a build and inspeck event keys in bp2build_metrics.pb
Bug: 260936908
2022-12-01 06:00:27 +00:00
Treehugger Robot
b4bac94eb5 Merge "Copy bazelrc files into the queryview workspace" 2022-11-30 18:36:48 +00:00
Treehugger Robot
e0229e6855 Merge "Add the symlinks of the external repository in api_bp2build workspace" 2022-11-30 17:38:09 +00:00
Treehugger Robot
9b2e24c318 Merge "Exclude prebuilts/clang/host/linux-x86/clang-dev/BUILD from the symlink forest." 2022-11-30 11:51:59 +00:00
Jingwen Chen
bcfadce598 Exclude prebuilts/clang/host/linux-x86/clang-dev/BUILD from the symlink forest.
Background: toolchain/llvm_android/test_compiler.py generates clang-dev, a directory
symlink pointing to out/install/linux-x86/clang-dev, which itself
contains a BUILD file. This BUILD file should be excluded from the
symlink forest because it's not an allowlisted BUILD file.

Problem: However, our current symlink forest logic and finder logic doesn't
handle this situation. It's not in bazel.list:

```
$ less out/.module_paths/bazel.list | grep prebuilts/clang
prebuilts/clang/host/linux-x86/BUILD.bazel
prebuilts/clang/host/linux-x86/cc_toolchain_config.bzl
prebuilts/clang/host/linux-x86/cc_toolchain_constants.bzl
prebuilts/clang/host/linux-x86/cc_toolchain_features.bzl
prebuilts/clang/host/linux-x86/clang-r450784d/BUILD.bazel
prebuilts/clang/host/linux-x86/clang-r450784e/BUILD.bazel
prebuilts/clang/host/linux-x86/clang-r458507/BUILD.bazel
prebuilts/clang/host/linux-x86/clang-r468909/BUILD.bazel
prebuilts/clang/host/linux-x86/clang-r468909b/BUILD.bazel
prebuilts/clang/host/linux-x86/clang-r475365/BUILD.bazel
```

The symlink forest logic uses this bazel.list file and matches it
against the keepExistingBuildFile list to exclude BUILD files from the
symlink forest. Since clang-dev/BUILD.bazel is not in bazel.list, it's
symlinked into the forest.

All of these gymnastics could be avoided if we added custom BUILD file
name support to Bazel, and only symlinked (e.g.) Android.bazel and
ignored all other BUILD files in the tree. It would be very clear which
checked-in BUILD files we want to use in the symlink forest.

I think we should pursue custom BUILD file names instead of adding more
complexities, to say, the finder logic, to support such a use case. It's
also why I decided to add this hardcoded exclusion to keep the
workaround simple.

Bug: 260809113
Test: presubmits
Test: $ DIST_DIR=/tmp/dist prebuilts/python/linux-x86/bin/python3 toolchain/llvm_android/test_compiler.py --build-only --target aosp_raven-userdebug --no-clean-built-target --module dist --module droid --module tidy-soong_subset --with-tidy ./
Change-Id: I415371543585c1c5e8e00e6958105f65ea5978ee
2022-11-30 08:44:05 +00:00
Spandan Das
6b91a38b51 Add the symlinks of the external repository in api_bp2build workspace
Unlike bp2build, api_bp2build depends on a well-defined subset of checked-in
BUILD/bzl files, and we create symlinks for that subsset in
out/soong/api_bp2build. Since we now cd into the workspace after
aosp/2308141, we need to add the sylimks of the external repositories as
well

Test: bazel build --config=api_bp2build //:empty
Change-Id: Ia7ecc5543226893a3878bc0fd35e025a37c80413
2022-11-30 02:22:57 +00:00
Cole Faust
6d51e731a6 Copy bazelrc files into the queryview workspace
They are still read when using bazel with queryview, so they
need to be in the workspace so that they can be found.

Bug: 234449134
Test: m queryview && ./build/bazel/bin/bazel query --config=queryview //...
Change-Id: I1f2187dffd5a0e6cfb44ebe0c6738fa9bbef509d
2022-11-29 12:46:48 -08:00
Jason Wu
47d7ccfffd Merge "Upload bp2build_metrics file" 2022-11-29 18:50:32 +00:00
Jason Wu
c4a03138e0 Upload bp2build_metrics file
Test: m nothing
Test: m --bazel-mode-dev
Test: Verified bp2build_metrics is available in local metrics tables from builds that include this CL

Bug: 257537925

Change-Id: I09617a7850f1471f18192a0418396126fd4c98ef
2022-11-29 16:18:45 +00:00
Anton Hansson
c5cee23d16 Merge "extract_apks matches APKs with >= 1 matching ABI" 2022-11-23 16:29:31 +00:00
Sam Delmerico
b48d57bdcd extract_apks matches APKs with >= 1 matching ABI
Prior to this change, the bundletool and extract_apks tools require that
all ABIs that an APEX or APK provides must be compatible with the
TargetConfig. Instead, this change allows an APK to be selected if it
has at least one compatible ABI with the TargetConfig.

Bug: 260115309
Test: go test .
Change-Id: If67ce8128099611257a834862295a2bf5fa427d3
2022-11-22 17:53:26 -05:00
Sasha Smundak
4975c82666 Provide Bazel timing breakdown for the mixed builds
Instead of single event in the build metrics
```
| soong_build.mixed_build.bazel          | 1:17.1 |
```
it will now show:
```
| soong_build.mixed_build.bazel          | 1:17.1 |
| soong_build.mixed_build.bazel.cquery   |   51.9 |
| soong_build.mixed_build.bazel.aquery   |   23.1 |
| soong_build.mixed_build.bazel.symlinks |    2.1 |
```

Test: treehugger
Change-Id: I84a7dda6e3122860da9aaa98bfa6afe33d392dcf
2022-11-16 18:44:08 -08:00