Commit graph

731 commits

Author SHA1 Message Date
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
Spandan Das
ed9729727c Merge changes from topics "nested-nsjail", "ro-api-surfaces-dir"
* changes:
  Special-case Soong finder to look in out/api_surfaces
  nsjail support verification should respect BUILD_BROKEN* flag for SrcDir
2022-11-15 19:56:23 +00:00
Paul Duffin
c467a98bc0 Merge "Build mode function should return output file" 2022-11-15 09:37:52 +00:00
Paul Duffin
54616f20b0 Merge "Stop creating unnecessary Context objects" 2022-11-14 22:30:53 +00:00
Paul Duffin
2335544ef2 Merge "Avoid writing soong_build_metrics.pb multiple times" 2022-11-14 22:30:41 +00:00
Paul Duffin
3d12f4e997 Merge "Group mixed mode and normal soong build" 2022-11-14 22:30:26 +00:00
Spandan Das
394aa32e8b Special-case Soong finder to look in out/api_surfaces
Add a new argument in soong_ui that will be used to gate this behavior.

This approach is expected to solve incrementality issues in multi-tree.
As part of soong's bootstrap process, all source dirs are added to deps
of out/soong/build.ninja (via globs). Since multitree_build writes to the
"source" api_surfaces directory, it changes its mtime and causes a
recompilation of out/soong/build.ninja in the subsequent invocation.

Test: TH (for single-tree)
Test: Inspected ninja files (for multi-tree)
(Run a full build)
touch out/api_surfaces/vendorapi/libc/.../math.h
orchestrator/prebuilts/build-tools/linux-x86/bin/nsjail --config
out/trees/vendor_aosp_cf_arm64_phone/nsjail.cfg --
prebuilts/build-tools/linux-x86/bin/ninja -f out/soong/bootstrap.ninja
-d explain -n out/soong/build.ninja
(ninja: no work to do)

Change-Id: Ib823163ec1153344a2f593daa8d7156c24ff5bc3
2022-11-14 21:10:38 +00:00
Paul Duffin
3f7bf9fa0d Allow namespace config to be tested properly
Previously, the NewTextContext created a context that always called
NewNameResolver with a export filter that always returned true.

This change fixes that by:
1. Changing NewNameResolver to take a Config parameter instead of a
   filter parameter and pushing the code to create the filter from the
   Config from newNameResolver() in cmd/soong_build/main.go into the
   NewNameResolver function.

2. Extracting a newTestContextForFixture that does not create a
   NameResolver or set it on the context. That avoids creating a
   NameResolver before the test has prepared the config.

3. Modify the fixture to create and set the NameResolver in the Context
   after the config has been prepared by the test.

4. Added test to verify that it all works.

Bug: 234825639
Test: m nothing
Change-Id: Ie4b13f18093dc01a0ab65a9ecfd143585d843b55
2022-11-08 17:38:56 +00:00
Paul Duffin
b713ddfcc1 Build mode function should return output file
Each build mode has to provide an output file, which also has a
corresponding dependency file (<output file>.d). Previously, some of
the build mode functions returned that file, others just returned and
relied on the doChosenActivity() method to return the file.

That was confusing as the same file name was referenced from two
separate places. This change makes all the build mode functions return
their output file explicitly and the doChosenActivity()just returns
what it receives. It also moves the writeDepsFile call to adjacent to
the return.

Bug: 257650737
Test: m nothing
Change-Id: I35f96ab404d9ffb1da747a3ecb8fc4e1feb9c026
2022-11-08 10:42:55 +00:00
Paul Duffin
b4e8d91d72 Stop creating unnecessary Context objects
Previously, the Context object created in the main() method was
initialized (ctx.Register()) for the main soong build. Build modes
that did not want that build modes that did not want that (symlink,
bp2build, apiBp2build) had to create their own context, or in the
case of runSymlinkForestCreation its own EventHandler. That was
very confusing.

This change avoids that by simply pushing the call to ctx.Register()
into the build modes that require it and that allows the other build
modes to use the main context and its EventHandler.

One point to note is that to ensure the exact same initialization as
before the runApiBp2build has to explicitly call the following:
    ctx.SetAllowMissingDependencies(false)
That is because the main context could have that set to true.

Bug: 257650737
Test: m nothing
Change-Id: Iee239fb87edf443fed65156fa14b8a30c89a2328
2022-11-08 10:42:55 +00:00
Paul Duffin
39eae8fb90 Avoid writing soong_build_metrics.pb multiple times
Previously, running `m nothing`	would write the	soong_build_metrics.pb
file 3 times:
1. For bp2build - it contains a single `soong_build` event as the rest
   is written to the `bp2build_metrics.pb` file.
2. For Bazel symlink forrest - it too contains a single `soong_build`
   event as the rest is appended to the `bp2build_metrics.pb` file.
3. For soong_build proper (including mixed builds) - it contains useful
   information.

This change avoids that by pushing the code to write the
soong_build_metrics.pb file from the top level where it applies to all
build modes into the build mode specific function that needs it.

Bug: 257590265
Test: m nothing
      # Run with some logging to make sure the file is only created once.
Change-Id: Iee239fb87edf443fed65156fa14b8a30c89a2328

Change-Id: I09724f6143352de6b7d6fb29eaf3fbed5a1abd21
2022-11-08 10:42:55 +00:00
Paul Duffin
0c09a43cef Group mixed mode and normal soong build
Mixed mode is a special form of the soong build. They both share common
initialization and metrics so they should be grouped together to avoid
duplicating that common behavior.

Bug: 257650737
Test: m nothing
Change-Id: I939b6264f94b69825735dce895132f33401238b6
2022-11-08 10:41:55 +00:00
Paul Duffin
f490656a0f Stop LOG_DIR changes causing bp2build to rerun
Retrieving an environment var through Config.Getenv() automatically
adds it to a soong.environment.used* file along with its current value.
Changes to its current value will trigger a rebuild of the appropriate
target. The LOG_DIR is a sub directory of DIST_DIR and on build servers
DIST_DIR encodes the build number making it unique every time. So,
using Config.Getenv("LOG_DIR") will mean the CI builds will never
re-use the previous output.

