blob: c8fafede6295f4544d7a0449791cdd8e8608bc9a [file] [log] [blame]
Paul Duffinbb7f1ac2021-03-29 22:18:45 +01001// Copyright 2021 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package java
16
17import (
Paul Duffin6a766452021-04-12 14:15:22 +010018 "fmt"
19
Paul Duffinbb7f1ac2021-03-29 22:18:45 +010020 "android/soong/android"
21 "android/soong/dexpreopt"
22)
23
24func init() {
25 registerPlatformBootclasspathBuildComponents(android.InitRegistrationContext)
26}
27
28func registerPlatformBootclasspathBuildComponents(ctx android.RegistrationContext) {
Paul Duffine3ecce62021-04-29 10:34:11 +010029 ctx.RegisterSingletonModuleType("platform_bootclasspath", platformBootclasspathFactory)
Paul Duffinbb7f1ac2021-03-29 22:18:45 +010030}
31
Paul Duffin01b463b2021-04-26 20:05:39 +010032// The tags used for the dependencies between the platform bootclasspath and any configured boot
33// jars.
34var (
35 platformBootclasspathArtBootJarDepTag = bootclasspathDependencyTag{name: "art-boot-jar"}
36 platformBootclasspathNonUpdatableBootJarDepTag = bootclasspathDependencyTag{name: "non-updatable-boot-jar"}
37 platformBootclasspathUpdatableBootJarDepTag = bootclasspathDependencyTag{name: "updatable-boot-jar"}
38)
Paul Duffinb432df92021-03-22 22:09:42 +000039
Paul Duffinbb7f1ac2021-03-29 22:18:45 +010040type platformBootclasspathModule struct {
Paul Duffine3ecce62021-04-29 10:34:11 +010041 android.SingletonModuleBase
Artur Satayev97259dc2021-04-07 15:17:14 +010042 ClasspathFragmentBase
Paul Duffinb432df92021-03-22 22:09:42 +000043
Paul Duffin62d8c3b2021-04-07 20:35:11 +010044 properties platformBootclasspathProperties
45
Paul Duffinb432df92021-03-22 22:09:42 +000046 // The apex:module pairs obtained from the configured modules.
47 //
48 // Currently only for testing.
49 configuredModules []android.Module
Paul Duffin62d8c3b2021-04-07 20:35:11 +010050
51 // The apex:module pairs obtained from the fragments.
52 //
53 // Currently only for testing.
54 fragments []android.Module
Paul Duffin6a766452021-04-12 14:15:22 +010055
56 // Path to the monolithic hiddenapi-flags.csv file.
Paul Duffin0b659862021-04-13 13:02:29 +010057 hiddenAPIFlagsCSV android.OutputPath
Paul Duffin6a766452021-04-12 14:15:22 +010058
59 // Path to the monolithic hiddenapi-index.csv file.
Paul Duffin0b659862021-04-13 13:02:29 +010060 hiddenAPIIndexCSV android.OutputPath
Paul Duffin6a766452021-04-12 14:15:22 +010061
62 // Path to the monolithic hiddenapi-unsupported.csv file.
Paul Duffin0b659862021-04-13 13:02:29 +010063 hiddenAPIMetadataCSV android.OutputPath
Paul Duffin62d8c3b2021-04-07 20:35:11 +010064}
65
Paul Duffin62d8c3b2021-04-07 20:35:11 +010066type platformBootclasspathProperties struct {
Paul Duffinb67d8782021-04-22 11:49:41 +010067 BootclasspathFragmentsDepsProperties
Paul Duffin702210b2021-04-08 20:12:41 +010068
Paul Duffin46169772021-04-14 15:01:56 +010069 Hidden_api HiddenAPIFlagFileProperties
Paul Duffinbb7f1ac2021-03-29 22:18:45 +010070}
71
Paul Duffine3ecce62021-04-29 10:34:11 +010072func platformBootclasspathFactory() android.SingletonModule {
Paul Duffinbb7f1ac2021-03-29 22:18:45 +010073 m := &platformBootclasspathModule{}
Paul Duffin62d8c3b2021-04-07 20:35:11 +010074 m.AddProperties(&m.properties)
satayev95e9c5b2021-04-29 11:50:26 +010075 // TODO(satayev): split apex jars into separate configs.
76 initClasspathFragment(m, BOOTCLASSPATH)
Paul Duffinbb7f1ac2021-03-29 22:18:45 +010077 android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
78 return m
79}
80
Paul Duffin6a766452021-04-12 14:15:22 +010081var _ android.OutputFileProducer = (*platformBootclasspathModule)(nil)
82
Artur Satayev97259dc2021-04-07 15:17:14 +010083func (b *platformBootclasspathModule) AndroidMkEntries() (entries []android.AndroidMkEntries) {
84 entries = append(entries, android.AndroidMkEntries{
85 Class: "FAKE",
86 // Need at least one output file in order for this to take effect.
87 OutputFile: android.OptionalPathForPath(b.hiddenAPIFlagsCSV),
88 Include: "$(BUILD_PHONY_PACKAGE)",
89 })
satayev128ce2f2021-05-06 13:21:15 +010090 entries = append(entries, b.classpathFragmentBase().androidMkEntries()...)
Artur Satayev97259dc2021-04-07 15:17:14 +010091 return
Paul Duffin6a766452021-04-12 14:15:22 +010092}
93
94// Make the hidden API files available from the platform-bootclasspath module.
95func (b *platformBootclasspathModule) OutputFiles(tag string) (android.Paths, error) {
96 switch tag {
97 case "hiddenapi-flags.csv":
98 return android.Paths{b.hiddenAPIFlagsCSV}, nil
99 case "hiddenapi-index.csv":
100 return android.Paths{b.hiddenAPIIndexCSV}, nil
101 case "hiddenapi-metadata.csv":
102 return android.Paths{b.hiddenAPIMetadataCSV}, nil
103 }
104
105 return nil, fmt.Errorf("unknown tag %s", tag)
106}
107
Paul Duffinbb7f1ac2021-03-29 22:18:45 +0100108func (b *platformBootclasspathModule) DepsMutator(ctx android.BottomUpMutatorContext) {
Paul Duffin74431d52021-04-21 14:10:42 +0100109 b.hiddenAPIDepsMutator(ctx)
110
Paul Duffinbb7f1ac2021-03-29 22:18:45 +0100111 if SkipDexpreoptBootJars(ctx) {
112 return
113 }
114
115 // Add a dependency onto the dex2oat tool which is needed for creating the boot image. The
116 // path is retrieved from the dependency by GetGlobalSoongConfig(ctx).
117 dexpreopt.RegisterToolDeps(ctx)
118}
119
Paul Duffin74431d52021-04-21 14:10:42 +0100120func (b *platformBootclasspathModule) hiddenAPIDepsMutator(ctx android.BottomUpMutatorContext) {
121 if ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") {
122 return
123 }
124
125 // Add dependencies onto the stub lib modules.
126 sdkKindToStubLibModules := hiddenAPIComputeMonolithicStubLibModules(ctx.Config())
127 hiddenAPIAddStubLibDependencies(ctx, sdkKindToStubLibModules)
128}
129
Paul Duffin4994d262021-04-22 12:08:59 +0100130func (b *platformBootclasspathModule) BootclasspathDepsMutator(ctx android.BottomUpMutatorContext) {
131 // Add dependencies on all the modules configured in the "art" boot image.
132 artImageConfig := genBootImageConfigs(ctx)[artBootImageName]
Paul Duffin01b463b2021-04-26 20:05:39 +0100133 addDependenciesOntoBootImageModules(ctx, artImageConfig.modules, platformBootclasspathArtBootJarDepTag)
Paul Duffinb432df92021-03-22 22:09:42 +0000134
Paul Duffin01b463b2021-04-26 20:05:39 +0100135 // Add dependencies on all the non-updatable module configured in the "boot" boot image. That does
136 // not include modules configured in the "art" boot image.
Paul Duffin4994d262021-04-22 12:08:59 +0100137 bootImageConfig := b.getImageConfig(ctx)
Paul Duffin01b463b2021-04-26 20:05:39 +0100138 addDependenciesOntoBootImageModules(ctx, bootImageConfig.modules, platformBootclasspathNonUpdatableBootJarDepTag)
Paul Duffinb432df92021-03-22 22:09:42 +0000139
Paul Duffin4994d262021-04-22 12:08:59 +0100140 // Add dependencies on all the updatable modules.
141 updatableModules := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars
Paul Duffin01b463b2021-04-26 20:05:39 +0100142 addDependenciesOntoBootImageModules(ctx, updatableModules, platformBootclasspathUpdatableBootJarDepTag)
Paul Duffin62d8c3b2021-04-07 20:35:11 +0100143
Paul Duffin4994d262021-04-22 12:08:59 +0100144 // Add dependencies on all the fragments.
145 b.properties.BootclasspathFragmentsDepsProperties.addDependenciesOntoFragments(ctx)
Paul Duffinb432df92021-03-22 22:09:42 +0000146}
147
Paul Duffin01b463b2021-04-26 20:05:39 +0100148func addDependenciesOntoBootImageModules(ctx android.BottomUpMutatorContext, modules android.ConfiguredJarList, tag bootclasspathDependencyTag) {
Paul Duffinb432df92021-03-22 22:09:42 +0000149 for i := 0; i < modules.Len(); i++ {
150 apex := modules.Apex(i)
151 name := modules.Jar(i)
152
Paul Duffin01b463b2021-04-26 20:05:39 +0100153 addDependencyOntoApexModulePair(ctx, apex, name, tag)
Paul Duffinb432df92021-03-22 22:09:42 +0000154 }
155}
156
Paul Duffine3ecce62021-04-29 10:34:11 +0100157// GenerateSingletonBuildActions does nothing and must never do anything.
158//
159// This module only implements android.SingletonModule so that it can implement
160// android.SingletonMakeVarsProvider.
161func (b *platformBootclasspathModule) GenerateSingletonBuildActions(android.SingletonContext) {
162 // Keep empty
163}
164
165func (d *platformBootclasspathModule) MakeVars(ctx android.MakeVarsContext) {
Paul Duffin12d29b72021-04-29 13:50:01 +0100166 d.generateHiddenApiMakeVars(ctx)
Paul Duffine3ecce62021-04-29 10:34:11 +0100167}
168
Paul Duffinbb7f1ac2021-03-29 22:18:45 +0100169func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Paul Duffin01b463b2021-04-26 20:05:39 +0100170 // Gather all the dependencies from the art, updatable and non-updatable boot jars.
171 artModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathArtBootJarDepTag)
172 nonUpdatableModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathNonUpdatableBootJarDepTag)
173 updatableModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathUpdatableBootJarDepTag)
174
175 // Concatenate them all, in order as they would appear on the bootclasspath.
176 var allModules []android.Module
177 allModules = append(allModules, artModules...)
178 allModules = append(allModules, nonUpdatableModules...)
179 allModules = append(allModules, updatableModules...)
180 b.configuredModules = allModules
181
182 // Gather all the fragments dependencies.
Paul Duffin9bacf562021-04-28 21:16:02 +0100183 b.fragments = gatherApexModulePairDepsWithTag(ctx, bootclasspathFragmentDepTag)
Paul Duffinb432df92021-03-22 22:09:42 +0000184
Paul Duffinf23bc472021-04-27 12:42:20 +0100185 // Check the configuration of the boot modules.
186 // ART modules are checked by the art-bootclasspath-fragment.
187 b.checkNonUpdatableModules(ctx, nonUpdatableModules)
188 b.checkUpdatableModules(ctx, updatableModules)
189
satayev013485b2021-05-06 23:38:10 +0100190 b.generateClasspathProtoBuildActions(ctx)
191
Paul Duffin9b381ef2021-04-08 23:01:37 +0100192 b.generateHiddenAPIBuildActions(ctx, b.configuredModules, b.fragments)
Paul Duffin702210b2021-04-08 20:12:41 +0100193
Paul Duffinbb7f1ac2021-03-29 22:18:45 +0100194 // Nothing to do if skipping the dexpreopt of boot image jars.
195 if SkipDexpreoptBootJars(ctx) {
196 return
197 }
198
Paul Duffin7ebebfd2021-04-27 19:36:57 +0100199 b.generateBootImageBuildActions(ctx, nonUpdatableModules, updatableModules)
Paul Duffinbb7f1ac2021-03-29 22:18:45 +0100200}
201
satayev013485b2021-05-06 23:38:10 +0100202// Generate classpaths.proto config
203func (b *platformBootclasspathModule) generateClasspathProtoBuildActions(ctx android.ModuleContext) {
204 // ART and platform boot jars must have a corresponding entry in DEX2OATBOOTCLASSPATH
205 classpathJars := configuredJarListToClasspathJars(ctx, b.ClasspathFragmentToConfiguredJarList(ctx), BOOTCLASSPATH, DEX2OATBOOTCLASSPATH)
satayev3db35472021-05-06 23:59:58 +0100206
satayev013485b2021-05-06 23:38:10 +0100207 // TODO(satayev): remove updatable boot jars once each apex has its own fragment
208 global := dexpreopt.GetGlobalConfig(ctx)
209 classpathJars = append(classpathJars, configuredJarListToClasspathJars(ctx, global.UpdatableBootJars, BOOTCLASSPATH)...)
210
211 b.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, classpathJars)
212}
213
214func (b *platformBootclasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList {
215 global := dexpreopt.GetGlobalConfig(ctx)
216 // TODO(satayev): split ART apex jars into their own classpathFragment
217 return global.BootJars
218}
219
Paul Duffinf23bc472021-04-27 12:42:20 +0100220// checkNonUpdatableModules ensures that the non-updatable modules supplied are not part of an
221// updatable module.
222func (b *platformBootclasspathModule) checkNonUpdatableModules(ctx android.ModuleContext, modules []android.Module) {
223 for _, m := range modules {
224 apexInfo := ctx.OtherModuleProvider(m, android.ApexInfoProvider).(android.ApexInfo)
225 fromUpdatableApex := apexInfo.Updatable
226 if fromUpdatableApex {
227 // error: this jar is part of an updatable apex
228 ctx.ModuleErrorf("module %q from updatable apexes %q is not allowed in the framework boot image", ctx.OtherModuleName(m), apexInfo.InApexes)
229 } else {
230 // ok: this jar is part of the platform or a non-updatable apex
231 }
232 }
233}
234
235// checkUpdatableModules ensures that the updatable modules supplied are not from the platform.
236func (b *platformBootclasspathModule) checkUpdatableModules(ctx android.ModuleContext, modules []android.Module) {
237 for _, m := range modules {
238 apexInfo := ctx.OtherModuleProvider(m, android.ApexInfoProvider).(android.ApexInfo)
239 fromUpdatableApex := apexInfo.Updatable
240 if fromUpdatableApex {
241 // ok: this jar is part of an updatable apex
242 } else {
243 name := ctx.OtherModuleName(m)
244 if apexInfo.IsForPlatform() {
245 // error: this jar is part of the platform
246 ctx.ModuleErrorf("module %q from platform is not allowed in the updatable boot jars list", name)
247 } else {
248 // TODO(b/177892522): Treat this as an error.
249 // Cannot do that at the moment because framework-wifi and framework-tethering are in the
250 // PRODUCT_UPDATABLE_BOOT_JARS but not marked as updatable in AOSP.
251 }
252 }
253 }
254}
255
Paul Duffinbb7f1ac2021-03-29 22:18:45 +0100256func (b *platformBootclasspathModule) getImageConfig(ctx android.EarlyModuleContext) *bootImageConfig {
257 return defaultBootImageConfig(ctx)
258}
Paul Duffin702210b2021-04-08 20:12:41 +0100259
260// generateHiddenAPIBuildActions generates all the hidden API related build rules.
Paul Duffin9b381ef2021-04-08 23:01:37 +0100261func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.ModuleContext, modules []android.Module, fragments []android.Module) {
Paul Duffin702210b2021-04-08 20:12:41 +0100262
Paul Duffin90b8ad32021-04-13 12:25:01 +0100263 // Save the paths to the monolithic files for retrieval via OutputFiles().
264 b.hiddenAPIFlagsCSV = hiddenAPISingletonPaths(ctx).flags
265 b.hiddenAPIIndexCSV = hiddenAPISingletonPaths(ctx).index
266 b.hiddenAPIMetadataCSV = hiddenAPISingletonPaths(ctx).metadata
Paul Duffin6a766452021-04-12 14:15:22 +0100267
Paul Duffin0b659862021-04-13 13:02:29 +0100268 // Don't run any hiddenapi rules if UNSAFE_DISABLE_HIDDENAPI_FLAGS=true. This is a performance
269 // optimization that can be used to reduce the incremental build time but as its name suggests it
270 // can be unsafe to use, e.g. when the changes affect anything that goes on the bootclasspath.
Vishnu Nair0dbd02a2021-04-30 00:24:07 +0000271 if ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") {
Paul Duffin0b659862021-04-13 13:02:29 +0100272 paths := android.OutputPaths{b.hiddenAPIFlagsCSV, b.hiddenAPIIndexCSV, b.hiddenAPIMetadataCSV}
273 for _, path := range paths {
274 ctx.Build(pctx, android.BuildParams{
275 Rule: android.Touch,
276 Output: path,
277 })
278 }
279 return
280 }
281
Paul Duffin9b381ef2021-04-08 23:01:37 +0100282 flagFileInfo := b.properties.Hidden_api.hiddenAPIFlagFileInfo(ctx)
283 for _, fragment := range fragments {
284 if ctx.OtherModuleHasProvider(fragment, hiddenAPIFlagFileInfoProvider) {
285 info := ctx.OtherModuleProvider(fragment, hiddenAPIFlagFileInfoProvider).(hiddenAPIFlagFileInfo)
286 flagFileInfo.append(info)
287 }
288 }
289
290 // Store the information for testing.
291 ctx.SetProvider(hiddenAPIFlagFileInfoProvider, flagFileInfo)
Paul Duffin702210b2021-04-08 20:12:41 +0100292
Paul Duffin537ea3d2021-05-14 10:38:00 +0100293 hiddenAPIModules := gatherHiddenAPIModuleFromContents(ctx, modules)
Paul Duffin74431d52021-04-21 14:10:42 +0100294
Paul Duffin34827d42021-05-13 21:25:05 +0100295 sdkKindToStubPaths := hiddenAPIGatherStubLibDexJarPaths(ctx, nil)
Paul Duffin74431d52021-04-21 14:10:42 +0100296
Paul Duffin537ea3d2021-05-14 10:38:00 +0100297 // Generate the monolithic stub-flags.csv file.
298 bootDexJars := extractBootDexJarsFromHiddenAPIModules(ctx, hiddenAPIModules)
299 stubFlags := hiddenAPISingletonPaths(ctx).stubFlags
300 rule := ruleToGenerateHiddenAPIStubFlagsFile(ctx, stubFlags, bootDexJars, sdkKindToStubPaths)
Paul Duffin74431d52021-04-21 14:10:42 +0100301 rule.Build("platform-bootclasspath-monolithic-hiddenapi-stub-flags", "monolithic hidden API stub flags")
Paul Duffin537ea3d2021-05-14 10:38:00 +0100302
303 // Extract the classes jars from the contents.
304 classesJars := extractClassJarsFromHiddenAPIModules(ctx, hiddenAPIModules)
305
306 // Generate the annotation-flags.csv file from all the module annotations.
307 annotationFlags := android.PathForModuleOut(ctx, "hiddenapi-monolithic", "annotation-flags.csv")
308 buildRuleToGenerateAnnotationFlags(ctx, "monolithic hiddenapi flags", classesJars, stubFlags, annotationFlags)
309
310 // Generate the monotlithic hiddenapi-flags.csv file.
311 allFlags := hiddenAPISingletonPaths(ctx).flags
312 buildRuleToGenerateHiddenApiFlags(ctx, "hiddenAPIFlagsFile", "hiddenapi flags", allFlags, stubFlags, annotationFlags, &flagFileInfo)
313
314 // Generate an intermediate monolithic hiddenapi-metadata.csv file directly from the annotations
315 // in the source code.
316 intermediateMetadataCSV := android.PathForModuleOut(ctx, "hiddenapi-monolithic", "intermediate-metadata.csv")
317 buildRuleToGenerateMetadata(ctx, "monolithic hidden API metadata", classesJars, stubFlags, intermediateMetadataCSV)
318
319 // Reformat the intermediate file to add | quotes just in case that is important for the tools
320 // that consume the metadata file.
321 // TODO(b/179354495): Investigate whether it is possible to remove this reformatting step.
322 metadataCSV := hiddenAPISingletonPaths(ctx).metadata
323 b.buildRuleMergeCSV(ctx, "reformat monolithic hidden API metadata", android.Paths{intermediateMetadataCSV}, metadataCSV)
324
325 // Generate the monolithic hiddenapi-index.csv file directly from the CSV files in the classes
326 // jars.
327 indexCSV := hiddenAPISingletonPaths(ctx).index
328 buildRuleToGenerateIndex(ctx, "monolithic hidden API index", classesJars, indexCSV)
Paul Duffin74431d52021-04-21 14:10:42 +0100329}
330
Paul Duffin537ea3d2021-05-14 10:38:00 +0100331func (b *platformBootclasspathModule) buildRuleMergeCSV(ctx android.ModuleContext, desc string, inputPaths android.Paths, outputPath android.WritablePath) {
Paul Duffin00b2bfd2021-04-12 17:24:36 +0100332 rule := android.NewRuleBuilder(pctx, ctx)
333 rule.Command().
334 BuiltTool("merge_csv").
335 Flag("--key_field signature").
Paul Duffin85dee5d2021-04-13 00:14:38 +0100336 FlagWithOutput("--output=", outputPath).
Paul Duffin537ea3d2021-05-14 10:38:00 +0100337 Inputs(inputPaths)
Paul Duffin85dee5d2021-04-13 00:14:38 +0100338
Paul Duffin537ea3d2021-05-14 10:38:00 +0100339 rule.Build(desc, desc)
Paul Duffin85dee5d2021-04-13 00:14:38 +0100340}
Paul Duffinad19d382021-04-26 16:44:00 +0100341
Paul Duffin12d29b72021-04-29 13:50:01 +0100342// generateHiddenApiMakeVars generates make variables needed by hidden API related make rules, e.g.
343// veridex and run-appcompat.
344func (b *platformBootclasspathModule) generateHiddenApiMakeVars(ctx android.MakeVarsContext) {
345 if ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") {
346 return
347 }
348 // INTERNAL_PLATFORM_HIDDENAPI_FLAGS is used by Make rules in art/ and cts/.
349 ctx.Strict("INTERNAL_PLATFORM_HIDDENAPI_FLAGS", b.hiddenAPIFlagsCSV.String())
350}
351
Paul Duffinad19d382021-04-26 16:44:00 +0100352// generateBootImageBuildActions generates ninja rules related to the boot image creation.
Paul Duffin7ebebfd2021-04-27 19:36:57 +0100353func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android.ModuleContext, nonUpdatableModules, updatableModules []android.Module) {
Paul Duffinad19d382021-04-26 16:44:00 +0100354 // Force the GlobalSoongConfig to be created and cached for use by the dex_bootjars
355 // GenerateSingletonBuildActions method as it cannot create it for itself.
356 dexpreopt.GetGlobalSoongConfig(ctx)
357
358 imageConfig := b.getImageConfig(ctx)
359 if imageConfig == nil {
360 return
361 }
362
363 global := dexpreopt.GetGlobalConfig(ctx)
364 if !shouldBuildBootImages(ctx.Config(), global) {
365 return
366 }
367
368 // Generate the framework profile rule
369 bootFrameworkProfileRule(ctx, imageConfig)
Paul Duffin4c094422021-04-26 20:10:48 +0100370
371 // Generate the updatable bootclasspath packages rule.
372 generateUpdatableBcpPackagesRule(ctx, imageConfig, updatableModules)
Paul Duffinf7a55922021-04-26 23:09:15 +0100373
Paul Duffin7ebebfd2021-04-27 19:36:57 +0100374 // Copy non-updatable module dex jars to their predefined locations.
375 copyBootJarsToPredefinedLocations(ctx, nonUpdatableModules, imageConfig.modules, imageConfig.dexPaths)
376
377 // Copy updatable module dex jars to their predefined locations.
378 config := GetUpdatableBootConfig(ctx)
379 copyBootJarsToPredefinedLocations(ctx, updatableModules, config.modules, config.dexPaths)
380
Paul Duffin2fc82ad2021-04-29 23:36:12 +0100381 // Build a profile for the image config and then use that to build the boot image.
382 profile := bootImageProfileRule(ctx, imageConfig)
383 buildBootImage(ctx, imageConfig, profile)
384
Paul Duffinf7a55922021-04-26 23:09:15 +0100385 dumpOatRules(ctx, imageConfig)
Paul Duffinad19d382021-04-26 16:44:00 +0100386}