Commit graph

578 commits

Author SHA1 Message Date
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