Previously, bp2build and symlink forrest both added LOG_DIR to their
respective soong.environment.used* file. This change avoids that by
passing through the value from the main() function which retrieves it
using availableEnv["LOG_DIR"] which avoids it being added to that
file.

Bug: 257590265
Test: grep LOG_DIR out/soong/soong.environment.used*
      # Before this change it includes LOG_DIR, after it does not.
Change-Id: Iac76aca2d5dc04f47b0924ab5afedef5014bc8b6
2022-11-07 14:12:11 +00:00
Paul Duffin
780a185ede Avoid loss of ninja_deps events
Previously, writeDepFile was passed a copy of the main EventHandler to
which it then added an event. Adding an event requires appending
information to slices in the EventHandler structure. As the slices are
a copy the addition only affects the copy and are not present in the
EventHandler which is written out as part of the metrics.

This change fixes that by passing a pointer to an EventHandler into
writeDepFile. For consistency it also replaces a few other uses of
EventHandler with *EventHandler instead.

Bug: 257590265
Test: m nothing
      # Check generated text metrics to make sure they don't contain ninja_deps.
      # Apply this change.
      m nothing
      # Check generated text metrics to make sure they do contain  ninja_deps.
Change-Id: I0fa0f2b08844cb7c7b4e99b37602703deb43ad20
2022-11-07 14:12:11 +00:00
Paul Duffin
c639059fd8 Make CodegenContext reference *android.Context
Previously, it stored an android.Context (no pointer) which while it
worked (because the current contents are themselves pointers) it is
inconsistent with how the rest of the code references it and could
cause weird behavior if additional fields were added to the Context.

Test: m nothing
      m bp2build
Change-Id: I9c70f925dde85e5b15431cc232b0c2eb6371ec6d
2022-11-05 17:43:12 +00:00
Spandan Das
7b6d5331bd Use CreateCodegenMetrics in api_bp2build as well
The internals of CodegenMetrics was updated in aosp/2276671. Use the
new API to initialize an empty object to prevent a null pointer
exception in api_bp2uild.

Test: m api_bp2build
Change-Id: Iad9c38b9881da896171f1c6d4e49d4875acfaab8
2022-11-01 17:37:07 +00:00
Jingwen Chen
e647db8186 Fix --bazel-mode-staging flag.
It was assigning --bazel-mode-staging to cmdlineArgs.BazelMode, which
looks wrong.

Test: presubmits
Change-Id: I24b087977fc6861eef3a1c30e58d9bf42a344c52
2022-11-01 11:28:29 +00:00
usta
4f5d2c1e97 include symlink metrics in bp2build_metrics.pb
Bug: b/256212479
Test: Prior to thi CL bp2build.symlink_forest event was missing in bp2build_metrics.pb after a clean mixed build
Change-Id: I53bfc4114a383c0d1f9c4c7945e7d4c69bc50b0c
2022-10-31 11:38:10 -04:00
Mark Dacek
df02a8c258 Merge "Add bazelMode arguments to multiproduct_kati." 2022-10-28 15:22:02 +00:00
MarkDacek
c9d5bd8816 Add bazelMode arguments to multiproduct_kati.
These are needed to add staging-mode to some throttled builds. See go/roboleaf-launch-tests for details.

Test: m nothing
Test: build/soong/build_test.bash --bazel-mode-staging

Change-Id: I456ef80fb9c50579a28fba3dbd184d4e4653dde7
2022-10-27 21:24:13 +00:00
Lukacs T. Berki
c541cd27fa Create Bazel symlink forest in a separate process.
This helps with incrementality a lot: the symlink forest must depend on
almost every directory in the source tree so that if a new file is added
or removed from *anywhere*, it is regenerated.

Previously, we couldn't do this without invoking bp2build, which is
quite wasteful because bp2build takes way more time than the symlink
forest creation, even though we do the latter in a very suboptimal way
at the moment.

This means that if a source file is added or removed (which does not
affect globs), we don't pay the cost of bp2build anymore.

Also refactored symlink_forest.go on the side. Too much state was being
passed around in arguments.

This change reimplements aosp/2263423 ; the semantics of not touching an
output file is the exact same as order-only inputs and the latter is a
bit fewer lines of code.

Test: Presubmits.
Change-Id: I565c580df8a01bacf175d56747c3f50743d4a4d4
2022-10-27 08:08:45 +00:00
Usta (Tsering) Shrestha
39f17ad8b8 Merge "don't touch bp2build_workspace_marker file if it exists" 2022-10-25 13:40:59 +00:00
Usta (Tsering) Shrestha
5689aa36f6 don't touch bp2build_workspace_marker file if it exists
- the generating rule has `restat=true`, so its output need not have a newer timestamp to prevent it from rerunning on subsequent ninja invocations
- its dependents (so far only bootstrap.ninja's "build build.ninja") already have proper dependencies in the depfile, namely
  1. Android.bp.list,
  2. entries in Android.bp.list,
  3. bazel.list and
  4. entries in bazel.list

This change prevents symlink related changes from spuriously retriggering build.ninja

Change-Id: I93f1fea7054dfbfc7c13ece34d2d1f07a81bbe07
Test: manually verifying bazel analysis is triggered only under the right set of CUJs using build/bazel/ci/incremental_build.py
Bug: b/239044236
2022-10-25 13:40:34 +00:00
Lukacs T. Berki
a3b9688859 Do not add .bp files to the .d file of bp2build.
This is okay because Blueprint already adds the module files to the
.d file of its output, so until now, they were duplicated.

Test: presubmits
Change-Id: I1bb75c5124aadd1703f3d150948dd7540ba772be
2022-10-25 09:26:06 +00:00
Treehugger Robot
63108dc2be Merge "write soong.environment.used.* file only if changed" 2022-10-24 21:36:06 +00:00
Usta Shrestha
2ba28a34bd write soong.environment.used.* file only if changed
Bug: b/255309129
Test: `lunch aosp_x86-userdebug` and `export NINJA_ARGS="-d explain"`
      Then do the following:
        1) rm -rf out && m bp2build
        2) touch bionic/libc && m bp2build
        3) ALLOW_MISSING_DEPENDENCIES=true m bp2build
      After each step above observe the following two
        a)`stat out/soong/soong.environment.used.bp2build | grep Modify`
        b)`stat out/soong/bp2build_workspace_marker | grep Modify`
      Verified:
       step 2 changes only (b) - prior to this CL, it'd change (a) as well
       step 3 still changes both (as expected)
