Commit Graph

4943 Commits

Author SHA1 Message Date
Paul Duffin b508405e08 Export boot image files from prebuilt_apex/apex_set
Previously, the prebuilt art-bootclasspath-fragment did not provide any
boot image files. That meant it was impossible to build any module that
requires access to those files from prebuilts, e.g. any module that
needs to be dexpreopt-ed.

This change enables that module to retrieve those files from the
prebuilt_apex.

Bug: 177892522
Bug: 189298093
Test: m nothing
      m droid SOONG_CONFIG_art_module_source_build=false SKIP_BOOT_JARS_CHECK=true
      - the previous command does not work but this change does fix one
        of the issues reported.
Merged-In: I1d4d9545172d79282918130df6b9aa55471bffc1
Change-Id: I1d4d9545172d79282918130df6b9aa55471bffc1
(cherry picked from commit 5466a3699c550d1fa67066db48951b765156be4f)
2021-06-18 12:11:17 +01:00
Paul Duffin a0089ec78c Copy boot dex jars from prebuilt art-bootclasspath-fragment if preferred
Previously, the boot dex jars were only copied to the predefined
locations used by the build from the source art-bootclasspath-fragment
if it was preferred, otherwise no files were copied. That caused build
failures when attempting to build with ART prebuilts. This change
copies the files from prebuilts too.

Bug: 177892522
Bug: 189298093
Test: m nothing
      m droid SOONG_CONFIG_art_module_source_build=false SKIP_BOOT_JARS_CHECK=true
      - the previous command does not work but this change does fix one
        of the issues reported.
Merged-In: I35b37355170546daf6ecac2134d1ca9a73d0e3bc
Change-Id: I35b37355170546daf6ecac2134d1ca9a73d0e3bc
(cherry picked from commit ce918b0278628afe4de73b09f73bac777d545b7e)
2021-06-18 12:11:17 +01:00
Paul Duffin 4fd7dc7de0 Exclude jacocoagent from boot jars package check
This replicates the previous behavior when the boot jars package check
was performed by a singleton. When the singleton was removed and the
check was performed by the platform-bootclasspath the logic to exclude
jacocoagent from the list was lost. This change replaces it.

Bug: 191377804
Test: m EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true check-boot-jars
      - fails without this change passes with this change.
Merged-In: If9eae254045bef9a0c0963213721fc12a9f463cb
Change-Id: If9eae254045bef9a0c0963213721fc12a9f463cb
(cherry picked from commit 7f8721618cbdcd169694d980cd598d0b80ef9629)
2021-06-18 12:11:17 +01:00
Paul Duffin e11254793d Move boot jars package check into platform_bootclasspath
Bug: 177892522
Bug: 189298093
Test: m check-boot-jars
      m SOONG_CONFIG_art_module_source_build=false check-boot-jars
      - Ran both commands with and without java.lang in the
        package_allowed_list.txt
Merged-In: Iba1a881c8f6b6919d5c0c0520eb3073658f3b8d2
Change-Id: Iba1a881c8f6b6919d5c0c0520eb3073658f3b8d2
(cherry picked from commit c8ead41ba9426a31c8ca3d7228991a45ccff6299)
2021-06-18 12:11:17 +01:00
Paul Duffin 360f8359f3 Cleanup bootclasspathFragmentInitContentsFromImage
Removes some unnecessary logic left over from previous changes.

Bug: 177892522
Test: m nothing
Merged-In: Id11e2ea8a647283af1b152b33757132e44dcd6c3
Change-Id: Id11e2ea8a647283af1b152b33757132e44dcd6c3
(cherry picked from commit 58e7586b3d8fffa63b869c421a36c69fdd30a264)
2021-06-18 12:11:17 +01:00
Paul Duffin c75bbcecdb Combine hidden API encoding with flag generation
Previously, the rules to perform hidden API encoding were generated
separately to the rules to perform hidden API flag generation. This
change combines them within the (renamed) produceHiddenAPIOutput()
method and makes the paths to the encoded dex files an output of the
generateHiddenAPIBuildActions method alongside the paths to the
generated flag files.

As encoded dex jars are now an output of the produceHiddenAPIOutput()
method which is implemented for both prebuilts and source
bootclasspath_fragment modules that necessitated the prebuilt also
providing paths to encoded dex files. That in turn required updates to
some of the tests to provide dex files from prebuilt_apex modules.

Similarly, as the produceHiddenAPIOutput() method may not be called
for some bootclasspath_fragment modules as they do not yet provide all
the information needed to perform hidden API encoding then it is
necessary to extract the encoded dex files produced by the modules
themselves. That also required a few changes to tests that did not
previously provide dex files.

Bug: 177892522
Test: m com.android.art
      - check that this change does not change the contents of the apex
        file, i.e. is byte-for-byte identical.
Merged-In: I60996a34d06ed1c87ed244ab3509621999ad86ec
Change-Id: I60996a34d06ed1c87ed244ab3509621999ad86ec
(cherry picked from commit e521881bd45de0306bc2e80d5c746ae361d6ffe2)
2021-06-18 12:11:17 +01:00
Paul Duffin 98ea0d4926 Avoid passing around []hiddenAPIModule
Previously, an []android.Module was converted to an []hiddenAPIModule
that was then used to retrieve boot dex jars. That was ok when
obtaining the dex jar files from source modules for
bootclasspath_fragment but does not work well for other use cases as
it would require doing that conversion in multiple places.

This change pushes the use of hiddenAPIModule down to the methods that
retrieve information from it which makes the methods more flexible and
easier to reuse.

Bug: 177892522
Test: m nothing
Change-Id: Ib84aaf03d8f5a63b48232036fe4589646fc23352
Merged-In: Ib84aaf03d8f5a63b48232036fe4589646fc23352
(cherry picked from commit dd5993f6d41efa932c06afef71c40af446c85b4e)
2021-06-16 11:07:58 +01:00
Paul Duffin 3e2db5c10b Make copyBootJarsToPredefinedLocations simpler and less fragile
Previously, copyBootJarsToPredefinedLocations relied on all its
parameters having the same length and the same order. That made it
quite fragile as changes to one of the parameters without corresponding
changes to the other would cause failures. It also combined the
retrieval of the boot dex jars from the modules, handling of missing
boot dex jar files and the generation of the rules to copy the files.

This change separates the retrieval of boot dex jars and handling of
missing files from the copying of those files while at the same time
making the function less fragile by replacing the three ordered
parameters with two maps that shared common keys.

Bug: 179354495
Test: m nothing
Merged-In: Idbcd24a7e8af89f7895a20aeddc58502dcbaad03
Change-Id: Idbcd24a7e8af89f7895a20aeddc58502dcbaad03
(cherry picked from commit 5f148ca7cf2e9a9478922577b7ed70b1caacb55e)
2021-06-16 03:06:35 +01:00
Paul Duffin 8c666a3665 Ensure primary boot image files are created before they are used
Previously, when building a framework boot image variant it added an
implicit dependency onto the first file in the primary boot image
variant to ensure that the primary boot image variant files that the
dex2oat command needs have been created. That works when generating
from source as in that case all the files for a boot image variant are
created by a single command. However, it does not work for prebuilts as
each prebuilt file will be copied into the required location by
separate copy commands.

This change adds all the files that the dex2oat command uses implicitly
when building an extension boot image as implicit dependencies.

Bug: 177892522
Test: m SOONG_CONFIG_art_module_source_build=false droid
      - the previous command only works in combination with a number of
        other build changes.
