Commit graph

7112 commits

Author SHA1 Message Date
Treehugger Robot
35bc07cb2a Merge "don't compress JNI libs extracted from aar_import" into main 2023-09-18 18:20:52 +00:00
Jared Duke
b832fbb643 Unconditionally generate hash-based proguard mapping files
Previously, this was restricted to targets that enable R8 full mode, but
that was really just a temporary carveout to avoid disrupting other
targets. Since then, R8 full mode has been enabled by default for all
app targets, and the hash-based mapping mechanism is further integrated
into various debugging and retracing pipelines.

As of now, there are are only a very small number of targets that have
enabled optimization/obfuscation and are still using R8 compat mode, so
the build-time impact of this change should be minimal, and there should
be no functional runtime side effects.

Bug: 297566172
Test: m framework-appsearch + inspect proguard mapping
Change-Id: I5dfea60f60dc37b8445c8fddba6a4eab0dc41d96
2023-09-18 16:05:16 +00:00
Romain Jobredeaux
3132f843f1 Use raw {min,target}_sdk_version properties in android_app converter
The logic of EffectiveVersionString is product-variable dependent and
is being implemented bazel-side in order to produce product agnostic
BUILD files. A required additional product variable is added to the
export list, and the "updatable" property of android_app is also bp2build-converted.
Handling of max sdk version was not correct (it does not affect
manifest values in Soong), so removing it for now.

Bug: 274474008
Bug: 274474002
Test: CI
Change-Id: I7a10bfabf914c8e86064b7ce61926701f87517e3
2023-09-18 10:02:35 -04:00
Jingwen Chen
e12c083198 [bp2build] android_test bp2build.
android_test is just an android_app, but the test bits are handled
purely in Starlark (tradefed_test_impl).

This enables building HelloWorldTests (android_test) with Bazel.

Bug: 297030120
Bug: 297029612
Test: WIP
Change-Id: I6d287c94b31698ea247da48e4cd6b5a75bc71e11
2023-09-18 12:39:06 +00:00
Jihoon Kang
fdf323697e Add java_api_contribution_import module type
java_api_contribution_import is a prebuilt module type of
java_api_contribution. It's build actions are identical to those of
java_api_contribution.

Test: m nothing
Bug: 300174357
Change-Id: I831806990b37b340af21858eb2bab5de62fdf7a9
2023-09-15 22:52:52 +00:00
Zi Wang
5d982b398e Merge changes from topic "drop_deps_no_srcs" into main
* changes:
  Always drop deps from java_library with no srcs
  Do not append deps to exports when java_library has only proto srcs
2023-09-15 20:39:35 +00:00
Zi Wang
dd93636f1e Always drop deps from java_library with no srcs
This is the follow up from aosp/2750763

Test: CI and added unit test

Bug: 285952385
Change-Id: I64703ee4fa742b718ffb43f2af1b6ab43ddeb606
2023-09-15 10:37:16 -07:00
usta
72c6c6c8be Bp2build-convert droiddoc_exported_dir
Bug: 283299388
Test: `m bp2build` and manual inspection
Change-Id: Ieec2094e446bb030f30103a7e1a06e35cbdcc72e
2023-09-14 12:06:54 -04:00
Cole Faust
3835509f95 Merge "Error out if skip_preprocessed_apk_checks is set when it's not necessary" into main 2023-09-13 22:38:33 +00:00
Zi Wang
f038cde8df Do not append deps to exports when java_library has only proto srcs
This is to address the comment in aosp/2748099

Test: CI

Bug: 285952385
Change-Id: I0bc8c76e2bc9ee113ced8642e0ab93a95799211c
2023-09-13 10:15:10 -07:00
Jihoon Kang
ef1fc04e1a Merge "Utilize -quiet flag in java_api_library" into main 2023-09-13 15:57:11 +00:00
Paul Duffin
93961bfbe5 Merge "Replace --api-overloaded-method--order with --format-defaults" into main 2023-09-13 11:57:03 +00:00
Jihoon Kang
d02a43668a Utilize -quiet flag in java_api_library
java_api_library finds and zips class files based on pattern matching,
leading to multiple missing files warnings being printed to console
during from-text stub build. This change passes the `-quiet` flag to
soong_zip to prevent such warnings from being printed.

Test: m --build-from-text-stub and inspect console output
Bug: 300166930
Change-Id: I23d49b5e3a29d2127f5e917169620e18a98bc06b
2023-09-13 00:11:01 +00:00
Paul Duffin
504d356579 Replace --api-overloaded-method--order with --format-defaults
Bug: 300052204
Test: m checkapi
Change-Id: I8952a828437872ceebf7f9da4dc297173ed2a90b
2023-09-13 00:00:58 +01:00
Zi Wang
774c6eaf10 Bp2build: handle the case where java_library has only proto srcs
java_library doesn't accept deps when there are no srcs because
no compilation happens, but it accepts exports.

The deps from the module are not necessary for compiling the protos,
in which case they are unnecessary as deps on the java_library as well
since they are not be propagated to any dependencies.

So we can put the deps to exports and drop deps here.

Test: CI and added unit test

Bug: 285952385
Change-Id: Ie54a4ac0db592fb96fede64f0e67df309dca9c1d
2023-09-12 10:41:42 -07:00
Romain Jobredeaux
d2cc5037c2 Re-order android_app bp2build converter logic.
This change is a no-op but makes it easier to single out framework-res
for conversion in subsequent CL aosp/2720593.

Bug: 276928228
Test: CI
Change-Id: I7c7338add1857697912dec3c34b7c43e06d2d12d
2023-09-11 16:37:50 -04:00
Treehugger Robot
3fb2002c9e Merge changes I86f30b99,I2769c0d5 into main
* changes:
  Do not convert resource dirs without resources
  Do not convert java libraries with core_platform
2023-09-08 16:04:45 +00:00
Liz Kammer
33dddf5a7e Do not convert resource dirs without resources
Previously we would convert to java_resources when there were no
resources and get an error.

Test: b build //external/libphonenumber/... --config=android
Change-Id: I86f30b993a3ffdb20000f6a4c5261e2c4c74263c
2023-09-08 09:44:00 -04:00
Liz Kammer
65942c8467 Do not convert java libraries with core_platform
Test: go bp2build tests
Change-Id: I2769c0d589c304caeb24a8ecba38a4a5ee6c63e5
2023-09-08 09:43:57 -04:00
Treehugger Robot
8763530dff Merge "android_app APEX_GLOBAL_MIN_SDK_VERSION_OVERRIDE" into main 2023-09-07 16:55:45 +00:00
Cole Faust
1b365e350a Merge "Revert^2 "Only allow setting presigned without preprocessed on targetSdk < 30"" into main 2023-09-07 16:42:08 +00:00
Treehugger Robot
968c735108 Merge "Modify static lib stub library visiblity" into main 2023-09-07 12:07:17 +00:00
Cole Faust
51d7bfd9a1 Revert^2 "Only allow setting presigned without preprocessed on targetSdk < 30"
This reverts commit d293e28f52.

Reason for revert: The underlying issue was fixed in ag/24685010

Change-Id: I06810d37dba37aa12f9a1e14b0749f1e1eb41136
2023-09-07 05:31:32 +00:00
Jihoon Kang
786df93db0 Modify static lib stub library visiblity
java_sdk_library generates stub java_library module which compiles the
stub generated from either source or txt files, which is toggled based
on the build configuration. The java_api_library/java_library module
that compiles the stubs should not be directly accessible to the modules
outside of the sdk_library module scope, thus modify their visibility as
private.

Test: m nothing
Bug: 299373105
Change-Id: Ia4a08bf6e65c521814c82f54ea43cc8d367834e3
2023-09-07 01:22:12 +00:00
Karl Shaffer
d79c10f71f Merge "Revert "Only allow setting presigned without preprocessed on targetSdk < 30"" into main 2023-09-07 00:58:24 +00:00
Karl Shaffer
d293e28f52 Revert "Only allow setting presigned without preprocessed on targetSdk < 30"
This reverts commit 6158528e15.

Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.corp.google.com/builds/quarterdeck?branch=git_udc-d1-dev-plus-aosp&target=aosp_bramble-trunk_staging-userdebug&lkgb=10771573&lkbb=10771600&fkbb=10771587, bug https://buganizer.corp.google.com/issues/299369971

BUG: 299369971

Change-Id: I6bf6eb5c0fb9e30197e145121adc7ed58871526f
2023-09-07 00:51:09 +00:00
Cole Faust
9c5c09f0ad Error out if skip_preprocessed_apk_checks is set when it's not necessary
So that we don't erroneously add skip_preprocessed_apk_checks
everywhere.

