Commit graph

5776 commits

Author SHA1 Message Date
Jared Duke
4e445be558 Revert "Use D8 by default for android_test"
This reverts commit 02edc10047.

Reason for revert: Breaks test_suites_x86_64_coverage

Bug: 233421462
Change-Id: I7b04d3fd7802be0f271ea3c29ef25e3d08ab1389
2022-05-23 04:00:44 +00:00
Jared Duke
02edc10047 Use D8 by default for android_test
android_test defaults to using R8, but with shrinking, optimization and
obfuscation disabled, eliminating most of the benefits of R8. Instead,
use D8 by default, improving build performance and avoiding any other
issues that may arise in test-specific code related to whole-program R8
execution. An initial audit shows that android_test targets that *do*
enable shrinking or optimization also explicitly opt in to R8.

A follow-up CL will do the same for android_test_helper_app, but that
requires some additional auditing of downstream targets.

Bug: 192032291
Test: m + presubmit
Change-Id: I5b14a0986dde210f241a77c3a93daacf9e53d667
2022-05-20 12:02:13 -07:00
Treehugger Robot
be4c7eda08 Merge "Revert "Don't add uses_libs/optional_uses_libs to the manifest_fixer."" 2022-05-04 15:19:37 +00:00
Ulya Trafimovich
f5d91bb3b4 Revert "Don't add uses_libs/optional_uses_libs to the manifest_fixer."
This reverts commit 0b1c70efbc.

The reverted commit was based on the idea that uses-libraries that are
explicitly specified in build files should not be implicitly added to
the manifest, as that would mean that anything added to the build files
will flow to the manifest.

Although this logic is correct, it prevents propagation of
uses-libraries from dependencies, which is wrong: if a library has an
explicit uses-library property in Android.bp, this property is expected
to be propagated to the library's dependencies. Failing to do so would
mean that every user of that library has to add uses-library property to
their build files, which doesn't scale (see b/214255490 for example).

Bug: 214255490
Test: lunch aosp_cf_x86_64_phone-userdebug && m && launch_cvd \
    && adb wait-for-device && adb root \
    && adb logcat | grep -E 'ClassLoaderContext [a-z ]+ mismatch'
    # empty output, no errors at boot
Change-Id: I6f420e76a89aa2f37be99f877711736640f2c361
2022-05-04 12:10:06 +01:00
Paul Duffin
0038a8d374 Prevent non-app/non-test modules from statically including jacocoagent
(cherry picked from commit 3953153c9e)

Previously, the .impl library of java_sdk_library modules would end up
with the jacocoagent statically included. That is because their
Instrument flag was set to true when created by their parent. As that
was before the deps were added that meant that they ended up with a
static dependency on jacoagent (at least when UnbundledBuild() was
true).

That was not previously a problem because the .impl files were only
used at build time. However, a recent change to make updatable-media
statically include framework-media.impl (which statically included the
jacocoagent classes) broke the coverage build because the jacocoagent
classes are not in the permitted packages for the updatable-media.

When instrumenting the bootclasspath the jacocoagent library is added
to the art-bootclasspath-fragment.

The jacocoagent should only be statically included in apps, or test
apps. This change adds an extra flag to specify whether the module type
supports statically including the jacocoagent. This is set to true by
apps and test apps but not when the java_sdk_library creates the .impl
java_library preventing it from statically including jacocoagent.

Bug: 230967146
Bug: 229932396
Test: COVERAGE_MODULES=media \
      PRODUCT=mainline_modules_x86 \
      TARGET_BUILD_APPS=com.google.android.media \
      vendor/google/build/build_unbundled_coverage_mainline_module.sh
      # Fails without this change, passes with it.