Merged-In: I183748fd17f8f3003890675b8c6bb9fcab331443
Change-Id: I183748fd17f8f3003890675b8c6bb9fcab331443
(cherry picked from commit bff50e2b803ede32c9b17b6b7bf3054424703bf5)
2021-06-16 03:06:35 +01:00
Paul Duffin 5991ba5119 Move TestPlatformBootclasspath_Fragments to apex package
This test checks that fragments which are referenced from a
platform_bootclasspath module contribute their hidden API flags to those
used by platform_bootclasspath module. Previously, it was unrealistic
because the bootclasspath_fragment does not belong in an APEX.

This change moves the test from the java package to the apex package to
allow it to be modified to make the bootclasspath_fragment part of an
apex.

Bug: 179354495
Test: m nothing
Merged-In: Icb57f2e1eaea4b14aab5f47f3af7d05ea0555816
Change-Id: Icb57f2e1eaea4b14aab5f47f3af7d05ea0555816
(cherry picked from commit ffa8375f072bab79666eb1e0f313ec1689dcc92b)
2021-06-16 03:06:34 +01:00
Paul Duffin c45a86a65d Export hidden api related types and fields
This will export some hidden api related types and fields so they can
be used from outside the java package. This is needed to allow a follow
up change to move the TestPlatformBootclasspath_Fragments from the java
to the apex package.

Bug: 179354495
Test: m nothing
Merged-In: Ib69eea9d79cc83b8e3fc29919a29f071e1ec17b5
Change-Id: Ib69eea9d79cc83b8e3fc29919a29f071e1ec17b5
(cherry picked from commit 524c82c01acbd1f45a401d3444354cd69dd342e3)
2021-06-16 03:06:33 +01:00
Paul Duffin 2aae98f029 Maintain header order in merge_csv
Previously, if the --header property was not specified then merge_csv
would use a header constructed by sorting all the fields in the input
files. That required that any use of merge_csv which did not already
have headers in the required order would have to explicitly specify the
headers. That made it harder to use merge_csv as a generic tool as each
invocation needed to be aware of what headers were exported in the
output.

This change causes merge_csv to simply use the headers in the order in
which they are encountered in the input files. That removes the need to
specify the --header option when generating the index files.

Bug: 179354495
Test: m out/soong/hiddenapi/hiddenapi-index.csv out/soong/hiddenapi/hiddenapi-unsupported.csv
      - make sure that they are not changed by this change.
Merged-In: I420b7d07aea85af6372cd7580a8be5e2cc82a513
Change-Id: I420b7d07aea85af6372cd7580a8be5e2cc82a513
(cherry picked from commit 84c1cdf31f8f888ee9c0beb201d35ad9d293c341)
2021-06-16 03:06:33 +01:00
Jeff Sharkey 930610f64b Merge "Revert "Hacky workaround for half-finalized builds."" into sc-dev 2021-06-15 03:51:41 +00:00
Jeff Sharkey 46d18dbd7a Revert "Hacky workaround for half-finalized builds."
This reverts commit 05597c0cc4.

Bug: 171506470
Test: Build
Change-Id: Id45b2eec2c9c1ba1a33ba35232229004d67c026c
2021-06-13 18:15:26 -06:00
Colin Cross fb618c387a Always propagate some environment variables to RBE
Always propagate LANG, LC_MESSAGES and PYTHONDONTWRITEBYTECODE
to RBE to get more consistent behavior between local actions and
RBE.

Bug: 182415460
Bug: 190593001
Test: treehugger
Change-Id: I726e6f02fd3ef77e158baf6fde77ffb7247a1375
Merged-In: I726e6f02fd3ef77e158baf6fde77ffb7247a1375
2021-06-11 12:54:36 +01:00
Anton Hansson e7db515506 Merge changes from topic "met-html" into sc-dev
* changes:
  Remove sourcepath argument from metalava invocations
  Stop filtering html files from droidstubs input
2021-06-10 12:22:17 +00:00
TreeHugger Robot f524f1f957 Merge "Add exemption for framework-sdkextensions-classpaths boot jar." into sc-dev 2021-06-10 10:40:52 +00:00
Anton Hansson 363aae4343 Remove sourcepath argument from metalava invocations
This is no longer required to find package.html files, so remove it.

Bug: 153703940
Test: m checkapi
Merged-In: I80ec219cb9ef8922094336a5d45652c8e59aa113
Change-Id: I80ec219cb9ef8922094336a5d45652c8e59aa113
(cherry picked from commit 556e8149cb7781cbe01ea01a8b8a05eb1b018f1a)
2021-06-09 13:55:13 +01:00
Anton Hansson 701857903a Stop filtering html files from droidstubs input
Metalava now expects html files to be specified explicitly. This
filtering was originally added because jdiff could not cope with html
inputs, but jdiff support has been removed in r.android.com/1455335.

Bug: 153703940
Test: m checkapi
Merged-In: I34164b633bab2892e3a1c0fd0257fcf98d537655
Change-Id: I34164b633bab2892e3a1c0fd0257fcf98d537655
(cherry picked from commit edd61643be3096af46d1f6aea1091897f668c66b)
2021-06-09 13:54:38 +01:00
Colin Cross 7104aae119 Don't use unsafe_ignore_missing_latest_api in TestJavaSdkLibraryDist
Use FixtureWithLastReleaseApis to create the necessary files instead
of disabling the check with unsafe_ignore_missing_latest_api.

Bug: 186723288
Test: TestJavaSdkLibraryDist
Change-Id: I162b0f68eec596274f8d98dca9d3f0500ab13f5d
Merged-In: I162b0f68eec596274f8d98dca9d3f0500ab13f5d
(cherry picked from commit 67c17aede87e3e6d9e1abefc6ad86e987fc9bee9)
2021-06-08 10:17:58 -07:00
Colin Cross ea0e69897e Remove core_lib property from java_sdk_library
Its not used, remove it.

Bug: 186723288
Test: TestJavaSdkLibraryDist
Change-Id: I1689b670a8ae6a614e5e4ec5e79cb5e283b2e277
Merged-In: I1689b670a8ae6a614e5e4ec5e79cb5e283b2e277
(cherry picked from commit f0eace9eed83c0d7cd06df29379ed7e090bd2c27)
2021-06-08 10:17:58 -07:00
Colin Cross 1072a71089 Ignore owner property when computing java_sdk_library dist subdirectory
The owner property is no longer used, the dist subdirectory is determined
by the dist_group property.

Bug: 186723288
Test: TestJavaSdkLibraryDist
Change-Id: Id6d997eef05f6511070677974219674f248cb754
Merged-In: Id6d997eef05f6511070677974219674f248cb754
(cherry picked from commit 59b92bfdb300d93558d685e9ea9f4cb5c7378a3b)
2021-06-08 10:17:58 -07:00
Colin Cross 0f9eeb753d Make the default java_sdk_library dist_group "unknown"
Change the default dist_group from "android" to "unknown" to prevent
accidentally including java_sdk_library stubs that do not set
dist_group or owner in the public SDK.

Bug: 186723288
Test: TestJavaSdkLibraryDist
Change-Id: I9aae2a16254ac1a8d444acfa63bc571d1ef4b045
Merged-In: I9aae2a16254ac1a8d444acfa63bc571d1ef4b045
(cherry picked from commit 3dd662509d02914a09f9954b37eaa7dd164a3523)
2021-06-08 10:17:58 -07:00
satayev b75cd4ed7a Add exemption for framework-sdkextensions-classpaths boot jar.
As long as we have boot jars defined in make, we should try to keep
global.UpdatableBootJars as a source of truth when it comes to classpath
configuration. However, for testing purposes there is a need to add
java libraries to bootclasspath that aren't present in
PRODUCT_UPDATABLE_BOOT_JARS variable.