Bug: 185811447
Test: Presubmits
Change-Id: Icb1c6163d170ca4181c5c6a814b51fda4777746f
2023-09-06 16:11:44 -07:00
Cole Faust
2f681324c2 Merge "Only allow setting presigned without preprocessed on targetSdk < 30" into main 2023-09-06 21:00:15 +00:00
Sam Delmerico
0e0d96efa7 android_app APEX_GLOBAL_MIN_SDK_VERSION_OVERRIDE
Currently the product variable that is controlled by
APEX_GLOBAL_MIN_SDK_VERSION_OVERRIDE only overrides apexes, but it
doesn't apply to android_apps. This commit allows android_apps which set
updatable: true in their Android.bp to have their min_sdk_version be
overriden by this product variable.

Bug: 295311875
Test: go test
Change-Id: If3cb82a17cae4553b577dd1a4637ee13c3c95302
2023-09-05 21:38:16 +00:00
Romain Jobredeaux
765beb237a Merge "Bp2build support for app R8-related fields" into main 2023-08-31 18:54:49 +00:00
Treehugger Robot
c09e38de00 Merge "Remove unnecessary options when generating stubs from signatures" into main 2023-08-31 09:45:30 +00:00
Paul Duffin
336b16a325 Remove unnecessary options when generating stubs from signatures
These options are unnecessary because:
* `--format` and `--api-overloaded-method-order` only affects the
  generation of signature files which this does not do.

Also changed the build rule description to differentiate from the
usual metalava command to make it easier to find in the ninja file.

Bug: 296115567
Test: m --build-from-text-stub
Change-Id: I7986cba00c364282ddc436d2e69bfb66eda46436
2023-08-31 08:07:26 +01:00
Romain Jobredeaux
9973ace1c7 Bp2build support for app R8-related fields
Bug: 293304784
Test: CI
Change-Id: I0aefa57f968cb41e50d7c1d29b2d8a1480655355
2023-08-31 01:35:44 -04:00
Liz Kammer
f236cd9247 Merge "Add do not convert for sdk_version unset" into main 2023-08-30 16:59:50 +00:00
Jared Duke
2860cf1bc8 Merge "Reland "Enable R8 full mode by default for apps"" into main 2023-08-30 16:03:18 +00:00
Liz Kammer
02914408de Add do not convert for sdk_version unset
When sdk_version is unset, the build with fail with Bazel because
private APIs are do not build with Bazel at this time.

This instead prevents migrating the relevant target to Bazel in bp2build

Test: go tests
Change-Id: I31dabcf143de7933706d1b734ef21467a01b65e9
2023-08-29 20:06:48 -04:00
Cole Faust
6158528e15 Only allow setting presigned without preprocessed on targetSdk < 30
When targetSdk is >= 30, the system verifies that you use a valid
signature V2+ certificate. Uncompressing ndk/dex files or aligning
the zip file will break a signature V2, so these apks should really
just set preprocessed: true.

Fixes: 185811447
Test: Presubmits
Change-Id: Id89c42bcd5b5daa6eda1716bff4023423298036b
2023-08-29 11:18:44 -07:00
Jared Duke
aa88b3d020 Reland "Enable R8 full mode by default for apps"
This is attempt 4 at landing this change. Prior attempts were
reverted due to downstream test breakages not in presubmit.
Those issues have been resolved, and additional manual heavy
presubmit tests were run to ensure stability.

Observed APK savings: ~24MB

This reverts commit 74a5c2ec76.

Reason for revert: Fixed ManagedProvisioningTests

Bug: 215530220
Change-Id: I223228a345fa1a3bad52fb3e91c744107e04fc07
2023-08-29 17:07:20 +00:00
Todd Lee
5b6d1d87d6 Merge "Support for incremetal platform prebuilt APIs" into main 2023-08-28 18:42:58 +00:00
Mark White
387a658e2d Created empty framework-location non-updatable module
Bug: 289776578
Test: presubmit
Change-Id: Iebc6d016b8313759ac1f6f3ab6f4834f5ad7b93e
Merged-In: Iebc6d016b8313759ac1f6f3ab6f4834f5ad7b93e
2023-08-28 17:45:30 +00:00
Treehugger Robot
7eb6ffc796 Merge changes from topic "java-proto-include-dir" into main
* changes:
  Handle proto.include_dirs for java
  Translate python_libray.pkg_path to proto.import_prefix
2023-08-28 17:18:29 +00:00
Alix Espino
5dbb696c53 Merge "support for multiple filegroups and resource_dirs" into main 2023-08-28 17:10:13 +00:00
Treehugger Robot
01f70e8d0e Merge "Add aconfig annotations for java_aconfig_library" into main 2023-08-28 13:03:56 +00:00
Ian Zerny
f94c8113a3 Merge "Translate SDK level 10000 to a valid compiler min-api" into main 2023-08-28 06:26:36 +00:00
Joe Onorato
8f75585b37 Add aconfig annotations for java_aconfig_library
Test: m
Bug: 289087078
Change-Id: I860b91f984b2f2c596360490337fb25a4df7a988
2023-08-26 08:26:18 -07:00
Todd Lee
2ec7e1c55c Support for incremetal platform prebuilt APIs
This change provides support for prebuilt incremental platform API (i.e.
API changes associated with a QPR, as opposed to a major dessert
releas).

This feature is provided via the existing prebuilt_apis module with the
introduction of a new attribute:

    allow_incremental_platform_api

While typical platform prebuilt APIs are presumed to be under a
directory structure that follows the pattern:

<version>/<scope>/<module>.jar
<version>/<scope>/api/<module>.txt

Where <version> is limited to a single integer signifying the API level.

For modules where allow_incremental_platform_api is set to 'true' (false
by default) the pattern is the same, however <version> is presumed to be
of the form MM.m, where MM aligns with the existing API level and m
signifies the incremental release (e.g. QPR).

Bug: b/280790094
Test: platform build check with both incremental & non-incremental API
      cd build/soong && go test ./java
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:eee6995093485497bc29cdce01c2a86765ffb4eb)
Change-Id: I67e293006ccfa210d0dcc0a294db894632f1b6cb
2023-08-25 18:03:44 +00:00
Alix
289e9c607b support for multiple filegroups and resource_dirs
Test: tests in bp2build and b build //external/emma:emma

Change-Id: I57e60389aec926c55d01818a6a3b1ec33e9c53b8
2023-08-25 16:12:15 +00:00
Ian Zerny
c26029b473 Translate SDK level 10000 to a valid compiler min-api
Targets with the special level 10000 are compiled using the current
platform SDK level. They are also compiled as a "platform build" which
will disable features such as API modeling and method backports.

Bug: 295591477
Test: manual inspection of the updated build commands
Change-Id: Ifda8859396b33dde4c46a9b212ddb855b012bf07
2023-08-25 13:48:21 +02:00
Spandan Das
e8a90c57e0 Handle proto.include_dirs for java
The proto_library(s) created for include_dirs will be added to
transitive_deps

This also fixes an existing bug for java_library containing .protos in
srcs via filegroups.
```
java_library {
  name: "foo",
  srcs: ["foo.proto", "foo_filegroup"],
}
```

At ToT, foo_filegroup was missing from the equivalent proto_library in
bp2build workspace.

Bug: 285140726
Test: allowlisted pandora-proto-java and built that
Change-Id: I2657d8cdef2e47434bc3e0d09a074c8e27299afc
2023-08-24 19:21:10 +00:00
Mark White
03fe33ad1c Merge "java_library support for building headers-only" into main 2023-08-23 15:03:21 +00:00
Mark White
a15790ac1e java_library support for building headers-only
Flag for java_library modules to build just the Turbine headers and
skip building an impl jar.

Test: go test java
Bug: 289776578
Change-Id: Iad0babf951710476bc32df93c25d17065a14ab84
2023-08-22 21:29:05 +00:00
Joe Onorato
9e3716caea Allow generated java libs to specify libraries.
Not having them before was just being conservative, and now libs at
least is needed.

Bug: 293195086
Test: m
Change-Id: Ieaa66d11fc983751fd302a21e17802748a535fa7
2023-08-20 07:41:31 -07:00
Joe Onorato
ffac9be887 Allow access to the generated srcjars for GeneratedJavaLibrary
Bug: 293195086
Test: m
Change-Id: I42cf0238241314376f5fe0091cde9bef196f4b9d
2023-08-20 07:41:17 -07:00
Treehugger Robot
b4cd93ccc0 Merge "export_proguard_spec for libs deps" into main 2023-08-18 18:17:19 +00:00
Sam Delmerico
95d709402a export_proguard_spec for libs deps
Add a property to export proguard flags files for libs dependencies.
Currently only proguard flags files from static deps are propagated up
to reverse dependencies, but it is necessary sometimes to have flags
from libs dependencies also be propagated.