Merged-In: Ic95cf11a05f59b67e623474ed3dd9be6b4442c42
Change-Id: Ic95cf11a05f59b67e623474ed3dd9be6b4442c42
2022-05-03 10:11:59 +00:00
Treehugger Robot
6c59cdb5c7 Merge "Add missing dependency on compose plugin in kapt rules" 2022-05-03 02:28:14 +00:00
Colin Cross
08b0a1cd79 Add missing dependency on compose plugin in kapt rules
The kapt rule uses kotlincFlags but was not using kotlincDeps,
causing the rule to get the -Xplugin argument on the compose
compiler plugin jar, but not have a dependency on it.

Bug: 231222079
Test: TestKotlinCompose
Change-Id: I4c2cf30fb7d8cad4eededa29f67f4ffd459caa41
2022-05-02 14:00:50 -07:00
Treehugger Robot
9c60cc4f22 Merge "java_sdk_library_import: Delegate OutputFiles to impl library if needed" 2022-04-29 17:27:23 +00:00
Paul Duffin
1e940d5b44 java_sdk_library_import: Delegate OutputFiles to impl library if needed
Bug: 230846030
Test: m nothing
      # Cherry pick into build with prebuilts enabled to verify.
Change-Id: I5ac9b1cdd2fc61efbc988e84556202ff6cd57146
2022-04-29 14:42:04 +01:00
Paul Duffin
a09d95f605 Merge "hiddenapi: Prevent libraries for Q/R from include S+ flags." 2022-04-29 13:37:35 +00:00
Victor Chang
99666e2720 Merge "Revert "Fix erroneous "Field requires API level 33 (current min is 32)" warnings"" 2022-04-29 10:34:41 +00:00
Nataniel Borges
5d80d895b6 Revert "Fix erroneous "Field requires API level 33 (current min is 32)" warnings"
This reverts commit 8b7f627f30.

Reason for revert: b/230821289

Change-Id: I3032103b174c78586b38b64d2748ec5a42fa9522
2022-04-29 09:49:16 +00:00
Vinh Tran
3ac6daf47c bp2build converts java_version property to javacopts attribute
This CL also converts `external/rappor` (which already set `java_version` to `1.7`) to be bazelable to testify the changes.

Results from `b build //external/rappor && cat bazel-bin/external/rappor/librappor.jar-0.params`: https://paste.googleplex.com/5518725462622208.

Test: go test ./bp2build/...
Bug: 227618664
Change-Id: I8d370d4639f70fba51e6de6ceb7bcb5ace9ccd91
2022-04-28 18:52:48 -04:00
Paul Duffin
fb14b52747 Merge "Allow framework-media to build the framework-media.impl" 2022-04-28 21:10:16 +00:00
Paul Duffin
09817d66de hiddenapi: Prevent libraries for Q/R from include S+ flags.
The Q and R runtimes can handle Q/R flags but not S flags. So, this
change verifies that any library that can run on Q/R
(min_sdk_version <= R) by adding --max-hiddenapi-level=max-target-r
to the "hiddenapi encode" command. That will cause a failure if any
S+ flags are found in the flags to encode.

Bug: 172453495
Test: m droid && launch_cvd
      Cherry pick changes in https://r.android.com/q/topic:max-target-s
      Add @UnsupportedAppUsage maxTargetSdk=S in classes in framework-permission (for r/q)
      and framework-permission-s (nominally for S+). I had to incresed the min_sdk_version
      in the latter to 31 (S) as it was still set at 30 (R).
Change-Id: Ie0f68482603adc7b4e3d7a5c81bf203d81a84a9e
2022-04-28 18:34:48 +01:00
Paul Duffin
77590a8263 Allow framework-media to build the framework-media.impl
The framework-media java_sdk_library is currently api_only for legacy
reasons. This change allows it to also build the framework-media.impl
library by making the following changes:
* Adds impl_only_static_libs to allow the implementation to statically
  include other libraries, something no other java_sdk_library has
  needed to do.
* Passes the apex_availability property through to the impl library so
  it can be statically included in the updatable-media which is what is
  included in the apex, again for legacy reasons.

Bug: 190807367
Bug: 229932396
Test: m com.android.media media-module-sdk
      # Compare before and after this change (and corresponding change
      # to updatable-media/framework-media.
