Commit graph

719 commits

Author SHA1 Message Date
Rico Wind
351bac996c Add soong support for resource shrinking
This adds a new flag to the optimize section to allow invoking the resource shrinker

Bug: 246217952
Test: m
Change-Id: I2e7851af1189db2a6adf6f9f9f444a1d7f3a8d60
2022-09-23 19:11:11 +02:00
Harshit Mahajan
5b8b730cdd Enforce mainline modules to have latest target sdk version by default.
Due to GMS target SDK requirements (https://docs.partner.android.com/gms/policies/preview/mba#min-target-sdk)
we need to ensure all the  mainline packages to target latest API
level. Currently, the team chases each module to bump their target
API level.

Updating the build code to make sure that mainline modules
(i.e updatable modules) target the latest sdk version by default.
It would be by default set to 10000 before SDK finalization and updated to the new API level after finalization.

Effectively it would mean:
1. '10000' in aosp and internal master
2. Finalized number in development branches like "33" in "tm-dev"
3. As sdk hasn't been finalised in "udc-dev", it would be "10000"
which would be automatically updated to finalized version after sdk finalization.

For local development if the target sdk version is required to be set,
users would need to set Updatable flag to false.
Enforce_default_target_sdk_version flag needs to be used in bp file,
if this feature needs to be tested locally when updatable: false.

Bug: b/227460469
Test: m nothing
Change-Id: I05e0ae74ae44fd73df75e91b926bcc924446253f
2022-09-21 19:09:38 +00:00
Colin Cross
bc2c8a7517 Move AllowMissingDependencies handling into processMainCert
I046d75dbbd4f21f4a2b6851f558e430e9879fcff fixed android_app modules
with missing certificate dependencies when AllowMissingDependencies
was set, but the same problem can occur in android_app_import and
android_rro modules.  Move the AllowMissingDependencies handling
into processMainCert so that it applies to all of them.

Bug: 246649647
Test: TestAppImportMissingCertificateAllowMissingDependencies
Change-Id: Ic7dd3e61e0e3af15c53b583cf680b1e52394a018
2022-09-14 12:48:17 -07:00
Treehugger Robot
48ec5b302a Merge "Add lint test property" 2022-08-16 21:23:12 +00:00
Cole Faust
d57e8b2c2a Add lint test property
Some libraries are only used for tests, but
are not test module types. These modules get warnings
about @VisibleForTesting usages when they really
shouldn't. Expose a test flag that module authors
can use to make lint treat a module as test code.

Bug: 235339747
Test: Manually tested applying it to SystemUI-tests
Change-Id: I1356749a669dc80a7725605d7159da27c9a211b4
2022-08-11 12:26:51 -07:00
Treehugger Robot
2a20239c70 Merge "Use aapt2" am: 258d296698
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2178198

Change-Id: I9fa8b617a0854826f6f4da5a66618d17338c5772
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-10 02:17:45 +00:00
Treehugger Robot
258d296698 Merge "Use aapt2" 2022-08-10 01:21:11 +00:00
Romain Jobredeaux
20f7fbc61e Merge "Bp2Build converter for android_library_import and android_library." am: aaf4f5ec8a
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2165698

Change-Id: I7b1a2b36507a3354bbe35769fdfebfdeb859066a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-09 18:14:50 +00:00
Saeid Farivar Asanjan
fd27c7cbcc Use aapt2
Replace usage of `aapt` with `aapt2`.

Bug: 236602069
Test: m nothing
Change-Id: I0c3b224351aff82fa251fbe83447fd262ab520b1
2022-08-08 20:21:32 +00:00
Romain Jobredeaux
c9b2bba3cd Bp2Build converter for android_library_import and android_library.
Minor refactor of android_app converted to account for common attributes
between library and app.

Test: go test
Test: ../bazel/ci/bp2build.sh
Change-Id: I60b06eef6d2b9bc2d91f8b83522747ebbe76bbb6
Bug: 215230093
Bug: 215230095
2022-08-08 11:23:02 -04:00
Spandan Das
83df960615 Merge "Set targetSdkVersion to 10000 for MTS tests targeting current" am: 0264058aea
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2164782

Change-Id: Ifff15aa2a63aed775150aa6d6147e6300633cbfb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-06 01:50:06 +00:00
Spandan Das
9f7ae7f565 Set targetSdkVersion to 10000 for MTS tests targeting current
MTS tests built on unstable branches (e.g. git_master) should be testable on
old system images (e.g. S). However, they run into an error during installation
on older images:
`Requires development platform $<current_codename>, but this is a
release platform`

This CL fixes this issue by updating the target_sdk_version of MTS test apps
targeting current to the magical sdk_version 10000

Bug: 227473065
Test: go build ./java
Test: TH
Change-Id: Ic0358a48a19dc239defbb4ee8ec99225cce75584
2022-08-04 21:23:14 +00:00
Alexei Nicoara
342945df01 Merge "Overriding placeholder version in updatable apks" am: 075571b5e7
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2167106

Change-Id: Ie411cb4fb7ba5c4c8b402bff916ac55fa1b6def8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-04 08:52:28 +00:00
Alexei Nicoara
075571b5e7 Merge "Overriding placeholder version in updatable apks" 2022-08-04 08:28:16 +00:00
Sam Delmerico
9276c1a4bb Merge "copy JNI from AAR files to android_app APK" am: fb845984df
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2149174

Change-Id: I8697a193bf054623dcdf67f6beded56a75c52875
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-03 13:31:01 +00:00
Alexei Nicoara
69cf0f3756 Overriding placeholder version in updatable apks
Test: presubmit, checked the app version after build locally
Bug: 231691162
Change-Id: Icd242432540ea424235b226a45aac839dbc995be
2022-08-03 12:05:14 +01:00
Sam Delmerico
82602492fc copy JNI from AAR files to android_app APK
JNI libs present in AAR files are ignored in the build. If those
libraries are necessary, they must be manually extracted and a
prebuilt_cc_library module must be created for them. Instead, we can
extract these libraries and copy them to an output APK as part of the build.

Bug: 228848794
Test: created android_app that depends on an android_library_import with
  JNI embedded, and verified that .so libs are present in APK
Test: created android_app that depends on an android_library which
  depends on android_library_import with JNI embedded, and verified
  that .so libs are present in APK
Test: verified that multiple .so's from a single architecture are copied
  to APK
Test: verified that the absence of a jni/<arch> folder or files in the
  folder will cause the Ninja action to error
Change-Id: I242a862d7bd881f7a4a8c23493924d8fe441ea25
2022-08-02 16:12:06 -04:00
Xin Li
313fdb5812 Merge tm-dev-plus-aosp-without-vendor@8763363
Bug: 236760014
Merged-In: I1421fb0dbcdb759281259abfae7bddc9aecdaa56
Change-Id: If059be00e6bdaaa94171b456afae1d585540639c
2022-06-28 21:23:06 +00:00
Ivan Lozano
3742d6ad9e Merge "rust: Allow rust_ffi_shared in jni_libs" 2022-06-28 12:57:05 +00:00
Ivan Lozano
7f67c2a665 rust: Allow rust_ffi_shared in jni_libs
Allow listing rust_ffi_shared modules as a jni_libs dependency
in conjunction with platform_api: true. This allows inclusion by
android_app modules.

Bug: 237304791
Test: android_app module builds with a rust_ffi_shared dependency.
Change-Id: I3a28e1baa522ad8f9c2aa86f1d23b19ce9f967e1
2022-06-27 16:00:26 -04:00
TreeHugger Robot
49030cd143 Merge "Move embedded notice file path above aapt rule generation" into tm-dev am: 8378feda12
Original change: https://googleplex-android-review.googlesource.com/c/platform/build/soong/+/19049995

Change-Id: I3a23f9b49c98c0c6662c768ac8b07b1d4dbeeff4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-23 20:07:24 +00:00
Colin Cross
61fb62e5e3 Move embedded notice file path above aapt rule generation
The embedded notice file generation for apps was moved below the aapt
rules, which meant the added asset path was ignored.  Move the code
to pick the notice file path selection back above the aapt rules,
and leave the code to generate the notice file rule where it is.

Bug: 236006463
Test: m NetworkStack ALWAYS_EMBED_NOTICES=true
Change-Id: I1421fb0dbcdb759281259abfae7bddc9aecdaa56
Merged-in: I1421fb0dbcdb759281259abfae7bddc9aecdaa56
2022-06-23 18:05:47 +00:00
Colin Cross
3d6cfd14d3 Move embedded notice file path above aapt rule generation
The embedded notice file generation for apps was moved below the aapt
rules, which meant the added asset path was ignored.  Move the code
to pick the notice file path selection back above the aapt rules,
and leave the code to generate the notice file rule where it is.

Bug: 236006463
Test: m NetworkStack ALWAYS_EMBED_NOTICES=true
Change-Id: I1421fb0dbcdb759281259abfae7bddc9aecdaa56
Merged-in: I1421fb0dbcdb759281259abfae7bddc9aecdaa56
2022-06-23 18:05:09 +00:00
Treehugger Robot
302846a63b Merge "Fix strip_prefix flags to strip install paths." am: 20b623da89 am: 28b9607224
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2120624

Change-Id: I5c9edaeb2df8a61eb18fe9368dd2f8e9d1321343
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-10 20:32:30 +00:00
Bob Badour
3d16d5ddf8 Fix strip_prefix flags to strip install paths.
Bug: 235331488

Test: m droid dist

Change-Id: I3cd2af5d90e46a4c983728bc9b2d941d6ffda229
Merged-in: I3cd2af5d90e46a4c983728bc9b2d941d6ffda229
2022-06-09 15:00:08 -07:00
Bob Badour
c6ec9fb849 Fix strip_prefix flags to strip install paths.
Bug: 235331488

Test: m droid dist

Change-Id: I3cd2af5d90e46a4c983728bc9b2d941d6ffda229
2022-06-09 14:24:41 -07:00
Jared Duke
2ecf00081a Merge "Revert "Revert "Use D8 by default for android_test""" am: 44338663a5 am: d810453e7c
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2115753

Change-Id: Ibb75070b8e99a4b1b522af5586536ee2652c6e16
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-02 23:30:03 +00:00
Jared Duke
44338663a5 Merge "Revert "Revert "Use D8 by default for android_test""" 2022-06-02 22:35:43 +00:00
Jared Duke
63a3da94d1 Revert "Revert "Use D8 by default for android_test""
This reverts commit 4e445be558.

Reason for revert: GtsExoPlayerTestCases now uses multidex.

Test: m + manual builds for test_suites_x86_64_coverage
Change-Id: I608b3b79137b216f546446e1c4f89f4542572581
Bug: 192032291
2022-06-02 19:12:30 +00:00
Treehugger Robot
d4899ce231 Merge "Revert "Use D8 by default for android_test"" am: 14b500daba am: 1e2e5fcb73
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2100965

Change-Id: I263ec410fc4a118374989d16e0fadee30d9ddf63
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-23 06:20:25 +00:00
Treehugger Robot
14b500daba Merge "Revert "Use D8 by default for android_test"" 2022-05-23 05:49:40 +00:00
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
Bob Badour
efdf8ab4cc Fix bug: allow multiple gen_notice modules. am: a5ea2479d3 am: d9771dedbb
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2098696

Change-Id: I921b541c513779e4a73a70876a9ffff23e4361f6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-21 03:22:39 +00:00
Bob Badour
a5ea2479d3 Fix bug: allow multiple gen_notice modules.
Test: m cts dist reportmissinglicenses

Change-Id: I07963c83eaddfe363a04871e813b56fe7f1465ad
2022-05-20 16:54:00 -07:00
Treehugger Robot
7158bc6012 Merge "Use D8 by default for android_test" am: 1811ed3764 am: db7ee090e1
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2097291

Change-Id: I898a3308b5fe5d7477a261fc4d20871f5cacb01d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-20 23:23:50 +00:00
Treehugger Robot
1811ed3764 Merge "Use D8 by default for android_test" 2022-05-20 22:46:15 +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
Bob Badour
00d6beecc9 Merge "Add gen_notice module." am: 335a4333fe am: 15aba3f5e0
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2095028

Change-Id: I56c39b0693a8a18b6e43f0536c724e5b26338504
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-19 19:09:45 +00:00
Bob Badour
335a4333fe Merge "Add gen_notice module." 2022-05-19 18:03:09 +00:00
Bob Badour
eef4c1c563 Add gen_notice module.
Refactor notices to support notices for multiple modules.

Enforce visibility and handle missing dependencies.

Bug: 213388645

Change-Id: Id6a81987f087419ad37d0cce57a71e8a7c4cd6e0
2022-05-18 16:38:19 -07:00
Colin Cross
d7d2a2a6bf Merge "Fix prebuilts of overridden apps" into tm-dev 2022-05-18 17:40:23 +00:00
Colin Cross
5088544ddc Fix prebuilts of overridden apps
AndroidApp had its own HideFromMake method and flag that shadowed
the one in ModuleBase.  This caused performOverrideMutator to set the
AndroidApp flag, but ModuleBase.skipInstall to read the ModuleBase
flag, resulting in a conflicting install rule being created.  Remove
AndroidApp's HideFromMake in favor of the ModuleBase one.

Bug: 232788722
Test: TestOverrideAndroidAppWithPrebuilt
Change-Id: I8c0dfcb50ff4dc1e4d0574f150b10d79908f46aa
Merged-In: I8c0dfcb50ff4dc1e4d0574f150b10d79908f46aa
(cherry picked from commit aaa0c1ffcd)
2022-05-17 14:39:36 -07:00
Treehugger Robot
9f2eab6462 Merge "Fix prebuilts of overridden apps" am: 822029166d am: 7a8e610703
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2099730

Change-Id: Ib50d77543a68c07a7c1f2391225132cf0c91b57a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-17 21:19:07 +00:00
Treehugger Robot
822029166d Merge "Fix prebuilts of overridden apps" 2022-05-17 19:03:42 +00:00
Treehugger Robot
7583481570 Merge "Make "overrides" attribute of Android_app overridable" 2022-05-17 06:38:19 +00:00
Colin Cross
aaa0c1ffcd Fix prebuilts of overridden apps
AndroidApp had its own HideFromMake method and flag that shadowed
the one in ModuleBase.  This caused performOverrideMutator to set the
AndroidApp flag, but ModuleBase.skipInstall to read the ModuleBase
flag, resulting in a conflicting install rule being created.  Remove
AndroidApp's HideFromMake in favor of the ModuleBase one.

Bug: 232788722
Test: TestOverrideAndroidAppWithPrebuilt
Change-Id: I8c0dfcb50ff4dc1e4d0574f150b10d79908f46aa
2022-05-16 18:27:00 -07:00
zhidou
198f589222 Make "overrides" attribute of Android_app overridable
Move overrides attribute from appProperties to overridableAppProperties

Bug: 220029162
Test: m
Change-Id: I6f527df3173f142311734333ad37018c83d5e279
Merged-In: I6f527df3173f142311734333ad37018c83d5e279
(cherry picked from commit a2ce78f80d)
2022-05-16 18:26:52 -07:00
Spandan Das
91250b1ae4 Enforce updatable=true on apps of updatable apexes
- Update apex_info (a topdown mutator) so that it sets updatable=true on
  apps of updatable apexes
- Write a unit test that tests different combinations of
  updatable/non-updatable apks-in-apexes
- Update an existing unit test that asserts a different error

Test: go test ./java
Test: m nothing (in internal)
Bug: 209409604

Change-Id: Ie8881b857afcec44addf27fc360c5b8abf726bd2
Merged-In: Ie8881b857afcec44addf27fc360c5b8abf726bd2
(cherry picked from commit 42e89508ee)
2022-05-13 19:16:23 +00:00
Spandan Das
456a77e9a0 Update sdk_version check for jni_libs of updatable apps
With aosp/1640364, all variants of a cc_* module use min_sdk_version as
the version part of the clang triple. Therefore, checking
min_sdk_version of jni_libs should be sufficient to ensure that there is
no unintended access to symbols in newer Android versions

Test: go test ./java
Test: TH
Bug: 155209650
Bug: 209409604

Change-Id: I6c064f8a6ea12c8aa40165a9063380306a180c9b
Merged-In: I6c064f8a6ea12c8aa40165a9063380306a180c9b
(cherry picked from commit 2e8c044b2c)
2022-05-13 19:15:58 +00:00
Spandan Das
f454194692 Merge changes Ie8881b85,I6c064f8a am: f923333a93 am: e41be189f0
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2090231

Change-Id: I1eebfc246a05fdb728d1c9460f322f657f7d36df
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-11 20:47:28 +00:00
Spandan Das
f923333a93 Merge changes Ie8881b85,I6c064f8a
* changes:
  Enforce updatable=true on apps of updatable apexes
  Update sdk_version check for jni_libs of updatable apps
2022-05-10 18:20:27 +00:00
Spandan Das
42e89508ee Enforce updatable=true on apps of updatable apexes
- Update apex_info (a topdown mutator) so that it sets updatable=true on
  apps of updatable apexes
- Write a unit test that tests different combinations of
  updatable/non-updatable apks-in-apexes
- Update an existing unit test that asserts a different error

Test: go test ./java
Test: m nothing (in internal)
Bug: 209409604

Change-Id: Ie8881b857afcec44addf27fc360c5b8abf726bd2
2022-05-10 00:01:34 +00:00
Spandan Das
2e8c044b2c Update sdk_version check for jni_libs of updatable apps
With aosp/1640364, all variants of a cc_* module use min_sdk_version as
the version part of the clang triple. Therefore, checking
min_sdk_version of jni_libs should be sufficient to ensure that there is
no unintended access to symbols in newer Android versions

Test: go test ./java
Test: TH
Bug: 155209650
Bug: 209409604

Change-Id: I6c064f8a6ea12c8aa40165a9063380306a180c9b
2022-05-08 01:26:58 +00:00
Treehugger Robot
eb89a79400 Merge "Revert "Don't add uses_libs/optional_uses_libs to the manifest_fixer."" am: be4c7eda08 am: b20002cdeb
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2085466

Change-Id: Ibc412099ec92bee26dc33c63f978e0ba14da9b2f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-04 16:38:28 +00: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
Paul Duffin
3953153c9e Prevent non-app/non-test modules from statically including jacocoagent
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.
Change-Id: Ic95cf11a05f59b67e623474ed3dd9be6b4442c42
2022-05-03 00:46:55 +00:00
Colin Cross
6bfe9bc4fa Merge changes I046d75db,Ie13817dc am: d2aa190bdc am: f2c86c8c76 am: 1a3ea67458
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2058908

Change-Id: I9ab91976903abbb4e3ec17b3d26db15447f074d6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-12 00:58:51 +00: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
Matt Banda
8c80126987 Surface Java APIs Used By APK-only Modules.
Previously we were only generating used-by API-coverage for APEX modules.
This change adds support for APK-only modules such as NetworkStack and DocumentsUI.

Bug: b/216313756
Forrest Run: https://android-build.googleplex.com/builds/abtd/run/L10800000953846781

Test: TARGET_BUILD_VARIANT=userdebug PRODUCT=mainline_modules_x86 ./vendor/google/build/build_unbundled_coverage_mainline_module.sh -j16

Change-Id: Id17e4a55c2a52e9903632a654e778f8d54982dfc
Merged-In: Id17e4a55c2a52e9903632a654e778f8d54982dfc
(cherry picked from commit 56d75785bd)
2022-04-05 21:28:29 +00:00
Treehugger Robot
c7f2125a26 Merge "Keep dependency files out of the apk file." am: 5f58c378b6 am: d4a37e0757 am: f82be53525
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2055425

Change-Id: Ifdaf251cae92a6cb38f338e1455390fea84fc5df
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-05 06:50:38 +00:00
Bob Badour
2c8888edef Keep dependency files out of the apk file.
Bug: 227682036

Test: TARGET_BUILD_VARIANT=userdebug UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true vendor/google/build/mainline_modules_bundles.sh -j97

Change-Id: I1a9775af7c652191bb1ce3b97c1cb9365b469c19
2022-04-04 19:21:18 -07:00
Bob Badour
0a6539dd21 Merge "Revert "Revert "Build notice files from license metadata.""" am: 3aae38d451 am: b0489dec23 am: bf82573d27
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2051564

Change-Id: I0a1a9a0ea0ccd052dbc84cc6b2cce0b128393f63
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-02 01:48:21 +00:00
Bob Badour
de6a087d2d Revert "Revert "Build notice files from license metadata.""
This reverts commit 77807b3c27.

Reason for revert: fix and roll forward again

Change-Id: I80c796ca81ecf29df9522babe54d684a0d11b9e6
2022-04-01 18:00:00 +00:00
Wei Sheng Shih
67c0b63929 Revert "Build notice files from license metadata." am: 77807b3c27 am: 72f9cdb599 am: 6c698e406d
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2052565

Change-Id: I7e4f410833a4b8349e476d6fca4b2161c8f254f6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-01 17:26:29 +00:00
Wei Sheng Shih
77807b3c27 Revert "Build notice files from license metadata."
This reverts commit 43c2dcaef6.

Reason for revert: suspect build break

Bug: 227682036

Test: TARGET_BUILD_VARIANT=userdebug UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true vendor/google/build/mainline_modules_bundles.sh -j97


Change-Id: Ibfb8b4fefc264f52f32ba661c269a9cd625d800a
2022-04-01 14:10:53 +00:00
Bob Badour
c64d309ce2 Fix breakage: bad path join using '/' literal am: 2a5c090c31 am: cf96d25b3d am: ec84245e25
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2052015

Change-Id: I5e8ea66626e0cde29a7c24f370b85548ae6b5d4a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-01 09:27:15 +00:00
Bob Badour
2a5c090c31 Fix breakage: bad path join using '/' literal
Typo in filename s/b NOTICE.html.gz not NOTICES.html.gz

Bug: 227682036

Test: TARGET_BUILD_VARIANT=userdebug UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true vendor/google/build/mainline_modules_bundles.sh -j97

Change-Id: I75cc28e3ef22d975ad46f4e167071f6d82ba253d
2022-03-31 23:40:28 -07:00
Bob Badour
8d17118d5a Build notice files from license metadata. am: 43c2dcaef6 am: 6f7de5b1a9 am: cbcf8d9b05
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2047886

Change-Id: I6a76eee6321538b70c331a2e2a9cb1e5b644ac04
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-31 23:13:51 +00:00
Bob Badour
43c2dcaef6 Build notice files from license metadata.
Switch from generate-notice-files.py and mergenotice.py to htmlnotice.

Bug: 151177513
Bug: 213388645
Bug: 210912771

Test: m droid dist reportmissinglicenses
Change-Id: I6cac049d24f35ec358c6f341a04f4ba6161703bf
2022-03-31 17:29:01 +00:00
Treehugger Robot
5d123b15d9 Merge changes from topic "no-srcs-no-deps" am: d93afba1e6 am: d218781011 am: beb28cd9ad
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1995730

Change-Id: I8c8c7b973ffc6a6dfd91c35dc96e73c42bf30577
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-30 22:07:01 +00:00
Sam Delmerico
c016143602 emulate java_library static_deps with Bazel exports
In Soong, java_library can specify static_deps which are dependencies
that get aggregated into the final jar (akin to static linking). This is
useful because it allows dependencies higher up in the chain to compile
against the APIs exported by transitive dependencies. Bazel does not
support this functionality directly, but it can be emulated via the
exports attribute which makes any targets listed in the attribute public
to targets further up the chain.

Bug: 217236083
Bug: 219908977
Test: b build //external/error_prone:error_prone_core
Test: b build //external/bouncycastle:bouncycastle-host
Test: b build --platforms=//build/bazel/platforms:linux_x86
  //prebuilts/sdk/tools/jetifier/jetifier-standalone:jetifier
Change-Id: I2867e3f816de720a6f4bd9ff7a847d1b0c2da2d6
2022-03-30 18:58:38 +00:00
Sam Delmerico
865358d90c Merge "convert android_app certificate property, bp2build" am: d508a638c3 am: 9e3f98b8cf am: 19b7975f03
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1980606

Change-Id: Iaa8fb9a85d42e2c299fadd34f81fe0b55bcd1a9a
2022-03-04 18:39:36 +00:00
Sam Delmerico
9dfb139b6d convert android_app certificate property, bp2build
The android_app certificate property can be converted to the
@android_rules debug_signing_keys attribute in Bazel after converting
the .pk8/.pem key pairs to a JKS keystore in Starlark.

Test: b build -s //frameworks/base/tests/appwidgets/AppWidgetHostTest
  and verify includes SignApk action with generated keystore
Bug: 194133023
Change-Id: I2c4276f94a7856fc68a7674e89742f887dca31b4
2022-02-18 20:17:01 +00:00
zhidou
a2ce78f80d Make "overrides" attribute of Android_app overridable
Move overrides attribute from appProperties to overridableAppProperties

Bug: 220029162
Test: m
Change-Id: I6f527df3173f142311734333ad37018c83d5e279
2022-02-17 13:40:53 +00:00
Paul Duffin
3ed2d0e53c Merge "Add support for excluding libraries from class loader contexts" am: e95d77b964 am: ab9e6fe18f am: 7c89c48887 am: 10ccb6c274
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1971343

Change-Id: Ia03300d88199034f2cf07dbb9ca229e5e13ceb00
2022-02-07 18:39:48 +00:00
Paul Duffin
0653057603 Add support for excluding libraries from class loader contexts
A number of tests in the cts/tests/signature/api-check check for the
accessibility of classes from the android.test.base,
android.test.runner and android.test.mock libraries. Some tests expect
to find the classes other do not. Unfortunately, the tests use
libraries, specifically compatibility-device-util-axt, that depend on
the android.test... libraries which causes Soong to implicitly add
<uses-library> entries to the manifest so that they will be accessible
at runtime. That causes the tests that do not expect to find the
classes to fail.

Bug: 209607558
Test: m nothing
Change-Id: I54c194ab23d5a70df790ece3fe98f2b3d6a1c1f6
2022-02-07 14:57:53 +00:00
Romain Jobredeaux
a50778b117 Merge "Use common java library attributes for android_app bp2build converter." am: 99a81c8dfd am: abf2323829 am: 7b368117a6 am: 9be703df2c
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1969119

Change-Id: I49791f01bdeced17d8ce5964d7e170ef588b922a
2022-02-03 22:16:09 +00:00
Romain Jobredeaux
e8acade177 Use common java library attributes for android_app bp2build converter.
Change-Id: I4dc7600fbe80eddc54a7fadd6418d6911af0b7f2
Test: go test ./bp2build
2022-02-02 12:18:37 -05:00
Romain Jobredeaux
9246215c1d Merge "Revert "Revert "Add static_libs support to android_app bp2build converter.""" am: f49ca9e40d am: 2303c67479 am: b2e3ee4575 am: 0b93c3e3f1
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1948956

Change-Id: I8ba757d3164908e6c2f9361cb2d6f8735c67a98b
2022-01-21 22:13:58 +00:00
Romain Jobredeaux
f49ca9e40d Merge "Revert "Revert "Add static_libs support to android_app bp2build converter.""" 2022-01-21 20:51:06 +00:00
Romain Jobredeaux
355851b520 Revert "Revert "Add static_libs support to android_app bp2build converter.""
This reverts commit b33e0b8b5b.

Reason for revert: CI failure deemed to be a fluke

Change-Id: Ia804d531092921e4ad090740420c4a4e02e6ff00
2022-01-19 21:13:51 +00:00
Romain Jobredeaux
cd41dd5c33 Merge "Revert "Add static_libs support to android_app bp2build converter."" am: 8a9a97b4a0 am: 474eddd20b am: 9b36f4b981 am: c19a2c16bd
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1948756

Change-Id: I36a0fd3f7147ef9975f55b61e872020a4bcd6c9e
2022-01-13 17:57:52 +00:00
Romain Jobredeaux
8a9a97b4a0 Merge "Revert "Add static_libs support to android_app bp2build converter."" 2022-01-13 17:03:26 +00:00
Romain Jobredeaux
8a36f521f8 Merge "Add static_libs support to android_app bp2build converter." am: 24431448b2 am: 6eae04a33f am: 519e09f11d am: 9dbe366934
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1917405

Change-Id: I253922076c5eb0e947bcc6948987b8d38e9c4f06
2022-01-13 16:02:34 +00:00
Romain Jobredeaux
b33e0b8b5b Revert "Add static_libs support to android_app bp2build converter."
This reverts commit de722acd96.

Reason for revert: broke bp2build CI

Change-Id: I535e8746e846c20f1a47c2a1eb0362276af49206
2022-01-13 15:16:12 +00:00
Romain Jobredeaux
24431448b2 Merge "Add static_libs support to android_app bp2build converter." 2022-01-13 15:00:44 +00:00
Treehugger Robot
d887d9b452 Merge changes I9ad66ea2,I4c95b77b am: 57271b9f45 am: a7c0107744 am: 16213c6bbe am: f7e9e1f434
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1934955

Change-Id: I5e05dbd3bca3c14bb52ad383c8af3eaf491222a1
2022-01-11 08:11:46 +00:00
Jooyung Han
01d80d8b4b Make android_app.stem overridable
override_android_app can set "stem" property to set the APK name.

Bug: 193504286
Test: m (soong test)
Change-Id: I9ad66ea28bd1b030cb2c588d1f070d72e62ab1c7
2022-01-11 13:07:44 +09:00
Jooyung Han
29e2f6d2c4 Use 'stem' to override APK name
When android_app.stem is set, use it as the APK name like other module
types.

Bug: 193504286
Test: m (soong test)
Change-Id: I4c95b77be382cff3cfecaf6ce38f99aed9f3238f
2022-01-11 13:03:49 +09:00
Romain Jobredeaux
de722acd96 Add static_libs support to android_app bp2build converter.
With this change we can allow list WifiDirectDemo, as its dependencies
happen to have manual BUILD file conversions.

Test: ./build/bazel/scripts/run_presubmits.sh
Change-Id: I68b4c2b129fe750913f013384c87a5332fdcc9b6
2022-01-07 16:47:14 -05:00
Treehugger Robot
dbd3553d83 Merge "Remove InstallBypassMake and ToMakePath" am: f1228f570a am: a9f335cf5a am: fd865c6688 am: 8ef2179a6e
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1889722

Change-Id: If49c894804c5ca0dfd197ca848ff1c9ac79556f4
2021-12-17 07:36:53 +00:00
Colin Cross
c68db4b305 Remove InstallBypassMake and ToMakePath
InstallBypassMake and ToMakePath are obsolete, remove them.

Bug: 204136549
Test: m checkbuild
Change-Id: Ie5a6f7254b3d317ed6039e114ed6aec35e1ce273
2021-12-15 15:22:53 -08:00
Liz Kammer
6299b235bb Merge "Use one mutator for all bp2build conversion." am: 92344259c5 am: 782f37eaee am: 5f4df317ee am: 037105c0f8
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1878397

Change-Id: I56073dc653947ebf69d7a74e97c1092f06aab139
2021-12-14 20:25:04 +00:00
Liz Kammer
be46fccc40 Use one mutator for all bp2build conversion.
Each conversion required defining a separate mutator, which will each
operate on _all_ modules and requires each to repeat checks whether the
mutator should operator. Instead, we introduce a single mutator and
modules can define a ConvertWithBp2build to implement bp2build
conversion for that module.

Test: bp2build.sh
Bug: 183079158
Change-Id: I99d4b51f441c2903879092c5b56313d606d4338d
2021-12-14 09:37:45 -05:00
Romain Jobredeaux
fa0f10d6d3 Merge "Initial bp2build converter for android_app." am: 4526269c2e am: f7a7a95c07 am: 019d78829d am: 6ba0a6a4a9
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1907394

Change-Id: Ia3aa0e678b02c8405b391fb2665be0c336798c57
2021-12-07 21:34:00 +00:00
Romain Jobredeaux
4526269c2e Merge "Initial bp2build converter for android_app." 2021-12-07 20:14:29 +00:00
Romain Jobredeaux
1282c42484 Initial bp2build converter for android_app.
The only supported attributes at this point are:
- srcs
- manifest
- package_name
- resource_dirs
as they most easily map to bazel's android_binary's srcs, manifest, custom_package, and resource_files respectively.
Allow-listing all apps that use these fields, along with sdk_version and dex_preopt. The latter 2 are ignored by the converter,
- sdk_version because we're currently relying on a single pre-built SDK,
- dex_preopt because,
   1. though it is not supported in Bazel builds yet, it doesn't prevent the apps from building, and
   2. the apps being converted only use the dex_preopt attribute to disable dex_preopt, which is what is happening anyway.

Change-Id: I4a4f771eeb8f60a1cd4844b2ac1ce3df7c070e73
Test: ./build/bazel/scripts/run_presubmits.sh
Bug: 198224074
Bug: 203688791
2021-12-07 09:41:49 -05:00
Artur Satayev
6e8071d17a Merge "Add ModuleWithMinSdkVersionCheck type." am: a4fc08d204 am: 25f5783263 am: fe55ffd190 am: 44d0ef55da
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1907860

Change-Id: I147da371d445f09ca2f131df1be91545eba37772
2021-12-06 18:09:34 +00:00
satayev
b3fd411465 Add ModuleWithMinSdkVersionCheck type.
This is to help following refactor for individual modules to have their
own version of checking where needed.

For example, apk in apex may want to enforce it's own version of
CheckMinSdkVersion.

Bug: 205923322
Test: presubmit
Change-Id: Ia2fad6c52af39e21f65385bcb283f1e3adab5548
2021-12-06 12:05:48 +00:00
Treehugger Robot
e558319465 Merge changes I9e38ac73,I9412147f am: 45da465ef6 am: 0a93afc2b9 am: 331599f461 am: 76df6461c5 am: 0d3522cece
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1887532

Change-Id: Ia74c51187284aad60b8e700c488a60a0083f4cfc
2021-11-11 07:35:58 +00:00
Colin Cross
fa9bfcd0d2 Honor PreventInstall for APKs and dexpreopt files
Native coverage builds create a second variant of APKs and set
PreventInstall on the non-coverage variant.  Skip calling
ctx.InstallFile for APKs and in dexpreopt when PreventInstall
is set.

Fixes: 205865567
Test: m EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true CLANG_COVERAGE=true NATIVE_COVERAGE_PATHS="*" NATIVE_COVERAGE_EXCLUDE_PATHS="art bionic/libc device external/compiler-rt external/clang external/llvm external/swiftshader/third_party/llvm-10.0"
Change-Id: I9e38ac737315db12475e8f9bfb3e0e7c0327fc06
2021-11-10 16:42:38 -08:00
Colin Cross
da9b639573 Fix ctx.InstallFile calls for java modules am: 1d0eb7a9d0 am: c871fe905e am: 406461d954 am: 0978bcd3c1 am: 57c4a25fe3
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1880649

Change-Id: Icd21a62944d48b02d573f109deb0333ffb63da77
2021-11-10 18:10:39 +00:00
Colin Cross
1d0eb7a9d0 Fix ctx.InstallFile calls for java modules
Call ctx.InstallFile on the primary install file last so that the
primary install file can depend on the extra install files, and so that
the primary install file can be inferred from the last installed file.

Add missing ctx.InstallFile calls for the dexpreopt and hostdex outputs.

Fix the install subdirectory for modules installing to the testcases
directory.

Bug: 204136549
Test: m checkbuild
Change-Id: I7edd7647be27439d3ca0ecc589ca5e89d4ba8474
2021-11-05 14:20:28 -07:00
Rupert Shuttleworth
8eab869bfe Add ability to set --rotation-min-sdk-version for signapk via Android.bp files.
(vs via Android.mk files, done earlier in http://ag/16094391)

Bug: 197787352

Test: Added unit tests.

Change-Id: I3ccd2f2134b069fb4c4a90fe384c23c1814c2ba2
2021-11-03 10:46:15 -04:00
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
447f6c99c9 Bp2Build common properties auto-handling
Introduce `commonAttributes` & `fillCommonBp2BuildModuleAttrs used in
CreateBazelTargetModule

Adapt `bp2BuildInfo` to use `commonAttrs` instead of `Name`.
And thus also all downstream users of `CreateBazelTargetModule`.

As initial user, the Soong `required` property will be
translated to Bazel's `data`.

Bug: 198146582, 196091467
Test: build_converstion_test.go:TestCommonBp2BuildModuleAttrs
Test: go test
Test: mixed_{libc,droid}.sh
Change-Id: Ib500e40f7e2cb48c459f1ebe3188962fc41ec124
2021-10-04 14:43:04 +00:00
Colin Cross
cfb0f5e102 Support per-testcase directories in all test suites
There are cases where two modules try to install the same test data
into CTS, which results in collisions when CTS puts the data for all
tests in the same directory.  Add a flag that allows enabling a
per-testcase directory for an individual test for all test suites.

Bug: 193168159
Test: cts-tradefed run commandAndExit CtsBionicTestCases
Change-Id: If034723e8fe937ca71d3e2d39b7d46702e41bc8c
2021-09-27 15:56:26 -07:00
Martin Stjernholm
8be1e6db16 Propagate the dex jar path as an OptionalPath which is either valid or
invalid with a message.

This will allow propagating any error from the deapexer module for
prebuilt APEXes to the location where the dex jars get used. It's only
at those points that we can raise errors about not being able to
extract files from the deapexer modules if they are invalid, and this
way we avoid encoding knowledge there about why they may be invalid.

To keep the refactoring limited it intentionally does not change any of
the existing logic for when dexJarFiles are set or not (non-nil vs nil
prior to this change), although there may be opportunity to use this
for more conditions when dex jars aren't available.

The refactoring is also not extended to
dexpreopt.ClassLoaderContextMap.

Test: m nothing
Bug: 192006406
Change-Id: I68986dccd9a9b3fee4d24caa1947ea17a36caedc
2021-09-23 17:19:55 +01:00
Cole Faust
64cb7c964a Fix panic when a module has an invalid output path
dep.OutputFile().Path() can panic if the OutputFile
is invalid, so move more of the code into the check
for validity. This changes the go crash into a
build error.

Bug: 158624492
Test: Apply the patchset 1 of ag/11815659, lunch aosp_x86_64-eng, m
Change-Id: Ic8a728be1b570ac73be7b2b9461676f9fd99c266
2021-09-14 17:35:19 -07:00
Ulya Trafimovich
0b1c70efbc Don't add uses_libs/optional_uses_libs to the manifest_fixer.
These properties specify libraries that cannot be implicitly inferred by
Soong. If these properties are added to Android.bp, this can only be for
the reason that there is a <uses-library> tag in the manifest which is
unknown to the build system. Adding them to the manifest_fixer doesn't
make sense: if they are not in the manifest, they should be removed from
Android.bp as well.

Bug: 132357300
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 grep output, no errors
Change-Id: Ic6eb5268a954ef3be7f06a181ec72af99000c547
2021-08-20 15:54:42 +01:00
Liz Kammer
2ada09a546 Don't create a new module for bp2build conversion.
A performance improvement for bp2build as Blueprint/Soong no longer have
the overhead of additional modules. The creation of these modules
results in:
* traversal of additional modules for each subsequent mutator
* synchronization over a go channel to collect newly created modules:
https://cs.android.com/android/platform/superproject/+/master:build/blueprint/context.go;l=2594,2600;drc=1602226f23181b8c3fbfcaf3358f0297e839d7d3

We avoid both of these by storing the information directly in the
underlying module.

Also as a fringe benefit, removes some necessary boilerplate for
conversion.

For benchmarks, reduces runtime ~1% for 1% converted, ~24% for 100%
converted. See more: go/benchmarks-for-https:-r.android.com-1792714

Test: ran benchmarks/tests in bp2build
Test: build/bazel/ci/bp2build.sh
Change-Id: Ie9273b8cbab5bc6edac1728067ce184382feb211
2021-08-17 15:57:09 -04:00
Ulya Trafimovich
fc0f6e34ce Fix the way manifest fixer detects optional <uses-library> entries.
Previously manifest_fixer used a naive way to distiniguish optional libs
from required ones: it checked if a library is on the list of optional
compatibility libraries. This works for compatibility libs, but not for
other libs.

Now we properly track optionality through all stages of the build,
starting with the addition of the library as a dependency (here's where
the `uses_libs`/`optional_uses_libs` distinction kicks in), store it in
dependency tag and propagate to class loader context, and from there to
the manifest_fixer.

The tests have been updated accordingly.

Bug: 196377222
Test: lunch bertha_x86_64-userdebug && m droid dist cts mts
Change-Id: I3631ce59ebe47116ce7a9b3d33a86f636846ef0f
2021-08-13 16:10:42 +01:00
Rupert Shuttleworth
5c4881c8ec Add initial bp2build support for converting android_app_certificate modules.
Test: Added unit test.

Change-Id: Ib5bf1711eca5be772e1bed73663dcb86252e0b4a
2021-07-28 06:51:07 -04:00
Rupert Shuttleworth
6e4950a061 Add some more properties to the bp2build APEX converter (second try)
In particular:

- AndroidManifest
- file_contexts
- key
- certificate
- min_sdk_version
- updatable
- installable
- native_shared_libs
- binaries

Test: Updated unit test

Change-Id: I1c6e8c4b6b24ce487f64e5d37bd594dbb000fe6f
2021-07-27 05:02:50 -04:00
Rupert Shuttleworth
0358478150 Revert "Add some more properties to the bp2build APEX converter."
This reverts commit 69bf4c0d60.

Reason for revert: Possibly broke CI (https://android-build.googleplex.com/builds/quarterdeck?branch=aosp-master-bazel&target=bp2build-incremental&lkgb=7266256&fkbb=7237028), rolling back just in case...

Change-Id: I14ebac4f47576a73285d1f724ae4499036e8e678
2021-07-27 02:37:32 +00:00
Rupert Shuttleworth
69bf4c0d60 Add some more properties to the bp2build APEX converter.
In particular:

- AndroidManifest
- file_contexts
- key
- certificate
- min_sdk_version
- updatable
- installable
- native_shared_libs
- binaries

Test: Updated unit test

Change-Id: I9ea13f021d63ec0f75006b3b0b23ec8178c7e9da
2021-07-26 07:32:36 -04:00
Ulya Trafimovich
840efb6661 Don't attempt to add stub libraries to class loader context.
A Java module may depend on a stub library. In that case an additional
dependency on the implementation library is created, and it is used to
add the implementation library to class loader context. We should not
attempt to add the stubs library as well (previously the attempt to add
it happend after the implemention was added to CLC, to the attempt was
unsuccessful).

Raise an error if someone tries to add the same library with different
build/instal paths.

Also, rename local variable `implicitSdkLib` to `sdkLib` to better
reflect its meaning.

Bug: 193425964

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' -C1
      # empty output, no errors
Change-Id: I01c1bdd23f9d118d891d0b806e7e3b4d78896a34
2021-07-16 14:44:18 +01:00
Ulya Trafimovich
e14f80b2d3 Fix handling of "prebuilt_" prefix in classLoaderContextForUsesLibDeps.
Changes:
- Cut off "prebuilt_" prefix from `dep`, not `libName`, because `dep` is
  used to replace library name in `usesLibraryProperties`, and these
  properties are specified without "prebuilt_" prefix.

- Do not remove "prebuilt_" prefix on the return value of
  `ProvidesUsesLib()`: this boils down to `provides_uses_lib` property
  which is specified without the prefix.

Bug: 193425964
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' -C1
      # empty output, no errors
Change-Id: I6cb65040027023d12ca0bc132d60c2c245174c40
2021-07-15 15:19:26 +01:00
Ulya Trafimovich
2444671b4a Refactor function to reduce nestedness level. No functional changes.
Bug: 193425964
Test: m nothing
Change-Id: Ic2d20eb5317f397919ecb01b64c5dd0da78e4a1a
2021-07-15 15:18:25 +01:00
Jeongik Cha
4b073cd083 dexpreopt.config should be created even though unbundled image is built
Bug: 188179858
Test: compare dexpreopt_config.zip files from
 1. TARGET_BUILD_UNBUNDLED_IMAGE=true m dexpreopt_config_zip
 2. m dexpreopt_config_zip
(note that m clean should run between steps)

Change-Id: I36a6e8b10b9922cc5522accaf90af1aa05049a86
2021-07-15 09:57:49 +09:00
Ivan Lozano
d7586b6526 Refactor vendor snapshot to use LinkableInterface.
Refactors the vendor snapshot support to use the LinkableInterface
so that support can be extended to Rust. This CL does not add
vendor snapshot support for Rust; that is left for a follow-on CL.

Bug: 184042776
Test: m nothing
Change-Id: Id0c4970ca00053484a52677d182153cbc454c301
2021-05-12 14:01:10 -04:00
Jiyong Park
9231537fe2 SdkSpec is fully using ApiLevel
Previously, SdkSpec was constructed only from the user string. It didn't
make use of the Config struct where information about the latest stable
SDK version, etc. is recorded. As a result, the build system couldn't
check if the sdk version "current" is referring to the in-development
(i.e.  not-yet-frozen) SDK version or the latest stable version.
"current" was always assumed to be in-development (IsPreview() returns
true) even when Platform_sdk_final == true.

As the first step for fixing that, this change requires
android.EarlyModuleContext to be passed when constructing SdkSpec from
the user string.

In the following changes, "current" will be mapped to either
FutureApiLevel (10000) or one of the FinalApiLevels() depending on
whether the platform SDK was finalized or not.

Bug: 175678607
Test: m
Change-Id: Ifea12ebf147ecccf12e7266dd382819806571543
2021-04-08 11:27:24 +09:00
Treehugger Robot
4238c5fe07 Merge "Set the usesNonSdk manifest attribute whan targeting module SDKs." 2021-04-06 18:25:12 +00:00
Lorenzo Colitti
fa9b3f30fd Set the usesNonSdk manifest attribute whan targeting module SDKs.
From an ART perspective, calling module-lib APIs requires the
ability to bypass hiddenapi enforcement entirely. This CL ensures
that if an APK compiles against module-lib APIs, it will be able
to call those APIs. Currently, compiling against module-lib APIs
is not safe because APKs that are subject to hiddenapi protection
will crash at runtime.

Bug: 181309531
Test: made NetworkStackNext compile against module-current, and:
Test: aapt dump xmltree .../NetworkStackNext.apk AndroidManifest.xml | grep usesNonSdk
Change-Id: I5ca3328c64412078d803e0e3ffa1d8383602416f
2021-04-05 22:53:41 +09:00
Jiyong Park
54105c48f4 SdkSpec = Scope + ApiLevel
SdkSpec.Version was an int type. Now it becomes ApiLevel type which
is a better abstraction of the version (or api level).

Bug: 1655587
Test: m

Change-Id: I4d67b9b9eae45f653b6af4f5b73da9e091b3dfab
2021-04-05 09:32:06 +09:00
Jiyong Park
f1691d2a2c Move java.sdkSpec to the android package
... in preparation for making the handling of sdk versions consistent
across java and cc modules.

Bug: 175678607
Test: m
Change-Id: I598f0454bce9b7320621022115412fbe97403945
2021-04-03 08:25:12 +09:00
Ulya Trafimovich
39dd0a4b87 Don't enforce <uses-library> checks if dexpreopt for apps is disabled.
Otherwise the check fails, as it depend on non-existent dexpreopt.config
files. This CL fixes broken build cf_x86_phone-userdebug_coverage.

Bug: 183931403
Bug: 132357300
Test: forrest build for cf_x86_phone-userdebug_coverage.
Change-Id: Id3ffeb742c1b82c677795fa701a7b5a867eabbbd
2021-03-29 14:57:34 +01:00
Jaewoong Jung
9f315dea28 Merge "Improve java.go readability." 2021-03-16 21:32:48 +00:00
Ulya Trafimovich
a76d6606ce Don't depend on nonexistent manifest when manifest_check is disabled.
This is a follow-up for https://android-review.googlesource.com/1614807.

Bug: 132357300
Test: lunch aosp_cf_x86_64_phone-userdebug && m
Test: lunch qemu_trusty_arm64-userdebug && \
  m out/soong/.intermediates/packages/apps/DocumentsUI/DocumentsUI/android_common/DocumentsUI-unsigned.apk
Change-Id: I84c5d171bd976f35f342abd94b592506c71e4b1d
2021-03-16 15:34:50 +00:00
Jaewoong Jung
bc15e3a798 Improve java.go readability.
Test: TreeHugger
Change-Id: I98bb7bddb740451ff2ccd28dcdaddff27e35a8cd
2021-03-15 13:58:44 -07:00
Ulya Trafimovich
0aba252e15 Reimplement verify_uses_libraries.sh in manifest_check.py.
Previously there were two different scripts that did similar things:
1) build/soong/scripts/manifest_check.py
2) build/make/core/verify_uses_libraries.sh

Both scripts extracted <uses-library> tags and `targetSdkVersion` from
the manifests of Java modules, but 1) worked for XML manifests, and 2)
worked for APKs. This CL reimplements the functionality from 2) in 1),
so that one script can handle both XML manifests and APKs.

Bug: 132357300

Test: lunch cf_x86_64_phone-userdebug && m && launch_cvd \
      adb wait-for-device && adb root && adb logcat \
      | grep -E 'ClassLoaderContext [a-z ]+ mismatch'
      # empty grep output, no errors

Change-Id: Id1b66e4f3f30f307dba70cb111c7571762cb546a
2021-03-15 13:50:49 +00:00
Artur Satayev
533b98cde3 Don't track modules that are only available to APEXes.
Modules that are not available for platform are developed with
updatability in mind, and do not require manual approvals.

Bug: 181223240
Test: checkbuild
Change-Id: I10b91053b3ef5a9ff5400d9d7a68fae3144a671c
2021-03-11 18:13:18 +00:00
Jaewoong Jung
1c1b6e6d95 Lineage properties support module references.
They should have had `android:"path"` tags attached so that users can
point them to filegroup modules.

Test: app_test.go & app_import_test.go
Bug: 182175153
Change-Id: I5580408488ffe5fc12c869cbfb7a468713dcbc96
2021-03-09 15:14:34 -08:00
Ulya Trafimovich
6e55ef157c Disable verify_uses_libraries check if dexpreopt is globally disabled.
Without dexpreopt the check is not necessary, and although it is good to
have, it is difficult to maintain on non-linux build platforms where
dexpreopt is generally disabled (the check may fail due to various
unrelated reasons, such as a failure to get manifest from an APK).

Bug: 181570790
Bug: 132357300
Test: m nothing
Change-Id: Ie012690e8f047ae9256e26565d162c19af4e8921
2021-03-04 18:40:40 +00:00
Ulyana Trafimovich
ae5cdfffa3 Merge "Respect provides_uses_lib for modules added via [optional_]uses_libs" 2021-03-02 13:47:03 +00:00
Ulya Trafimovich
eea486a580 Respect provides_uses_lib for modules added via [optional_]uses_libs
Previously `provides_uses_lib` property affected only those
<uses-library> dependencies that are automatically deduced by Soong as
implicit Java SDK libraries reachable from the `libs` property. Other
<uses-library> dependencies that are explicitly added in `uses_libs` and
`optional_uses_libs` properties ignored `provides_uses_lib`.

As TestUsesLibraries shows (see the TODOs), Soong behaviour is still
incorrect in two ways (to be addressed in follow-up CLs):

- `uses_libs`/`optional_uses_libs` are passed to manifest_fixer
- verify_uses_libraries check is based on `uses_libs`/
  `optional_uses_libs`, and not on the CLC as it should be

Bug: 132357300
Test: m nothing
Change-Id: I0ec7aab9dcd44554d1a79ddd382491c562266fa3
2021-03-01 17:31:23 +00:00
Colin Cross
b014f0787e Propagate java resources in apps with no code
Use the java resources jar as the dex jar when building apps that
have no code.

Also remove maybeStrippedDexJar, the dex jar is never stripped now.

Fixes: 176305357
Test: TestAppJavaResources
Change-Id: Ic8b1165bd35d71237d307e7f5f895764e203a10d
2021-02-26 16:28:12 -08:00
Jaewoong Jung
8431282af4 Fix the releax_check flag format verb.
%b prints base 2 numbers. %t is the right one to use for booleans.

Test: TreeHugger
Change-Id: Ifbae0170ba03583182ae848bcfc6bb104f1be7e0
2021-02-24 21:09:10 -08:00
Ulya Trafimovich
8c35fcf4d5 Add non-fatal mode for verify_uses_libraries check.
The new mode is enabled with environment variable
RELAX_USES_LIBRARY_CHECK. If the variable is set to true, then a
verify_uses_libraries check failure does not fail the build, instead it
sets a special compiler filter "extract" for dexpreopt, which means that
the DEX file will be extracted, but it won't be compiled to native code.
Class loader context will be set to empty in this case (not &, as it is
going to be deprecated soon).

If the variable RELAX_USES_LIBRARY_CHECK is unset or set to something
other than "true", then the old behaviour of the verify_uses_libraries
check is preserved.

The intended use case for this flag is to have a smoother migration path
for the Java modules that need to add <uses-library> information in
the build files. The flag allows to quickly silence build errors. This
flag should be used with caution and only as a temporary measure, as it
masks real errors and affects performance.

verify_uses_libraries check is reworked so that it writes the error
message to a status file (which is used instead of the former timestamp
file). Currently the stored error message is not used, but it may be
used later to produce a warning. Dexpreopt command checks if the status
file exists and is nonempty; if that is the case, then compiler filter
is set to "extract".
Bug: 132357300

Test: Manually add some mismatch between the libraries in the Android.bp
      and Android.mk files for dexpreopted apps, build with
      RELAX_USES_LIBRARY_CHECK=true and obsserve that the build doesn't
      fail and they are compiled with compiler-filter "extract".
      Unset RELAX_USES_LIBRARY_CHECK and observe that the build fails.

Change-Id: Ibb5d993a25b1df1d2e70b7d5aafc6997f9d64e67
2021-02-22 15:41:03 +00:00
Ulya Trafimovich
76b0852a48 Write module dexpreopt.config for Make.
This is needed for Java libraries that are <uses-library> dependencies
of Java libraries and apps defined as Make modules. Each dexpreopted
module in Make generates a dexpreopt.config file, which incorporates
information from its dependencies' dexpreopt.config files. For
dependencies that are Make modules their dexpreopt.config files are
generated by Make, and for Soong modules they are generated by Soong.
Since Soong doesn't know which libraries are used by Make, it generates
build rules for a superset of the necessary libraries.

Bug: 132357300
Test: lunch aosp_cf_x86_phone-userdebug && m
Change-Id: I325b1037658736ee3c02450b08c00eca1a175962
2021-01-28 06:29:13 +00:00
Ulyana Trafimovich
53230fefa3 Merge "Remove obsolete class loader context API and update unit tests." 2021-01-08 17:00:56 +00:00
Ulya Trafimovich
7bc1cf508f Remove obsolete class loader context API and update unit tests.
The removed API has been unused since https://r.android.com/1533342
(except for unit tests).

Changes in the unit tests reflect the change of API in
https://r.android.com/1533342: early errors caused by unknown library
paths at CLC construction time have been replaced with late errors at
the time of CLC validation.

Bug: 132357300
Test: m nothing
Change-Id: I739c7c41b6f882b7e28cdd6acd05961d754d8687
2021-01-05 15:41:55 +00:00
Ulya Trafimovich
22890c466e Enforce <uses-library> checks for android_app and android_app_import.
Bug: 132357300
Test: lunch aosp_cf_x86_phone-userdebug && m
Change-Id: Ib9653aa27a173f0f0c03c7c9b0963d8ea71bb155
2021-01-05 12:04:17 +00:00
Jaewoong Jung
8bfb63c5a9 Merge "Break up app.go." 2020-12-28 17:50:44 +00:00
Ulyana Trafimovich
b630c37d61 Merge changes I6a512209,I56437f26
* changes:
  Unify addition of class loader subcontext from dependencies.
  Move ClassLoaderContexts() method to UsesLibraryDependency interface.
2020-12-22 10:14:41 +00:00
Jaewoong Jung
f9b44657c8 Break up app.go.
Test: m nothing + TreeHugger
Change-Id: I64c6d7f10530c424bc282d8111dfaf9159426f00
2020-12-21 12:31:51 -08:00
Jaewoong Jung
4b97a56615 Remove the return value from dexpreopt
dexpreopt doesn't strip dex files from the input jar anymore, so there's
no point returning the input jar path untouched.

Test: m nothing + TreeHugger
Change-Id: I8fde6cdc19e85a2fbc946513696417b945c5de0f
2020-12-17 09:43:28 -08:00
Ulya Trafimovich
dbf31665ab Move ClassLoaderContexts() method to UsesLibraryDependency interface.
This method logically belongs with other UsesLibraryDependency methods,
as it is used in the same context when computing class loader context.
Previously it was part of Dependency interface, which doesn't cover SDK
libraries. We do not currently have the necessary information for
SdkLibraryImport (so ClassLoaderContexts() returns nil for it), but we
do have it for SdkLibrary (via Library).

Bug: 132357300
Test: m nothing
Change-Id: I56437f260efc6a9af3f45b334e84e915244ccce1
2020-12-17 15:05:26 +00:00
Jiyong Park
45bf82e953 Assert android.ApexModule interface for types having ApexModuleBase
Bug: 173472337
Test: m nothing
Change-Id: Idf1c6cb9fff6c18e34c4636e38a662ba4ff7d538
2020-12-15 14:31:27 +00:00
Jaewoong Jung
84f1b80866 No matching variant android_app_import fix
This fixes a bug where android_app_import or android_test_import without
a matching variant or a default apk property value breaks the build.

Test: app_test.go
Fixes: 152343232
Change-Id: I8215aa1a6dad74b503eaa1169a64f8c30dda287c
2020-12-04 11:51:29 -08:00
Colin Cross
f1a035e6be Pass pctx and ctx to NewRuleBuilder
Enable the RuleBuilder and RuleBuilderCommand methods to access
the BuilderContext by passing it to NewRuleBuilder instead of
RuleBuilder.Build.

Test: genrule_test.go
Test: rule_builder_test.go
Test: m checkbuild
Change-Id: I63e6597e19167393876dc2259d6f521363b7dabc
2020-12-01 16:22:16 -08:00
Ulya Trafimovich
78a7155c17 Assume any <uses-library> is shared, add only toplevel ones to manifest.
This patch reworks the approach introduced in
https://r.android.com/1450819. That patch based the decision which
libraries should be added to the manifest <uses-library> tags by the
manifest_fixer on the "shared" status of the library.

That approach is incorrect for two reasons:

  - It doesn't make sense to have a non-shared library in class loader
    context ("shared" libraries are those specified in
    frameworks/base/data/etc/platform.xml, and they are the only ones
    that PackageManager knows about).

  - It doesn't make sense to add anything but the top-level of the
    class loader context tree to the manifest, because this part of the
    tree is flattened to a sequence, and PackageManager cannot restore
    it to the previous tree shape (there is an information loss).

This patch removes the "shared" bit of information from class loader
context elements and assumes that all libraries that end up in class
loader context are shared. Consequently, only the top-level libraries
should be passed to manifest_fixer.

Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Bug: 168686456
Change-Id: I902690f0f38f1047fa79cf6ccbe956077eceaab0
2020-11-25 14:47:05 +00:00
Colin Cross
95f1ca07ce Store ndkKnownLibs in the config
Storing ndkKnownLibs prevents multiple tests from running in parallel
as one may be writing to the list while another is reading from it.
Store it in the config so each test has its own copy.

Test: go test -race ./apex
Change-Id: Iba57c9494012c9e0ae9e5ffaa63b9b2bd2c77492
2020-11-17 10:50:19 -08:00
Ulya Trafimovich
b23d28c6e2 Rename fields and methods to reflect class loader context changes.
Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Change-Id: Iebfbf2ffdac5ee48476d2aac312b3b8f4471fc85
2020-11-16 14:59:07 +00:00
Ulya Trafimovich
a8c28e27bc Do not add dependencies of shared SDK libraries to manifest_fixer.
Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Bug: 168686456
Change-Id: Ibd9742684fa6a8f1353ca0e513f7fa814a6ec9fc
2020-11-16 14:58:11 +00:00
Ulya Trafimovich
18554243de Add nested class loader subcontext at the proper hierarchy level.
When adding a subcontext in a class loader context tree, there are two
possible cases: 1) the root of the subcontext is itself a <uses-library>
and should be present as a node in the tree, or 2) the root is not a
<uses-library>, but some of its dependencies are -- in that case they
should be disconnected from the root, and the resulting forrest should
be added at the top-level.

Example:

  1) C is a <uses-library>:

     A
     ├── B
     └── C
         ├── D
         └── E
             └── F

  2) C is not a <uses-library>:

     A
     ├── B
     ├── D
     └── E
         └── F

Before the patch subcontexts for transitive dependencies were added
before the subcontext for the direct dependency (even if it was a
<uses-library>, resulting in case-2 hierarchy when case-1 should have
been used. Previosuly this didn't matter because class loader context
was a flat set of libraries, but now it matters because class loader
context is a tree.

This patch changes the order in which libraries are added, so that
direct dependencies are added before transitive ones. The context adding
method now accepts an "implicit root" parameter, so that when adding
transitive dependencies it can check if the corresponding direct
dependency is a <uses-library> and already present in the context.

Partially constructed class loader context is now propagated top-down
into aapt.buildActions, so that the method can use existing part of the
context to decide where the missing part should be connected.

Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Change-Id: I649aff9e27494306885a4f4fc90226c399636b57
2020-11-16 14:57:05 +00:00
Ulya Trafimovich
8cbc5d269b Rework class loader context implementation.
The old representation consisted of a list of libraries (UsesLibraries),
a list of optional libraries (OptionalUsesLibraries) and a mapping from
library name to its build/install paths (LibraryPaths). The separation
into lists and map was necessary because of special handling of
compatibility libraries, which is now unified with normal libraries.

The new representation is a mapping from target SDK version to a tree
structure ClassLoaderContext. Each node of the tree represents a library
and contains library name, build/install paths and a slice of
subcontexts for dependencies. The same library may occur in the tree
multiple times in case it is a dependency of multiple libraries. The
order in which libraries are added matters (the resulting tree shape may
be different).

Test results have to be updated, as the resulting <uses-library> list is
reodered (previously it was a sorted list of map keys, and now it is
formed by a depth-first preorder traversal of the class loader tree).

Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Bug: 168686456
Change-Id: I11be8cd2967f004fd58753d7c5fb99fed179cd63
2020-11-03 15:15:46 +00:00
Ulya Trafimovich
b521811d7b Add separate dependency tags for compat libs based on SDK version.
The version in the tag is the SDK version that in which compatibility
library was added as a separate libary. Using distinct tags makes it
possible to differentiate between dependencies for different SDK
versions (this will be needed in subsequent CLs).

Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Change-Id: I72296c05d6649e811ddc701aaeb84f91d1ba66cb
2020-10-27 17:05:30 +00:00
Colin Cross
9ebc22cf2d Merge changes Ieeca3c39,Iddeea2d0,I8d66a5d3
* changes:
  Add jni_libs to host java binaries
  Make java_binary common variant a dependency
  Replace jniDependencyTag with a value
2020-10-13 03:33:10 +00:00
Jaewoong Jung
19bc60abee Merge "Add config.AndroidFirstDeviceTarget." 2020-10-12 17:30:18 +00:00
Jaewoong Jung
642916f20a Add config.AndroidFirstDeviceTarget.
Targets[Android][0] is not always the first, preferred target. Add a new
field to config to provide the correct target and begin to use it.

Test: m nothing
Test: build/soong/scripts/build-ndk-prebuilts.sh
Fixes: 156980228
Change-Id: Ib56f52424ebf47f3eee6ac62b9fd9eca2919d63a
2020-10-12 14:15:19 +00:00
Colin Cross
de78d138a1 Replace jniDependencyTag with a value
Support GetDirectDepsWithTag on JNI deps by replacing the
jniDependencyTag type with a jniLibTag value.

Test: app_test.go
Change-Id: I8d66a5d3f433562e131a1fbafce75891d1b094dd
2020-10-09 19:24:05 -07:00
Colin Cross
56a8321c21 Remove global state from apex modules
A global variant was used to store the global mapping between
modules and APEXes.  Replace it with storing pointers to APEX
contents inside each module so that they can query the contents
of any APEXes they belong to.

Bug: 146393795
Test: all Soong tests
Test: single line change to build.ninja host install dependency ordering
Test: no Android-${TARGET_PRODUCT}.mk, make_vars-${TARGET_PRODUCT}.mk or late-${TARGET_PRODUCT}.mk
Change-Id: Id2d7b73ea27f8c3b41d30820bdd86b65c539bfa4
2020-10-06 13:39:57 -07:00
Treehugger Robot
4f6eebff0c Merge changes I0885e493,Ic37c8db9
* changes:
  linux_bionic_arm64 is added when Host_bionic_arm64 is true
  HostCross is an attribute of a Target, not OsType
2020-09-24 22:56:43 +00:00
Jiyong Park
1613e5541f HostCross is an attribute of a Target, not OsType
A host target is considered as being cross-compiled when the target
can't run natively on the build machine. For example, linux_glibc/x86_64
is a non-cross target on a standard x86/Linux machine, but is a cross
host on Mac. Previously, whether cross or not was a static attribute of
an OsType. For example, Windows was always considered as cross host,
while linux_bionic was not. This becomes a problem when we support more
host targets like linux_bionic/arm64 which should be cross-host on
standard x86/Linux machines.

This change removes HostCross from the OsClass type and instead adds a
property HostCross to the Target type. When a target is being added, it
is initialized to true when the target can't run natively on the current
build machine.

Bug: 168086242
Test: m
Change-Id: Ic37c8db918873ddf324c86b12b5412952b0f2be2
2020-09-24 14:14:31 +09:00
Dan Albert
4f378d75aa Convert more versions in config to ApiLevel.
The test case I removed is invalid. The codename has had its int
assigned, but the config claims it is not final.

If this ever does need to be supported it's just a matter of making
sure the Q -> 29 mapping (or whatever) in the finalized codenames map
in android/api_levels.go.

Test: treehugger
Bug: http://b/154667674
Change-Id: I4f42ec2fd4a37750519ee3937938a1c65b6bb1e8
2020-09-22 16:01:56 -07:00
Dan Albert
c8060536e8 Replace ApiStrToNum uses with ApiLevel.
Test: treehugger
Bug: http://b/154667674
Change-Id: I2954bb21c1cfdeb305f25cfb6c8711c930f6ed50
2020-09-22 15:04:48 -07:00
Ulya Trafimovich
663dc53c94 Consistently use default install path for compatibility <uses-library>.
Previously default install path was provided only for comatibility
libraries that are added explicitly via `uses_libs`/`optional_uses_libs`
properties. This didn't take into account compatibility libraries that
are added by Soong when it computes transitive closure of SDK library
dependencies. As a result, install path in such cases remained unknown,
and the corresponding compatibility library was omitted from class
loader context, which caused 'ClassLoaderContext shared library size
mismatch' errors at first boot on device.

Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Change-Id: If661272f46803299c8640f7f5ef161c8217d07e4
2020-09-11 11:31:22 +01:00
Xin Li
80dc4f137a Merge "Merge Android R" 2020-09-10 17:22:09 +00:00
Ulya Trafimovich
54027b572e Replace is_uses_lib property with provides_uses_lib.
The previous property was boolean-valued and provided only the
information whether the library should be treated as <uses-library>
by Soong. The new property is an optional string, which is the name of
the <uses-library>. The name can be different from the module name, as
in the case of "qcrilhook" module which provides <uses-library>
"com.qualcomm.qcrilhook".

Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Change-Id: I65b68e6f7c420ab9c443a76de4c917d31fcd8c8f
2020-09-10 10:47:41 +01:00
Ulyana Trafimovich
0f13eff149 Merge "Be more strict about unknown install <uses-library> paths." am: 117a5ef307
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1418529

Change-Id: Ib28e902e7f8ec57a15ef50692024cd37a96696bc
2020-09-08 15:34:50 +00:00
Ulya Trafimovich
045e11ad0d Be more strict about unknown install <uses-library> paths.
Allow default install paths only for compatibility libraries. For other
libraries that are explicitly specified in `uses_libs` and
`optional_uses_libs` unknown install path should be an error.

Bug: 132357300
Test: lunch cf_x86_phone-userdebug && m
Change-Id: I2209c90a939a8aa46c42e13bb42d09c07e4d0895
2020-09-07 13:58:51 +01:00
Ulyana Trafimovich
99bd329274 Merge "Allow non-SDK Java libraries to masquerade as <uses-library>." am: bb3467d297
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1417188

Change-Id: If25aaa0174091e966cc5c6b16063b6486a7b4ab6
2020-09-07 10:23:53 +00:00
Ulya Trafimovich
21a7375205 Allow non-SDK Java libraries to masquerade as <uses-library>.
Extend usesLibraryProperties with a boolean is_uses_lib property and
move these properties from java.AndroidApp to java.Module to allow
java.Library modules set the new propery and be recognized as
<uses-library> by Soong.

Bug: 132357300
Test: lunch cf_x86_phone-userdebug && m
Change-Id: I01cd5e0da3dd543c1c0597249d37d0914b213ca7
2020-09-01 17:45:39 +01:00
Xin Li
65cb5c69ea Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507
Merged-In: Ifca7b65f4e27bf14cdc30f72f790b0de90130bae
Change-Id: I3a39be5f0b8736de4822c6a14072c78d4e4ad89d
2020-08-29 01:17:45 -07:00
Ulya Trafimovich
fc24ad3d4e Propagate transitive SDK Java library dependencies to dexpreopt.
For some dependencies, like stubs, the SDK library may not be found at
build time (either because the implementation library is not among the
dependencies of the dexpreopted module, or because it's part of a
prebuilt, or because it's missing from the build altogether). In such
cases dexpreopt is useless, because dex2oat does not have access to the
full classpath (unless the &-classpath is used). Therefore do not
dexpreopt in such cases.

Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Change-Id: If289088cfd103011ccb16165e95a97b30fd31b81
2020-08-27 11:47:15 +01:00
Treehugger Robot
ec7a91f9fa Merge "Add extra_test_configs option" 2020-08-21 16:22:43 +00:00
Ulyana Trafimovich
9ce2221791 Merge "Collect paths to transitive SDK Java library dependencies." 2020-08-20 10:37:58 +00:00
Dan Shi
95d19422a6 Add extra_test_configs option
Bug: 163344047
Test: m -j HelloWorldHostTest hello_world_test HelloWorldTests
Change-Id: I237e3aa3f40df1f6387ba8ff6a16e56535cdeae9
2020-08-19 15:27:03 -07:00
Ulya Trafimovich
31e444e101 Collect paths to transitive SDK Java library dependencies.
Previously only the names were collected, and later used in the
manifest_fixer to add missing <uses-library> entries to the manifest.
Now we also need to collect build-time and on-device paths, to be used
in class loader context for dexpreopt. This commit only collects paths,
but does not pass them to dexpreopt yet.

Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Change-Id: I34b229ee68f16ba215ba03770feadb4d890ec2bf
2020-08-19 13:51:21 +01:00
Anton Hansson
72ce814def Merge "Add a tagged output for app's exportPackage" 2020-08-18 11:38:46 +00:00
Anton Hansson
092aca410f Add a tagged output for app's exportPackage
This allows the android stubs to depend on framework-res' exportPackage
without special-casing inside the build system.

Bug: 161214753
Test: depending on this output in a followup CL
Change-Id: I8c5d17540d2624974983d73e56ba17898505dba8
2020-08-17 11:00:00 +01:00
Colin Cross
a24b9deb5f Merge changes I02fb745a,Iccc96c0d
* changes:
  Follow all shared library dependencies when collecting JNI libraries
  Handle static unwinder in ltoDepsMutator
2020-08-13 21:55:53 +00:00
Colin Cross
2eddd06879 Merge "Add libraryDependencyTag to track dependencies on static and shared libraries" 2020-08-06 00:06:28 +00:00
Liz Kammer
9eb51fc9d4 Merge "Refactor java compileDex" 2020-08-05 15:41:03 +00:00
Liz Kammer
a7a64f3c5b Refactor java compileDex
We want to support a compile_dex property for java_import. This splits
dex-related properties into a dexer struct which can be embedded in
relevant modules.

Test: m
Test: soong tests
Bug: 160455085
Change-Id: If56a51dac43f630d49483a36db29cd50e9ccd529
2020-08-04 10:15:04 -07:00
Colin Cross
f0913fb0a0 Follow all shared library dependencies when collecting JNI libraries
The implementation before libraryDependencyTag was added failed to
include some JNI libraries into apps because it did not handle
sharedExportDepTag, earlySharedDepTag or lateSharedDepTag.

Also fix a bug in cc.*Module.IsNdk that was comparing "liblog.ndk"
against "liblog" and incorrectly returning false that would have
caused NDK libraries that now pass the check above to incorrectly be
packaged into the APK.

Bug: 162437057
Test: m checkbuild
Change-Id: I02fb745abb5cace2b4e5bfff2f35cef6d2e0a4ff
2020-07-29 13:22:33 -07:00
Colin Cross
6e511a9a9f Add libraryDependencyTag to track dependencies on static and shared libraries
dependencyTag uses a set of predefined tags to identify different types
of dependencies.  There are already multiple bits of metadata stored
in the dependency tag (Library, Shared, ReexportFlags), and supporting
them all requires a combinatorial explosion of predefined tags and
causes issues when using equality comparisons if a new bit of metadata
is added.

Add a new libraryDependencyTag type that will contain the metadata
bits, and replace the quality comparisons with checks on the metadata
bits.

There are 5 TODOs where modifying the checks identified problems with
the existing checks.  These were left in place to produce identical
build output and will be fixed separately.

Bug: 162437057
Test: no change to build.ninja or {Android,make_vars,late}-${TARGET_PRODUCT}.mk
Change-Id: I72d4207dcf381c07c92e00e5a03968ebb5ed8d30
2020-07-29 13:22:30 -07:00
Liz Kammer
cada807a92 Update language to comply with inclusive guidance
Update android_app_set to use word install rather than master for
android_app_sets, this better matches the phrasing used for apex_set.

See https://source.android.com/setup/contribute/respectful-code for
reference

Bug: 161896447
Test: m nothing
Change-Id: I429e7f8b16c42c10ad4d9543110f5ce814a893b1
2020-07-28 15:47:38 -07:00
Liz Kammer
464e5f720c Merge "Add android app property rename_resources_package" into rvc-dev-plus-aosp 2020-07-17 16:56:04 +00:00
Colin Cross
f5ada2c731 Merge changes from topic "lint-unbundled-apps" am: 70f0b53000 am: 8d984239e1
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1360941

Change-Id: Ic1b7ec667b2f4ba2a3205ca372bf3afccffff1f3
2020-07-16 23:19:43 +00:00
Treehugger Robot
0add164d0e Merge "Pass unstripped JNI libraries to Make" am: bf81ed4fd1 am: 9a6d827dc3
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1356262

Change-Id: I99a111aafcab5a8a8a5b704b9dd67904c93b0aea
2020-07-16 23:19:16 +00:00
Colin Cross
70f0b53000 Merge changes from topic "lint-unbundled-apps"
* changes:
  Build a zip of transitive lint reports for apps
  Add DepSets
2020-07-16 23:06:22 +00:00
Treehugger Robot
bf81ed4fd1 Merge "Pass unstripped JNI libraries to Make" 2020-07-16 22:43:53 +00:00
Colin Cross
c0efd1db13 Build a zip of transitive lint reports for apps
Add a rule to build a zip containing the lint reports from transitive
dependencies for apps, and pass it to Make.

Bug: 153485543
Test: m TARGET_BUILD_APPS=Gallery2 lint-check
Change-Id: I523c09016251377ff89d76084769be7401b95425
2020-07-16 12:51:42 -07:00
Liz Kammer
9f9fd02363 Add android app property rename_resources_package
This relands I70a43c2163709afc90262d74f975ce14a556cf55 with a property
to disable renaming of the package in resource files to support
compatibility with packages that would be infeasible to change without
causing failures.

When rename_resources_package is true, uses aapt2 flag to change the
package name encoded in the resources table for override apps.

Test: app_test.go
Bug: 147434671
Change-Id: I3a051ddeb5979f9c0838d176656a1b5cf2677a9b
2020-07-14 19:28:15 +00:00
Colin Cross
4fb652d681 Set LOCAL_APKCERTS_FILE for apk_set modules in apexes
I321e80fd636a955213761f56a3ac64bfe7f7f7c0 missed setting
LOCAL_APKCERTS_FILE for apk_set modules in apexes, which causes
invalid apkcerts.txt files.

Bug: 160652723
Test: m apkcerts-list
Change-Id: I1ccaafd04978374d0da10363a1d782cfeae428e7
Merged-In: I1ccaafd04978374d0da10363a1d782cfeae428e7
(cherry picked from commit 7e2b36c7d5)
2020-07-10 20:38:50 -07:00
Colin Cross
403cc15f1b Pass unstripped JNI libraries to Make
Pass a list of unstripped JNI libraries to Make so that they can be
installed into the symbols directory.

Bug: 159726429
Test: forrest
Change-Id: Ieb4bffbb3d0a09f476da011399c5b8b1611929d7
2020-07-10 13:44:32 -07:00
Colin Cross
44440f8bf3 Set LOCAL_APKCERTS_FILE for apk_set modules in apexes am: 7e2b36c7d5
Original change: https://googleplex-android-review.googlesource.com/c/platform/build/soong/+/12124681

Change-Id: I35ad9081f9908362f37d8fc558e392347a41b104
2020-07-10 04:42:13 +00:00