From b0c28d63d608572cc55cf2ec5edd9fc3ef257ec0 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 1 Jul 2022 15:56:06 +0000 Subject: 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. The Merged-In value was chosen to prevent this from being merged into branches where it will conflict due to https://r.android.com/2105804. That will allow this change to be submitted in tm-dev before it is submitted in AOSP. 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 Merged-In: Ib6d1b72bc8399fbb39075494ae37da92f4b28d03 --- java/java.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'java/java.go') diff --git a/java/java.go b/java/java.go index c8fb93cca..9ab77a54e 100644 --- a/java/java.go +++ b/java/java.go @@ -164,6 +164,9 @@ var ( android.SdkMemberTypeBase{ PropertyName: "java_systemserver_libs", SupportsSdk: true, + + // This was only added in Tiramisu. + SupportedBuildReleaseSpecification: "Tiramisu+", }, func(ctx android.SdkMemberContext, j *Library) android.Path { // Java systemserver libs are only provided in the SDK to provide access to their dex -- cgit v1.2.3 From 8a61b59e1798d3dce5208881c005dbe9526f4043 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 15 Jul 2022 13:12:35 +0000 Subject: Use implementation jar for updatable-media in snapshot for S While enabling prebuilts in T we hit b/229932396 which was caused by some parts of the build depending on the prebuilt updatable-media jar which used to be a full implementation jar but which is now an invalid jar as the snapshot must not be including implementation details. We fixed the issue in T but we are hitting the same problem in S with the M-2022-07. That is the first train in which the prebuilt updatable-media module provides an invalid jar, prior to that it was always providing an implementation jar. This change tweaks the sdk snapshot generation code to use an implementation jar for updatable-media in the S snapshot to avoid partners having to cherry pick changes similar to those needed to fix b/229932396 in T. Bug: 239121291 Test: packages/modules/common/build/mainline_modules_sdks.sh # Check that S media snapshot includes implementation jar. # Check that S art snapshot includes invalid jar. # Check that T media snapshot includes invalid jar. Change-Id: Ib49484d00a60b4ed7f8268e04f9c10a3498edb56 (cherry picked from commit 1364891fad13901c3b47d31e9d9dfaaf04ecaa79) Merged-In: Ib49484d00a60b4ed7f8268e04f9c10a3498edb56 --- java/java.go | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'java/java.go') diff --git a/java/java.go b/java/java.go index 9ab77a54e..1e99aa32f 100644 --- a/java/java.go +++ b/java/java.go @@ -118,6 +118,16 @@ var ( copyEverythingToSnapshot, } + snapshotRequiresImplementationJar = func(ctx android.SdkMemberContext) bool { + // In the S build the build will break if updatable-media does not provide a full implementation + // jar. That issue was fixed in Tiramisu by b/229932396. + if ctx.IsTargetBuildBeforeTiramisu() && ctx.Name() == "updatable-media" { + return true + } + + return false + } + // Supports adding java boot libraries to module_exports and sdk. // // The build has some implicit dependencies (via the boot jars configuration) on a number of @@ -135,13 +145,21 @@ var ( SupportsSdk: true, }, func(ctx android.SdkMemberContext, j *Library) android.Path { + if snapshotRequiresImplementationJar(ctx) { + return exportImplementationClassesJar(ctx, j) + } + // Java boot libs are only provided in the SDK to provide access to their dex implementation // jar for use by dexpreopting and boot jars package check. They do not need to provide an // actual implementation jar but the java_import will need a file that exists so just copy an // empty file. Any attempt to use that file as a jar will cause a build error. return ctx.SnapshotBuilder().EmptyFile() }, - func(osPrefix, name string) string { + func(ctx android.SdkMemberContext, osPrefix, name string) string { + if snapshotRequiresImplementationJar(ctx) { + return sdkSnapshotFilePathForJar(ctx, osPrefix, name) + } + // Create a special name for the implementation jar to try and provide some useful information // to a developer that attempts to compile against this. // TODO(b/175714559): Provide a proper error message in Soong not ninja. @@ -175,7 +193,7 @@ var ( // file. Any attempt to use that file as a jar will cause a build error. return ctx.SnapshotBuilder().EmptyFile() }, - func(osPrefix, name string) string { + func(_ android.SdkMemberContext, osPrefix, name string) string { // Create a special name for the implementation jar to try and provide some useful information // to a developer that attempts to compile against this. // TODO(b/175714559): Provide a proper error message in Soong not ninja. @@ -649,7 +667,7 @@ const ( ) // path to the jar file of a java library. Relative to / -func sdkSnapshotFilePathForJar(osPrefix, name string) string { +func sdkSnapshotFilePathForJar(_ android.SdkMemberContext, osPrefix, name string) string { return sdkSnapshotFilePathForMember(osPrefix, name, jarFileSuffix) } @@ -666,7 +684,7 @@ type librarySdkMemberType struct { // Function to compute the snapshot relative path to which the named library's // jar should be copied. - snapshotPathGetter func(osPrefix, name string) string + snapshotPathGetter func(ctx android.SdkMemberContext, osPrefix, name string) string // True if only the jar should be copied to the snapshot, false if the jar plus any additional // files like aidl files should also be copied. @@ -724,7 +742,7 @@ func (p *librarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberConte exportedJar := p.JarToExport if exportedJar != nil { // Delegate the creation of the snapshot relative path to the member type. - snapshotRelativeJavaLibPath := memberType.snapshotPathGetter(p.OsPrefix(), ctx.Name()) + snapshotRelativeJavaLibPath := memberType.snapshotPathGetter(ctx, p.OsPrefix(), ctx.Name()) // Copy the exported jar to the snapshot. builder.CopyToSnapshot(exportedJar, snapshotRelativeJavaLibPath) @@ -1190,7 +1208,7 @@ func (p *testSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, exportedJar := p.JarToExport if exportedJar != nil { - snapshotRelativeJavaLibPath := sdkSnapshotFilePathForJar(p.OsPrefix(), ctx.Name()) + snapshotRelativeJavaLibPath := sdkSnapshotFilePathForJar(ctx, p.OsPrefix(), ctx.Name()) builder.CopyToSnapshot(exportedJar, snapshotRelativeJavaLibPath) propertySet.AddProperty("jars", []string{snapshotRelativeJavaLibPath}) -- cgit v1.2.3