Change-Id: I9e1837edcca6f5fa84fc611274cf8fbba8a896b8
2022-04-28 14:30:14 +00:00
Treehugger Robot
d5a57a5679 Merge "Replace DEX_FLAGS by flags for D8 and R8." 2022-04-28 12:40:13 +00:00
Ulya Trofimovich
a465e28bcb Merge "Remove obsolete dexpreopt config option UseArtImage." 2022-04-28 09:44:21 +00:00
Cole Faust
8b7f627f30 Fix erroneous "Field requires API level 33 (current min is 32)" warnings
Bug: 215567981
Bug: 204776549
Test: m out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/lint/lint-report.xml, then check that that file doesn't have any of these warnings
Change-Id: I39aa2228474630c93250bf5833ac6bd9bbadcc7f
2022-04-27 12:20:08 -07:00
Muhammad Haseeb Ahmad
4e70b7586a Merge "Add jni support to java_fuzz_host" 2022-04-27 16:14:29 +00:00
Treehugger Robot
b3f437ae7b Merge "Deduplicate classLoaderContexts field between two structs." 2022-04-27 14:53:14 +00:00
Ulya Trafimovich
442ec7fc07 Remove obsolete dexpreopt config option UseArtImage.
Bug: 170935728
Test: lunch aosp_cf_x86_64_phone-userdebug && m && lunch_cvd
Change-Id: Id83b9085794fd2ec338077ca909f84e04ccad041
2022-04-27 13:36:47 +01:00
Ulya Trafimovich
12164ded20 Deduplicate classLoaderContexts field between two structs.
This field is provided by the `dexpreopter` struct, which is a part of
`java.Module` and also had an identially named field. This created
confusion when the latter field was not properly copied into the former,
which resulted in not propagating class loader context, e.g. for static
library "androidx.preference_preference". This didn't cause class loader
context mismatch errors at boot previously, because the library didn't
have any uses-library dependencies before a recent prebuilt update.

Bug: 214255490
Test: lunch aosp_cf_x86_64_phone-userdebug && m && launch_cvd \
    && adb wait-for-device && adb root \
    && adb logcat | grep -E 'ClassLoaderContext [a-z ]+ mismatch'
    # empty output, no errors at boot
Change-Id: Ib818c5d2934d28817bb7a04b6114ae8b82a5c04d
2022-04-27 11:59:34 +01:00
Treehugger Robot
7cb3f50fda Merge changes I8ef31373,Ic408857d
* changes:
  Disable newapi check in defaults
  Enforce newapi check only if min_sdk_version < compile_sdk_version
2022-04-27 00:55:56 +00:00
Muhammad Haseeb Ahmad
7e74405b2d Add jni support to java_fuzz_host
Bug: 219782880
Test: m example_java_fuzzer_with_native_lib, go test -run TestJavaFuzz
Change-Id: I1d05fb449e5378a27a0096869d9c12ca0a1245c6
2022-04-26 18:49:02 +00:00
Spandan Das
397e910835 Disable newapi check in defaults
- Making newapi disabled by default will ensure that this lint check
  does not run on the platform. This prevents noisy lint warnings like b/228956345#1
- This lint check will continue to be enforced on the transitive deps of
  apexes, since lint.strict_updatability_linting will be true for those
  Soong modules

Test: TH
Test: m
out/soong/.intermediates/frameworks/base/services/core/services.core.unboosted/android_common/lint/lint-report.xml
// file no longer contains "Call requires API level ..." warning
Bug: 228956345

Change-Id: I8ef3137394011fb679a1129f80f6351fb05a4eff
2022-04-25 18:17:11 +00:00
Spandan Das
ba7e532a11 Enforce newapi check only if min_sdk_version < compile_sdk_version
- NewApi check should be enforced only if min_sdk_version is less than
  the compile_sdk_version (the opposite direction should be a different
  build-time error)
- Change the datatype of *sdkVersion to android.ApiLevel (from string)
  to support version comparisons

Test: go build ./java
Test: no changes in ninja file
Bug: 228956345

