From 5f5a17fd6b7ea404d9df2f31f2d074586b086326 Mon Sep 17 00:00:00 2001 From: Jiakai Zhang Date: Wed, 10 May 2023 18:38:34 +0100 Subject: Dexpreopt ART jars and framework jars together. Bug: 280776428 Test: atest art_standalone_dexpreopt_tests Test: - 1. m 2. Check .invocation file (http://gpaste/6498044089466880) 3. Check files in $ANDROID_PRODUCT_OUT/system/framework/x86_64 Test: - 1. m dist 2. Check files in out/dist/boot.zip Test: - 1. art/tools/buildbot-build.sh --host 2. m test-art-host-gtest 3. art/test/testrunner/testrunner.py --host Test: m build-art-target-golem (cherry picked from https://android-review.googlesource.com/q/commit:c08c162b5a82ddfc44e9944d798636b2241308de) Merged-In: I89490252e56a05edab03fdddc6539fa4d7f79756 Change-Id: I89490252e56a05edab03fdddc6539fa4d7f79756 --- java/dexpreopt_bootjars.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'java/dexpreopt_bootjars.go') diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index 792fa6396..f477f404e 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -295,6 +295,11 @@ type bootImageConfig struct { // The "--single-image" argument. singleImage bool + + // Profiles imported from other boot image configs. Each element must represent a + // `bootclasspath_fragment` of an APEX (i.e., the `name` field of each element must refer to the + // `image_name` property of a `bootclasspath_fragment`). + profileImports []*bootImageConfig } // Target-dependent description of a boot image. @@ -711,6 +716,34 @@ func buildBootImageVariant(ctx android.ModuleContext, image *bootImageVariant, p cmd.FlagWithInput("--profile-file=", profile) } + fragments := make(map[string]commonBootclasspathFragment) + ctx.VisitDirectDepsWithTag(bootclasspathFragmentDepTag, func(child android.Module) { + fragment := child.(commonBootclasspathFragment) + if fragment.getImageName() != nil && android.IsModulePreferred(child) { + fragments[*fragment.getImageName()] = fragment + } + }) + + for _, profileImport := range image.profileImports { + fragment := fragments[profileImport.name] + if fragment == nil { + ctx.ModuleErrorf("Boot image config '%[1]s' imports profile from '%[2]s', but a "+ + "bootclasspath_fragment with image name '%[2]s' doesn't exist or is not added as a "+ + "dependency of '%[1]s'", + image.name, + profileImport.name) + return bootImageVariantOutputs{} + } + if fragment.getProfilePath() == nil { + ctx.ModuleErrorf("Boot image config '%[1]s' imports profile from '%[2]s', but '%[2]s' "+ + "doesn't provide a profile", + image.name, + profileImport.name) + return bootImageVariantOutputs{} + } + cmd.FlagWithInput("--profile-file=", fragment.getProfilePath()) + } + dirtyImageFile := "frameworks/base/config/dirty-image-objects" dirtyImagePath := android.ExistentPathForSource(ctx, dirtyImageFile) if dirtyImagePath.Valid() { -- cgit v1.2.3-59-g8ed1b