Ideally, we would unconditionally add all contents to the config for
test apexes, however, I don't fully understand apex merging to support
it.

Bug: 180105615
Test: atest sdkextensions_classpaths_e2e_tests
Change-Id: I552f93289c27b3713e75dcda1faed909b0bfcef2
Merged-In: I552f93289c27b3713e75dcda1faed909b0bfcef2
(cherry picked from commit 1b75a3ce623357020ec6f1446edff974a0dc283a)
2021-06-08 15:29:19 +01:00
Anton Hansson b6d94b6999 Merge "Make soong create sourcepath dirs" into sc-dev 2021-06-04 17:48:44 +00:00
Anton Hansson 7eff3a8fc3 Make soong create sourcepath dirs
Sourcepath is set to dir of the Android.bp, but that dir does not
necessarily have any inputs for the metalava invocation defined in that
Android.bp. This leads to problems when metalava tries to read a
non-existent dir, so create it first.

Bug: 153703940
Test: m sdk dist
Change-Id: I8c2ca45c8f066cabf3247b9652a7094cefc047a9
2021-06-04 10:27:18 +01:00
Yuntao Xu ad1668fc13 add the LOCAL_DISABLE_TEST_CONFIG variable
Introduce and set the variable LOCAL_DISABLE_TEST_CONFIG varaible to be
true for the `android_test_helper_app` type modules.

Bug: 188927912
Test: rum 'm module-name' (`android_test_helper_app` type module)
Test: TreeHugger
Change-Id: I5db1029f31d8afe1ca5e9fab95e39d751971058d
Merged-In: I5db1029f31d8afe1ca5e9fab95e39d751971058d
2021-06-03 10:16:39 -07:00
Jeff Sharkey 799822d7af Merge changes from topic "may27-sdk" into sc-dev
* changes:
  Hacky workaround for half-finalized builds.
  platform/build/soong - S is now 31
2021-06-02 20:11:14 +00:00
Colin Cross 0d3dd0600f Support dist_group property instead of owner for setting sdk dist subdirectory
Reusing the owner property is confusing, especially when the property is
required on every java_sdk_library module.  Create a new dist_group property
to use instead.

Bug: 186723288
Test: TestJavaSdkLibraryDist
Change-Id: I9e62c703a95d6b63cafa60bffb1b37ba85388593
Merged-In: I9e62c703a95d6b63cafa60bffb1b37ba85388593
(cherry picked from commit 986b69aa51062309f58923eee8571e824d1896d9)
2021-06-02 08:06:41 -07:00
Colin Cross 3b538082fe Add test for java_sdk_library dist properties
Add tests that cover the owner, core_lib and dist_stem properties.

Bug: 186723288
Test: TestJavaSdkLibraryDist
Change-Id: I4c2ae2a23dcd9a668c46ed5cc23b1d7dcfae798a
Merged-In: I4c2ae2a23dcd9a668c46ed5cc23b1d7dcfae798a
(cherry picked from commit 30c491b885c3dbd9094146b1e8054f3d62e2f55a)
2021-06-02 08:06:40 -07:00
Colin Cross 76069a30a4 Move java_sdk_library tests to sdk_library_test.go
Seperate the java_sdk_library tests into their own file.

Bug: 186723288
Test: go test ./java/...
Change-Id: I899c2946cb2234dc595a4281e64bbb239b89bda8
Merged-In: I899c2946cb2234dc595a4281e64bbb239b89bda8
(cherry picked from commit 1d2b6b3b2ecc6dac49b1a8be697d7374dbed5d79)
2021-06-02 08:06:40 -07:00
Jeff Sharkey 05597c0cc4 Hacky workaround for half-finalized builds.
Metalava increments the SDK level by one when it's not "REL", so we
temporarily force the build to be "REL" while we're still in the
process of finalizing it.

This CL must be reverted as part of actually declaring "REL".

Bug: 171506470
Test: Build
Change-Id: I95ee4879268eab3e28a653ca8c169bf6a83e2a19
2021-06-01 12:31:13 -06:00
Colin Cross f63cf839ca Merge changes I0116f5f4,I950c9b54,I967f5c42 into sc-dev
* changes:
  Treat java libraries in classpath fragments as directly in apex
  Make CopyDirectlyInAnyApex match the documentation
  Remove unused cc.copyDirectlyInAnyApexDependencyTag
2021-06-01 17:23:45 +00:00
Anton Hansson ea2d99c1a0 Merge "Remove support for removed_dex_api_filename" into sc-dev 2021-05-28 06:34:10 +00:00
Colin Cross cbb2b8172d Treat java libraries in classpath fragments as directly in apex
Coverage is applied to java libraries that are directly in an apex.
Mark java libraries that are in an apex through a bootclasspath_fragment
or a systemserverclasspath_fragment as directly in the apex by
implementing CopyDirectlyInAnyApexTag on the dependency tags used for
their contents.

Bug: 183759446
Test: TestApexJavaCoverage
Change-Id: I0116f5f415083b5194000988cb257454ef115200
Merged-In: I0116f5f415083b5194000988cb257454ef115200
(cherry picked from commit c33e5216f1eb3f837dee89cc65208eff058e9c5e)
2021-05-27 13:14:33 -07:00
Martin Stjernholm c4f4cedc47 Merge "Drop "prebuilt_" prefixes from names registered in ApexInfo.InApexXxx."
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1719298

Bug: 180325915
Change-Id: I1fd96bad2326612d153fed31308914902f58d3ec
Merged-In: Icbe4e025ce1a4c8dd258ff95d326ca2f27905188
(cherry picked from commit f4c44417a3c769be884ee1c2bdcd95689b5cecb4)
2021-05-27 17:23:16 +00:00
Anton Hansson a7bb86b48e Remove support for removed_dex_api_filename
Nothing uses this argument anymore, so simplify the droidstubs code by
removing the argument.

Bug: 189426360
Test: m
Change-Id: I0e4b84d73a954b3819db1149be3da287cf604eec
2021-05-27 12:31:03 +01:00
satayev 07753d8467 Use stem when filtering boot jars.
For testing purposes, a boot jar may be provided by a test java_library
that has a different content name, but sets "stem" property to match
the original java_library.

Given that Stem() returns either the property value or module name,
it is safe to replace all content names by their stems.

Bug: 180105615
Test: atest CtsClasspathsTestCases sdkextensions_e2e_tests
Change-Id: Ic519ffa0c5b616abddf15b41c934421dfac2e78a
2021-05-25 21:16:34 +01:00
Artur Satayev 5cb569794e Revert "Partial Revert "Populate individual classpath_fragments'..."
Revert submission 14717811-revert-populate-platform-bootclasspath

Reason for revert: retry with a fix
Reverted Changes:
Ib58cd0211:Revert "Add bootclasspath_fragments to platform-bo...
I13b622d6c:Partial Revert "Populate individual classpath_frag...

Bug: 180105615
Test: atest sdkextensions_e2e_tests

Change-Id: I7b6b6b980a4c6430a70394e85222f3b35c4efd5f
2021-05-25 21:00:31 +01:00
satayev 931a4488da Populate individual systemserverclasspath_fragments' proto configs.
Bug: 180105615
Test: m && launch_cvd; atest CtsClasspathsTestCases
Change-Id: Ic0ae897e9baca75dcc022d84656496563645e74e
Merged-In: Ic0ae897e9baca75dcc022d84656496563645e74e
2021-05-25 21:00:07 +01:00
Artur Satayev f1adfb38fb Merge "Rename generate proto config file to match classpath type." into sc-dev 2021-05-25 19:40:05 +00:00
Anton Hansson bbe2d3db4a Merge "Partial Revert "Populate individual classpath_fragments' classpaths.prot..."" into sc-dev 2021-05-25 14:18:42 +00:00
satayev a3fc817771 Partial Revert "Populate individual classpath_fragments' classpaths.prot..."
Reason for revert: test breakage b/189114287
Bug: 180105615
Bug: 189114287
Test: atest sdkextensions_e2e_tests