Change-Id: I98a94878a14e19043f448b0904fc67d5d1dc9733
2022-10-24 17:55:06 +00:00
Liz Kammer
f2a80c6396 Add non-zero exit + error message to soong metrics
Improves some error messages that would have given little/no information

Bug: 254650145
Test: relevant unit tests
Test: Induce errors and check metrics proto
Change-Id: Ife6116af74af6e62c2f8ae8774e53c28178fb8d0
2022-10-24 10:51:56 -04:00
Mark Dacek
99db041a14 Merge "Add bazel staging mode to soong build." 2022-10-21 17:38:43 +00:00
Dennis Shen
ff34e291d8 cherrypick of ag/20211286
update and create bundle config pb python library

update config.pb file to the source of truth:
google3/third_party/java_src/android_appbundle/bundletool/schemas/proto/config.proto

current config.pb is stale and needs update.

Also, add a python library host soong module config_proto, so that it
can be used by other python code.

BUG: b/240288941
TETS: tested along with primary_train_build_worker that reuse
BundleConfig.pb

Change-Id: I426a5cb7ec42573ed2110494c50813abc0a96296
2022-10-20 17:02:42 +00:00
MarkDacek
b78465de1d Add bazel staging mode to soong build.
This is to use bazel to build targets that are being prepared for an
incipient release to the prod mode allowlist.

Bug: 254265047
Test: m nothing
Test: m nothing --bazel-mode-dev
Test: m nothing --bazel-mode-staging
Change-Id: Ic78a59cf51dba83ef1ac26483586560ea9b24aaf
2022-10-19 15:57:18 +00:00
Treehugger Robot
883300c33b Merge "Add support for pom with packaging=apk to pom2bp." 2022-10-12 21:06:04 +00:00
Brett Chabot
98fb28670c Add support for pom with packaging=apk to pom2bp.
Bug: 251825866
Test: ./prebuilts/misc/common/androidx-test/update-from-gmaven.py
Change-Id: I7811898d9801bb733f3b43c55308f6741778a378
2022-10-12 12:12:02 -07:00
MarkDacek
0d5bca51b6 Add bazel paths to ninja deps.
Test: m nothing
Test: m nothing --bazel-mode-dev
Change-Id: I120e62ac3f2aa066aedaecf2a5d16c79f7097c76
2022-10-12 16:30:20 +00:00
Usta (Tsering) Shrestha
48f0d04275 Merge "Add timing of bp2build steps" 2022-10-06 04:41:21 +00:00
Usta Shrestha
a117c58308 Add timing of bp2build steps
Bug: b/239044089
Test: run build/bazel/ci/incremental_build --bazel-mode com.android.adbd and see the additional metrics in summary.csv
Change-Id: I2c3b9cead2ee43c700a9ad52e669a64aab1499ce
2022-10-05 21:35:40 +00:00
Spandan Das
5af0bd3e48 Create a new mode in soong_ui to generate API only BUILD files
The generated Bazel workspace will only contain api specific targets.
This is feasible since these targets do not have any cross dependencies
with the targets in the bp2build workspace

The advantages of a new mode are
1. Does not pollute bp2build workspace with api targets
2. Does not block api targets with the current allowlist conversion
   mechansims in bp2build
(In the future we might want to combine these two workspaces)

A Soong module type will generate a Bazel target if it implements
ApiProvider interface

Test: m apigen
Test: m nothing

Change-Id: I69c57ca6539f932e0ad554ce84a87fb7936fdba0
2022-10-04 17:32:56 +00:00
Treehugger Robot
7ea3a82480 Merge "Make writing command-line arguments as a comment in the generated file optional" 2022-09-29 17:49:36 +00:00
Alan Viverette
efab514e51 Make writing command-line arguments as a comment in the generated file optional
Bug: 246630004
Test: ./update_prebuilts.py -x ######
Change-Id: Ic7d5d5ba55f5bba5cc2d0866a7a25f753f3428f8
2022-09-26 15:26:06 +00:00
Jingwen Chen
f50817d511 Add zip2zip alias and allowlist unblocked rdeps.
Test: presubmit
Change-Id: Ia4eb3e6af5cf43dc5c1d924cbf7dcf812f4b8703
2022-09-23 02:29:02 +00:00
Treehugger Robot
5eba1a24cb Merge "update MultiAbiTargeting matching logic" 2022-09-16 23:27:26 +00:00
Sam Delmerico
b74f0a0084 update MultiAbiTargeting matching logic
The logic here has diverged from the logic in bundletool and resulted in
the wrong APEX variant being chosen for a 64bit-only product.

Bug: 246476965
Test: go test .
Change-Id: Ic3b067e98a65146cfa399e7c9b231f397e51c23e
2022-09-16 15:29:46 -04:00
Martin Stjernholm
56d691eba9 Fixed error return condition when the toc is read.
Prior to this `getToc` could return (nil, nil) which caused a crash
later.

Test: m extract_apks && out/host/linux-x86/bin/extract_apks \
        -o foo.apks -sdk-version=33 \
        -abis=X86_64,X86,ARM64_V8A,ARMEABI_V7A \
        -screen-densities=all -extract-single test.apks
  where test.apks comes from ag/19673938
 Test: vendor/google/modules/ArtGoogle/build-with-prebuilt-art-module.sh droid
  with prebuilts in place for cf_x86_64_phone_prebuilt_art-userdebug
  chained build on git_master_throttled