Bug: 289087274
Test: go test ./java
Change-Id: Ic0aa22b086792bf322041aa5780db6c4f4eb2770
2023-08-18 15:43:56 +00:00
Treehugger Robot
cc259040b5 Merge "Revert "Revert "Move from-text stub java_api_library modules clo..."" into main 2023-08-17 23:50:00 +00:00
Jihoon Kang
b281ddc8a2 Revert "Revert "Move from-text stub java_api_library modules clo..."
Revert submission 2713677-revert-2655262-move_java_api_libraries-JTESUMBERD

Reason for revert: Initial revert was created to resolve build breakage, but the breakage was caused because not all CLs included in the topic were being included in the build, and was not a problem of the CLs itself.

Reverted changes: /q/submissionid:2713677-revert-2655262-move_java_api_libraries-JTESUMBERD

Merged-In: If66b5bba719bb389a69f2353d2218a89b2b96b90
Change-Id: I879c9d3fb7427cfeff45fff423d4d536548e766f
2023-08-17 20:51:46 +00:00
Romain Jobredeaux
491fa2fe50 Merge "Support asset_dirs property in bp2build for android_{app,library}" into main 2023-08-17 17:43:18 +00:00
Romain Jobredeaux
7a71e07040 Support asset_dirs property in bp2build for android_{app,library}
Bug: 276928228
Test: Unit Tests
Change-Id: I6a2899de21e046e54cd0cd71314bf7aec4a470f6
2023-08-17 10:18:55 -04:00
Jihoon Kang
4434b7132c Revert "Move from-text stub java_api_library modules closer to s..."
Revert submission 2655262-move_java_api_libraries

Reason for revert: Breaking build

Reverted changes: /q/submissionid:2655262-move_java_api_libraries

Change-Id: I2719de4d35e5a4131468d7e84b369631ec86eb2b
2023-08-17 01:26:23 +00:00
Jihoon Kang
b6ec2c8ea0 Move from-text stub java_api_library modules closer to source
This change moves java_api_library modules that were previously defined
in build/orchestrator closer to where their from-source equivalents are
defined.

Test: m (default to from-text stub build)
Bug: 274805756
Merged-In: If66b5bba719bb389a69f2353d2218a89b2b96b90
Change-Id: If66b5bba719bb389a69f2353d2218a89b2b96b90
2023-08-16 22:12:11 +00:00
Jihoon Kang
e7ee256746 Stop sdk_library generated api_library to depend on full surface api_library
Since full_api_surface_libs extract class files instead of srcjar file,
full_api_surface_stub can be replace with android_*_stubs_current,
instead of the api_library android_*_stubs_current.from-text.
Functionally, the class files of the two modules are identical (in
from-text stub build), but depending on the from-text java_api_library
leads to missing dependency errors in partial branches (especially ART
branches). To resolve this problem, make sdk_library generated
api_library depend on the missing dependency handled
android_*_stubs_current.

Since android_module_lib_stubs_current.from-text does not have its
from-source equivalent, this can remain as dependency as the module is
moved to build/soong in aosp/2674196

Test: m (default to from-text stub build)
Bug: 274805756
Change-Id: Ic8bbd25252e5f9f1dc7c059ce6b00a951188985d
2023-08-14 21:18:13 +00:00
Jihoon Kang
862da6f233 Add previous_api property to java_api_library module
`Previous_api` is used to migrate nullness information in metalava (i.e.
convert @Nullable and @NonNull to @RecentlyNullable and @RecentlyNonNull
for some methods). The input is required to generate loosely equivalent
from-text stubs.

Test: m && compare nullness annotations between from-source stubs and from-text stubs
Bug: 293962901
Change-Id: Ic7a0868415fdb2c65d0d472e527fe73280b7651d
2023-08-14 17:18:40 +00:00
Jihoon Kang
0c705a448f Convert additional sdk_library stub libraries to from stub generation
legacy.i18n.module.platform.api, stable.i18n.module.platform.api and
conscrypt.module.platform.api contributes to api surfaces, but the
corresponding stub libraries were being generated from source during
from-text stub build. This discrepancy may lead to hiddenapi failure.
Thus, enable these modules to be built from txt files during from-text
stub build.

Test: m
Bug: 274805756
Change-Id: I940dc8484b210bb8aea57ead1055983be7cdf5ec
2023-08-14 17:17:48 +00:00
Paul Duffin
64876012de Merge "Pass the current API file to the metalava --use-same-format-as option" into main 2023-08-12 13:27:37 +00:00
Jihoon Kang
478ca5b79e Move scopeOrderedSourceFileNames as outside var
This change enables scopeOrderedSourceFileNames to be not computed
everytime when the function is called, but instead is computed once.

Test: m
Bug: 295429988
Change-Id: I33846cdb7a750e44e45049dbd342aa6ab8b70c4c
2023-08-11 23:36:11 +00:00
Paul Duffin
10a23c29e2 Pass the current API file to the metalava --use-same-format-as option
That will allow the format of a file to be changed by simply modifying
the signature format in the current API file (e.g. from `2.0` to `3.0`)
and then running `m update-api` and it will just update the current API
file (and the corresponding removed API file).

Bug: 295577788
Test: m checkapi && m update-api
      # Also did as described above and modified the
      # `libcore/api/current.txt` file from `2.0` to `3.0` and ran
      # `m update-api` and checked that only that file and the
      # corresponding `removed.text` file was changed.
Change-Id: I20c9bc151677502cf09b0c06fb442fd385caccdd
2023-08-12 00:06:42 +01:00
Jihoon Kang
84473f55d7 Sort api files by api scope in java_api_library
Recent changes in metalava (aosp/2704325) enforces api files passed as
inputs to generate stubs from txt to be sorted in the order from the
narrower api scope to the wider api scope. In order to comply with this
change, all api files passed as inputs to metalava invocations need to
be sorted in the respective order.

Test: m out/soong/.intermediates/packages/modules/IPsec/tests/cts/CtsIkeTestCases/android_common/e10894d3da5db41239526c9048962355/javac/CtsIkeTestCases.jar --build-from-text-stub --skip-soong-tests (Failing module from incorrect class hierarchy when building from text stub)
Bug: 295429988
Change-Id: I1eb1f4bf8fa34fd7dc8a0e4c04aa056258a975c5
2023-08-11 22:58:54 +00:00
Paul Duffin
f8aaaa13f4 Replace -bootclasspath and -classpath metalava options with --classpath
Metalava has not differentiated between bootclasspath and classpath for
years so this change replaces the use of the two deprecated single
hyphen options with `--classpath`.

Bug: 295136054
Test: m checkapi
Change-Id: I3ab20b76a60cab66a27784b7d87a069813d19835
2023-08-10 15:16:35 +01:00
Treehugger Robot
18801036c7 Merge "Stop using single-hyphen metalava options" into main 2023-08-09 14:35:40 +00:00
Paul Duffin
808211e519 Stop using single-hyphen metalava options
`-encoding` and `-source` have been deprecated in metalava.

`-encoding` actually does nothing apart from check to make sure that
the value is `utf-8` (in some case). Metalava always uses `utf-8`.

`-source` has been deprecated in favor of `--java-source` as metalava
also can consume kotlin and it has its own `--kotlin-source` option.

Bug: 295136054
Test: ./gradlew
Change-Id: I08e6931958f40022d65d417360e32b72a1d70444
2023-08-09 12:38:46 +01:00
Colin Cross
002764c8ee Merge "Don't generate aapt2 srcjars when using resource processor" into main 2023-08-08 18:57:02 +00:00
Liz Kammer
7f375869ab Add unconverted reason for jarjar incompatibility.
Test: m bp2build
Change-Id: I112b84fa53f57b9df2bd1e1616012fe55b48001e
2023-08-04 16:39:57 -04:00
Colin Cross
bd6294cc9c Merge "Downgrade newly failing lint checks" into main 2023-08-04 16:50:08 +00:00
Colin Cross
482ccfab04 Merge "Delete aapt2 generated java files after creating srcjars" into main 2023-08-03 18:57:24 +00:00
Colin Cross
f3b7bada56 Don't generate aapt2 srcjars when using resource processor
When using resource processor the R.class files are generated
directly, and the R.java files generated by aapt2 are unused.  These
files can huge, reaching 500 MB for some modules and 76 GB across
all modules for a checkbuild on internal main.  They will be deleted
after zipping into srcjars after Ie5143e1e4b36ca1f4e45b001d79aca5379063517,
but we can skip generating them completely for modules where resource
processor is used.