Change-Id: Ic408857db7760d912ef4694d2ed72c0b7106eb04
2022-04-25 18:12:50 +00:00
Ian Zerny
727ab9033a Replace DEX_FLAGS by flags for D8 and R8.
This adds the heap space flag currently set in wrappers.

Bug: b/227746536
Test: manual
Change-Id: Ic3cb8feb7a09d690ecd309162236e49a8d1e52c6
2022-04-25 11:17:07 +02:00
Treehugger Robot
224879e794 Merge "Fix error message formatting" 2022-04-23 12:24:08 +00:00
Pedro Loureiro
ea2f5eff5e Fix error message formatting
Test: m nothing

Fixes: 230086179
Change-Id: Ieb6a7de9dcf0c12184c868b5af9af52c7b4bfa5e
2022-04-22 13:53:16 +00:00
Jared Duke
0cf7c9686d Limit JIT tier for D8
Standalone D8 invocations tend to be shorter-lived than R8 invocations
that involve deeper layers of bytecode optimization. Introduce a
separate set of JVM flags to pass to D8 invocations which limit the
runtime JIT tiering, reducing overall compile times and significantly
reducing total CPU consumption for D8 build workloads.

Representative incremental build times with this change:
 * real 6m1.388s
 * user 63m32.412s
and without:
 * real 6m30.624s
 * user 79m12.626s

Bug: 205303544
Test: time m
Change-Id: Ic568a4316325c6a4e0da41ffebbb07f0c5f7e8e3
2022-04-21 18:24:52 +00:00
Vinh Tran
ef4a5a3028 Merge "Update doc for Platform_apis field in DeviceProperties" 2022-04-19 00:14:16 +00:00
Vinh Tran
d91939ee84 Update doc for Platform_apis field in DeviceProperties
The doc for Platform_apis is outdated. The property is used by not only android_app, but also android_test and android_test_helper_app

https://cs.android.com/android/platform/superproject/+/master:build/soong/java/app.go;l=382;bpv=1

Next steps:
1. Clean up existing misuse of Platform_apis and Sdk_version in android_test and android_test_helper_app.

2. Add validation check to ensure proper use of Platform_apis and Sdk_version moving forward android_test and android_test_helper_app.
Currently, android_app already has validation in place. https://cs.android.com/android/platform/superproject/+/master:build/soong/java/app.go;l=275;bpv=1;bpt=1
WIP: https://android-review.googlesource.com/c/platform/build/soong/+/2065270

Test: N/A
Change-Id: I934860cdc8b23268d70e205089118c6451d4cf8a
2022-04-18 19:51:34 +00:00
Yike Zhang
29f5068a1c Merge "Export Java library dependency information" 2022-04-18 04:58:47 +00:00
Yike
f628202aab Export Java library dependency information
Write `static_libs` and `libs` of Java library and Android app modules to module_bp_java_deps.json. This enables downstream tools to correctly set up the runtime environment. Note that while static libraries don't need to be on the Java classpath these modules could have non-static library dependencies that do need to be present.

Test: m out/soong/module_bp_java_deps.json
Bug: 227538646
Change-Id: I7c4aecb2fb03c890f0d2aaae80e619f6176809ef
2022-04-18 10:23:28 +08:00
Vinh Tran
62a2fd93de Merge "Update doc for DeviceProperties's Sdk_version field" 2022-04-14 23:42:51 +00:00
Vinh Tran
a9c8f7db27 Update doc for DeviceProperties's Sdk_version field
Test: N/A
Change-Id: I7848ce27a5dcecaf24b0129908f6673dd1fdb63f
2022-04-14 21:02:16 +00:00
Vinh Tran
08e0f96841 Merge "Document AARImportProperties fields" 2022-04-14 20:25:11 +00:00
Vinh Tran
4ae8d4ac46 Fix documentation for android_app_import
Test: N/A
Fix: 226586426
Change-Id: I588a249a85d152f37f5d1bd7157cfab120185648
2022-04-13 21:40:23 +00:00
Vinh Tran
ce0781f8f5 Document AARImportProperties fields
Test: no testing necessary

