Loading apex/bootclasspath_fragment_test.go +55 −0 Original line number Diff line number Diff line Loading @@ -553,12 +553,66 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) { `prebuilt_com.android.art`, }) // The boot images are installed in the APEX by Soong, so there shouldn't be any dexpreopt-related Make modules. ensureDoesNotContainRequiredDeps(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{ "mybootclasspathfragment-dexpreopt-arm64-boot.art", "mybootclasspathfragment-dexpreopt-arm64-boot.oat", "mybootclasspathfragment-dexpreopt-arm64-boot.vdex", "mybootclasspathfragment-dexpreopt-arm64-boot-bar.art", "mybootclasspathfragment-dexpreopt-arm64-boot-bar.oat", "mybootclasspathfragment-dexpreopt-arm64-boot-bar.vdex", "mybootclasspathfragment-dexpreopt-arm-boot.art", "mybootclasspathfragment-dexpreopt-arm-boot.oat", "mybootclasspathfragment-dexpreopt-arm-boot.vdex", "mybootclasspathfragment-dexpreopt-arm-boot-bar.art", "mybootclasspathfragment-dexpreopt-arm-boot-bar.oat", "mybootclasspathfragment-dexpreopt-arm-boot-bar.vdex", }) // Make sure that the prebuilt bootclasspath_fragment copies its dex files to the predefined // locations for the art image. module := result.ModuleForTests("prebuilt_mybootclasspathfragment", "android_common_com.android.art") checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo") }) t.Run("boot image files from preferred prebuilt no boot image in apex", func(t *testing.T) { result := android.GroupFixturePreparers( commonPreparer, // Configure some libraries in the art bootclasspath_fragment that match the source // bootclasspath_fragment's contents property. java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"), addSource("foo", "bar"), // Make sure that a preferred prebuilt with consistent contents doesn't affect the apex. addPrebuilt(true, "foo", "bar"), java.FixtureSetBootImageInstallDirOnDevice("art", "system/framework"), ).RunTest(t) ensureExactContents(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{ "etc/boot-image.prof", "etc/classpaths/bootclasspath.pb", "javalib/bar.jar", "javalib/foo.jar", }) ensureContainsRequiredDeps(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{ "mybootclasspathfragment-dexpreopt-arm64-boot.art", "mybootclasspathfragment-dexpreopt-arm64-boot.oat", "mybootclasspathfragment-dexpreopt-arm64-boot.vdex", "mybootclasspathfragment-dexpreopt-arm64-boot-bar.art", "mybootclasspathfragment-dexpreopt-arm64-boot-bar.oat", "mybootclasspathfragment-dexpreopt-arm64-boot-bar.vdex", "mybootclasspathfragment-dexpreopt-arm-boot.art", "mybootclasspathfragment-dexpreopt-arm-boot.oat", "mybootclasspathfragment-dexpreopt-arm-boot.vdex", "mybootclasspathfragment-dexpreopt-arm-boot-bar.art", "mybootclasspathfragment-dexpreopt-arm-boot-bar.oat", "mybootclasspathfragment-dexpreopt-arm-boot-bar.vdex", }) }) t.Run("source with inconsistency between config and contents", func(t *testing.T) { android.GroupFixturePreparers( commonPreparer, Loading Loading @@ -631,6 +685,7 @@ func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) { // Configure some libraries in the art bootclasspath_fragment. java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"), java.FixtureSetBootImageInstallDirOnDevice("art", "apex/com.android.art/javalib"), ) bp := ` Loading apex/prebuilt.go +16 −4 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ type prebuiltCommon struct { compatSymlinks android.InstallPaths hostRequired []string requiredModuleNames []string } type sanitizedPrebuilt interface { Loading Loading @@ -195,9 +196,19 @@ func (p *prebuiltCommon) initApexFilesForAndroidMk(ctx android.ModuleContext) { } p.apexFilesForAndroidMk = append(p.apexFilesForAndroidMk, af) } } else if tag == exportedBootclasspathFragmentTag || tag == exportedSystemserverclasspathFragmentTag { // Visit the children of the bootclasspath_fragment and systemserver_fragment. } else if tag == exportedBootclasspathFragmentTag { bcpfModule, ok := child.(*java.PrebuiltBootclasspathFragmentModule) if !ok { ctx.PropertyErrorf("exported_bootclasspath_fragments", "%q is not a prebuilt_bootclasspath_fragment module", name) return false } for _, makeModuleName := range bcpfModule.BootImageDeviceInstallMakeModules() { p.requiredModuleNames = append(p.requiredModuleNames, makeModuleName) } // Visit the children of the bootclasspath_fragment. return true } else if tag == exportedSystemserverclasspathFragmentTag { // Visit the children of the systemserver_fragment. return true } Loading @@ -211,6 +222,7 @@ func (p *prebuiltCommon) addRequiredModules(entries *android.AndroidMkEntries) { entries.AddStrings("LOCAL_TARGET_REQUIRED_MODULES", fi.targetRequiredModuleNames...) entries.AddStrings("LOCAL_HOST_REQUIRED_MODULES", fi.hostRequiredModuleNames...) } entries.AddStrings("LOCAL_REQUIRED_MODULES", p.requiredModuleNames...) } func (p *prebuiltCommon) AndroidMkEntries() []android.AndroidMkEntries { Loading java/bootclasspath_fragment.go +62 −40 Original line number Diff line number Diff line Loading @@ -1073,7 +1073,7 @@ type prebuiltBootclasspathFragmentProperties struct { // At the moment this is basically just a bootclasspath_fragment module that can be used as a // prebuilt. Eventually as more functionality is migrated into the bootclasspath_fragment module // type from the various singletons then this will diverge. type prebuiltBootclasspathFragmentModule struct { type PrebuiltBootclasspathFragmentModule struct { BootclasspathFragmentModule prebuilt android.Prebuilt Loading @@ -1081,16 +1081,16 @@ type prebuiltBootclasspathFragmentModule struct { prebuiltProperties prebuiltBootclasspathFragmentProperties } func (module *prebuiltBootclasspathFragmentModule) Prebuilt() *android.Prebuilt { func (module *PrebuiltBootclasspathFragmentModule) Prebuilt() *android.Prebuilt { return &module.prebuilt } func (module *prebuiltBootclasspathFragmentModule) Name() string { func (module *PrebuiltBootclasspathFragmentModule) Name() string { return module.prebuilt.Name(module.ModuleBase.Name()) } // produceHiddenAPIOutput returns a path to the prebuilt all-flags.csv or nil if none is specified. func (module *prebuiltBootclasspathFragmentModule) produceHiddenAPIOutput(ctx android.ModuleContext, contents []android.Module, input HiddenAPIFlagInput) *HiddenAPIOutput { func (module *PrebuiltBootclasspathFragmentModule) produceHiddenAPIOutput(ctx android.ModuleContext, contents []android.Module, input HiddenAPIFlagInput) *HiddenAPIOutput { pathForOptionalSrc := func(src *string, defaultPath android.Path) android.Path { if src == nil { return defaultPath Loading Loading @@ -1131,7 +1131,7 @@ func (module *prebuiltBootclasspathFragmentModule) produceHiddenAPIOutput(ctx an } // produceBootImageFiles extracts the boot image files from the APEX if available. func (module *prebuiltBootclasspathFragmentModule) produceBootImageFiles(ctx android.ModuleContext, imageConfig *bootImageConfig) bootImageFilesByArch { func (module *PrebuiltBootclasspathFragmentModule) produceBootImageFiles(ctx android.ModuleContext, imageConfig *bootImageConfig) bootImageFilesByArch { if !shouldCopyBootFilesToPredefinedLocations(ctx, imageConfig) { return nil } Loading @@ -1141,6 +1141,20 @@ func (module *prebuiltBootclasspathFragmentModule) produceBootImageFiles(ctx and return nil // An error has been reported by FindDeapexerProviderForModule. } profile := (android.WritablePath)(nil) if imageConfig.profileInstallPathInApex != "" { profile = di.PrebuiltExportPath(imageConfig.profileInstallPathInApex) } // Build the boot image files for the host variants. These are always built from the dex files // provided by the contents of this module as prebuilt versions of the host boot image files are // not available, i.e. there is no host specific prebuilt apex containing them. This has to be // built without a profile as the prebuilt modules do not provide a profile. buildBootImageVariantsForBuildOs(ctx, imageConfig, profile) if imageConfig.shouldInstallInApex() { // If the boot image files for the android variants are in the prebuilt apex, we must use those // rather than building new ones because those boot image files are going to be used on device. files := bootImageFilesByArch{} for _, variant := range imageConfig.apexVariants() { arch := variant.target.Arch.ArchType Loading @@ -1161,17 +1175,19 @@ func (module *prebuiltBootclasspathFragmentModule) produceBootImageFiles(ctx and }) } } // Build the boot image files for the host variants. These are built from the dex files provided // by the contents of this module as prebuilt versions of the host boot image files are not // available, i.e. there is no host specific prebuilt apex containing them. This has to be built // without a profile as the prebuilt modules do not provide a profile. buildBootImageVariantsForBuildOs(ctx, imageConfig, nil) return files } else { if profile == nil { ctx.ModuleErrorf("Unable to produce boot image files: neither boot image files nor profiles exists in the prebuilt apex") return nil } // Build boot image files for the android variants from the dex files provided by the contents // of this module. return buildBootImageVariantsForAndroidOs(ctx, imageConfig, profile) } } var _ commonBootclasspathFragment = (*prebuiltBootclasspathFragmentModule)(nil) var _ commonBootclasspathFragment = (*PrebuiltBootclasspathFragmentModule)(nil) // createBootImageTag creates the tag to uniquely identify the boot image file among all of the // files that a module requires from the prebuilt .apex file. Loading @@ -1185,11 +1201,16 @@ func createBootImageTag(arch android.ArchType, baseName string) string { // // If there is no image config associated with this fragment then it returns nil. Otherwise, it // returns the files that are listed in the image config. func (module *prebuiltBootclasspathFragmentModule) RequiredFilesFromPrebuiltApex(ctx android.BaseModuleContext) []string { func (module *PrebuiltBootclasspathFragmentModule) RequiredFilesFromPrebuiltApex(ctx android.BaseModuleContext) []string { imageConfig := module.getImageConfig(ctx) if imageConfig != nil { // Add the boot image files, e.g. .art, .oat and .vdex files. files := []string{} if imageConfig.profileInstallPathInApex != "" { // Add the boot image profile. files = append(files, imageConfig.profileInstallPathInApex) } if imageConfig.shouldInstallInApex() { // Add the boot image files, e.g. .art, .oat and .vdex files. for _, variant := range imageConfig.apexVariants() { arch := variant.target.Arch.ArchType for _, path := range variant.imagesDeps.Paths() { Loading @@ -1197,6 +1218,7 @@ func (module *prebuiltBootclasspathFragmentModule) RequiredFilesFromPrebuiltApex files = append(files, apexRootRelativePathToBootImageFile(arch, base)) } } } return files } return nil Loading @@ -1206,10 +1228,10 @@ func apexRootRelativePathToBootImageFile(arch android.ArchType, base string) str return filepath.Join("javalib", arch.String(), base) } var _ android.RequiredFilesFromPrebuiltApex = (*prebuiltBootclasspathFragmentModule)(nil) var _ android.RequiredFilesFromPrebuiltApex = (*PrebuiltBootclasspathFragmentModule)(nil) func prebuiltBootclasspathFragmentFactory() android.Module { m := &prebuiltBootclasspathFragmentModule{} m := &PrebuiltBootclasspathFragmentModule{} m.AddProperties(&m.properties, &m.prebuiltProperties) // This doesn't actually have any prebuilt files of its own so pass a placeholder for the srcs // array. Loading Loading
apex/bootclasspath_fragment_test.go +55 −0 Original line number Diff line number Diff line Loading @@ -553,12 +553,66 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) { `prebuilt_com.android.art`, }) // The boot images are installed in the APEX by Soong, so there shouldn't be any dexpreopt-related Make modules. ensureDoesNotContainRequiredDeps(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{ "mybootclasspathfragment-dexpreopt-arm64-boot.art", "mybootclasspathfragment-dexpreopt-arm64-boot.oat", "mybootclasspathfragment-dexpreopt-arm64-boot.vdex", "mybootclasspathfragment-dexpreopt-arm64-boot-bar.art", "mybootclasspathfragment-dexpreopt-arm64-boot-bar.oat", "mybootclasspathfragment-dexpreopt-arm64-boot-bar.vdex", "mybootclasspathfragment-dexpreopt-arm-boot.art", "mybootclasspathfragment-dexpreopt-arm-boot.oat", "mybootclasspathfragment-dexpreopt-arm-boot.vdex", "mybootclasspathfragment-dexpreopt-arm-boot-bar.art", "mybootclasspathfragment-dexpreopt-arm-boot-bar.oat", "mybootclasspathfragment-dexpreopt-arm-boot-bar.vdex", }) // Make sure that the prebuilt bootclasspath_fragment copies its dex files to the predefined // locations for the art image. module := result.ModuleForTests("prebuilt_mybootclasspathfragment", "android_common_com.android.art") checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo") }) t.Run("boot image files from preferred prebuilt no boot image in apex", func(t *testing.T) { result := android.GroupFixturePreparers( commonPreparer, // Configure some libraries in the art bootclasspath_fragment that match the source // bootclasspath_fragment's contents property. java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"), addSource("foo", "bar"), // Make sure that a preferred prebuilt with consistent contents doesn't affect the apex. addPrebuilt(true, "foo", "bar"), java.FixtureSetBootImageInstallDirOnDevice("art", "system/framework"), ).RunTest(t) ensureExactContents(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{ "etc/boot-image.prof", "etc/classpaths/bootclasspath.pb", "javalib/bar.jar", "javalib/foo.jar", }) ensureContainsRequiredDeps(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{ "mybootclasspathfragment-dexpreopt-arm64-boot.art", "mybootclasspathfragment-dexpreopt-arm64-boot.oat", "mybootclasspathfragment-dexpreopt-arm64-boot.vdex", "mybootclasspathfragment-dexpreopt-arm64-boot-bar.art", "mybootclasspathfragment-dexpreopt-arm64-boot-bar.oat", "mybootclasspathfragment-dexpreopt-arm64-boot-bar.vdex", "mybootclasspathfragment-dexpreopt-arm-boot.art", "mybootclasspathfragment-dexpreopt-arm-boot.oat", "mybootclasspathfragment-dexpreopt-arm-boot.vdex", "mybootclasspathfragment-dexpreopt-arm-boot-bar.art", "mybootclasspathfragment-dexpreopt-arm-boot-bar.oat", "mybootclasspathfragment-dexpreopt-arm-boot-bar.vdex", }) }) t.Run("source with inconsistency between config and contents", func(t *testing.T) { android.GroupFixturePreparers( commonPreparer, Loading Loading @@ -631,6 +685,7 @@ func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) { // Configure some libraries in the art bootclasspath_fragment. java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"), java.FixtureSetBootImageInstallDirOnDevice("art", "apex/com.android.art/javalib"), ) bp := ` Loading
apex/prebuilt.go +16 −4 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ type prebuiltCommon struct { compatSymlinks android.InstallPaths hostRequired []string requiredModuleNames []string } type sanitizedPrebuilt interface { Loading Loading @@ -195,9 +196,19 @@ func (p *prebuiltCommon) initApexFilesForAndroidMk(ctx android.ModuleContext) { } p.apexFilesForAndroidMk = append(p.apexFilesForAndroidMk, af) } } else if tag == exportedBootclasspathFragmentTag || tag == exportedSystemserverclasspathFragmentTag { // Visit the children of the bootclasspath_fragment and systemserver_fragment. } else if tag == exportedBootclasspathFragmentTag { bcpfModule, ok := child.(*java.PrebuiltBootclasspathFragmentModule) if !ok { ctx.PropertyErrorf("exported_bootclasspath_fragments", "%q is not a prebuilt_bootclasspath_fragment module", name) return false } for _, makeModuleName := range bcpfModule.BootImageDeviceInstallMakeModules() { p.requiredModuleNames = append(p.requiredModuleNames, makeModuleName) } // Visit the children of the bootclasspath_fragment. return true } else if tag == exportedSystemserverclasspathFragmentTag { // Visit the children of the systemserver_fragment. return true } Loading @@ -211,6 +222,7 @@ func (p *prebuiltCommon) addRequiredModules(entries *android.AndroidMkEntries) { entries.AddStrings("LOCAL_TARGET_REQUIRED_MODULES", fi.targetRequiredModuleNames...) entries.AddStrings("LOCAL_HOST_REQUIRED_MODULES", fi.hostRequiredModuleNames...) } entries.AddStrings("LOCAL_REQUIRED_MODULES", p.requiredModuleNames...) } func (p *prebuiltCommon) AndroidMkEntries() []android.AndroidMkEntries { Loading
java/bootclasspath_fragment.go +62 −40 Original line number Diff line number Diff line Loading @@ -1073,7 +1073,7 @@ type prebuiltBootclasspathFragmentProperties struct { // At the moment this is basically just a bootclasspath_fragment module that can be used as a // prebuilt. Eventually as more functionality is migrated into the bootclasspath_fragment module // type from the various singletons then this will diverge. type prebuiltBootclasspathFragmentModule struct { type PrebuiltBootclasspathFragmentModule struct { BootclasspathFragmentModule prebuilt android.Prebuilt Loading @@ -1081,16 +1081,16 @@ type prebuiltBootclasspathFragmentModule struct { prebuiltProperties prebuiltBootclasspathFragmentProperties } func (module *prebuiltBootclasspathFragmentModule) Prebuilt() *android.Prebuilt { func (module *PrebuiltBootclasspathFragmentModule) Prebuilt() *android.Prebuilt { return &module.prebuilt } func (module *prebuiltBootclasspathFragmentModule) Name() string { func (module *PrebuiltBootclasspathFragmentModule) Name() string { return module.prebuilt.Name(module.ModuleBase.Name()) } // produceHiddenAPIOutput returns a path to the prebuilt all-flags.csv or nil if none is specified. func (module *prebuiltBootclasspathFragmentModule) produceHiddenAPIOutput(ctx android.ModuleContext, contents []android.Module, input HiddenAPIFlagInput) *HiddenAPIOutput { func (module *PrebuiltBootclasspathFragmentModule) produceHiddenAPIOutput(ctx android.ModuleContext, contents []android.Module, input HiddenAPIFlagInput) *HiddenAPIOutput { pathForOptionalSrc := func(src *string, defaultPath android.Path) android.Path { if src == nil { return defaultPath Loading Loading @@ -1131,7 +1131,7 @@ func (module *prebuiltBootclasspathFragmentModule) produceHiddenAPIOutput(ctx an } // produceBootImageFiles extracts the boot image files from the APEX if available. func (module *prebuiltBootclasspathFragmentModule) produceBootImageFiles(ctx android.ModuleContext, imageConfig *bootImageConfig) bootImageFilesByArch { func (module *PrebuiltBootclasspathFragmentModule) produceBootImageFiles(ctx android.ModuleContext, imageConfig *bootImageConfig) bootImageFilesByArch { if !shouldCopyBootFilesToPredefinedLocations(ctx, imageConfig) { return nil } Loading @@ -1141,6 +1141,20 @@ func (module *prebuiltBootclasspathFragmentModule) produceBootImageFiles(ctx and return nil // An error has been reported by FindDeapexerProviderForModule. } profile := (android.WritablePath)(nil) if imageConfig.profileInstallPathInApex != "" { profile = di.PrebuiltExportPath(imageConfig.profileInstallPathInApex) } // Build the boot image files for the host variants. These are always built from the dex files // provided by the contents of this module as prebuilt versions of the host boot image files are // not available, i.e. there is no host specific prebuilt apex containing them. This has to be // built without a profile as the prebuilt modules do not provide a profile. buildBootImageVariantsForBuildOs(ctx, imageConfig, profile) if imageConfig.shouldInstallInApex() { // If the boot image files for the android variants are in the prebuilt apex, we must use those // rather than building new ones because those boot image files are going to be used on device. files := bootImageFilesByArch{} for _, variant := range imageConfig.apexVariants() { arch := variant.target.Arch.ArchType Loading @@ -1161,17 +1175,19 @@ func (module *prebuiltBootclasspathFragmentModule) produceBootImageFiles(ctx and }) } } // Build the boot image files for the host variants. These are built from the dex files provided // by the contents of this module as prebuilt versions of the host boot image files are not // available, i.e. there is no host specific prebuilt apex containing them. This has to be built // without a profile as the prebuilt modules do not provide a profile. buildBootImageVariantsForBuildOs(ctx, imageConfig, nil) return files } else { if profile == nil { ctx.ModuleErrorf("Unable to produce boot image files: neither boot image files nor profiles exists in the prebuilt apex") return nil } // Build boot image files for the android variants from the dex files provided by the contents // of this module. return buildBootImageVariantsForAndroidOs(ctx, imageConfig, profile) } } var _ commonBootclasspathFragment = (*prebuiltBootclasspathFragmentModule)(nil) var _ commonBootclasspathFragment = (*PrebuiltBootclasspathFragmentModule)(nil) // createBootImageTag creates the tag to uniquely identify the boot image file among all of the // files that a module requires from the prebuilt .apex file. Loading @@ -1185,11 +1201,16 @@ func createBootImageTag(arch android.ArchType, baseName string) string { // // If there is no image config associated with this fragment then it returns nil. Otherwise, it // returns the files that are listed in the image config. func (module *prebuiltBootclasspathFragmentModule) RequiredFilesFromPrebuiltApex(ctx android.BaseModuleContext) []string { func (module *PrebuiltBootclasspathFragmentModule) RequiredFilesFromPrebuiltApex(ctx android.BaseModuleContext) []string { imageConfig := module.getImageConfig(ctx) if imageConfig != nil { // Add the boot image files, e.g. .art, .oat and .vdex files. files := []string{} if imageConfig.profileInstallPathInApex != "" { // Add the boot image profile. files = append(files, imageConfig.profileInstallPathInApex) } if imageConfig.shouldInstallInApex() { // Add the boot image files, e.g. .art, .oat and .vdex files. for _, variant := range imageConfig.apexVariants() { arch := variant.target.Arch.ArchType for _, path := range variant.imagesDeps.Paths() { Loading @@ -1197,6 +1218,7 @@ func (module *prebuiltBootclasspathFragmentModule) RequiredFilesFromPrebuiltApex files = append(files, apexRootRelativePathToBootImageFile(arch, base)) } } } return files } return nil Loading @@ -1206,10 +1228,10 @@ func apexRootRelativePathToBootImageFile(arch android.ArchType, base string) str return filepath.Join("javalib", arch.String(), base) } var _ android.RequiredFilesFromPrebuiltApex = (*prebuiltBootclasspathFragmentModule)(nil) var _ android.RequiredFilesFromPrebuiltApex = (*PrebuiltBootclasspathFragmentModule)(nil) func prebuiltBootclasspathFragmentFactory() android.Module { m := &prebuiltBootclasspathFragmentModule{} m := &PrebuiltBootclasspathFragmentModule{} m.AddProperties(&m.properties, &m.prebuiltProperties) // This doesn't actually have any prebuilt files of its own so pass a placeholder for the srcs // array. Loading