Bug: 284023594
Bug: 294285775
Test: m checkbuild
Change-Id: If5e3fd1d25c6c7860898776ecdd392be8850c17c
2023-08-02 21:50:38 -07:00
Colin Cross
3b1e71c958 Delete aapt2 generated java files after creating srcjars
The R.java files generated by aapt2 are unused after they are zipped
into srcjars.  These files can huge, reaching 500 MB for some modules
and 76 GB across all modules for a checkbuild on internal main.
Delete the R.java files after after zipping them into srcjars.

Bug: 294285775
Test: m checkbuild
Change-Id: Ie5143e1e4b36ca1f4e45b001d79aca5379063517
2023-08-02 21:50:37 -07:00
Colin Cross
9fa43ad2e3 Downgrade newly failing lint checks
Downgrade new lint checks that are failing to warnings.

Bug: 294098365
Test: treehugger
Change-Id: If236199b22c31d95acbffaefee569c806ef0018d
2023-08-03 00:57:41 +00:00
Roy Luo
2631bcd34e Merge "Revert "Reland "Enable R8 full mode by default for apps""" into main 2023-08-03 00:00:25 +00:00
Roy Luo
74a5c2ec76 Revert "Reland "Enable R8 full mode by default for apps""
This reverts commit a9f5c57b90.

Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.corp.google.com/test_investigate/?invocationId=I59400010184068138&testResultId=TR41428835561759069&tab=trace, bug b/294287299

Bug:294287299
Change-Id: Id7bbe3b1a4cdc999c6a4cb9002b60c882b34f11e
2023-08-02 23:56:46 +00:00
Treehugger Robot
cfe9e6d008 Merge "Reland "Enable R8 full mode by default for apps"" into main 2023-08-02 21:38:29 +00:00
Treehugger Robot
a7c5278fbe Merge "Ensure extracted JNIs are stored properly in APKs" into main 2023-07-31 22:47:05 +00:00
Jared Duke
a9f5c57b90 Reland "Enable R8 full mode by default for apps"
This is attempt 3 at landing this change. Prior attempts were
reverted due to downstream test breakages not in presubmit.
Those issues have been resolved, and additional manual heavy
presubmit tests were run to ensure stability.

Observed APK savings: ~24MB

This reverts commit a2ab93666d.

Reason for revert: Fixed SdkSandboxManagerTest by preserving
existing R8 compat mode for the aosp variant of SdkSandbox target.

Bug: 215530220
Bug: 293177283
Test: atest SdkSandboxManagerTests && \
      atest SdkSandboxStorageHostTest && \
      atest SdkSandboxLifecycleHostTest

Change-Id: If5636638875b6f67e0cc0ba4fd253a8d99d8db1d
2023-07-31 22:11:00 +00:00
Luca Stefani
813de60e00 Ensure extracted JNIs are stored properly in APKs
If the android_app has the use_embedded_native_libs flag
all its JNIs must be stored with the store compression method.

The logic to add JNIs from ARR is as follows:
1) Extract JNI libs from AAR
2) Store JNI libs with deflate
3) Merge deflated JNI libs with APK

This process produces a bogus APK that won't be loaded by the
framework if the use_embedded_native_libs is set as the resulting
APK will have all its merged entries stored as deflate.

To solve the problem in case we merge JNIs with an app requiring
uncompressed JNI we add an extra step to ensure they're compressed
using the store method.

Test: m, verify apk using jni_extract has stored libs
Change-Id: Ic31d47f15412171b5898dd0e2a554cb6bf93293b
2023-07-31 21:16:18 +02:00
Romain Jobredeaux
6553cf54fb Merge "Enable from-source vs from-text toggling for core.module_lib.stubs." into main 2023-07-31 13:19:25 +00:00
Pratyush
d938f83be1 Merge "Disable Hidden API Checks for ENG Builds" into main 2023-07-30 13:57:36 +00:00
Pratyush
faec4db56f Disable Hidden API Checks for ENG Builds
For more discussions/details, please check internal CL ag/24145146

Bug: 289409213
BUg: 285976182
Test: Look for hiddenapi calls in build trace
Change-Id: Ia2780ee419b8da1418ba1c7a7d732712b7c2a322
2023-07-30 13:57:10 +00:00
Romain Jobredeaux
9d54fdac3d Enable from-source vs from-text toggling for core.module_lib.stubs.
Also fix a typo in legacy core for system modules

Change-Id: I0b3bb04773d7ee616b94252711053d5be396b84a
2023-07-28 16:02:12 -04:00
Colin Cross
61bf9ef31e Merge "Delete the javac/classes directory after zipping it" into main 2023-07-28 16:18:31 +00:00
Colin Cross
b3168bac7f Avoid extra copy of JNI libs zip
Don't call merge_zips if there are no prebuilt JNI libraries to
merge with.

Test: builds
Change-Id: Ife5386fbbfcff35bdea2914519a78dfd89163a25
2023-07-27 08:09:37 -07:00
Colin Cross
49889c088b Delete the javac/classes directory after zipping it
javac produces a directory containing class files, which is then zipped
with soong_zip into a jar file.  The class files are never used outside
of the rule, so delete them after zipping them.  This should save 19 GB
of disk space in checkbuilds.

Do the same for kotlinc/classes directories for consistency.

Bug: 293352015
Test: treehugger
Change-Id: Id1e889cfbee47eab552a5bb27134fa4b3b4c4d14
2023-07-27 14:57:45 +00:00
Liz Kammer
c796de83c8 Merge "Handle xsd config more like other partitions" into main 2023-07-26 19:18:52 +00:00
Treehugger Robot
06c246c1af Merge "Revert "Enable R8 full mode by default for apps"""" into main 2023-07-26 00:42:06 +00:00
Treehugger Robot
245482e039 Merge "Move android_library resource handling to Bazel's ResourceProcessorBusyBox" into main 2023-07-26 00:34:57 +00:00
Jared Duke
a2ab93666d Revert "Enable R8 full mode by default for apps"""
This reverts commit 5d3ec54b6b.

Reason for revert: Breaks a SdkSandboxManagerTest

Change-Id: I30c03d70a2b683f663b00866035ebf56339a4b0b
2023-07-25 21:37:17 +00:00
Colin Cross
4eae06dcc9 Move android_library resource handling to Bazel's ResourceProcessorBusyBox
The R.Java files generated by aapt2 link --no-static-lib-packages
cause scaling problems by combining all resources into every package
listed in a dependencies' AndroidManifest.xml file.  For SystemUI-core
this results in 74 R.java files, each with 76k lines, and takes 20
seconds to compile in javac.

Both AGP and Bazel have workarounds for this that avoid using the
R.java files generated by aapt2, instead generating more efficient
R.class files directly based on the R.txt file.

Bazel uses the ResourceProcessorBusyBox tool that is already present
in our tree to process the resources.  Reuse the same tool in Soong
to create the R.jar.

The more efficient R.class files require modifiying source files
that use incorrect packages to refer to resources.

Bug: 284023594
Test: TestAndroidResourceProcessor
Change-Id: I026073b40dabcfdb10e5d7a52e9348205b0e9a66
Merged-In: I026073b40dabcfdb10e5d7a52e9348205b0e9a66
2023-07-25 21:30:21 +00:00
Treehugger Robot
5ad5c918a3 Merge "Revert "Revert "Enable R8 full mode by default for apps""" into main 2023-07-25 20:22:01 +00:00
Liz Kammer
5f5dbaad65 Handle xsd config more like other partitions
This is prep work to add additional special handling for genrule
generated headers as there will be similar partitioning for those
headers.