Bug: 246562532
Change-Id: Id849371b4dea04f08c07b201c8a466735b5b0994
2022-09-16 00:22:52 +01:00
Treehugger Robot
2701ecd502 Merge "Remove USE_BAZEL and its dead code" 2022-09-01 17:32:00 +00:00
Chris Parsons
19ab9a455f Remove USE_BAZEL and its dead code
This environment variable has been out of use for some time. It used to
control Bazel-as-executor, which has been removed from Bazel for several
releases.

Bug: 243077098
Test: Treehugger
Change-Id: I4edfb5f3574c369a16547ea06ba780293c37ecb3
2022-09-01 11:33:02 -04:00
Cole Faust
3e8c964fb7 Merge "Always merge build files" 2022-08-31 01:07:14 +00:00
Cole Faust
324a92e404 Always merge build files
Previous behavior:

- Packge not listed in bp2buildKeepExistingBuildFile:
    - Use bp2build generated build file
- Package listed in bp2buildKeepExistingBuildFile:
    - Use handcrafted build file even if there were allowlisted bp2build
      modules in the same package.
- Package listed in bp2buildKeepExistingBuildFile and a soong module has
  a bp2build: { label } attribute:
    - Merge the handcrafted and bp2build generated build files

New behavior:

- Packge not listed in bp2buildKeepExistingBuildFile:
    - Use bp2build generated build file
- Package listed in bp2buildKeepExistingBuildFile:
    - Merge with bp2build generated build file.

Bug: 234167862
Test: ./build/bazel/ci/bp2build.sh
Change-Id: Ifbaf4f8f0f5158b5b2bd6d534eb2311e2e5f399b
2022-08-30 16:07:23 -07:00
usta
cd245f7004 cosmetic: remove unused arg
Test: m nothing
Bug: N/A
Change-Id: I93db309d7b086b65046c53ea3c8b2296209fb2a9
2022-08-30 17:40:24 +00:00
Chris Parsons
ef615e5841 Add --bazel-mode and --bazel-mode-dev
This allows "bazel mixed builds prod mode", in additional to reworking
the mechanism in which mixed builds dev mode is enabled.

As a followup, CI scripts will be migrated to use the new flags, as
USE_BAZEL_ANALYSIS=1 is deprecated.

Test: Manually ran --bazel-mode with an allowlist verifying that the
module alone was enabled
Test: Manually verified --bazel-mode and --bazel-mode-dev cause a build
failure

Change-Id: If0d34360e60452f428b05828f4ec7596b7cb619a
2022-08-29 10:56:04 -04:00
Chris Parsons
ad876010fe Refactor mixed build allowlist handling
This refactoring prepares for introduction of bazel prod mode, an
alternative mechanism for mixed builds allowlist handling.

 * Decide bazel-mode as close to soong_build main as possible
 * BazelContext itself decides whether a module is allowlisted
 * Separate bp2build and mixed build allowlist

Test: m nothing, manually verified all modules are mixed build disabled
(via metrics)
Test: USE_BAZEL_ANALYSIS=1 m nothing, manually verified that mixed build
disabled/enabled modules are identical before and after change.

Change-Id: I0f55d8b85000cb4a871a099edc6d7d868d7df509
2022-08-23 13:15:12 -04:00
Colin Cross
d079e0b270 Reformat build/soong for go 1.19
Test: none
Change-Id: I132368f0fcbdb5ea088b5b84dbe4ccfdd9e94cad
2022-08-17 10:43:13 -07:00
Alan Viverette
63e738ffe0 Merge "Add support for prepending text from a file" 2022-08-16 14:47:29 +00:00
Usta Shrestha
675564daa8 Cosmetic: More helpful error message
Test: various invocations of ./build/soong/soong_ui.bash
Bug: N/A
Change-Id: I7be5b84330bc7525b5633314a111e5e1fa9fc844
2022-08-12 13:43:48 -04:00
Alan Viverette
d3be6f5885 Add support for prepending text from a file
Fixes: 241826272
Test: ./update_prebuilts.py -x <bid>
Change-Id: I47146fc8a4f9120891ee28d15b006448d66aaff7
2022-08-11 11:41:38 -04:00
Usta Shrestha
96ff7227a0 soong_ui to reject "showcommands"
deprecated flag that simply adds 5s to a build
the `ctx.Done()` signal handling is unnecessary because of clean-up hooks already in place

Test: m libc
Bug: N/A
Change-Id: Ica12d727264af1e61e97393bc8cbeba9f78cbc83
2022-08-09 18:07:25 -04:00
Usta Shrestha
59417a19c8 cosmetic: unnecessary method indirection
Test: m nothing
Bug: N/A
Change-Id: Ie750d6556a12fb077d4592b1b7cb3e8edc8ef80e
2022-08-09 18:07:12 -04:00
Joe Onorato
2e5e401722 Add top level and per-mutator traces to soong_build
- Top-level trace for all soong_build runs
  - Includes adding Peek() to OncePer because not all soong_build
    invocations have GenerateBuildActions run.
- A trace per mutator invocation

Test: m && build/bazel/scripts/print_analysis_metrics.py
Change-Id: Ief5c04630484fb38ec7e3757de45c7dc294d3b3c
2022-07-22 10:01:35 -07:00
Sasha Smundak
0fd93e0756 Output informational messages only when BP2BUILD_VERBOSE is set.
Test: manual
Change-Id: Ieeb00a002e07b04449d70614ce205c47c1dd7bce
2022-07-18 13:34:44 -07:00
Kousik Kumar
7bc781949a Add a broad warning about missing LOAS creds
This is to generally warn Google devs about lack of LOAS creds.

Given the switch to RBE, lack of LOAS creds will start resulting in build
failures, so adding a warning message ahead of time to all builds. Will
convert this to a build failure after a week.
We need LOAS creds to be able to even fetch the CDPush config file to
determine whether to use RBE in a build a not, which is why I'm making
this a broad error message across builds.

Test: ran "m nothing" build with / without gcert and with / without
"stubby" in $PATH and confirmed appropriate error message.
Bug: b/235985591