Change-Id: I13b622d6c61ea392bfcc8a40535045c87fa3a7b5
2021-05-25 15:12:23 +01:00
Paul Duffin 588e22a6bc Tighten bootclasspath_fragment property validation
Previously, due to legacy reasons, the property validation did not
require a contents property and allowed the image_name to be either
"art" or "boot". Those reasons no longer apply and so this change
requires a contents property and only allows the image_name to be set
to "art" if specified.

Bug: 177892522
Test: m nothing
Merged-In: I8855d6e5365ef0b55490e90e7b6c0081cf070ee5
Change-Id: I8855d6e5365ef0b55490e90e7b6c0081cf070ee5
(cherry picked from commit 8018e50ddb141dea7891918c4178a7a394a788d8)
2021-05-25 09:30:20 +01:00
Paul Duffin 0788cd6038 Only export boot image files to APEX if they are actually created
Previously, the generation of the rules to create the boot image files
was separate from the code to provide those files to the APEX which
meant that it was possible for the APEX to try and use files that had
no rules to create them.

This changes avoids that by only exporting the files once the rules
have been created.

This necessitated a few changes to tests that were relying on the
previous behavior. Including removing completely the test that used an
image_name: "boot" as that is no longer a valid configuration name as
its functionality has been replaced by platform_bootclasspath.

A follow up change will make the validation of the properties of
bootclasspath_fragment stricter to prevent "boot" being used as the
image_name.

Bug: 177892522
Bug: 188680624
Test: lunch qemu_trusty_arm64-userdebug
      m droid dist
      - verify that before this change it fails and after this change
        it works.
      m com.android.art
      - verify that this change does not change the APEX contents with
        either qemu_trusty_arm64-userdebug or aosp_arm64-userdebug
Merged-In: I0497a151eb0731cbe6a1a7e7bbbb1e4dda75898f
Change-Id: I0497a151eb0731cbe6a1a7e7bbbb1e4dda75898f
(cherry picked from commit 58e0e769c9b1f4dbad95acfd1792dd91e716e456)
2021-05-25 09:30:20 +01:00
Paul Duffin 54c1f08aa9 Support removed API members in modular hidden API processing
Previously, the hidden API flags generated for a bootclasspath_fragment
did not include removed API members. That was because it did not supply
a file containing the dex signatures of the removed API members.

The monolithic hidden API processing uses combined-removed-dex which is
the output of a genrule that takes as input the *removed.txt files from
all the APIs and uses metalava to construct the dex signatures file.
This change does the equivalent for the *removed.txt files for the APIs
provided by a bootclasspath_fragment and then passes them to the rule
that generates the final all-flags.csv.

Bug: 179354495
Test: - Update packages/modules/RuntimeI18N to enable hidden API
        processing.
      m out/soong/hiddenapi/hiddenapi-flags.csv
      - Before this change that fails as the flags generated for the
        i18n-bootclasspath-fragment differ from the monolithic flags.
	After this change that passes.
      - Verify that this change does not change any of the monolithic
        hidden API files.
      m com.android.i18n
      - Verify that the apex file before and after this change are byte
        for byte identical.
Merged-In: I6a21edb8a5231666e3f35b2c99a8687f36dd98fd
Change-Id: I6a21edb8a5231666e3f35b2c99a8687f36dd98fd
(cherry picked from commit 32cf58a8fcfc043246a9c402b32c863e8aebc499)
2021-05-24 20:26:02 +01:00
Paul Duffin 67c1e57551 Support hidden API processing for fragments with dependencies
Previously, a bootclasspath_fragment that depended on classes provided
by another bootclasspath_fragment did not support hidden API processing
as it would not supply information about those dependencies.

This change adds support for that as follows. Each fragment:
1. Exports the transitive sets of stub dex jars for each of the public,
   system, test and core_platform APIs (where relevant).
2. Adds dependencies onto its dependent fragments.
3. Retrieves the API stubs dex jars from its dependent fragments and
   passes them to the "hiddenapi list" tool which will use them to
   resolve dependencies but will not output them to the generated
   flags.

Once the flags are generated the existing encoding functionality
encodes the flags into the dex files of the bootclasspath_fragment's
content modules which are then packaged into the apex.

Bug: 179354495
Test: m com.android.sdkext
      - verify that this does not change the contents of the apex files
Merged-In: I3e82a6dbb437f1e417e5d7e25aeb212e378603d0
Change-Id: I3e82a6dbb437f1e417e5d7e25aeb212e378603d0
(cherry picked from commit f1b358cb5764039ff7502e9f73ad0abfdc91c7aa)
2021-05-24 20:26:02 +01:00
Paul Duffin 6a58cc94d1 Remove bootclasspathApiInfo
Previously, the bootclasspathApiInfo was only used for tests and follow
up changes will need to provide the stub dex jars. This change moves
the stubJarsByKind into HiddenAPIInfo and removes bootclasspathApiInfo
and the corresponding provider.

Bug: 179354495
Test: m nothing
Merged-In: I5459c56de561c053ed671dc9d5cb3ee4820c0ee8
Change-Id: I5459c56de561c053ed671dc9d5cb3ee4820c0ee8
(cherry picked from commit 18cf19745e2fffb184a7b42f50609ea98d4adb1d)
2021-05-24 18:20:09 +01:00
Paul Duffin 699a00489e Fix hidden API flags in com.android.i18n
Change 70cfdff3da2ea07cd5cb7f7b91474f6fa0c248e5 changed the hidden API
flags in com.android.i18n as it stopped the i18n-bootclasspath-fragment
from making the hidden API flag files available for use by
platform-bootclasspath.

This change fixes that by exporting the flag files even if hidden API
flag generation is skipped.

Bug: 179354495
Test: m com.android.i18 out/soong/hiddenapi/hiddenapi-flags.csv
      - make sure that the flags in
        packages/modules/RuntimeI18n/apex/hiddenapi/hiddenapi-max-target-o-low-priority.txt
        are reflected in the core-icu4j dex files in the apex.
Merged-In: I9b5c7c74bd996ab447bc0e0452da5fd49191a35d
Change-Id: I9b5c7c74bd996ab447bc0e0452da5fd49191a35d
(cherry picked from commit 62370923911827d0a9cf6103e47652f40ca2cd25)
2021-05-24 18:20:08 +01:00
Paul Duffin 71955b4bc3 Rename hiddenAPIFlagFileInfo to HiddenAPIInfo
This reflects that it has expanded from its initial purpose to include
more than just flag files. It is exported for use in tests in other
packages.

Bug: 179354495
Test: m nothing
Merged-In: I9f780b20e18ce3a774e4aa04a276463070a64c34
Change-Id: I9f780b20e18ce3a774e4aa04a276463070a64c34
(cherry picked from commit af99afa919790cc76a9b1a1947d473065ecb65a5)
2021-05-24 18:20:08 +01:00
Paul Duffin 5aadef8ab5 Separate input to flag generation from hiddenAPIFlagFileInfo
Encapsulating the information needed by hidden API processing in a
struct makes it easy to add additional information in future and allows
the code to populate that struct from various different sources to be
grouped together.

Bug: 179354495
Test: m com.android.art com.android.ipsec com.android.os.statsd com.android.conscrypt
      - verify that this does not change the contents of the apex files