Test: go test soong tests
Change-Id: Ib63e7e4f7554b2b7b7bc78b2825b20c05403216a
2023-07-24 13:01:22 -04:00
Treehugger Robot
ed89d33fb1 Merge changes I69f80d12,I40d48644 into main
* changes:
  Merge META-INF/services/* files in merge_zips -jar
  Strip META-INF/services from implementation jars when using as header jars
2023-07-24 14:27:25 +00:00
Zi Wang
8348ce92f5 Merge "java_test macro needs srcs and deps to create .jar for tradefed_test_suite" into main 2023-07-21 20:48:13 +00:00
Treehugger Robot
8bad43ad53 Merge "Track transitive usage of aconfig flags and add LOCAL_ACONFIG_FILES to Android-<product>.mk" into main 2023-07-21 14:34:44 +00:00
Treehugger Robot
9064761816 Merge "Relax preprocessed apk check for non-privileged apps" into main 2023-07-21 03:47:42 +00:00
Cole Faust
93b89b4110 Relax preprocessed apk check for non-privileged apps
Non-priviledged apps can have compressed dex files.
See go/gms-uncompressed-jni-slides

Bug: 185811447
Test: Presubmits
Change-Id: I14f70fb9286bce132e451a0c930333455517cdc3
2023-07-20 17:57:33 -07:00
Jared Duke
5d3ec54b6b Revert "Revert "Enable R8 full mode by default for apps""
This reverts commit ba283992ef.

Reason for revert: Resolved associated test/build failures

Bug: 215530220
Test: atest BluetoothInstrumentationTests
Test: atest RkpdAppGoogleUnitTests
Change-Id: I27ad6a4f910fa8d48a3dc122c7542f8d7667de5a
2023-07-20 23:29:41 +00:00
Joe Onorato
6fe59eb7f0 Track transitive usage of aconfig flags and add LOCAL_ACONFIG_FILES to Android-<product>.mk
Bug: 283910439
Test: m nothing (runs soong tests)
Change-Id: I59f9bef7b7c502565d531a5685c002a177e0a77c
2023-07-20 11:33:06 -07:00
LaMont Jones
feff3f3f99 Enable restat for javac rules
Bug: 280820245
Test: presubmit
Change-Id: I315fb864f8df3d749fa1545b6e59ee37f8f5ec18
2023-07-20 18:28:54 +00:00
Colin Cross
f06d8dc8e3 Strip META-INF/services from implementation jars when using as header jars
If a header jar couldn't be built (for example when an API generating
annoation processor is in use) the implementation jar is reused as the
header jar.  If the implementation jar contains an annotation processor
listed in META-INF/services/javax.annotation.processing.Processor then
later javac executions with the implementation jar in the classpath
could attempt to run the annotation processors unexpectedly.  Remove
the META-INF/services directory when using an implementation jar as
a header jar.

Bug: 290933559
Test: builds
Change-Id: I40d48644bc5a09a9564dc2c4b38f627edd00fcf8
2023-07-19 21:48:11 +00:00
Sam Delmerico
cfcd0a4960 Merge "make android.InList generic" into main 2023-07-19 15:02:56 +00:00
Sam Delmerico
1717b3bb7a make android.InList generic
Change-Id: Ic166216cb473371a5e34cd97a068ca35f5534740
2023-07-18 15:07:24 -04:00
Jihoon Kang
ef5d8278be Merge "Fix stem to be propagated to output jar name in java_library" into main 2023-07-18 18:26:36 +00:00
Zi Wang
7873f613c4 java_test macro needs srcs and deps to create .jar for tradefed_test_suite
Test: java_test_host_conversion_test.go and TH

Bug: 280452825
Change-Id: Ibf0c7eed415fc58a4d228f0347ab125fdc4466e4
2023-07-17 16:39:07 -07:00
Colin Cross
adb892c539 Merge changes Ied0a6cfe,I8c025efe into main
* changes:
  Reland: Use depsets for transitive manifests and assets
  Add test for manifest merger
2023-07-17 16:30:55 +00:00
Alix Espino
2a779ea829 Merge changes from topics "errProne_bp2build_manually_enabled", "error_prone_config" into main
* changes:
  Bp2build for errorprone modules that manually enabled/disabled it
  Make errorprone a configurable attribute for bazel conversion
2023-07-17 13:54:50 +00:00
Jihoon Kang
1bfb6f231e Fix stem to be propagated to output jar name in java_library
Currently, java_library.stem property is not correctly reflected in the
output jar name in java_library when the module specifies
java_resource_dirs property. This change fixes the unexpected behavior
so that setting the stem property behaves as expected.

Test: go test ./java && m
Bug: 285843207
Change-Id: I0941fcea83c92f4c42ae415aa6ad9125da5cf57b
2023-07-14 21:41:46 +00:00
Colin Cross
ab8d138d42 Reland: Use depsets for transitive manifests and assets
Instead of rolling assets and manifests up through each static lib,
provide them as a DepSet.  This will help with the next patch, which
needs to pass all the transitive manifests and R.txt files together.

This relands Id8b3aa2bed3771e82ab6bde192c9b43baa38b54c with a fix
to include additional manifests from dependencies in the final
manifest merger.

Test: app_test.go
Test: TestManifestMerger
Change-Id: Ied0a6cfee2f18e87188db145b9411d4a903ab6c9
2023-07-14 11:26:43 -07:00
Colin Cross
02bccdf37c Add test for manifest merger
Add a test for the manifest merger command line that would have prevented
b/291252863.

Bug: 291252863
Test: TestManifestMerger
Change-Id: I8c025efe7ccb06ad97b405e2927a4df07f9d3f27
2023-07-14 11:24:54 -07:00
Colin Cross
0a30ce7c4b Merge "Revert "Use depsets for transitive manifests and assets"" into main 2023-07-14 16:10:31 +00:00
Colin Cross
d8c711f884 Revert "Use depsets for transitive manifests and assets"
This reverts commit 4c90f99cb3.

Reason for revert: b/291252863

Change-Id: I646b039a305a1297167e0c56b0bce0f541da260d
2023-07-14 15:52:41 +00:00
Jiakai Zhang
a1140990a1 Merge changes from topics "art-boot-image-jars", "configured-jar-location-overrides" into main
* changes:
  Add a Make variable to determine ART boot image jars for testing.
  Add a Make variable that overrides configured jar locations.
  Refactor dexpreopt for boot jars to make it flexible to config changes.
2023-07-14 11:47:59 +00:00
Jiakai Zhang
556bdf8e96 Add a Make variable to determine ART boot image jars for testing.
Bug: 290583827
Test: m nothing
Change-Id: I6eb0c83dd14682905ebaf3af55171856300eb2e3
2023-07-14 12:13:30 +01:00
Jiakai Zhang
4d90da29a8 Add a Make variable that overrides configured jar locations.
We had hardcoded logic to override "framework-minus-apex", but we need
to override more jars, so this CL adds a general solution for this.

Bug: 290583827
Test: m nothing
Change-Id: I211ebda7aa2803886ab6e6d081d26327665e49a6
2023-07-14 12:13:30 +01:00
Jiakai Zhang
cb13b5d1bd Refactor dexpreopt for boot jars to make it flexible to config changes.
In the past, dexpreopt for boot jars was very inflexible, and it was
incredibly hard to make a change that is as simple as adding a jar to a
boot image. Boot image generation was handled by
"platform_bootclasspath" and "bootclasspath_fragment" separately. This
caused not only code duplication but also the inflexiblity as such a
design did not fit today's use cases, where a boot image may take jars
from multiple mainline modules and the platform, and a mainline module
can contribute to multiple boot images. The design casued a huge
maintenance burden as any change to the boot image cost multi-week
efforts.

In recent years, efforts have been made to improve this a bit by a bit.
This change is another step towards making dexpreopt reasonable.

After this change, all boot images are generated by "dex_bootjars",
which is in build/soong and is therefore available on both the full
source tree and the thin manifest (master-art). The change decouples
profile generation/extraction from boot image generation. Profiles for
mainline modules are still handled by "bootclasspath_fragment"
because they need to be packed into APEXes when building mainline
modules and extracted from APEXes whem building the system image from
prebuilt modules. Boot images are not handled by
"bootclasspath_fragment" anymore.

Bug: 290583827
Test: m (all existing tests are still passing)
Test: Manually checked that the boot images are exactly the same as
  before.
Change-Id: Ib5a5f401bee334ffcab5c26618e0c8888b84575a
2023-07-14 12:13:28 +01:00
Alix
b1e5c6a69a Bp2build for errorprone modules that manually enabled/disabled it
Test: go test ./bp2build
Change-Id: Ie60c0959ee9ae8ce86c11a8e85a0bc7592f63df8
2023-07-13 15:50:18 +00:00
Colin Cross
654f176379 Merge "Use depsets for transitive manifests and assets" into main 2023-07-12 21:49:13 +00:00
Vadim Spivak
7a2e48bd36 Merge "AIDEGen: Collect apt generated sources" into main 2023-07-12 21:33:59 +00:00
Vadim Spivak
3c496f00fa AIDEGen: Collect apt generated sources
The Java compiler may generate sources when processing annotations.
These sources are currently not included in the IDE project model, which
results in unresolved symbols when using Hilt and other annotation
processors. These sources are not passed to the Java compiler for
compilation, so they cannot be handled like other Java module sources.

This change archives the generated sources and appends them to the
existing srcjar list in module_bp_java_deps.json.

Test: go test .
Test: Verified that module_bp_java_deps.json contained srcjar entry
Test:   with path/to/android_common/javac/anno.srcjar.
Test: Verified that IntelliJ can resolve generated symbols after
Test:   invoking aidegen.
Change-Id: I6a3011f9140fd25f785178baee0cd6074ad94600
2023-07-12 17:34:39 +00:00
Treehugger Robot
105005bfd4 Merge "Remove metalava --no-banner argument" into main 2023-07-12 17:08:42 +00:00
Mårten Kongstad
bd2624442b Remove metalava --no-banner argument
metalava no longer prints an ASCII banner, and has removed its
--no-banner argument. Update all call sites accordingly.

Test: presubmit
Bug: 286023667
Change-Id: I61cf5f1125dfbd93496e6a59eb1ea62886b32046
2023-07-12 14:07:01 +02:00
Jiakai Zhang
b898c112a2 Merge changes I0918f2fa,I3fc6ff91,I7adc97cb,I674a5fa1,I22c45cbf into main
* changes:
  Change the profile path on host.
  Extract duplicate code to common helper functions.
  Fix dumpOatRules.
  Remove Modules() from BootclasspathFragmentApexContentInfo.
  Fix some tests for dexpreopt and remove unnecessary tests.
2023-07-11 20:59:07 +00:00
Colin Cross
120b55a7ca Merge "Add tests for code that will be affected by resource processor feature" into main 2023-07-11 20:17:05 +00:00
Jiakai Zhang
3444e561dc Change the profile path on host.
This is to decouple profile generation from image configs. A boot image
profile is either for a mainline module or for the platform, which is
orthogonal to boot images.

Bug: 290583827
Test: m nothing
Change-Id: I0918f2fa945a2af1839f1a08ecede331c64d0317
2023-07-11 17:59:24 +01:00
Jiakai Zhang
b1639db53f Extract duplicate code to common helper functions.
Also, fall back to using a default name for the dexpreopt directory if
we are not building for Android.

Bug: 290583827
Test: m nothing
Change-Id: I3fc6ff9142a2dcdf995796f75891b242fe2848d0
2023-07-11 17:59:05 +01:00
Colin Cross
4c90f99cb3 Use depsets for transitive manifests and assets
Instead of rolling assets and manifests up through each static lib,
provide them as a DepSet.  This will help with the next patch, which
needs to pass all the transitive manifests and R.txt files together.

Test: app_test.go
Change-Id: Id8b3aa2bed3771e82ab6bde192c9b43baa38b54c
2023-07-11 09:54:59 -07:00
Jiakai Zhang
da47d3c6f3 Fix dumpOatRules.
This method generates a build rule that runs oatdump for debugging
purposes.

- Pass "--runtime-arg -Xgc:CMC" to oatdump if UFFD GC is enabled.
- Build the phony name from the image name to avoid conflicts when using
  this method for multiple boot images.

Bug: 290583827
Test: m dump-oat-boot
Change-Id: I7adc97cb85b571486b78f173fb80ff7da2c4bfe4
2023-07-11 16:27:01 +01:00
Jiakai Zhang
f7f782c4f1 Remove Modules() from BootclasspathFragmentApexContentInfo.
The Modules() method was for the ART boot image in the ART APEX. It's no
longer needed because we don't install the ART boot image in the ART
APEX anymore.

Bug: 290583827
Test: m nothing
Change-Id: I674a5fa1ed18908413a64129df5947c7d26e638e
2023-07-11 15:29:17 +01:00
Jiakai Zhang
b69e89559f Fix some tests for dexpreopt and remove unnecessary tests.
This CL is to prepare for the changes in http://r.android.com/2652081.
See the description of that CL for the reasons.

Some tests were set up in a fragile way and were easy to be broken when
the implementation changes. This CL is a pure test change that fixes
them.

This CL also removes TestNoUpdatableJarsInBootImage. That test checks
what should go to the ART boot image and what should go to the
platform one, which does not apply today because boot images are not
associated with mainline modules anymore: a boot image may take jars
from multiple mainline modules and the platform, and a mainline module
can contribute to multiple boot images. In practice, we have ART jars in
the platform boot image, and we are going to add core-icu4j and
consrypt to the ART boot image, which is now for testing only.

Bug: 290583827
Test: m nothing
Change-Id: I22c45cbf6f853b030b68edb51197854e9c53a02e
2023-07-11 15:29:12 +01:00
Romain Jobredeaux
aa634fdbdb Merge "Support target and max sdk version in app bp2build." into main 2023-07-11 13:34:29 +00:00
Colin Cross
5780d57a71 Copy imported APKs to output filename
android_app_import and android_test_import modules with processed: true
and skip_preprocessed_apk_checks are used directly from the source tree.
If the source file name doesn t match the module name and the file is
used as test data it can result in the wrong filename being used.  Copy
the source file to an output file with the correct name first.

Bug: 290376750
Test: m CtsAppSecurityHostTestCases
Change-Id: I4a6dd1c5e48db7085ea41035def31f0844948a46
2023-07-10 22:18:01 +00:00
Romain Jobredeaux
496660d38a Support target and max sdk version in app bp2build.
Test: Unit tests + CI
Bug: 285304294
Bug: 280465047
Change-Id: I9bb1b6f9729ad783a43837d77dcf2d02b50ca77e
2023-07-10 11:50:00 -04:00
Colin Cross
5368d0b44a Implement OutputFileProducer for android_app_import and android_test_import
Fixes: 290376750
Test: builds
Change-Id: I5fc3a759462cfd4342b9330ac8978368feee26ca
2023-07-07 18:36:08 +00:00
Colin Cross
ff3ff7f354 Add tests for code that will be affected by resource processor feature
Add a test for the aapt2 resource processing code that will be affected
by the resource processor feature in a subsequent CL.

Test: TestAndroidResourceProcessor
Change-Id: I39712853f7bbfb7963f1b71e234d039d5ccaae53
2023-07-07 10:58:31 -07:00
Treehugger Robot
ece97e5658 Merge "Suppress resourceshrinker stdout in soong" 2023-06-30 23:26:28 +00:00
Nicolas Geoffray
3799533b87 Merge "Don't strip oat files on host." 2023-06-30 10:49:50 +00:00
Jihoon Kang
ca198c2639 Extract class files from dep_api_srcs instead of java files
Currently, stub java files are extracted from srcjar file provided from
dep_api_srcs in java_api_library module generated in java_sdk_library
per api scope. However, compiling the java files may lead to difference
in the content of the generated class files even if the stub java files
are equivalent, as javac may arbitrarily add overridden methods. Thus,
create a stub jar file instead of creating a stub srcjar file and
compiling it, in order to guarantee stub jar files content equivalence
and thus enable hiddenapi during from-text stub build.

Note that this change does not fully resolve differences between the
full api surface csv and the per sdk_library csv. Instead, it removes
the difference caused by methods arbitrarily added by javac.

This change also renames dep_api_srcs to full_api_surface_stubs to be
more intuitive.

Test: rebase on top of aosp/2617274 and `m --build-from-text-stub`
Bug: 275570206
Change-Id: I22b6d56624633681f5c3b000370b5782655c7b8d
2023-06-29 22:43:05 +00:00
Treehugger Robot
da169a1ee3 Merge "Fix FirstUniqueStrings after conversion to generics" 2023-06-29 18:46:20 +00:00
Zi Wang
187aa29056 Merge "Use java_library_host bp2build converter for tradefed_java_library_host" 2023-06-29 18:03:22 +00:00
Nicolas Geoffray
1ad8a13e47 Don't strip oat files on host.
We need the debugging info for perf.

Test: m
Change-Id: Iceaa72d8b1c7d27ea113ca72c8af1174ce6f05ba
2023-06-29 15:45:39 +01:00
Kenneth Ford
ba283992ef Revert "Enable R8 full mode by default for apps"
This reverts commit 93d0bffafe.

Reason for revert: Possible culprit for b/289285719

Change-Id: If818db9d38008ea9d8c7813b9f6fabc2975e8507
2023-06-28 23:29:21 +00:00
Jiakai Zhang
51b2a8b5eb Use per-app package list to avoid unnecessary dexpreopt.
Starting from aosp/2594905, dexpreopt depends on
`$PRODUCT_OUT/product_packages.txt`. When PRODUCT_PACKAGES changes,
dexpreopt has to rerun for all apps. This is not ideal.

After this change, dexpreopt uses a per-app product_packages.txt that is
filtered by the app's dependencies, and it uses `rsync --checksum` to
prevent the file's mtime from being changed if the contents don't change.
This avoids unnecessary dexpreopt reruns.

Bug: 288218403
Test: m
Test: Change PRODUCT_PACKAGES and see no dexpreopt reruns.
Change-Id: I5788a9ee987dfd0abfd7d91cbcef748452290004
2023-06-28 17:59:56 +01:00
Zi Wang
3096e68e64 Use java_library_host bp2build converter for tradefed_java_library_host
Test: presubmit

Bug: 285959156
Change-Id: I18cefd4bf71b674771718411887b140a5d61d3f6
2023-06-27 15:44:10 -07:00
Jared Duke
93d0bffafe Enable R8 full mode by default for apps
This provides significant size savings over the default compatibility
mode, roughly ~20MB in aggregate for a recent Pixel build. Targets can opt out using `proguard_compatibility = true`.

Future work will enable for all targets, not just apps, but this
incremental change yields the most benefit.

Bug: 215530220
Test: m + presubmit
Change-Id: I52a9b27ebe71835849e200e23ae2a250eaf1bbe1
2023-06-27 22:33:58 +00:00
Colin Cross
48016d5a2f Fix FirstUniqueStrings after conversion to generics
The conversion of FirstUniqueStrings to be implemented on top of the
generic firstUnique accidentally used a different threshold to switch
from the list implementation to the map implementation.  Modify the
threshold of firstUnique to match the old value from FirstUniqueStrings
now that it doesn't have the reflection overhead.  While we're at it,
also make firstUnique make a copy of the list, and make FirstUniqueStrings
a pure wrapper around firstUnique.

Test: BenchmarkFirstUniqueStrings
Change-Id: Icc2febea663142c508ff2e4be65a8a68121631d5
2023-06-27 11:07:55 -07:00
Treehugger Robot
a41c679fe1 Merge "Cleanup remaining android.JavaApiLibraryName() references" 2023-06-23 21:35:02 +00:00
Colin Cross
313d32f730 Merge "Use generics for DepSets" 2023-06-22 20:57:01 +00:00
Sam Delmerico
80ee45ccc9 don't compress JNI libs extracted from aar_import
APKs expect JNI libs in the libs folder to be stored uncompressed, so we
should not compress libs that we extract from the AAR.

Bug: 280339573
Test: m AiWallpapers before this change &&
  compare to AiWallpapers with ag/22948656
Change-Id: I63baa3763bc01c74d8df9b0b3e035ea50c31904c
2023-06-22 15:38:46 -04:00
Colin Cross
c85750bfe3 Use generics for DepSets
Use Go's generics for DepSets so they don't require a type-specific
wrapper and reflection.

Test: depsets_test.go
Change-Id: I22ba0b7d680d37d2cd05230b0f560d166c4dd20b
2023-06-22 08:18:33 -07:00
Paul Duffin
c0036491cd Remove reference to the deprecated and disabled Typo issue
Metalava no longer looks for common typos. It relies on the code
analyzers that run on Gerrit to detect them.

Bug: 288072162
Test: m checkapi
Change-Id: I08eca8008af39ebe69442db419ebd3d3378aa0de
2023-06-21 15:42:49 +01:00
Jared Duke
91f32e7ae5 Suppress resourceshrinker stdout in soong
The resourceshrinker command prints an info log for successful runs,
which we don't really need to surface in build output. Suppress stdout
for such invocations; errors will surface through stderr.

Bug: 202959019
Test: m + compare log output
Change-Id: I08ed465bb7e3a0fa8d5e967d858f6739b5ef7fad
2023-06-16 23:12:33 +00:00
Christopher Parsons
df9c3441aa Merge "Provide reason for unconverted bp2build modules" 2023-06-16 13:49:49 +00:00
Chris Parsons
39a169721c Provide reason for unconverted bp2build modules
This also changes the expectation of ConvertWithBp2build. Each
implementation must either create one or more Bazel target modules, or
mark the module as unconvertible (with a specific reason).

Manually verified no runtime hit in AOSP
In AOSP, the metrics file size increases from 252K to 1.6M

This changes some effective module counts in bp2build metrics:
 - Removes "package" modules from the module count list in
metrics, as these will not be converted like regular modules.
 - Counts Handcrafted modules as being "unconverted", as bp2build is not
   responsible for them.

Bug: 285631638
Test: Verified generated BUILD.bazel files are bit-for-bit identical
with this change
Test: Manually verified one case of each implemented reasonType

Change-Id: I308dd451d8f28379b15671dae9f931bd0446f5c1
2023-06-16 13:45:17 +00:00
Treehugger Robot
0e7d0fa05c Merge "Dynamically link static libs for sdk_library created java_library" 2023-06-15 23:39:39 +00:00
Jihoon Kang
6c0df88809 Cleanup remaining android.JavaApiLibraryName() references
Since the name of the java_library generated from sdk_library per api
scope does not depend on the build configuration anymore, all
dependency switching "magic" via android.JavaApiLibraryName() can be
removed.

This change also removes from-text-build-specific test cases, as those
test cases depend on build configurations.

Test: m nothing && m nothing --build-from-text-stub
Bug: 287340610
Change-Id: I3bac35259e0cbaa16432a46cb2b128951c9bc075
2023-06-15 19:42:34 +00:00
Jihoon Kang
1147b31eb0 Dynamically link static libs for sdk_library created java_library
Rename java_library created inside sdk_library with the ".from-source"
suffix, and set it as static lib of the top level java_library, which
gets java_api_library instead as static lib during from-text stub build.

Test: m nothing && m nothing --build-from-text-stub
Bug: 286446015
Change-Id: I32e8ea264987e9f9df05e462292bd54e45074912
2023-06-15 18:18:09 +00:00
Chris Parsons
715c417ba3 Remove print statement
I suspect this was accidentally committed. We shouldn't just printf such
a statement every build analysis.

Test: Presubmits
Change-Id: If5ee66ce1b366f28254cd1bfdcaed9e085a60094
2023-06-14 16:24:37 +00:00
Zi Wang
6a66e3d01e Support multiple filters in zipsync
Also applied this feature to kotlinc since it needs both java and kt files.

Test: local test and presubmits

Bug: 287071909
Change-Id: I28c725b03115aef47055448cb75412980015da15
2023-06-14 06:44:49 +00:00
Sorin Basca
5498faf505 Merge "Revert^2 "Add exports needed for Doclava"" 2023-06-12 14:53:14 +00:00
Joe Onorato
175073c472 Make aconfig flags generate a library instead of a srcjar.
Also add unit tests for the rest of device_config

Bug: 283475679
Test: m nothing (soong unit tests)
Change-Id: Iee18a1f2f2cbb23e8c8d84c54e903b32be29a693
2023-06-09 06:16:06 -07:00
Sorin Basca
a7b777f800 Revert^2 "Add exports needed for Doclava"
a39209b565

Change-Id: Ib7c674e5142d2dff719d14092ac5383b6484d54c
2023-06-09 09:19:36 +00:00
Treehugger Robot
f253d23e95 Merge changes from topic "cc_stem"
* changes:
  Remove modules from denylist
  Update runpath for jni libs
  bp2build support for stem
2023-06-08 22:38:34 +00:00
Himanshu Rawat
4ead3a807d Merge "Revert "Add exports needed for Doclava"" 2023-06-08 16:45:02 +00:00
Himanshu Rawat
a39209b565 Revert "Add exports needed for Doclava"
Revert submission 2615972-b-270335653-doclava-search-imports

Reason for revert: DroidMonitor: Potential culprit for Bug 286398320 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted

Reverted changes: /q/submissionid:2615972-b-270335653-doclava-search-imports

Change-Id: Ibc3bdb301110b564e1427432a1b530e07bb840cd
2023-06-08 16:12:31 +00:00
Treehugger Robot
02761e58a0 Merge "Add exports needed for Doclava" 2023-06-08 15:35:48 +00:00
Jihoon Kang
346a117921 Create bp2build converter for platform_compat_config module type
This change adds bp2build converter for platform_compat_config module
type and its corresponding test case.

Bug: 269202028
Test: bp2build unit tests
Change-Id: I17d560c8f0e725efe69e151685d003c3dcb11f2f
2023-06-06 19:35:36 +00:00
Jihoon Kang
4190764669 Merge changes from topic "android_stubs_current_refactor"
* changes:
  Cleanup android.JavaApiLibraryName references
  Redefine core and core platform API surface java_library
  Introduce product variable Build_from_text_stub
  Introduce "Exclude_static_libs" property for Java modules
2023-06-06 19:16:25 +00:00
Anton Hansson
efd18370b0 Merge "Allow Bluetooth to use privapp_allowlist" 2023-06-06 18:29:07 +00:00
Sorin Basca
23741cac4d Add exports needed for Doclava
Bug: 270335653
Test: m doclava docs dist
Change-Id: Id46c877ddfd64b36f1ee96a7678076af69d91cdb
2023-06-06 09:43:53 +01:00
Spandan Das
5dba0ec98c Update runpath for jni libs
To support stem, cc libraries will be generated in
<pacakge_name>/<label.name>. Update RUNPATH of java binaries so that it
can find its jni deps

Test: bp2build
Test: TH
Bug: 240563612
Change-Id: Ia2f70f0424a8526ee35856225c1a8cd1067a8570
2023-06-06 00:07:40 +00:00
Spandan Das
91a8820688 Merge changes from topics "xsd_config_bp2build_cc_rdeps", "xsd_config_bp2build_java_rdeps"
* changes:
  bp2build for cc libraries that use xsd_config as gen srcs
  bp2build for java libraries using xsd_config srcs
2023-06-05 22:23:37 +00:00
Jihoon Kang
91c839566e Cleanup android.JavaApiLibraryName references
This change cleans up references to android.JavaApiLibraryName() so that
rdeps link against "android_*_stubs_current" instead of
"android_*_stubs_current.from-text".

Bug: 284995489
Test: m
Change-Id: Ibdf33b15981317c43e468dbc1657229d54bbd226
2023-06-05 21:45:01 +00:00
Jihoon Kang
67b6443258 Redefine core and core platform API surface java_library
Redefined core and core platform API surface java_library using the
product variable build_from_text_stub so that the correct static libs
are linked based on build configuration

Test: m --build-from-text-stub and verify no ninja path between "core.current.stubs" and "core.current.stubs.from-source"
Bug: 285410821
Change-Id: I26febc65697be6278624a504ffbb61be0953d798
2023-06-05 21:44:33 +00:00
Jihoon Kang
381c2fa27c Introduce "Exclude_static_libs" property for Java modules
Exclude_static_libs property can be used to specify static libs that
should not be used to build the module. The list acts as filter for
static_libs.

Bug: 285410821
Test: go test ./java
Change-Id: Iee7f160ba88b5f64bdd265c30d47c9f51feb0f5e
2023-06-05 21:42:48 +00:00
Mark Teffeteller
3bc9c57dc4 Merge "Add use_platform_libs to fuzz config" 2023-06-05 14:41:51 +00:00
Anton Hansson
e3f31cfd1e Allow Bluetooth to use privapp_allowlist
Apparently there's some special case-code in package manager that
scans apps as privileged regardless of their location. BT is one
such app -- so allow it to specify a privapp allowlist even though
it isn't in priv-app.

Bug: 284500052
Test: use privapp_allowlist in Bluetooth and its overriddes
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:a91268a690e2aa98a0fa7b376a948a48f41b1265)
Merged-In: Ib9ac86ebc45087a176100fe8df07db7bf81a85a7
Change-Id: Ib9ac86ebc45087a176100fe8df07db7bf81a85a7
2023-06-03 08:53:47 +00:00
Jiakai Zhang
48203e3dee Add an allowlist for modules that have broken optional_uses_libs.
Bug: 282877248
Test: m nothing
Change-Id: I1afe9d523af0633f0428d4c15e1417db1dae4e93
2023-06-02 23:42:53 +01:00
Jiakai Zhang
f508c252bb Merge "Drop INTERNAL_PLATFORM_MISSING_USES_LIBRARIES." 2023-06-02 14:59:10 +00:00
Mark
f736b924db Add use_platform_libs to fuzz config
BUG: b/279082026
TEST: mma <java_fuzz>
Change-Id: Ia3dba44f66ec18d1076f1b13cc654a35b31c02d4
WANT_LGTM=ccross
2023-06-02 14:46:53 +00:00
Treehugger Robot
b25cbb3449 Merge "Support test runnner option in auto generated test configs" 2023-06-02 11:20:23 +00:00
Anton Hansson
672c1467d5 Merge "Change install name of privapp allowlists" 2023-06-02 08:19:21 +00:00
Anton Hansson
0e486a4198 Change install name of privapp allowlists
Use the APK's filename as the on-device filename for the allowlist.
Previously the filename of the source xml file was used, which leads to
a problem when the same source file is used for different apps (even
if only one of those modules ends up being installed).

Bug: 284500052
Test: app_test.go & presubmit boot tests
Change-Id: I0b43a35e3a310464d79d7f37e0900d639f4a479c
2023-06-02 08:18:42 +00:00
Zi Wang
4af4ff33f0 Merge "Add simple bp2build converter for java_test_host" 2023-06-01 22:37:28 +00:00
Paul Duffin
f6b1e23448 Merge "Explicitly specify --api-overloaded-method-order source for metalava" 2023-06-01 22:10:24 +00:00
Spandan Das
370f13c3bd bp2build for java libraries using xsd_config srcs
In Soong, java libraries can use src files generated from xsd_config. In
Bazel, instead of providing srcs, java_xsd_config_library will provide a
jar. Update bp2build so that all src references to xsd_config modules in
srcs get routed to deps and exports attributes

This CL creates an interface in build/soong/android to get around a
circular dependency issue. The bp2build logic needs to exist in
soong-java, but soong-java does have soong-xsdc in its package path. Use
the interface and type assertions to special case xsd_config references

Bug: 211678537
Test: bp2build test in sibling CL in system/tools/xsdc
Change-Id: Ida924bb20b1fd7eb8beeef950b070d37a9c6f3b5
2023-06-01 19:12:12 +00:00
Treehugger Robot
f618c60df6 Merge "Only pass "-Xgc:CMC" when building for Android." 2023-06-01 17:59:45 +00:00
Paul Duffin
7202ffebf9 Explicitly specify --api-overloaded-method-order source for metalava
Previously, `--api-overloaded-method-order source` was the default if
that option was not specified but the other change in this topic is
switching it to `--api-overloaded-method-order signature` to match the
behavior in AndroidX. This change explicitly specifies the option
needed by Soong's use of metalava.

Bug: 285140653
Test: m checkapi
Change-Id: I00e049e0d991e650ab9940a3d495ed2b6e7480f8
2023-06-01 18:45:51 +01:00
Zi Wang
65b36729c3 Add simple bp2build converter for java_test_host
Bug:281551424

Test: java_test_host_conversion_test.go and presubmits
Change-Id: I43ed26df0bacd63ef402de4d9733d19604005c35
2023-06-01 10:37:09 -07:00
Paul Duffin
5b7035f850 Explicitly specify --api-class-resolution api for metalava
Previously, `--api-class-resolution api` was the default if that option
was not specified but the other change in this topic is switching it to
`--api-class-resolution api:classpath` to match the behavior in
AndroidX. This change explicitly specifies the option needed by Soong's
use of metalava.

Bug: 285140653
Test: m checkapi
Change-Id: Ief3c7f9dfdfa946f21cb048a579ec90309fb350f
2023-06-01 15:26:40 +01:00
Jiakai Zhang
4f65a03d30 Drop INTERNAL_PLATFORM_MISSING_USES_LIBRARIES.
Bug: 282877248
Test: Presubmit build tests.
Change-Id: Idd69433f308f5f47973ff0d5340a2399a27cb32c
2023-06-01 15:21:42 +01:00
Jiakai Zhang
225c4767ac Only pass "-Xgc:CMC" when building for Android.
The runtime always uses CC on host unless CMC is explicitly asked
(http://cs/android-internal/art/runtime/gc/collector/mark_compact.cc;l=212-214;rcl=50fe05b4f4650bc0888d2c218a1bfa476f811ea0).
This CL matches the build system behavior with the runtime.

Bug: 285228269
Test: m test-art-host-gtest-art_dex2oat_tests
Change-Id: I652ad6f754ab8c51283e5fb0e9e1ba644629fa11
2023-06-01 13:27:25 +00:00
Jiakai Zhang
5324cc84ad Merge "Move CLC construction to Ninja phase." 2023-05-30 14:58:15 +00:00
Jiakai Zhang
a449678996 Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.

For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.

After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.

Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.

Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
  1. lunch aosp_cf_x86_64_phone-userdebug && m
  2. Check the .invocation file of the "Settings" package (defined in
     .bp file)
  3. See androidx.window.extensions
Test: -
  1. lunch aosp_redfin-userdebug && m
  2. Check the .invocation file of the "Settings" package (defined in
     .bp file)
  3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
  .mk file)
Test: -
  1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
  2. adb shell pm art dump
  3. See "reason=prebuilt" instead of "reason=vdex".
     (https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
     after: right)

Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-30 15:46:38 +01:00