Change-Id: I15cbaf372b0a7b79f868a06c7d5ede19b49ae687
2022-06-29 17:48:52 +00:00
Yu Liu
57c1edc4d9 Merge "Support cc code coverage for mixed build" 2022-06-13 18:57:50 +00:00
Jingwen Chen
c0c5021eb1 Denylist more infinite symlinks in the tree.
These new symlinks were added as part of an upstream main merge in https://android-review.googlesource.com/c/platform/external/autotest/+/2112105/-1..1

Test: bp2build
Change-Id: I054be0f14bf114b19e1437937ccb598c3ab02e71
2022-06-07 10:07:22 +00:00
Yu Liu
8d82ac58b4 Support cc code coverage for mixed build
Bug: 231322627
Test: Manual tests and unit tests
Change-Id: I786042af0d612192c54c3572f63a86a47174a242
2022-06-06 12:29:25 -07:00
Dan Willemsen
ccf36aa928 LOG_DIR changes should not trigger soong_build to re-run
On the build servers, LOG_DIR is a subset of DIST_DIR, which encodes the
build number. This means that LOG_DIR is guaranteed to be different for
every build, and we'll never re-use previous soong runs on CI builds.

The current use case (writing out soong metrics) shouldn't care if the
value changes, so pipe the environment variable through, bypassing the
env dep checks. It's not clear if this is the only issue triggering
soong_build re-runs on the build servers, but it's a start.

Test: Change DIST_DIR, soong_build does not re-run.
Change-Id: I59bf117f3fbc0e7f10f0506d3d1ac7564c6a00dc
2022-06-01 21:06:17 +00:00
Usta Shrestha
5c6b9484f4 Use EventHandler.Do()
Bug: N/A
Test: manually verified (e.g. ran `m nothing` successfully)
Change-Id: Ie832019f8a81e127e64946070a712126997f7a35
2022-05-26 12:40:08 -04:00
Chris Parsons
027881cf35 Add extraNinjaDeps to mixed builds depfile
This was accidentally removed in aosp/2094705. Among other possible
issues, this caused the "used environment variable" file to be omitted
from the depfile of soong_build during mixed builds, which would result
in soong_build not being subsequently retriggered during env var
changes.

Sendng this out as a quickfix, regression test to follow.

Bug: 233774464
Test: Manual `m nothing && USE_BAZEL_ANALYSIS=1 m nothing && m nothing`,
verifying that a rebuild was retriggered in each invocation.

Change-Id: I1d9dbd1bc4696df760ebb9be262bc165c161bb21
2022-05-24 19:41:17 +00:00
Chris Parsons
f874e46153 Refactor mixed builds to only take one pass
This large refactoring has both immense performance implications and
improves mixed builds complexity / usability. Summary:

1. Queueing calls to Bazel is done in a new mutator instead of a full
   soong_build pass. Normal soong_build flow is interrupted (via a
   functional hook in blueprint) to invoke bazel and parse its response.
2. Implementing mixed build support for additional modules is as simple
   as implementing MixedBuildsBuildable. In this interface, define the
   request that must be queued to Bazel, and then subsequently define
   how to handle the returned bazel cquery metadata.
3. Mixed builds consists of only a single pass. This greatly
   improves mixed build performance.

Result:
  A 33% runtime improvement on soong analysis phase with mixed builds.

Caveats:
  C++ BazelHandler handling still remains a bit of a mess; I did what
  I could within this CL's scope, but this may require additional cleanup.

Test: Treehugger
Test: Verified that aosp_arm ninja file is bit-for-bit identical with or
without this change.

Change-Id: I412d9c94d429105f4ebfafc84100d546069e6621
2022-05-20 10:04:13 -04:00
Lukacs T. Berki
2388f64e76 Add comments for path_interposer.
Test: Presubmits.
Change-Id: I22c08f282019050da1198cce1f92f5d825ee649f
2022-05-06 12:42:05 +02:00
Sasha Smundak
d5fc469dd8 If invoked 'go list' command fails, show its stderr.
Test: manual
Change-Id: I776b71f8b6c6c3d46d60e790d944282efd6d55d7
2022-04-19 11:32:28 -07:00
Colin Cross
fa8e9cc3a1 sbox: fix typo when comparing files
A typo caused one of the two files to be compared to itself if they
both had the same size.

Bug: 228496289
Test: Test_filesHaveSameContents
Change-Id: Ie44f32e3c9b8ef725f0d9933c7e701340036710a
2022-04-13 00:28:32 +00:00
Colin Cross
338df53621 symbols_map: allow unexpected EOF in ELF files
Some of the prebuilt ELF files used for bionic heads cause an
unexpected EOF error, ignore unexpected EOF the same way we do
for EOF.

Test: not yet
Change-Id: I267d11b4d12b83ecebedc72a565e148c5e53af6d
2022-04-12 21:18:09 +00:00
Colin Cross
70b9a7e493 Merge "sbox: report the script path instead of the full command line" 2022-04-06 20:11:20 +00:00
Colin Cross
07907127b9 Merge "symbols_map: don't error on bad elf files" 2022-04-06 18:20:43 +00:00
Wei Li
c055d88c16 Merge "Export provenance metadata for prebuilt APKs and APEXes." 2022-04-06 04:03:41 +00:00
Colin Cross
6285c65e3b symbols_map: don't error on bad elf files
There are cc_binary_prebuilt modules in the tree that are shell
scripts, and attempting to extract an elf ID from them results
in an error.  Ignore too short files and files missing the elf
magic header the same way we do for elf files without an elf ID.

Bug: 218888599
Test: Test_elfIdentifierFromReaderAt_BadElfFile
Change-Id: If7117925ca2371a8ee61ba3616372f6e9b0fab0e
2022-04-05 18:08:32 -07:00
Wei Li
340ee8e699 Export provenance metadata for prebuilt APKs and APEXes.
Bug: 217434690
Test: atest --host gen_provenance_metadata_test
Test: m provenance_metadata

Change-Id: I91c184b6e6fe5ccfc3fc65b55b09e7a3da9502a0
2022-04-05 16:16:16 -07:00
Colin Cross
209844ce1c Merge "Enable restat for sbox rules" 2022-04-05 22:49:10 +00:00
Colin Cross
40cade4b5b sbox: report the script path instead of the full command line
The command line run inside the sbox sandbox can be very long and
printing it obscures the error message.  It is already written to
a script for execution, so point to the script instead of printing
it.