Merged-In: I53805737dff36a3ae87aca5aad51cf46ae1361fe
Change-Id: I53805737dff36a3ae87aca5aad51cf46ae1361fe
(cherry picked from commit 1352f7c4715d3d311a2644b9337e4b1028d82cb0)
2021-05-24 18:20:08 +01:00
Paul Duffin cad63842d2 Separate output of flag generation from hiddenAPIFlagFileInfo
HiddenAPIFlagOutput encapsulates the paths to the files produced by the
hidden API flag generation of a single bootclasspath_fragment. It is
returned from hidden API flag generation and is embedded within the
hiddenAPIFlagFileInfo so they can be passed to other modules.

Unlike the fields it replaces in hiddenAPIFlagFileInfo the fields in
HiddenAPIFlagOutput are of type Path not Paths which makes it easier to
use.

Bug: 179354495
Test: m com.android.art com.android.ipsec com.android.os.statsd com.android.conscrypt
      - verify that this does not change the contents of the apex files
Merged-In: I7373ba1001cac3a75eb54a23e62fa52f5013ee7f
Change-Id: I7373ba1001cac3a75eb54a23e62fa52f5013ee7f
(cherry picked from commit 1e6f5c4e633bab71d82eace7bad0f52494ef1839)
2021-05-24 18:20:07 +01:00
Paul Duffin 9e3b906581 Separate monolithic hidden API processing from hiddenAPIFlagFileInfo
The hiddenAPIFlagFileInfo was being used for both the input and output
of bootclasspath_fragment and platform_bootclasspath and also to pass
information around to various hidden API rule methods. Supporting
multiple different uses in this way made it hard to reason about.

This change creates a separate structure for use by the
platform_bootclasspath. Follow up changes will split out other
functionality into separate types.

Bug: 179354495
Test: m com.android.art com.android.ipsec com.android.os.statsd com.android.conscrypt
      - verify that this does not change the contents of the apex files
Merged-In: Ia5c5f65ae5645486c42819c669a8601588217f88
Change-Id: Ia5c5f65ae5645486c42819c669a8601588217f88
(cherry picked from commit 438eb57a2744b9b0bd38a5526e67cacf43c42b31)
2021-05-24 18:20:07 +01:00
satayev 53d0678b57 Rename generate proto config file to match classpath type.
There is no need to leak soong module names.

Bug: 180105615
Test: m && launch_cvd; atest CtsClasspathsTestCases
Change-Id: I04f4e181d2f42b9d71641980a2c7c4e8cbc8e426
Merged-In: I04f4e181d2f42b9d71641980a2c7c4e8cbc8e426
2021-05-24 13:38:45 +01:00
Paul Duffin b40610ad00 Perform hidden API encoding in bootclasspath_fragment
Previously, the apex content info was populated with hidden API encoded
dex jars retrieved directly from the java module. This change retrieves
the unencoded dex jars from the java module, encodes them and then
stores the result in the apex content info.

Bug: 179354495
Test: m com.android.art com.android.ipsec com.android.os.statsd com.android.conscrypt
      - verify that this does not change the contents of the apex files
Merged-In: Ib1b6eb8b62ac50e03b9e0d07c877ca70bb6f6d25
Change-Id: Ib1b6eb8b62ac50e03b9e0d07c877ca70bb6f6d25
(cherry picked from commit 54c98f5b4af1b47b922bd76a4dbf0aca50c2a453)
2021-05-23 18:41:47 +01:00
Paul Duffin ed587c367b Refactor hiddenAPIEncodeDex for use by bootclasspath_fragment
Previously, if the method was called multiple times by the same module
the resulting build rules would all use the same temporary directory
which meant that if run in parallel they would conflict with each
other. This change fixes that by providing a jar specific temporary
directory so it can be used by bootclasspath_fragment to encode its
content modules.

Also, cleans up, simplifies and improves the documentation.

Bug: 179354495
Test: m com.android.art com.android.ipsec com.android.os.statsd com.android.conscrypt
      - verify that this does not change the contents of the apex files
Merged-In: I0ebe61abc8e16111c6e8a822eb96c57846b98461
Change-Id: I0ebe61abc8e16111c6e8a822eb96c57846b98461
(cherry picked from commit 0916595b1c9bf71224b98a6a2fdee941690446f6)
2021-05-23 18:41:47 +01:00
Martin Stjernholm f7a62e6c73 Merge changes I4e7a7ac5,I0c73361b into sc-dev
* changes:
  Record the actual APEXes that a module is part of.
  Rename InApexes -> InApexVariants
2021-05-21 19:22:15 +00:00
Martin Stjernholm 55d7ed4bbf Merge changes I0c80b546,Ibc673303,I70317eb8 into sc-dev
* changes:
  Skip TestDex2oatToolDeps on Darwin.
  Don't fail if the target module is disabled in dex2oat tool dependencies.
  Use oatdump rather than oatdumpd for boot jar boot.*.oatdump.txt files.
2021-05-21 16:00:02 +00:00
Paul Duffin 7555fcbab3 Store dex jar paths in bootclasspath_fragment's apex content info
Previously, the DexBootJarPathForContentModule(module) simply called
directly through to the module to retrieve the dex jar path. This
change changes it so the bootclasspath_fragment retrieves the dex
jars from the module and stores them in the info structure for this
method to retrieve directly.

This makes it easier for the bootclasspath_fragment to stop retrieving
hidden API encoded dex jars from the module and perform the encoding
itself.

Bug: 179354495
Test: m com.android.art com.android.ipsec com.android.os.statsd com.android.conscrypt
      - verify that this does not change the contents of the apex files
Merged-In: Ic79dea080f10f4017f1a75d6d1fb5a3bfe04c2ce
Change-Id: Ic79dea080f10f4017f1a75d6d1fb5a3bfe04c2ce
(cherry picked from commit 1a8010a24171c4ac1928b659f48dc680ee8b0353)
2021-05-21 09:34:53 +01:00
Paul Duffin 0bd5b06209 Move hidden API encoding after resource merging
Previously, the hidden API encoding was done before resource merging.
However, hidden API modularization requires that the encoding be done
by the bootclasspath_fragment/platform_bootclasspath modules which will
be after the resource merging. Therefore, this change moves the hidden
API encoding after to match the future behavior.

It also moves the initHiddenAPI() method call after resource merging
too and passes it the result of the resource merging so it is available
for the bootclasspath modules via bootDexJar().

Although the resource merging was not always done when it was done it
would reorder the entries in the generated jar to match java ordering,
which puts the MANIFEST.MF first. This change preserves that behavior
by adding -j to the call to MergeZipCmds. This does mean that jars
which did not require resource merging now have a different order but
as both orders work that is not a significant change.

Bug: 179354495
Test: m com.android.art com.android.ipsec com.android.os.statsd com.android.conscrypt
      - verify that apart from the ordering change in the jars that this does
        not change the contents of the apex files
Merged-In: If74baad5659301ca6ca9c0f6484374420dda8c34
Change-Id: If74baad5659301ca6ca9c0f6484374420dda8c34
(cherry picked from commit 4de94504335e614efcdc4d0d86f1cfad758f83e8)
2021-05-21 09:34:53 +01:00
satayev 95bfbb169f Populate individual classpath_fragments' classpaths.proto configs.
To avoid duplicates on *CLASSPATH environ variables at runtime, remove
split entries from platform-*classpath, i.e. all updatable jars that
have their own classpath fragments should not appear in the
platform-*classpath's classpaths.proto config.

