Commit graph

7 commits

Author SHA1 Message Date
Paul Duffin
bb638eba50 Output min_sdk_version to snapshot
The min_sdk_version was added to the java_import in Tiramisu. This
change will propagate the min_sdk_version set on a java_library to the
java_import snapshot. If possible the min_sdk_version will be resolved
into a numerical version to ensure consistent behavior across build
releases.

Bug: 260560424
Test: m nothing
      BUILD_NUMBER=fixed packages/modules/common/build/mainline_modules_sdks.sh
      # Ran above before and after this change and made sure that only
      # Tiramisu, UpsideDownCake and latest were changed and those changes
      # were the addition of a min_sdk_version property.
      #
      # Ran the following command in tm-mainline-prod:
      #     lunch cf_x86_64_phone-userdebug
      #     m ART_MODULE_BUILD_FROM_SOURCE=false nothing`.
      #
      # It failed with:
      #     module "prebuilt_okhttp-norepackage" variant "android_common": should support min_sdk_version(33) for "AdServicesApk": min_sdk_version is not specified.
      #
      # Unpacked the Tiramisu art snapshot generated with this change into
      # tm-mainline-prod and reran the previous command and it succeeded.
Change-Id: I9d9d730845554fc175d17f38c038e4e3c7d39e07
2022-11-26 15:52:32 +00:00
Paul Duffin
7ed6ff8c76 Revert "Improve error reporting when depending on prebuilt implementation jar"
This reverts commit c61783b20d.

Bug: 257969510
Reason for revert: b/255275437 - breaks checkbuild target

Change-Id: I01f88053cc24dbc1a4eb5c009f15473bdff3d565
2022-11-21 10:57:30 +00:00
Paul Duffin
c61783b20d Improve error reporting when depending on prebuilt implementation jar
The sdk snapshot must not be including implementation code for boot
libraries, the implementation is provided by dex jars within the
corresponding APEX. However, the snapshot does need a module for each
boot library so that the build can seamlessly access the dex files from
the APEX.

A java_library boot library (like core-oj) is represented in the
snapshot by a java_import module which requires a jar file to be
provided, otherwise it is disabled. However, that is provided purely
to keep Soong happy and should never be used.

Previously, the snapshot would contain an empty file for the jar. As
an empty file is an invalid jar any tool (like compiler) that tried
to consume it would fail which was the correct behavior. Unfortunately,
the error message that was produced was not very helpful, it was just
some variant on `invalid file` which lead to a lot of bugs being
raised.

This change replaces that empty file with a reference to the output
from a genrule which runs a script which produces a more useful error
message, with information on how to fix the issue, and fails the build.

It also adds a Name() method to the SdkMemberProperties type as that is
needed in AddInternalModule() to construct the name of the additional
module.

Tested as follows:

In AOSP/master make the following changes:
1. Temporarily set visibility on core-oj and core-libart to
   //visibility:public.
2. Run packages/modules/common/build/mainline_modules_sdks.py to create
   the snapshots.

For each of the S, T and latest snapshots I did the following in the
s-aml-prebuilt-test, t-aml-prebuilt-test and aosp/master branches:

1. Created an Android.bp file containing the following:
  java_library {
    name: "broken",
    static_libs: [
      "prebuilt_core-libart",
      "prebuilt_core-oj",
    ],
  }

2. Fix the visibility issues and run `m broken` where it fails with an
   invalid file.

3. Delete the contents of the prebuilts/module_sdk/art/current/sdk
   directory.

4. Unpack the relevant version of the art-module-sdk snapshot into the
   directory.

5. Run `m broken` where it fails with the helpful message.

6. Test the instructions on how to use the ninja -t path tool to
   identify the cause of the problem and fix it.

Bug: 257969510
Test: See above.
Change-Id: I125bde2d7202afff84c97daebcef37e21c548a3a
2022-11-14 10:14:10 +00:00
Paul Duffin
4e7d1c43e2 Add apexes property to sdk
Specifying an apex in the apexes propety will cause all the
*classpath_fragments that are contents of the APEX to be automatically
added as members of the sdk and appear in the snapshot.

The purpose of this change is to dedup the APEX and sdk definitions and
try and avoid some of the issues that we have been finding while
attempting to build against the prebuilts.

Two tests, one each for bootclasspath_fragment and
systemserverclasspath_fragment, have been refactored to compare the
output when adding the *fragment to the sdk directly of via the APEX.
That ensures switching to use the APEX will not change the sdk snapshot
unless it was previously missing a *fragment.

There was also a slight difference in where the hidden API flags were
copied from. That should have no impact on the output as the flags are
identical.

The sdk snapshot generation needed some tweaks to avoid generating a
prebuilt for the APEX.

Bug: 232401814
Test: m nothing
Change-Id: I7aaf16a3a0ab4bebf97765d1484215cc008dc4b8
2022-07-06 15:58:43 +00:00
Paul Duffin
f861df7907 Stop exporting systemserverclasspath_fragment when targeting S
Previously, when targeting the S release the generated sdk snapshot
would contain prebuilt_systemserverclasspath_fragment modules even
though they were only added in T.

This allows SdkMemberTypes to specify the set of target build releases
they support and ignores them when targeting an unsupported target
build release.

Test: m nothing
      packages/modules/common/build/mainline_modules_sdks.sh
      # Check that the for-S-build snapshots do not include SSCPFs.
Bug: 237718221
Change-Id: I2df08c2fcebf9b866695d691572a9d3783758b17
2022-07-05 15:13:09 +00:00
Paul Duffin
b01ac4b6ba Remove support for generating versioned snapshots
Previously, the code for selecting specific versions of sdk snapshots
was removed (along with the uses_sdks property). That makes versioned
snapshots useless so this change removes all the code and tests that
generated those versioned snapshots.

Bug: 232546567
Test: m nothing
      packages/modules/common/build/mainline_modules_sdks.sh
Change-Id: Ib6d1b72bc8399fbb39075494ae37da92f4b28d03
2022-05-24 20:10:05 +00:00
Jiakai Zhang
a8d8660ab1 Generate prebuilt_systemserverclasspath_fragment.
Bug: 194150908
Test: m nothing
Test: manual - 1. Patch aosp/1835087.
  2. m out/soong/.intermediates/art/build/sdk/art-module-sdk/common_os/snapshot/Android.bp
  3. See prebuilt_systemserverclasspath_fragment modules and
     systemserverclasspath_fragments in an sdk_snapshot module.
Change-Id: I7876b077b0b4ed190f01dbfa9533de04ea32d524
2021-09-30 10:06:24 +00:00