From 20d90e3e51ae85abb8c4133b19197201cae84ed1 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 4 Oct 2022 20:01:04 +0100 Subject: [PATCH] Prevent bootImageVariant.licenseMetadataFile being set twice Previously, in a build containing source and prebuilt art bootclasspath_fragments, the bootImageVariant.licenseMetadataFile was set twice with the source always being set after the prebuilt and so winning. This change only sets bootImageVariant.licenseMetadataFile for the active module so it will use the prebuilt's license file if that is preferred. Bug: 245956352 Test: m nothing Change-Id: I948c7e5123169452f67c85ad98c4bbdb90a5d2de --- java/dexpreopt_bootjars.go | 7 ++++++- sdk/bootclasspath_fragment_sdk_test.go | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index 9237e89b4..b3faae895 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -803,10 +803,15 @@ func buildBootImageVariant(ctx android.ModuleContext, image *bootImageVariant, p rule.Build(image.name+"JarsDexpreopt_"+image.target.String(), "dexpreopt "+image.name+" jars "+arch.String()) // save output and installed files for makevars + // TODO - these are always the same and so should be initialized in genBootImageConfigs image.installs = rule.Installs() image.vdexInstalls = vdexInstalls image.unstrippedInstalls = unstrippedInstalls - image.licenseMetadataFile = android.OptionalPathForPath(ctx.LicenseMetadataFile()) + + // Only set the licenseMetadataFile from the active module. + if isActiveModule(ctx.Module()) { + image.licenseMetadataFile = android.OptionalPathForPath(ctx.LicenseMetadataFile()) + } return bootImageVariantOutputs{ image, diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go index 6faa0c5b9..1b64130ce 100644 --- a/sdk/bootclasspath_fragment_sdk_test.go +++ b/sdk/bootclasspath_fragment_sdk_test.go @@ -215,8 +215,7 @@ java_import { // Check the behavior of the snapshot when it is preferred. snapshotTestChecker(checkSnapshotPreferredWithSource, func(t *testing.T, result *android.TestResult) { - // TODO - the expectedLicenseMetadataFile passed here is incorrect as it is for the source module not the prebuilt module. - java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/meta_lic") + java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/snapshot/prebuilt_mybootclasspathfragment/android_common_com.android.art/meta_lic") java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic") }), )