Bug: 180105615
Test: m && launch_cvd; atest CtsClasspathsTestCases
Change-Id: Id2759ab8e106cc183e695bf3509a6ab60ab0ef2a
2021-05-20 19:07:29 +01:00
Jiyong Park 59b9f14173 Record the actual APEXes that a module is part of.
Consider this case:

apex {
    name: "com.android.foo",
    native_libs: ["foo"],
}

override_apex {
    name: "com.mycompany.android.foo",
    base: "com.android.foo",
}

cc_library {
    name: "foo",
}

There are two APEXes defined: "com.android.foo" and
"com.mycompany.android.foo" which is a copy of "com.android.foo" with
some properties overridden (e.g. signing keys).

The module "foo" is mutated into two variants by the apex mutator: the
platform variant and the apex variant. The former has the variation name
"" and the later has "apex<min_api_ver>" which usually is "apex10000".

Internally, the apex variant has an alias "com.android.foo".

ApexInfo.InApexVariants() returns only "com.android.foo" when called for
the module "foo".

We can see that the information that "foo" is also part of
"com.mycompany.android.foo" is completely lost. This is causing problem
when we compare the apex membership by their "soong module name", not
the "apex name". In the example above, the two modules have different
soone module names, but have the same apex name: "com.android.foo".

To fix that, this CL introduces a new field `InApexes` to the `ApexInfo`
struct. It has the actual name of the APEXes that the module is part of.
With the example above, `InApexes` is ["com.android.foo",
"com.mycompany.android.foo"].

Cherry-picked from https://r.android.com/1710529.

Bug: 180325915
Test: m nothing
Test: m nothing on non-AOSP targets with ag/13740887 applied.

Change-Id: I4e7a7ac5495d2e622ba92a4358ed967e066c6c2e
Merged-In: I4e7a7ac5495d2e622ba92a4358ed967e066c6c2e
2021-05-20 17:36:22 +01:00
Martin Stjernholm 5053baab54 Skip TestDex2oatToolDeps on Darwin.
This fixes https://r.android.com/1711292.

Cherry-picked from https://r.android.com/1713990.

Test: m nothing
Bug: 188647117
Bug: 145934348
Bug: 172480615
Change-Id: I0c80b546a814d799562f374148eae5ca23b0e1f8
Merged-In: I0c80b546a814d799562f374148eae5ca23b0e1f8
2021-05-20 17:36:22 +01:00
Jiyong Park 712e8b5b1b Rename InApexes -> InApexVariants
.. in preparation for the upcoming change. This change doesn't alter any
behavior.

InApexes is a misleading name. People expects that it has the list of
soong module names of the APEXes that a module is part of. So, for
example, `core-oj` is a part of both `com.android.art` and
`com.google.android.art`. However, in reality, that's not true. The
field has `com.android.art` only. This is because the two APEXes
(android and Google) have the same apex name which is `com.android.art`.
That apex name is used in various places like the `apex_available` and
allows us to keep using the same name regardless of whether the APEX is
overridden or not.

However, this is causing problems in some cases where the exact list of
soong module names is required. The upcoming change will add a new field
to handle the case and the new field actually will get the name
'InApexes'. So, the existing field is renamed to a less misleading name
`InApexVariants`.

Cherry-picked from https://r.android.com/1710528.

Bug: 180325915
Test: m nothing

Change-Id: I0c73361b452eddb812acd5ebef5dcedaab382436
Merged-In: I0c73361b452eddb812acd5ebef5dcedaab382436
2021-05-20 17:36:22 +01:00
Martin Stjernholm cae43e1c16 Don't fail if the target module is disabled in dex2oat tool
dependencies.

dexpreopt.RegisterToolDeps runs late after prebuilt dependencies have
been resolved, and there's special code in dex2oatPathFromDep to
resolve the prebuilt from the source module. However, if the source
module is disabled then the dependencies check in validateAndroidModule
will complain, so we need to disable that check in this particular
situation.

Also add a comment to explain why dexpreopt.RegisterToolDeps needs to
run so late.

Cherry-picked from https://r.android.com/1711292.

Test: m nothing
Bug: 145934348
Bug: 172480615
Change-Id: Ibc673303d0336768fa23261a2068e91a08f46a30
Merged-In: Ibc673303d0336768fa23261a2068e91a08f46a30
2021-05-20 17:36:02 +01:00
Martin Stjernholm 244aebd4f8 Use oatdump rather than oatdumpd for boot jar boot.*.oatdump.txt files.
oatdumpd isn't available as a prebuilt.

Cherry-picked from https://r.android.com/1711291.

Test: m SOONG_CONFIG_art_module_source_build=false droid
Bug: 172480615
Change-Id: I70317eb8f253272d629f23063cbe265d556caad3
Merged-In: I70317eb8f253272d629f23063cbe265d556caad3
2021-05-20 17:36:02 +01:00
Artur Satayev 7334a69ab6 Merge "Use absolute paths in classpaths.proto." into sc-dev 2021-05-20 09:21:39 +00:00
TreeHugger Robot b05357c76e Merge "Add usesTargetFiles option in dexpreopt_gen" into sc-dev 2021-05-20 01:28:10 +00:00
Paul Duffin 59db6d4c5d Workaround to make AlwaysUsePrebuiltSdks() work with platform_bootclasspath
The AlwaysUsePrebuiltSdks() causes all java_sdk_library_import modules
to be preferred over the source, i.e. as if they had prefer: true set.
That interacts badly with the work that is being done to integrate the
bootclasspath_fragment/platform_bootclasspath modules into the build.

It would work fine once that integration has been completed but in the
interim it causes problems. e.g. it does not cause a problem in AOSP
because those java_sdk_library_import modules that are affected have
already been integrated into the build properly.

Unfortunately, internally that is not the case because there are
java_sdk_library/java_sdk_library_import modules that still need to
be updated.

Before the java_sdk_library_import can be safely preferred each
java_sdk_library/java_sdk_library_import module that contributes to the
bootclasspath must:
* Be in the contents of matching bootclasspath_fragment and
  prebuilt_bootclasspath_fragment modules.
* Have an apex and one of a prebuilt_apex/apex_set that contains the
  dex implementation jar and lists the prebuilt_bootclasspath_fragment
  name in its exported_bootclasspath_fragments property.

Safely preferred in this context means that the whole build will
continue to work rather than the current situation which is that only
some of the build will work and some will fail if an attempt is
actually made to build it.

Unfortunately, many java_sdk_library_import modules are missing:
* The prebuilt_bootclasspath_fragment.
* The exported_bootclasspath_fragments property on the
  prebuilt_apex/apex_set that contains them.

Together these cause the following symptoms:
1. The java_sdk_library_import does not have a dex implementation jar.
2. The java_sdk_library_import does not have a myapex variant.

These workarounds will avoid Soong reporting build failures. However,
the build will still fail if an attempt is made to build anything
produced by the platform-bootclasspath, e.g. hidden API processing or
a system image.

Bug: 188505921
Bug: 179354495
Test: m TARGET_BUILD_APPS=Calendar
Change-Id: I3226e21cd6a7f9e4d6bbe94e54129ac5e1d4c679
2021-05-19 14:12:45 +00:00
satayev 6bd823241f Use absolute paths in classpaths.proto.
The intention before was to use relative paths to a partition where a
config is defined. However, jars in /system_ext partition are planned to
be declared in /system's classpaths.proto config.

Bug: 180105615
Test: derive_classpath_test, CtsClasspathsTestCases
Change-Id: Icc3e1a903c34187cfcd67a3ae7bc3dd746445c03
Merged-In: Icc3e1a903c34187cfcd67a3ae7bc3dd746445c03
(cherry picked from commit 7d22657c458b7cf7f79cdd3c298bfec13be93533)
2021-05-19 12:22:23 +01:00
satayev 2f45f4eec1 Add systemserverclasspath_fragments property to apex.
- All contents of the fragment are added as java_lib dependencies.
- Generated classpaths.proto is added into etc as required.