Change-Id: Idff223f5c9a0b89cd5e0e2c8782c700d8fe9e9b3
2022-04-13 02:12:37 +00:00
Paul Duffin
bd88c882f6 Remove implementation details from stub flags in sdk snapshot
Previously, the build applied the same filtering to remove
implementation details from the sdk snapshot's stub-flags.csv file as
it did for its all-flags.csv, i.e. removing the signatures that only
had a "blocked" flag. Unfortunately, that had no effect on the stub
flags as the implementation signatures had no flags, not a single
blocked flag. That meant that the sdk snapshot's
filtered-stub-flags.csv file contained a lot of implementation details.

This change removes signatures from stub-flags.csv that have no flags
which removes all implementation details from the sdk snapshot.

Bug: 194063708
Test: atest --host verify_overlaps_test
      m out/soong/hiddenapi/hiddenapi-flags.csv
      m art-module-sdk
      # Check contents of its filtered-stub-flags.csv file
Change-Id: I30edc77348fad118ea732e787ae8e206c8841f84
2022-04-12 17:44:15 +01:00
Colin Cross
412436f7fe Don't panic if no certificates found
Getting the first certificate will panic if there are no certificates,
which can happen when AllowMissingDependencies is set and the
certificate property is a module reference to a missing module.
Only get the first certificate if the list is not nil.

Bug: 228379411
Test: TestAppMissingCertificateAllowMissingDependencies
Change-Id: I046d75dbbd4f21f4a2b6851f558e430e9879fcff
2022-04-11 11:50:34 -07:00
Colin Cross
abc0dab477 Move proguard test files to java package
The proguard test files are duplicated in apex and sysprop and will
be needed by app tests, move them to the java package.

Test: run all soong tests
Change-Id: Ie13817dcda8d98801d16a97ffceef1100c7d5380
2022-04-11 11:44:32 -07:00
Treehugger Robot
b6e1614272 Merge "convert logtags in java srcs" 2022-04-08 22:37:22 +00:00
Treehugger Robot
a2a7b57924 Merge changes from topic "export-vars"
* changes:
  export Java variables to Bazel
  refactor Bazel variable export
2022-04-08 17:31:23 +00:00
Sam Delmerico
24da73c032 convert logtags in java srcs
Some java_* modules contain .logtag files in their srcs, but we should
separate these out into their own targets.

Test: enabled QuickSearchBox and build
Change-Id: I595722ca59686d450ff522987a15ce283d3607e0
2022-04-08 14:43:18 +00:00
Sam Delmerico
932c01cf9e export Java variables to Bazel
Test: build/bazel/bp2build.sh
Change-Id: Ia06f9265c9f96e6add6edbd0cee925fe37b430d3
2022-04-08 14:15:43 +00:00
Paul Duffin
0c12b78ae8 Use named options for verify_overlaps
Previously, verify_overlaps used positional arguments, the first was
the monolithi flags and the rest were the module flag pairs (filtered
flags file and signature patterns file). This change makes them use
named options to make the purpose of the arguments clearer on the
command line.

Bug: 194063708
Test: atest --host verify_overlaps_test
      m out/soong/hiddenapi/hiddenapi-flags.csv
Change-Id: Ife0af0016eb0f91416e8330d5d98cb53c97d68a4
2022-04-08 10:56:21 +01:00
Isaac Chiou
c7bb9d47d6 Merge "Revert "Use kapt stubs for kotlin header jar for javac"" 2022-04-06 08:25:29 +00:00
Isaac Chiou
a23d994022 Revert "Use kapt stubs for kotlin header jar for javac"
This reverts commit c6ef485370.

Reason for revert: Multiple systemui presubmits are broken due to this change

Bug: 228262695
Change-Id: I1efed519c49d8d0583815c7bf2b3801bf0ba12fa
2022-04-06 07:04:09 +00:00