Fixes: 220592170
Test: manual
Change-Id: Icf883344af0f707802b090b4cfb0ef6dcfe0e5c1
2022-04-04 18:16:04 -07:00
Colin Cross
e52c2ac7fb Enable restat for sbox rules
Add support to sbox for only writing output files if they are changed
to support enabling restat.  Move the clearing of the output directory
into sbox, and when write if changed is enabled delete obsolete output
files without deleting output files that will be replaced.

Enable restat for local metalava rules.  Restat for metalava rules
run remotely is still blocked on b/183630617.

Bug: 222095735
Test: TestRuleBuilder_Build
Test: m SystemUI
Change-Id: If8fc47e711f4a6f43947ab69f17cccc8ba6ae61a
2022-04-04 16:42:46 -07:00
Colin Cross
36f55aabcd Add a symbols_map tool for extracting identifiers from elf and r8 files
Add a symbols_map tool that can extract an identifiying hash from
and elf file or an r8 dictionary.  The tool writes the hash to a
textproto, and also supports a merge mode to combine textprotos into
a output file for inclusion in the build artifacts.

Bug: 218888599
Test: m dist
Test: symbols_map_test.go
Change-Id: Icd3ed6e5510e058c92d97c78759e7a4cfcdbb6ca
2022-04-04 15:53:38 -07:00
Treehugger Robot
1c2d87ba83 Merge "Add metrics collection to soong_build" 2022-03-26 00:21:21 +00:00
Chris Parsons
715b08fd82 Add metrics collection to soong_build
Metrics are added to a materialized protobuf soong_build_metrics.pb

Recorded events have scoped names and recorded runtimes.
For example, mixedbuilds includes the following events:

mixedbuilds.prepare
mixedbuilds.analyze.write_files
mixedbuild     (this is a total of all mixedbuild events)

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

Change-Id: I2e72d4502c0373bee0279bb1320b2e4dd586129c
2022-03-25 17:19:44 -04:00
Kousik Kumar
a1d8fa9961 Do not dump metrics if reproxy was never started
Dumping of RBE metrics should only happen when reproxy was started.
Reproxy is started only when Soong is run in make / build mode and not
in dumpvars mode.

Doc: https://docs.google.com/document/d/1Iqhu5QgozB_rA9fucMHO6X4U6A8e8qFtZyub9j83ICQ/edit#
Test: Ran a build with / without RBE. No metrics dumped during lunch
without RBE and metrics dumping worked as expected with RBE.
Bug: b/197213143

Change-Id: Ic3403331e1f4ac2c7c72fd9169aa7b82a7545c75
2022-03-18 02:53:36 -04:00
Colin Cross
36fd4eb081 Fix adding /DISCARD/ to linker script
I0e293944c5c804b4512fb834f8f18e1d6ecd053c accidentally used
Println instead of Fprintln, causing it to print the current
contents of the buffer instead of adding to it.

Bug: 216192129
Test: manual
Change-Id: I1ddeeef3443c1091cf729328cb8fd74c217432ec
2022-02-25 18:25:45 -08:00
Treehugger Robot
e1b9e95ddd Merge "Discard PT_INTERP in embedded linker linker script" 2022-02-17 04:08:58 +00:00
Colin Cross
4d9b1f1d87 Discard PT_INTERP in embedded linker linker script
Discarding PT_INTERP in the linker script generated for the embedded
linker allows linking without the --no-dynamic-linker argument.

Bug: 216192129
Test: manual
Change-Id: I0e293944c5c804b4512fb834f8f18e1d6ecd053c
2022-02-16 15:36:29 -08:00
Liz Kammer
124967f597 Show failing products in multiproduct_kati
Test: cause products to fail and verify they appear in error message
Change-Id: I4111b919aebc0b8d80ecbd17be3c2745c75b76a5
2022-02-14 15:42:53 -05:00
Liz Kammer
4ae119c14c In Soong, set max files soft limit to hard limit
Test: m nothing
Change-Id: I4f45ebcf8c7b74315c371012603aeb7c541ae336
2022-02-09 13:16:23 -05:00
Liz Kammer
a754178d4f Add logging of file resource limits in Soong
Test: m nothing and verify in logs
Change-Id: I4b51089ce1d222927a180b260fb9bc0e3b77c468
2022-02-07 13:38:52 -05:00
Kousik Kumar
5ddefa3df4 Merge "Move env var config loading to be within the config package." 2022-01-31 04:40:50 +00:00
Usta Shrestha
b3af19caa2 Merge "list all valid flags (commands) to soong_ui upon unknown command" 2022-01-29 06:34:19 +00:00
kgui
67007248a5 Add new file name to output inputs/outputs of actions of modules into a new file when m json-module-graph is executed.
And also delete the logic in droidstubs to output JSONDataActions.

Test: local.

Change-Id: Ib5d6f1f69c16c41f128e481131775c7699f96464
2022-01-28 13:52:50 +08:00
Kousik Kumar
3ff037e3d9 Move env var config loading to be within the config package.
When the environment variable config file is loaded after config object
is initialized, we  end up loading the USE_RBE variable in the config
file after the code to start reproxy process is run. This causes a
problem when USE_RBE variable itself is set in the config files. To
avoid this, I've moved the config file loading code to be within the
config package, this makes the main.go file cleaner too.

Test:
Ran a build with USE_RBE:true set in the config json file. The build
fails without this change and succeeds with this change.

Bug: b/209486170
Change-Id: Iab3957b64f4b5456a861057d16ad318f4f78e0cb
2022-01-26 18:40:43 -05:00
Usta
6feae38aa3 list all valid flags (commands) to soong_ui upon unknown command
Test: m nothing
Bug: N/A
Change-Id: I0dd94c18e945a0ef4311b076d49086281ef288af
2022-01-15 01:42:19 -05:00
Kousik Kumar
7b7dca4316 Add additional directories from which env config can be loaded
This is useful for external users to be able to specify their own config files that can be loaded by soong during startup. In addition, we need this for upcoming changes to incorporate an experiments framework in Soong since the config file will be fetched from CDPush and put into the OUT_DIR folder by the config file fetcher binary.