Bug: 180105615
Test: m nothing
Merged-In: I8e8e8b019c4ca2909182f205a47deffa946de6da
Change-Id: I8e8e8b019c4ca2909182f205a47deffa946de6da
(cherry picked from commit 333a1732b17887260f2290ffacffffeff760eee5)
2021-05-18 10:37:52 +01:00
satayev 7b182e7177 Add "contents" property to systemserverclasspath_fragment.
Similar to bcp_fragment's contents, this property lists all java library
contributions made by this fragment.

Bug: 180105615
Test: m nothing
Merged-In: Ifb1f54d5db290fffaa31933d15207014bb72d2fb
Change-Id: Ifb1f54d5db290fffaa31933d15207014bb72d2fb
(cherry picked from commit 9366a053da11ba44c9d70671dfac7c294c5427d0)
2021-05-18 10:37:51 +01:00
satayev 72ede0fac5 Move classpaths.proto related info into a separate provider.
The new info struct can be easily shared with systemserverclasspath
fragments.

Bug: 180105615
Test: m nothing
Merged-In: I9986e64fdf19f4168da63c156de3dc9bcafac8d8
Change-Id: I9986e64fdf19f4168da63c156de3dc9bcafac8d8
(cherry picked from commit 14e49130bbeba7d222c8851e2f59710ac0f6eb71)
2021-05-18 10:37:51 +01:00
satayev 0cf6de5ca9 Add no-op systemserverclasspath_fragment module.
This would allow to start introducing these modules for apexes that
contribute to SYSTEMSERVERCLASSPATH.

In follow up, it will be evolved:
- platform_systemserverclasspath would have "fragments" property to
  list all individual systemserverclasspath_fragments;
- systemserverclasspath_fragment would have "contents" property to list
  contibuting java libs;
- systemserverclasspath_fragment would generate non-empty
  classpaths.proto config within individual apexes.

Bug: 180105615
Test: m nothing
Merged-In: Ibaaa3fae5f1eab9a41ceecc1214a53be6bbc8ba6
Change-Id: Ibaaa3fae5f1eab9a41ceecc1214a53be6bbc8ba6
(cherry picked from commit aa86bac2b01f7565f1ea8ec7c88308ef5ed6e7e2)
2021-05-18 10:37:51 +01:00
Paul Duffin 6c6dde04bd Make uncompressDex available for use through hiddenAPIModule
In order for the bootclasspath_fragment to perform dex encoding on its
contents it needs to know whether the dex file is uncompressed or not.
This change makes that information available by passing it to
initHiddenAPI, storing it in hiddenAPI struct and providing access
through the hiddenAPIModule.

Bug: 179354495
Test: m droid
Merged-In: I913416b4836766de194203fd8ed5124b61dfa3dd
Change-Id: I913416b4836766de194203fd8ed5124b61dfa3dd
(cherry picked from commit 1bbd0626f2d83036b4e1225cc51edfea5e4055b7)
2021-05-18 08:00:16 +01:00
Paul Duffin c9e52dbc57 Remove hiddenAPI.primary field
Now that the individual modules no longer participate in the generation
of the monolithic files it is no longer necessary to select a single
primary module to provide the information they need.

Bug: 179354495
Test: m droid
Merged-In: If09796de710927e3e3f2ccecad0b57ca5fce5dc9
Change-Id: If09796de710927e3e3f2ccecad0b57ca5fce5dc9
(cherry picked from commit 45897dd66327c4b1dd578650dc2f7f0ec572539b)
2021-05-18 08:00:02 +01:00
Paul Duffin f88ab95d85 Merge initHiddenAPI and hiddenAPIUpdatePaths
These two methods did very similar jobs and merging them together
simplifies the behavior.

Bug: 179354495
Test: m droid
Merged-In: Ibe1a23d54105e6a0e5693079cd8743679301fc85
Change-Id: Ibe1a23d54105e6a0e5693079cd8743679301fc85
(cherry picked from commit 74d18d1d6ff1ad8ec47c34182d1a22945e05e9d5)
2021-05-18 07:59:52 +01:00
Paul Duffin 59190602af Remove configurationName from java library and hidden API
The configurationName was intended to separate the name of the module
from the name used in configuration (such as BootJars) so that the
child implementation library of a java_sdk_library on the bootclasspath
would have hidden API encoding performed on it just as for the main
java_library embedded within the java_sdk_library.

While that did use to work it no longer does as the test added in the
preceding change proves. It is not surprising that this regression does
not appear to have caused any issues as the the child implementation
library is only a build time artifact and not used at runtime.

In future the only modules that will require hidden API encoding are
those that are part of a bootclasspath module so there is no point in
maintaining this capability.

Bug: 179354495
Test: m droid
Merged-In: Ief8136fa9e98600cdd8d36108ec22edc2ebd7c69
Change-Id: Ief8136fa9e98600cdd8d36108ec22edc2ebd7c69
(cherry picked from commit 66cdbf07ef2af6caf42e2c7b77b1a5fb86a4cee3)
2021-05-18 07:59:41 +01:00
Paul Duffin 78fc68695e Add a test for hidden API encoding of java_sdk_library
Fill a hole in the testing of hidden API encoding. Some comments in the
code indicate that the child implementation java_library of a
java_sdk_library should have hidden API flags encoded in its dex jar
just like the embedded java_library. However, this test proves that it
is not working. This will be fixed in a follow up change.

Bug: 179354495
Test: m nothing
Merged-In: Ia581a17f1e48dff252d17f16bf76adf039f46b60
Change-Id: Ia581a17f1e48dff252d17f16bf76adf039f46b60
(cherry picked from commit 0d586581d1c2d6d22e7f00007e50e579ca90df29)
2021-05-18 07:59:29 +01:00
Jeongik Cha 036f8f5e8d Add usesTargetFiles option in dexpreopt_gen
For running dex2oat on the target_files, the paths should be use the
device install path instead of the path starting with $(OUT).
So add usesTargetFiles option and basePath option which indicates
extracted path. With those options, the path is replaced with
$(basePath)/$(device path)

And also, add DexPreoptImageDeviceLocations in the config which refers
to the boot image path(without arch) on the device. Because
DexPreoptImage related device path was missing.

Bug: 158843648
Test: dexpreopt_gen -usesTargetFiles -basePath (extract path) and then
check if paths in the generated shell script are based on on-device
path.

Change-Id: I9667fadbf3b7c6f770e0d1bcbee5d67c1ecd8a3d
Merged-In: I9667fadbf3b7c6f770e0d1bcbee5d67c1ecd8a3d
(cherry picked from commit 4dda75e73e3e52e11b1cd37af33645fcfe5ed980)
2021-05-18 12:09:28 +09:00
Paul Duffin 460952c7f4 Add temporary restriction on hidden API processing
Hidden API processing of a bootclasspath_fragment requires the fragment
provides information, such as dependencies on other fragments and flag
files to override the default flags. Failing to do so will cause hidden
API generation to either fail or to generate different flags to that
generated by the hidden API processing done by platform_bootclasspath
which will cause the build to fail.

Previously, this was handled by only performing hidden API processing
for those modules that provide stub libs and relied on there only being
bootclasspath_fragments defined for ART (which already supports hidden
API processing), and Conscrypt and I18n neither of which provide stubs.
Unfortunately, that can no longer be relied upon due to a couple of
recent changes:
1. A java_sdk_library in a bootclasspath_fragment's content property is
   automatically treated a stub library. That avoids duplication for
   most bootclasspath_fragments that provide the implementation and
   stub libraries through the same java_sdk_library. It does not affect
   either ART, conscrypt or i18n as they all define the implementation
   separately to the stubs.

