Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 1 | // 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 | |
| 15 | package java |
| 16 | |
| 17 | import ( |
Paul Duffin | 6a76645 | 2021-04-12 14:15:22 +0100 | [diff] [blame] | 18 | "fmt" |
| 19 | |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 20 | "android/soong/android" |
| 21 | "android/soong/dexpreopt" |
| 22 | ) |
| 23 | |
| 24 | func init() { |
| 25 | registerPlatformBootclasspathBuildComponents(android.InitRegistrationContext) |
| 26 | } |
| 27 | |
| 28 | func registerPlatformBootclasspathBuildComponents(ctx android.RegistrationContext) { |
| 29 | ctx.RegisterModuleType("platform_bootclasspath", platformBootclasspathFactory) |
| 30 | } |
| 31 | |
Paul Duffin | 01b463b | 2021-04-26 20:05:39 +0100 | [diff] [blame] | 32 | // The tags used for the dependencies between the platform bootclasspath and any configured boot |
| 33 | // jars. |
| 34 | var ( |
| 35 | platformBootclasspathArtBootJarDepTag = bootclasspathDependencyTag{name: "art-boot-jar"} |
| 36 | platformBootclasspathNonUpdatableBootJarDepTag = bootclasspathDependencyTag{name: "non-updatable-boot-jar"} |
| 37 | platformBootclasspathUpdatableBootJarDepTag = bootclasspathDependencyTag{name: "updatable-boot-jar"} |
| 38 | ) |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 39 | |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 40 | type platformBootclasspathModule struct { |
| 41 | android.ModuleBase |
Artur Satayev | 97259dc | 2021-04-07 15:17:14 +0100 | [diff] [blame] | 42 | ClasspathFragmentBase |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 43 | |
Paul Duffin | 62d8c3b | 2021-04-07 20:35:11 +0100 | [diff] [blame] | 44 | properties platformBootclasspathProperties |
| 45 | |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 46 | // The apex:module pairs obtained from the configured modules. |
| 47 | // |
| 48 | // Currently only for testing. |
| 49 | configuredModules []android.Module |
Paul Duffin | 62d8c3b | 2021-04-07 20:35:11 +0100 | [diff] [blame] | 50 | |
| 51 | // The apex:module pairs obtained from the fragments. |
| 52 | // |
| 53 | // Currently only for testing. |
| 54 | fragments []android.Module |
Paul Duffin | 6a76645 | 2021-04-12 14:15:22 +0100 | [diff] [blame] | 55 | |
| 56 | // Path to the monolithic hiddenapi-flags.csv file. |
Paul Duffin | 0b65986 | 2021-04-13 13:02:29 +0100 | [diff] [blame] | 57 | hiddenAPIFlagsCSV android.OutputPath |
Paul Duffin | 6a76645 | 2021-04-12 14:15:22 +0100 | [diff] [blame] | 58 | |
| 59 | // Path to the monolithic hiddenapi-index.csv file. |
Paul Duffin | 0b65986 | 2021-04-13 13:02:29 +0100 | [diff] [blame] | 60 | hiddenAPIIndexCSV android.OutputPath |
Paul Duffin | 6a76645 | 2021-04-12 14:15:22 +0100 | [diff] [blame] | 61 | |
| 62 | // Path to the monolithic hiddenapi-unsupported.csv file. |
Paul Duffin | 0b65986 | 2021-04-13 13:02:29 +0100 | [diff] [blame] | 63 | hiddenAPIMetadataCSV android.OutputPath |
Paul Duffin | 62d8c3b | 2021-04-07 20:35:11 +0100 | [diff] [blame] | 64 | } |
| 65 | |
Paul Duffin | 62d8c3b | 2021-04-07 20:35:11 +0100 | [diff] [blame] | 66 | type platformBootclasspathProperties struct { |
Paul Duffin | b67d878 | 2021-04-22 11:49:41 +0100 | [diff] [blame] | 67 | BootclasspathFragmentsDepsProperties |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 68 | |
Paul Duffin | 4616977 | 2021-04-14 15:01:56 +0100 | [diff] [blame] | 69 | Hidden_api HiddenAPIFlagFileProperties |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | func platformBootclasspathFactory() android.Module { |
| 73 | m := &platformBootclasspathModule{} |
Paul Duffin | 62d8c3b | 2021-04-07 20:35:11 +0100 | [diff] [blame] | 74 | m.AddProperties(&m.properties) |
Artur Satayev | 97259dc | 2021-04-07 15:17:14 +0100 | [diff] [blame] | 75 | // TODO(satayev): split systemserver and apex jars into separate configs. |
| 76 | initClasspathFragment(m) |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 77 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 78 | return m |
| 79 | } |
| 80 | |
Paul Duffin | 6a76645 | 2021-04-12 14:15:22 +0100 | [diff] [blame] | 81 | var _ android.OutputFileProducer = (*platformBootclasspathModule)(nil) |
| 82 | |
Artur Satayev | 97259dc | 2021-04-07 15:17:14 +0100 | [diff] [blame] | 83 | func (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 | }) |
| 90 | entries = append(entries, b.classpathFragmentBase().getAndroidMkEntries()...) |
| 91 | return |
Paul Duffin | 6a76645 | 2021-04-12 14:15:22 +0100 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | // Make the hidden API files available from the platform-bootclasspath module. |
| 95 | func (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 Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 108 | func (b *platformBootclasspathModule) DepsMutator(ctx android.BottomUpMutatorContext) { |
Paul Duffin | 74431d5 | 2021-04-21 14:10:42 +0100 | [diff] [blame] | 109 | b.hiddenAPIDepsMutator(ctx) |
| 110 | |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 111 | 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 Duffin | 74431d5 | 2021-04-21 14:10:42 +0100 | [diff] [blame] | 120 | func (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 Duffin | 4994d26 | 2021-04-22 12:08:59 +0100 | [diff] [blame] | 130 | func (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 Duffin | 01b463b | 2021-04-26 20:05:39 +0100 | [diff] [blame] | 133 | addDependenciesOntoBootImageModules(ctx, artImageConfig.modules, platformBootclasspathArtBootJarDepTag) |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 134 | |
Paul Duffin | 01b463b | 2021-04-26 20:05:39 +0100 | [diff] [blame] | 135 | // 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 Duffin | 4994d26 | 2021-04-22 12:08:59 +0100 | [diff] [blame] | 137 | bootImageConfig := b.getImageConfig(ctx) |
Paul Duffin | 01b463b | 2021-04-26 20:05:39 +0100 | [diff] [blame] | 138 | addDependenciesOntoBootImageModules(ctx, bootImageConfig.modules, platformBootclasspathNonUpdatableBootJarDepTag) |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 139 | |
Paul Duffin | 4994d26 | 2021-04-22 12:08:59 +0100 | [diff] [blame] | 140 | // Add dependencies on all the updatable modules. |
| 141 | updatableModules := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars |
Paul Duffin | 01b463b | 2021-04-26 20:05:39 +0100 | [diff] [blame] | 142 | addDependenciesOntoBootImageModules(ctx, updatableModules, platformBootclasspathUpdatableBootJarDepTag) |
Paul Duffin | 62d8c3b | 2021-04-07 20:35:11 +0100 | [diff] [blame] | 143 | |
Paul Duffin | 4994d26 | 2021-04-22 12:08:59 +0100 | [diff] [blame] | 144 | // Add dependencies on all the fragments. |
| 145 | b.properties.BootclasspathFragmentsDepsProperties.addDependenciesOntoFragments(ctx) |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 146 | } |
| 147 | |
Paul Duffin | 01b463b | 2021-04-26 20:05:39 +0100 | [diff] [blame] | 148 | func addDependenciesOntoBootImageModules(ctx android.BottomUpMutatorContext, modules android.ConfiguredJarList, tag bootclasspathDependencyTag) { |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 149 | for i := 0; i < modules.Len(); i++ { |
| 150 | apex := modules.Apex(i) |
| 151 | name := modules.Jar(i) |
| 152 | |
Paul Duffin | 01b463b | 2021-04-26 20:05:39 +0100 | [diff] [blame] | 153 | addDependencyOntoApexModulePair(ctx, apex, name, tag) |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 154 | } |
| 155 | } |
| 156 | |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 157 | func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Artur Satayev | 97259dc | 2021-04-07 15:17:14 +0100 | [diff] [blame] | 158 | b.classpathFragmentBase().generateAndroidBuildActions(ctx) |
| 159 | |
Paul Duffin | 01b463b | 2021-04-26 20:05:39 +0100 | [diff] [blame] | 160 | // Gather all the dependencies from the art, updatable and non-updatable boot jars. |
| 161 | artModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathArtBootJarDepTag) |
| 162 | nonUpdatableModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathNonUpdatableBootJarDepTag) |
| 163 | updatableModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathUpdatableBootJarDepTag) |
| 164 | |
| 165 | // Concatenate them all, in order as they would appear on the bootclasspath. |
| 166 | var allModules []android.Module |
| 167 | allModules = append(allModules, artModules...) |
| 168 | allModules = append(allModules, nonUpdatableModules...) |
| 169 | allModules = append(allModules, updatableModules...) |
| 170 | b.configuredModules = allModules |
| 171 | |
| 172 | // Gather all the fragments dependencies. |
Paul Duffin | 9bacf56 | 2021-04-28 21:16:02 +0100 | [diff] [blame] | 173 | b.fragments = gatherApexModulePairDepsWithTag(ctx, bootclasspathFragmentDepTag) |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 174 | |
Paul Duffin | 9b381ef | 2021-04-08 23:01:37 +0100 | [diff] [blame] | 175 | b.generateHiddenAPIBuildActions(ctx, b.configuredModules, b.fragments) |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 176 | |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 177 | // Nothing to do if skipping the dexpreopt of boot image jars. |
| 178 | if SkipDexpreoptBootJars(ctx) { |
| 179 | return |
| 180 | } |
| 181 | |
Paul Duffin | 4c09442 | 2021-04-26 20:10:48 +0100 | [diff] [blame] | 182 | b.generateBootImageBuildActions(ctx, updatableModules) |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | func (b *platformBootclasspathModule) getImageConfig(ctx android.EarlyModuleContext) *bootImageConfig { |
| 186 | return defaultBootImageConfig(ctx) |
| 187 | } |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 188 | |
| 189 | // generateHiddenAPIBuildActions generates all the hidden API related build rules. |
Paul Duffin | 9b381ef | 2021-04-08 23:01:37 +0100 | [diff] [blame] | 190 | func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.ModuleContext, modules []android.Module, fragments []android.Module) { |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 191 | |
Paul Duffin | 90b8ad3 | 2021-04-13 12:25:01 +0100 | [diff] [blame] | 192 | // Save the paths to the monolithic files for retrieval via OutputFiles(). |
| 193 | b.hiddenAPIFlagsCSV = hiddenAPISingletonPaths(ctx).flags |
| 194 | b.hiddenAPIIndexCSV = hiddenAPISingletonPaths(ctx).index |
| 195 | b.hiddenAPIMetadataCSV = hiddenAPISingletonPaths(ctx).metadata |
Paul Duffin | 6a76645 | 2021-04-12 14:15:22 +0100 | [diff] [blame] | 196 | |
Paul Duffin | 0b65986 | 2021-04-13 13:02:29 +0100 | [diff] [blame] | 197 | // Don't run any hiddenapi rules if UNSAFE_DISABLE_HIDDENAPI_FLAGS=true. This is a performance |
| 198 | // optimization that can be used to reduce the incremental build time but as its name suggests it |
| 199 | // can be unsafe to use, e.g. when the changes affect anything that goes on the bootclasspath. |
| 200 | if ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") { |
| 201 | paths := android.OutputPaths{b.hiddenAPIFlagsCSV, b.hiddenAPIIndexCSV, b.hiddenAPIMetadataCSV} |
| 202 | for _, path := range paths { |
| 203 | ctx.Build(pctx, android.BuildParams{ |
| 204 | Rule: android.Touch, |
| 205 | Output: path, |
| 206 | }) |
| 207 | } |
| 208 | return |
| 209 | } |
| 210 | |
Paul Duffin | 1ba2467 | 2021-04-12 23:26:14 +0100 | [diff] [blame] | 211 | hiddenAPISupportingModules := []hiddenAPISupportingModule{} |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 212 | for _, module := range modules { |
Paul Duffin | 1ba2467 | 2021-04-12 23:26:14 +0100 | [diff] [blame] | 213 | if h, ok := module.(hiddenAPISupportingModule); ok { |
| 214 | if h.bootDexJar() == nil { |
| 215 | ctx.ModuleErrorf("module %s does not provide a bootDexJar file", module) |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 216 | } |
Paul Duffin | 1ba2467 | 2021-04-12 23:26:14 +0100 | [diff] [blame] | 217 | if h.flagsCSV() == nil { |
| 218 | ctx.ModuleErrorf("module %s does not provide a flagsCSV file", module) |
| 219 | } |
| 220 | if h.indexCSV() == nil { |
| 221 | ctx.ModuleErrorf("module %s does not provide an indexCSV file", module) |
| 222 | } |
| 223 | if h.metadataCSV() == nil { |
| 224 | ctx.ModuleErrorf("module %s does not provide a metadataCSV file", module) |
| 225 | } |
| 226 | |
| 227 | if ctx.Failed() { |
| 228 | continue |
| 229 | } |
| 230 | |
| 231 | hiddenAPISupportingModules = append(hiddenAPISupportingModules, h) |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 232 | } else { |
Paul Duffin | 1ba2467 | 2021-04-12 23:26:14 +0100 | [diff] [blame] | 233 | ctx.ModuleErrorf("module %s of type %s does not support hidden API processing", module, ctx.OtherModuleType(module)) |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 234 | } |
| 235 | } |
| 236 | |
Paul Duffin | 1ba2467 | 2021-04-12 23:26:14 +0100 | [diff] [blame] | 237 | moduleSpecificFlagsPaths := android.Paths{} |
| 238 | for _, module := range hiddenAPISupportingModules { |
| 239 | moduleSpecificFlagsPaths = append(moduleSpecificFlagsPaths, module.flagsCSV()) |
| 240 | } |
| 241 | |
Paul Duffin | 9b381ef | 2021-04-08 23:01:37 +0100 | [diff] [blame] | 242 | flagFileInfo := b.properties.Hidden_api.hiddenAPIFlagFileInfo(ctx) |
| 243 | for _, fragment := range fragments { |
| 244 | if ctx.OtherModuleHasProvider(fragment, hiddenAPIFlagFileInfoProvider) { |
| 245 | info := ctx.OtherModuleProvider(fragment, hiddenAPIFlagFileInfoProvider).(hiddenAPIFlagFileInfo) |
| 246 | flagFileInfo.append(info) |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | // Store the information for testing. |
| 251 | ctx.SetProvider(hiddenAPIFlagFileInfoProvider, flagFileInfo) |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 252 | |
| 253 | outputPath := hiddenAPISingletonPaths(ctx).flags |
| 254 | baseFlagsPath := hiddenAPISingletonPaths(ctx).stubFlags |
Paul Duffin | 9b381ef | 2021-04-08 23:01:37 +0100 | [diff] [blame] | 255 | ruleToGenerateHiddenApiFlags(ctx, outputPath, baseFlagsPath, moduleSpecificFlagsPaths, flagFileInfo) |
Paul Duffin | 00b2bfd | 2021-04-12 17:24:36 +0100 | [diff] [blame] | 256 | |
Paul Duffin | 74431d5 | 2021-04-21 14:10:42 +0100 | [diff] [blame] | 257 | b.generateHiddenAPIStubFlagsRules(ctx, hiddenAPISupportingModules) |
Paul Duffin | 00b2bfd | 2021-04-12 17:24:36 +0100 | [diff] [blame] | 258 | b.generateHiddenAPIIndexRules(ctx, hiddenAPISupportingModules) |
Paul Duffin | 85dee5d | 2021-04-13 00:14:38 +0100 | [diff] [blame] | 259 | b.generatedHiddenAPIMetadataRules(ctx, hiddenAPISupportingModules) |
Paul Duffin | 00b2bfd | 2021-04-12 17:24:36 +0100 | [diff] [blame] | 260 | } |
| 261 | |
Paul Duffin | 74431d5 | 2021-04-21 14:10:42 +0100 | [diff] [blame] | 262 | func (b *platformBootclasspathModule) generateHiddenAPIStubFlagsRules(ctx android.ModuleContext, modules []hiddenAPISupportingModule) { |
| 263 | bootDexJars := android.Paths{} |
| 264 | for _, module := range modules { |
| 265 | bootDexJars = append(bootDexJars, module.bootDexJar()) |
| 266 | } |
| 267 | |
| 268 | sdkKindToStubPaths := hiddenAPIGatherStubLibDexJarPaths(ctx) |
| 269 | |
| 270 | outputPath := hiddenAPISingletonPaths(ctx).stubFlags |
| 271 | rule := ruleToGenerateHiddenAPIStubFlagsFile(ctx, outputPath, bootDexJars, sdkKindToStubPaths) |
| 272 | rule.Build("platform-bootclasspath-monolithic-hiddenapi-stub-flags", "monolithic hidden API stub flags") |
| 273 | } |
| 274 | |
Paul Duffin | 00b2bfd | 2021-04-12 17:24:36 +0100 | [diff] [blame] | 275 | func (b *platformBootclasspathModule) generateHiddenAPIIndexRules(ctx android.ModuleContext, modules []hiddenAPISupportingModule) { |
| 276 | indexes := android.Paths{} |
| 277 | for _, module := range modules { |
| 278 | indexes = append(indexes, module.indexCSV()) |
| 279 | } |
| 280 | |
| 281 | rule := android.NewRuleBuilder(pctx, ctx) |
| 282 | rule.Command(). |
| 283 | BuiltTool("merge_csv"). |
| 284 | Flag("--key_field signature"). |
| 285 | FlagWithArg("--header=", "signature,file,startline,startcol,endline,endcol,properties"). |
| 286 | FlagWithOutput("--output=", hiddenAPISingletonPaths(ctx).index). |
| 287 | Inputs(indexes) |
| 288 | rule.Build("platform-bootclasspath-monolithic-hiddenapi-index", "monolithic hidden API index") |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 289 | } |
Paul Duffin | 85dee5d | 2021-04-13 00:14:38 +0100 | [diff] [blame] | 290 | |
| 291 | func (b *platformBootclasspathModule) generatedHiddenAPIMetadataRules(ctx android.ModuleContext, modules []hiddenAPISupportingModule) { |
| 292 | metadataCSVFiles := android.Paths{} |
| 293 | for _, module := range modules { |
| 294 | metadataCSVFiles = append(metadataCSVFiles, module.metadataCSV()) |
| 295 | } |
| 296 | |
| 297 | rule := android.NewRuleBuilder(pctx, ctx) |
| 298 | |
| 299 | outputPath := hiddenAPISingletonPaths(ctx).metadata |
| 300 | |
| 301 | rule.Command(). |
| 302 | BuiltTool("merge_csv"). |
| 303 | Flag("--key_field signature"). |
| 304 | FlagWithOutput("--output=", outputPath). |
| 305 | Inputs(metadataCSVFiles) |
| 306 | |
| 307 | rule.Build("platform-bootclasspath-monolithic-hiddenapi-metadata", "monolithic hidden API metadata") |
| 308 | } |
Paul Duffin | ad19d38 | 2021-04-26 16:44:00 +0100 | [diff] [blame] | 309 | |
| 310 | // generateBootImageBuildActions generates ninja rules related to the boot image creation. |
Paul Duffin | 4c09442 | 2021-04-26 20:10:48 +0100 | [diff] [blame] | 311 | func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android.ModuleContext, updatableModules []android.Module) { |
Paul Duffin | ad19d38 | 2021-04-26 16:44:00 +0100 | [diff] [blame] | 312 | // Force the GlobalSoongConfig to be created and cached for use by the dex_bootjars |
| 313 | // GenerateSingletonBuildActions method as it cannot create it for itself. |
| 314 | dexpreopt.GetGlobalSoongConfig(ctx) |
| 315 | |
| 316 | imageConfig := b.getImageConfig(ctx) |
| 317 | if imageConfig == nil { |
| 318 | return |
| 319 | } |
| 320 | |
| 321 | global := dexpreopt.GetGlobalConfig(ctx) |
| 322 | if !shouldBuildBootImages(ctx.Config(), global) { |
| 323 | return |
| 324 | } |
| 325 | |
| 326 | // Generate the framework profile rule |
| 327 | bootFrameworkProfileRule(ctx, imageConfig) |
Paul Duffin | 4c09442 | 2021-04-26 20:10:48 +0100 | [diff] [blame] | 328 | |
| 329 | // Generate the updatable bootclasspath packages rule. |
| 330 | generateUpdatableBcpPackagesRule(ctx, imageConfig, updatableModules) |
Paul Duffin | f7a5592 | 2021-04-26 23:09:15 +0100 | [diff] [blame^] | 331 | |
| 332 | dumpOatRules(ctx, imageConfig) |
Paul Duffin | ad19d38 | 2021-04-26 16:44:00 +0100 | [diff] [blame] | 333 | } |