Note: Once this is merged into internal branch, I'll fully get rid of
the vendor/google/ path from Soong in aosp.

Test:
1. Ran a build in aosp with these changes and no config file was loaded.
2. Ran a build in internal master with these changes and the current
config file inside vendor/google was loaded as expected.

Bug: b/214035335
Change-Id: I9af83687d4eaeee1ffb0f88a750cfeb7c6d2bafb
2022-01-14 00:22:36 -05:00
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
947fdbfdee Log bp2build_metrics .pb
Also share `Save(pb proto.Message, filepath string)`

Bug: 201539536
Test: bp2build_metrics.pb has expected content & path
Test: m nothing
Test: {bp2build,mixed_{libc,droid}}.sh
Test: CI
Change-Id: I7d8ad87fca6a4b0355010090a527f5ae67b27c88
2021-12-13 13:03:44 -05:00
Liz Kammer
1aefc9d2d2 Support a quieter bp2build
Tie verbosity of bp2build to env var BP2BUILD_VERBOSE

Test: m bp2build
Test: BP2BUILD_VERBOSE=true m bp2build
Change-Id: Ib8f10ad73ed06c935126a77d18c1d9febc25348f
2021-12-02 10:00:29 -05:00
Treehugger Robot
ec014011ea Merge "sbox: run commands using script for large commands" 2021-11-19 22:06:02 +00:00
Colin Cross
ffbcd1d8a0 Extract primary apk from apk set zip
Extract and install the primary apk normally, and then unzip the rest
of them as a post install command.

Bug: 204136549
Test: app_set_test.go
Change-Id: I17437ff27f49df6bc91bdbbea6173b46c7d3ec4e
2021-11-17 19:55:33 -08:00
Kevin DuBois
0a5da7025e sbox: run commands using script for large commands
Linux has limit of 32 pages for a single argument. Sbox's method of
handling commands as a single large string can run into this limitation.

Write the large command to a script file and then execute that file.
This better accommodates the large commands, and leaves a script in the
temporary directory useful for manual inspection if necessary.

Bug: 177070955
Bug: 174232579
Fixes: 202297224
Test: m
Test: make particular target with very long command exceeding limit.
Change-Id: Ia298fdfd7a759821c37f540deaf800026041e511
2021-11-12 00:48:34 +00:00
Jingwen Chen
a47f28d28e bp2build: add support for soong_config_module_type.
Test: CI, go unit test
Bug: 198556411
Change-Id: Idf862904d51d822f92af0c072341c31b7a02fc64
2021-11-08 13:38:28 +00:00
Lukacs T. Berki
eb0454b2a4 Generate actions when building the module graph.
This is necessary because GenerateAndroidBuildActions() is effectively a
mutator and therefore can change the data stored in each module.
Sometimes one wants to dump that data in the JSON module graph, and in
order to do so, actions need to be generated.

I briefly entertained removing StopBeforePrepareBuildActions(), but it
incurs a 10-second penalty on "m soong_docs" and "m bp2build" so I
decided to keep it.

Test: Presubmits.
Change-Id: I438aaf981e989dc39a09e8a2ba73f7a08ee55386
2021-10-26 13:32:59 +02:00
Dan Willemsen
2a109db10b Merge "Reduce modules exposed to Make in Mac builds" 2021-10-19 00:32:54 +00:00
Dan Willemsen
def7b5d198 Reduce modules exposed to Make in Mac builds
Device builds are no longer supported on Mac, but we do support building
various host tools, including the SDK build-tools and platform-tools
packages. These have dependencies on [java] device modules, so we don't
completely disable device modules, only hide them from Make (which makes
them more difficult to trigger from the command line).

Also fix the mac build of multiproduct_kati, so that `m blueprint_tools`
works on Mac.

Bug: 187222815
Test: `m`, `m dist`, etc on Mac
Change-Id: I92f16605d5cd173d431cbcb79081234d45cc6e2e
2021-10-18 12:44:45 -07:00
Colin Cross
5cb7366c58 Up per-product memory usage to 30 GB
Reduce multiproduct_kati parallelism by upping required memory per product
to 30 GB.

Bug: 201671935
Test: builds
Change-Id: Ia756f309459d28e22a49f190a5227a139b356a1f
2021-10-18 10:18:51 -07:00
Romain Jobredeaux
6a779a4b50 Merge "remove redundant 'deps' section from template with 'exports' section." 2021-09-27 20:54:51 +00:00
Dan Willemsen
66213a64b2 Disable protobuf deterministic randomness in soong_build
Soong writes out text protos for the sbox manifests, and if those change
every time soong changes, we trigger rebuilds of significant portions of
the tree. This is very annoying when attempting to iterate on Soong, so
disable this functionality at the soong_build level.

Bug: 200727888
Change-Id: Icf21e1775a4c4200e983c1b8ac66ddd780d7c90c
2021-09-22 15:07:53 -07:00
Romain Jobredeaux
b669398c45 remove redundant 'deps' section from template with 'exports' section.
Test: pom2bp -regen prebuilts/sdk/current/support/BUILD.bazel
Bug: 198418951
Change-Id: I4d0e3d100d0e319473723a75077e2520fc1535e1
2021-09-22 16:50:33 -04:00
Colin Cross
fac6fd0927 Merge changes I0b78ceeb,Ic57e1efd
* changes:
  Add environment variable to force keeping ANSI codes
  Disable table mode in smart status if window size is not available
2021-09-22 18:19:15 +00:00
Romain Jobredeaux
5ff942285c Merge "Add a flag-protected (-pom2build) feature for pom2bp to produce Bazel BUILD files." 2021-09-22 14:47:02 +00:00
Romain Jobredeaux
89cb22416d Add a flag-protected (-pom2build) feature for pom2bp to produce Bazel BUILD files.
Note that this is an initial, rather crude attempt at this,
that unblocks generating BUILD files needed to build AOSP android apps.
In particular, note that
- Jetifier step currently ignored
- Visibility set to public for all output targets
- All dependencies are gathered in 'deps', though they are split under various categories in bp files
- Host, host-only notions are ignored for now