2. bootclasspath_fragment modules have been defined for a number of
   android modules as they are needed for reasons other than hidden API
   processing.

In combination this meant that rules to perform hidden API processing
were being created but they were not currently being used which is
good because they fail.

However, adding the fragment to the platform-bootclasspath will cause
those rules to be used as the platform_bootclasspath module performs a
consistency check on the hidden API flags generated by each of the
fragments to ensure that they are consistent with those it generates
itself.

The dynamic bootclasspath work will need to add fragments to the
platform_bootclasspath and without this change that would be blocked
until all fragments had been switched to generating hidden API flags
properly.

This change adds a new fragments property to the bootclasspath and
disables hidden API processing for everything other than ART and tests
if the fragments property or stub libs is empty.

Bug: 179354495
Test: - Before making this change.
      - Add com.android.os.statds-bootclasspath-fragment to platform-bootclasspath.fragments
      m out/soong/hiddenapi/hiddenapi-flags.csv
      - hidden API processing fails in statsd as it cannot find java.lang.Object.
      - After making this change, run the above command again and it should pass.

Merged-In: Ifbb362f8fcfb2c06595fbd5ae39421b536e329ef
Change-Id: Ifbb362f8fcfb2c06595fbd5ae39421b536e329ef
(cherry picked from commit 70cfdff3da2ea07cd5cb7f7b91474f6fa0c248e5)
2021-05-17 21:30:03 +01:00
Paul Duffin 20042da220 Merge "Refactor special handling of hidden API encoding for master-art" am: fdd9743609 am: 1b5e8cdbee am: 23b34baa5c
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1707569

Change-Id: I5dbe8a4c4fc0f4e8a91ec9c04f32a7d71f96715e
2021-05-14 19:52:52 +00:00
Paul Duffin 63472fe5ba Merge "Stop generating unnecessary hidden API rules" am: b7c78731d4 am: 97961f4837 am: d12106540b
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1707574

Change-Id: I592af32aa225403d5ba1d1a4c89dda84d3aad0ba
2021-05-14 19:52:47 +00:00
Paul Duffin 7b07c01f20 Merge "Generate monolithic hidden API files direct from class jars" am: 21f62ef867 am: b28f562092 am: 8063427dc4
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1707573

Change-Id: I116c3a4028fd199df12ead373fbfb4d47c6fdf8e
2021-05-14 19:52:42 +00:00
Paul Duffin f8b776e97f Merge "Dedup hidden API rule generation" am: 2bc8b3a646 am: 93b312c2dd am: 29c6e9fa55
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1707572

Change-Id: I584f17bd5ee9092730d4e37c5b34233805dd6b1a
2021-05-14 19:52:33 +00:00
Paul Duffin 23b34baa5c Merge "Refactor special handling of hidden API encoding for master-art" am: fdd9743609 am: 1b5e8cdbee
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1707569

Change-Id: I49f3ee3a7bb0eb9f26440a278c5f1ec56a6037bf
2021-05-14 19:33:34 +00:00
Paul Duffin d12106540b Merge "Stop generating unnecessary hidden API rules" am: b7c78731d4 am: 97961f4837
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1707574

Change-Id: Ida624f82ac4394cad434a943271ecc64203fce26
2021-05-14 19:33:28 +00:00
Paul Duffin 8063427dc4 Merge "Generate monolithic hidden API files direct from class jars" am: 21f62ef867 am: b28f562092
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1707573

Change-Id: I64919be5a862620eb5077e6f18982e02eae8dcb4
2021-05-14 19:33:23 +00:00
Paul Duffin 29c6e9fa55 Merge "Dedup hidden API rule generation" am: 2bc8b3a646 am: 93b312c2dd
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1707572

Change-Id: Ib9a86e05001db3571b1be5ebb851fa5aa63af044
2021-05-14 19:33:15 +00:00
Paul Duffin fdd9743609 Merge "Refactor special handling of hidden API encoding for master-art" 2021-05-14 18:53:43 +00:00
Paul Duffin b7c78731d4 Merge "Stop generating unnecessary hidden API rules" 2021-05-14 18:53:08 +00:00
Paul Duffin 21f62ef867 Merge "Generate monolithic hidden API files direct from class jars" 2021-05-14 18:52:11 +00:00
Paul Duffin 2bc8b3a646 Merge "Dedup hidden API rule generation" 2021-05-14 18:51:10 +00:00
Paul Duffin 1b3dbb7c7d Merge "Allow shared libraries on bootclasspath" am: b0f20d134f am: 42a9a2ede6 am: 8a9a8ffd2f
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1707576

Change-Id: I5d9603841e7dd422bcd18e45249556918f724fcc
2021-05-14 18:21:45 +00:00
Paul Duffin 8a9a8ffd2f Merge "Allow shared libraries on bootclasspath" am: b0f20d134f am: 42a9a2ede6
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1707576

Change-Id: I96dcd94c06aa2cbf12fbf4e0effb708d26658ccb
2021-05-14 17:51:21 +00:00
Paul Duffin b0f20d134f Merge "Allow shared libraries on bootclasspath" 2021-05-14 17:03:03 +00:00
Paul Duffin 79fd3d728c Allow shared libraries on bootclasspath
A previous change treated this as an error in order to try and detect
issues with misconfigured java_sdk_library modules and/or
bootclasspath_fragment modules but unfortunately this is not always an
error, e.g. when migrating a library that was a shared library to the
bootclasspath.

This change stops treating that as an error.

Bug: 179354495
Test: m nothing
Change-Id: I4a833ab5f4caf86c6cd340090fc65d2c2f141512
2021-05-14 16:14:17 +01:00
Paul Duffin b6f53c064e Refactor special handling of hidden API encoding for master-art
Instead of encoding the hidden API with an empty set of flags when the
monolithic flags are not available this simply disables encoding
altogether which should have the same behavior at runtime.

This change also removes the unused flags field in hiddenAPISingleton
which was set but never read.

Bug: 179354495
Test: m nothing
Change-Id: I32d5825e5271829993dd4e5be4d4ee1b22fa7b22
2021-05-14 15:57:10 +01:00
Paul Duffin afaa47c74a Stop generating unnecessary hidden API rules
The rules to extract hidden API information from an individual module
in order to create module specific files are no longer necessary as
the monolithic files are created directly from the module's class jars
and not the module specific files.

Bug: 179354495
Test: verified that the monolithic out/soong/hiddenapi/... files are
      unchanged by this change
Change-Id: I573ac17f3ea5da5a2a7e4f08718160dacca71c0c
2021-05-14 15:57:10 +01:00
Paul Duffin 537ea3d04c Generate monolithic hidden API files direct from class jars
Previously, the monolithic hidden API files, e.g. hiddenapi-index.csv
file, were generated in two steps. First, each module created its own
files using the information in its class jars. Then, the monolithic
files were created by merging those module specific files into a larger
file.

This change switches to generating the monolithic files directly from
the class jar files and bypassing the intermediate files.

In order to ensure that this change did not change the monolithic files
it is necessary for the hiddenapi-metadata.csv to go through a
reformatting step. Hopefully, this will be able to be removed in a
follow up change.

Bug: 179354495
Test: verified that the monolithic out/soong/hiddenapi/... files are
      unchanged by this change
Change-Id: I5a78e747516014b7c0f402a4b4431b14be6a84b2
2021-05-14 15:57:04 +01:00