Test: Copy first 2 lines of, e.g. prebuilts/sdk/current/support/Android.bp to a BUILD.bazel file and run pom2bp -pom2build -regen BUILD.bazel
Bug: 198433754
Change-Id: I5efa93517e6c319fd828da5b16ba7efd2d90bca8
2021-09-21 20:36:07 +00:00
Spandan Das
235a9443b7 Merge "Add Property.Type to bpdocs template" 2021-09-21 20:00:35 +00:00
Colin Cross
3c0fe0edc0 Add environment variable to force keeping ANSI codes
If SOONG_UI_ANSI_OUTPUT is set to a true value force the simple status
output to keep ANSI codes.  This will allow buildbots to collect logs
with ANSI codes in them.  Smart status output is not affected as it
always keeps ANSI codes.

Bug: 147310922
Test: manual
Change-Id: I0b78ceebb65125b8e8dafb4787816fb679d3eb3e
2021-09-21 12:53:30 -07:00
Colin Cross
2f08bc1a5c Increase timeouts in Test_runWithTimeout
Under load sometimes the 1 millisecond timeouts are not run before
a 1 second sleep finishes, or `echo foo` is not run before a 1
second timeoutt.  Increase the long sleeps and timeouts to 10 seconds.
This doesn't affect normal test runtime as the command should timeout
after 1 millisecond.

Bug: 199207577
Test: Test_runWithTimeout
Change-Id: I31166850a473b9cde37906a62d026580e7a7bd3f
2021-09-17 21:36:29 +00:00
Liz Kammer
83d07a4c41 Merge "Expand handling of unconverted deps in bp2build" 2021-09-15 13:49:48 +00:00
Liz Kammer
6eff323206 Expand handling of unconverted deps in bp2build
Support three options for converting modules with unconverted
dependencies
1. (default) Warn when converting a module if it has unconverted deps.
2. Error when encountering a module with unconverted deps. (not hooked
up yet)

Test: build/bazel/ci/bp2build.sh
Test: build/bazel/ci/mixed_libc.sh
Test: BP2BUILD_ERROR_UNCONVERTED=1 build/bazel/ci/bp2build.sh with
      unconverted deps -- get appropriate error
Bug: 181155349
Change-Id: Ifaabf0cd2e43e963366dc137159c705294165c3d
2021-09-14 19:55:55 +00:00
Alan Viverette
b89663b7d9 Merge "Patch "Add support for --optional-uses-libs to pom2bp" to match master" 2021-09-14 15:04:28 +00:00
Alan Viverette
bcbfc5f53c Patch "Add support for --optional-uses-libs to pom2bp" to match master
Cherry pick that was originally submitted was not up-to-date.

Change-Id: Ia599ea294926666cddfd84f8c2a3e22e7e7c0434
2021-09-13 19:28:35 +00:00
Spandan Das
eabda9708a Add Property.Type to bpdocs template
This field was missing for Property objects that have non-empty inner
Property objects

Bug: 172797653
Test: m soong_docs
Change-Id: Iee9c66f8b85d68a6b5bf18fd9787143191c4f002
2021-09-12 18:40:37 +00:00
Treehugger Robot
c521d5717d Merge "Add support for --optional-uses-libs to pom2bp" 2021-09-10 20:15:35 +00:00
Lukacs T. Berki
89fcdcb788 Refactor the creation of soong_build calls.
They were a bit repetitive.

In addition, make the environment checks more correct; they could
probably use an integration test or two to make sure that when the
environment changes, exactly those outputs are rebuilt that need to be,
but for now, this is an improvement already.

Test: Presubmits.
Change-Id: Idd79b81ca6975d57d00e5bf4699d266152505ff8
2021-09-08 09:36:22 +02:00
Lukacs T. Berki
c6012f36e1 Invoke soong_docs from the bootstrap Ninja file.
This makes soong_ui the only place where soong_build is invoked, thus
greatly simplifying the conceptual model of the build.

It comes with the slight limitation that now soong_docs (and queryview
and the JSON module graph) are not Make targets anymore, but I suppose
that's an acceptable loss.

The only place where someone depended on soong_docs from a Makefile is
removed in a separate change.

Test: Presubmits.
Change-Id: I3f9ac327725c15d84de725d05e3cdde1da3dcbe2
2021-09-08 09:31:52 +02:00
Lukacs T. Berki
ffc9e8d812 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: If928b34de075969fd42932212ce9187808cbdf86
2021-09-07 18:14:07 +02:00
Lukacs T. Berki
7edd91c0f4 Make incremental queryview builds work.
The breakage was because:
- aosp/1818236 removed the "rm -fr" invocation from the Ninja file that
removed the old queryview tree
- queryview files were created with permissions 440 to discourage manual
editing

These two together made incremental queryview invocations not be able to
overwrite its output files.

(Of course, it also made them incorrect since old files were lft in place)

Test: Presubmits.
Change-Id: Idaa3e1db82c9eb8325c48e37aca5146e69af7333
2021-09-07 08:47:21 +02:00
Lukacs T. Berki
3a82169a55 Invoke queryview from the bootstrap Ninja file.
It used to be invoked from out/soong/build.ninja, which required two
soong_build invocations one after the other (ne to generate
out/soong/build.ninja, one to generate the queryview workspace). This
was slower and required some shell-quoted-in-ninja-quoted-in-Go .

Test: Presubmits.
Change-Id: Idda79c067606663b66e9f94626fa24f3b5af4114
2021-09-06 17:10:49 +02:00
Lukacs T. Berki
d6cee7e374 Make OutDir() and SoongOutDir() be consistent.
They both used to return out/soong. Unfortunately, the tests seem to
assume the old behavior, so I had to keep tests inconsistent and I was
scared of dexpreopt, too.

Test: Presubmits.
Change-Id: Ib00c7956fd2cdb28cc11d481c17e5a3ff5ad563a
2021-09-02 13:35:49 +02:00