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" |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 22 | "github.com/google/blueprint" |
Paul Duffin | 62d8c3b | 2021-04-07 20:35:11 +0100 | [diff] [blame] | 23 | "github.com/google/blueprint/proptools" |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 24 | ) |
| 25 | |
| 26 | func init() { |
| 27 | registerPlatformBootclasspathBuildComponents(android.InitRegistrationContext) |
| 28 | } |
| 29 | |
| 30 | func registerPlatformBootclasspathBuildComponents(ctx android.RegistrationContext) { |
| 31 | ctx.RegisterModuleType("platform_bootclasspath", platformBootclasspathFactory) |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 32 | |
| 33 | ctx.FinalDepsMutators(func(ctx android.RegisterMutatorsContext) { |
| 34 | ctx.BottomUp("platform_bootclasspath_deps", platformBootclasspathDepsMutator) |
| 35 | }) |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 36 | } |
| 37 | |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 38 | type platformBootclasspathDependencyTag struct { |
| 39 | blueprint.BaseDependencyTag |
| 40 | |
| 41 | name string |
| 42 | } |
| 43 | |
| 44 | // Avoid having to make platform bootclasspath content visible to the platform bootclasspath. |
| 45 | // |
| 46 | // This is a temporary workaround to make it easier to migrate to platform bootclasspath with proper |
| 47 | // dependencies. |
| 48 | // TODO(b/177892522): Remove this and add needed visibility. |
| 49 | func (t platformBootclasspathDependencyTag) ExcludeFromVisibilityEnforcement() { |
| 50 | } |
| 51 | |
| 52 | // The tag used for the dependency between the platform bootclasspath and any configured boot jars. |
| 53 | var platformBootclasspathModuleDepTag = platformBootclasspathDependencyTag{name: "module"} |
| 54 | |
Paul Duffin | 62d8c3b | 2021-04-07 20:35:11 +0100 | [diff] [blame] | 55 | // The tag used for the dependency between the platform bootclasspath and bootclasspath_fragments. |
| 56 | var platformBootclasspathFragmentDepTag = platformBootclasspathDependencyTag{name: "fragment"} |
| 57 | |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 58 | var _ android.ExcludeFromVisibilityEnforcementTag = platformBootclasspathDependencyTag{} |
| 59 | |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 60 | type platformBootclasspathModule struct { |
| 61 | android.ModuleBase |
Artur Satayev | 97259dc | 2021-04-07 15:17:14 +0100 | [diff] [blame] | 62 | ClasspathFragmentBase |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 63 | |
Paul Duffin | 62d8c3b | 2021-04-07 20:35:11 +0100 | [diff] [blame] | 64 | properties platformBootclasspathProperties |
| 65 | |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 66 | // The apex:module pairs obtained from the configured modules. |
| 67 | // |
| 68 | // Currently only for testing. |
| 69 | configuredModules []android.Module |
Paul Duffin | 62d8c3b | 2021-04-07 20:35:11 +0100 | [diff] [blame] | 70 | |
| 71 | // The apex:module pairs obtained from the fragments. |
| 72 | // |
| 73 | // Currently only for testing. |
| 74 | fragments []android.Module |
Paul Duffin | 6a76645 | 2021-04-12 14:15:22 +0100 | [diff] [blame] | 75 | |
| 76 | // Path to the monolithic hiddenapi-flags.csv file. |
Paul Duffin | 0b65986 | 2021-04-13 13:02:29 +0100 | [diff] [blame] | 77 | hiddenAPIFlagsCSV android.OutputPath |
Paul Duffin | 6a76645 | 2021-04-12 14:15:22 +0100 | [diff] [blame] | 78 | |
| 79 | // Path to the monolithic hiddenapi-index.csv file. |
Paul Duffin | 0b65986 | 2021-04-13 13:02:29 +0100 | [diff] [blame] | 80 | hiddenAPIIndexCSV android.OutputPath |
Paul Duffin | 6a76645 | 2021-04-12 14:15:22 +0100 | [diff] [blame] | 81 | |
| 82 | // Path to the monolithic hiddenapi-unsupported.csv file. |
Paul Duffin | 0b65986 | 2021-04-13 13:02:29 +0100 | [diff] [blame] | 83 | hiddenAPIMetadataCSV android.OutputPath |
Paul Duffin | 62d8c3b | 2021-04-07 20:35:11 +0100 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | // ApexVariantReference specifies a particular apex variant of a module. |
| 87 | type ApexVariantReference struct { |
| 88 | // The name of the module apex variant, i.e. the apex containing the module variant. |
| 89 | // |
| 90 | // If this is not specified then it defaults to "platform" which will cause a dependency to be |
| 91 | // added to the module's platform variant. |
| 92 | Apex *string |
| 93 | |
| 94 | // The name of the module. |
| 95 | Module *string |
| 96 | } |
| 97 | |
| 98 | type platformBootclasspathProperties struct { |
Paul Duffin | 62d8c3b | 2021-04-07 20:35:11 +0100 | [diff] [blame] | 99 | // The names of the bootclasspath_fragment modules that form part of this |
| 100 | // platform_bootclasspath. |
| 101 | Fragments []ApexVariantReference |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 102 | |
Paul Duffin | 4616977 | 2021-04-14 15:01:56 +0100 | [diff] [blame] | 103 | Hidden_api HiddenAPIFlagFileProperties |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | func platformBootclasspathFactory() android.Module { |
| 107 | m := &platformBootclasspathModule{} |
Paul Duffin | 62d8c3b | 2021-04-07 20:35:11 +0100 | [diff] [blame] | 108 | m.AddProperties(&m.properties) |
Artur Satayev | 97259dc | 2021-04-07 15:17:14 +0100 | [diff] [blame] | 109 | // TODO(satayev): split systemserver and apex jars into separate configs. |
| 110 | initClasspathFragment(m) |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 111 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 112 | return m |
| 113 | } |
| 114 | |
Paul Duffin | 6a76645 | 2021-04-12 14:15:22 +0100 | [diff] [blame] | 115 | var _ android.OutputFileProducer = (*platformBootclasspathModule)(nil) |
| 116 | |
Artur Satayev | 97259dc | 2021-04-07 15:17:14 +0100 | [diff] [blame] | 117 | func (b *platformBootclasspathModule) AndroidMkEntries() (entries []android.AndroidMkEntries) { |
| 118 | entries = append(entries, android.AndroidMkEntries{ |
| 119 | Class: "FAKE", |
| 120 | // Need at least one output file in order for this to take effect. |
| 121 | OutputFile: android.OptionalPathForPath(b.hiddenAPIFlagsCSV), |
| 122 | Include: "$(BUILD_PHONY_PACKAGE)", |
| 123 | }) |
| 124 | entries = append(entries, b.classpathFragmentBase().getAndroidMkEntries()...) |
| 125 | return |
Paul Duffin | 6a76645 | 2021-04-12 14:15:22 +0100 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | // Make the hidden API files available from the platform-bootclasspath module. |
| 129 | func (b *platformBootclasspathModule) OutputFiles(tag string) (android.Paths, error) { |
| 130 | switch tag { |
| 131 | case "hiddenapi-flags.csv": |
| 132 | return android.Paths{b.hiddenAPIFlagsCSV}, nil |
| 133 | case "hiddenapi-index.csv": |
| 134 | return android.Paths{b.hiddenAPIIndexCSV}, nil |
| 135 | case "hiddenapi-metadata.csv": |
| 136 | return android.Paths{b.hiddenAPIMetadataCSV}, nil |
| 137 | } |
| 138 | |
| 139 | return nil, fmt.Errorf("unknown tag %s", tag) |
| 140 | } |
| 141 | |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 142 | func (b *platformBootclasspathModule) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 143 | if SkipDexpreoptBootJars(ctx) { |
| 144 | return |
| 145 | } |
| 146 | |
| 147 | // Add a dependency onto the dex2oat tool which is needed for creating the boot image. The |
| 148 | // path is retrieved from the dependency by GetGlobalSoongConfig(ctx). |
| 149 | dexpreopt.RegisterToolDeps(ctx) |
| 150 | } |
| 151 | |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 152 | func platformBootclasspathDepsMutator(ctx android.BottomUpMutatorContext) { |
| 153 | m := ctx.Module() |
| 154 | if p, ok := m.(*platformBootclasspathModule); ok { |
| 155 | // Add dependencies on all the modules configured in the "art" boot image. |
| 156 | artImageConfig := genBootImageConfigs(ctx)[artBootImageName] |
| 157 | addDependenciesOntoBootImageModules(ctx, artImageConfig.modules) |
| 158 | |
| 159 | // Add dependencies on all the modules configured in the "boot" boot image. That does not |
| 160 | // include modules configured in the "art" boot image. |
| 161 | bootImageConfig := p.getImageConfig(ctx) |
| 162 | addDependenciesOntoBootImageModules(ctx, bootImageConfig.modules) |
| 163 | |
| 164 | // Add dependencies on all the updatable modules. |
| 165 | updatableModules := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars |
| 166 | addDependenciesOntoBootImageModules(ctx, updatableModules) |
Paul Duffin | 62d8c3b | 2021-04-07 20:35:11 +0100 | [diff] [blame] | 167 | |
| 168 | // Add dependencies on all the fragments. |
| 169 | addDependencyOntoApexVariants(ctx, "fragments", p.properties.Fragments, platformBootclasspathFragmentDepTag) |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | func addDependencyOntoApexVariants(ctx android.BottomUpMutatorContext, propertyName string, refs []ApexVariantReference, tag blueprint.DependencyTag) { |
| 174 | for i, ref := range refs { |
| 175 | apex := proptools.StringDefault(ref.Apex, "platform") |
| 176 | |
| 177 | if ref.Module == nil { |
| 178 | ctx.PropertyErrorf(propertyName, "missing module name at position %d", i) |
| 179 | continue |
| 180 | } |
| 181 | name := proptools.String(ref.Module) |
| 182 | |
| 183 | addDependencyOntoApexModulePair(ctx, apex, name, tag) |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 184 | } |
| 185 | } |
| 186 | |
| 187 | func addDependencyOntoApexModulePair(ctx android.BottomUpMutatorContext, apex string, name string, tag blueprint.DependencyTag) { |
| 188 | var variations []blueprint.Variation |
| 189 | if apex != "platform" { |
| 190 | // Pick the correct apex variant. |
| 191 | variations = []blueprint.Variation{ |
| 192 | {Mutator: "apex", Variation: apex}, |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | addedDep := false |
| 197 | if ctx.OtherModuleDependencyVariantExists(variations, name) { |
| 198 | ctx.AddFarVariationDependencies(variations, tag, name) |
| 199 | addedDep = true |
| 200 | } |
| 201 | |
| 202 | // Add a dependency on the prebuilt module if it exists. |
| 203 | prebuiltName := android.PrebuiltNameFromSource(name) |
| 204 | if ctx.OtherModuleDependencyVariantExists(variations, prebuiltName) { |
| 205 | ctx.AddVariationDependencies(variations, tag, prebuiltName) |
| 206 | addedDep = true |
| 207 | } |
| 208 | |
| 209 | // If no appropriate variant existing for this, so no dependency could be added, then it is an |
| 210 | // error, unless missing dependencies are allowed. The simplest way to handle that is to add a |
| 211 | // dependency that will not be satisfied and the default behavior will handle it. |
| 212 | if !addedDep { |
Paul Duffin | 8f146b9 | 2021-04-12 17:24:18 +0100 | [diff] [blame] | 213 | // Add dependency on the unprefixed (i.e. source or renamed prebuilt) module which we know does |
| 214 | // not exist. The resulting error message will contain useful information about the available |
| 215 | // variants. |
| 216 | reportMissingVariationDependency(ctx, variations, name) |
| 217 | |
| 218 | // Add dependency on the missing prefixed prebuilt variant too if a module with that name exists |
| 219 | // so that information about its available variants will be reported too. |
| 220 | if ctx.OtherModuleExists(prebuiltName) { |
| 221 | reportMissingVariationDependency(ctx, variations, prebuiltName) |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | // reportMissingVariationDependency intentionally adds a dependency on a missing variation in order |
| 227 | // to generate an appropriate error message with information about the available variations. |
| 228 | func reportMissingVariationDependency(ctx android.BottomUpMutatorContext, variations []blueprint.Variation, name string) { |
| 229 | modules := ctx.AddFarVariationDependencies(variations, nil, name) |
| 230 | if len(modules) != 1 { |
| 231 | panic(fmt.Errorf("Internal Error: expected one module, found %d", len(modules))) |
| 232 | return |
| 233 | } |
| 234 | if modules[0] != nil { |
| 235 | panic(fmt.Errorf("Internal Error: expected module to be missing but was found: %q", modules[0])) |
| 236 | return |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 237 | } |
| 238 | } |
| 239 | |
| 240 | func addDependenciesOntoBootImageModules(ctx android.BottomUpMutatorContext, modules android.ConfiguredJarList) { |
| 241 | for i := 0; i < modules.Len(); i++ { |
| 242 | apex := modules.Apex(i) |
| 243 | name := modules.Jar(i) |
| 244 | |
| 245 | addDependencyOntoApexModulePair(ctx, apex, name, platformBootclasspathModuleDepTag) |
| 246 | } |
| 247 | } |
| 248 | |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 249 | func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Artur Satayev | 97259dc | 2021-04-07 15:17:14 +0100 | [diff] [blame] | 250 | b.classpathFragmentBase().generateAndroidBuildActions(ctx) |
| 251 | |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 252 | ctx.VisitDirectDepsIf(isActiveModule, func(module android.Module) { |
| 253 | tag := ctx.OtherModuleDependencyTag(module) |
| 254 | if tag == platformBootclasspathModuleDepTag { |
| 255 | b.configuredModules = append(b.configuredModules, module) |
Paul Duffin | 62d8c3b | 2021-04-07 20:35:11 +0100 | [diff] [blame] | 256 | } else if tag == platformBootclasspathFragmentDepTag { |
| 257 | b.fragments = append(b.fragments, module) |
Paul Duffin | b432df9 | 2021-03-22 22:09:42 +0000 | [diff] [blame] | 258 | } |
| 259 | }) |
| 260 | |
Paul Duffin | 9b381ef | 2021-04-08 23:01:37 +0100 | [diff] [blame] | 261 | b.generateHiddenAPIBuildActions(ctx, b.configuredModules, b.fragments) |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 262 | |
Paul Duffin | bb7f1ac | 2021-03-29 22:18:45 +0100 | [diff] [blame] | 263 | // Nothing to do if skipping the dexpreopt of boot image jars. |
| 264 | if SkipDexpreoptBootJars(ctx) { |
| 265 | return |
| 266 | } |
| 267 | |
| 268 | // Force the GlobalSoongConfig to be created and cached for use by the dex_bootjars |
| 269 | // GenerateSingletonBuildActions method as it cannot create it for itself. |
| 270 | dexpreopt.GetGlobalSoongConfig(ctx) |
| 271 | |
| 272 | imageConfig := b.getImageConfig(ctx) |
| 273 | if imageConfig == nil { |
| 274 | return |
| 275 | } |
| 276 | |
| 277 | // Construct the boot image info from the config. |
| 278 | info := BootImageInfo{imageConfig: imageConfig} |
| 279 | |
| 280 | // Make it available for other modules. |
| 281 | ctx.SetProvider(BootImageInfoProvider, info) |
| 282 | } |
| 283 | |
| 284 | func (b *platformBootclasspathModule) getImageConfig(ctx android.EarlyModuleContext) *bootImageConfig { |
| 285 | return defaultBootImageConfig(ctx) |
| 286 | } |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 287 | |
| 288 | // generateHiddenAPIBuildActions generates all the hidden API related build rules. |
Paul Duffin | 9b381ef | 2021-04-08 23:01:37 +0100 | [diff] [blame] | 289 | 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] | 290 | |
Paul Duffin | 90b8ad3 | 2021-04-13 12:25:01 +0100 | [diff] [blame] | 291 | // Save the paths to the monolithic files for retrieval via OutputFiles(). |
| 292 | b.hiddenAPIFlagsCSV = hiddenAPISingletonPaths(ctx).flags |
| 293 | b.hiddenAPIIndexCSV = hiddenAPISingletonPaths(ctx).index |
| 294 | b.hiddenAPIMetadataCSV = hiddenAPISingletonPaths(ctx).metadata |
Paul Duffin | 6a76645 | 2021-04-12 14:15:22 +0100 | [diff] [blame] | 295 | |
Paul Duffin | 0b65986 | 2021-04-13 13:02:29 +0100 | [diff] [blame] | 296 | // Don't run any hiddenapi rules if UNSAFE_DISABLE_HIDDENAPI_FLAGS=true. This is a performance |
| 297 | // optimization that can be used to reduce the incremental build time but as its name suggests it |
| 298 | // can be unsafe to use, e.g. when the changes affect anything that goes on the bootclasspath. |
| 299 | if ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") { |
| 300 | paths := android.OutputPaths{b.hiddenAPIFlagsCSV, b.hiddenAPIIndexCSV, b.hiddenAPIMetadataCSV} |
| 301 | for _, path := range paths { |
| 302 | ctx.Build(pctx, android.BuildParams{ |
| 303 | Rule: android.Touch, |
| 304 | Output: path, |
| 305 | }) |
| 306 | } |
| 307 | return |
| 308 | } |
| 309 | |
Paul Duffin | 1ba2467 | 2021-04-12 23:26:14 +0100 | [diff] [blame] | 310 | hiddenAPISupportingModules := []hiddenAPISupportingModule{} |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 311 | for _, module := range modules { |
Paul Duffin | 1ba2467 | 2021-04-12 23:26:14 +0100 | [diff] [blame] | 312 | if h, ok := module.(hiddenAPISupportingModule); ok { |
| 313 | if h.bootDexJar() == nil { |
| 314 | ctx.ModuleErrorf("module %s does not provide a bootDexJar file", module) |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 315 | } |
Paul Duffin | 1ba2467 | 2021-04-12 23:26:14 +0100 | [diff] [blame] | 316 | if h.flagsCSV() == nil { |
| 317 | ctx.ModuleErrorf("module %s does not provide a flagsCSV file", module) |
| 318 | } |
| 319 | if h.indexCSV() == nil { |
| 320 | ctx.ModuleErrorf("module %s does not provide an indexCSV file", module) |
| 321 | } |
| 322 | if h.metadataCSV() == nil { |
| 323 | ctx.ModuleErrorf("module %s does not provide a metadataCSV file", module) |
| 324 | } |
| 325 | |
| 326 | if ctx.Failed() { |
| 327 | continue |
| 328 | } |
| 329 | |
| 330 | hiddenAPISupportingModules = append(hiddenAPISupportingModules, h) |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 331 | } else { |
Paul Duffin | 1ba2467 | 2021-04-12 23:26:14 +0100 | [diff] [blame] | 332 | 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] | 333 | } |
| 334 | } |
| 335 | |
Paul Duffin | 1ba2467 | 2021-04-12 23:26:14 +0100 | [diff] [blame] | 336 | moduleSpecificFlagsPaths := android.Paths{} |
| 337 | for _, module := range hiddenAPISupportingModules { |
| 338 | moduleSpecificFlagsPaths = append(moduleSpecificFlagsPaths, module.flagsCSV()) |
| 339 | } |
| 340 | |
Paul Duffin | 9b381ef | 2021-04-08 23:01:37 +0100 | [diff] [blame] | 341 | flagFileInfo := b.properties.Hidden_api.hiddenAPIFlagFileInfo(ctx) |
| 342 | for _, fragment := range fragments { |
| 343 | if ctx.OtherModuleHasProvider(fragment, hiddenAPIFlagFileInfoProvider) { |
| 344 | info := ctx.OtherModuleProvider(fragment, hiddenAPIFlagFileInfoProvider).(hiddenAPIFlagFileInfo) |
| 345 | flagFileInfo.append(info) |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | // Store the information for testing. |
| 350 | ctx.SetProvider(hiddenAPIFlagFileInfoProvider, flagFileInfo) |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 351 | |
| 352 | outputPath := hiddenAPISingletonPaths(ctx).flags |
| 353 | baseFlagsPath := hiddenAPISingletonPaths(ctx).stubFlags |
Paul Duffin | 9b381ef | 2021-04-08 23:01:37 +0100 | [diff] [blame] | 354 | ruleToGenerateHiddenApiFlags(ctx, outputPath, baseFlagsPath, moduleSpecificFlagsPaths, flagFileInfo) |
Paul Duffin | 00b2bfd | 2021-04-12 17:24:36 +0100 | [diff] [blame] | 355 | |
| 356 | b.generateHiddenAPIIndexRules(ctx, hiddenAPISupportingModules) |
Paul Duffin | 85dee5d | 2021-04-13 00:14:38 +0100 | [diff] [blame] | 357 | b.generatedHiddenAPIMetadataRules(ctx, hiddenAPISupportingModules) |
Paul Duffin | 00b2bfd | 2021-04-12 17:24:36 +0100 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | func (b *platformBootclasspathModule) generateHiddenAPIIndexRules(ctx android.ModuleContext, modules []hiddenAPISupportingModule) { |
| 361 | indexes := android.Paths{} |
| 362 | for _, module := range modules { |
| 363 | indexes = append(indexes, module.indexCSV()) |
| 364 | } |
| 365 | |
| 366 | rule := android.NewRuleBuilder(pctx, ctx) |
| 367 | rule.Command(). |
| 368 | BuiltTool("merge_csv"). |
| 369 | Flag("--key_field signature"). |
| 370 | FlagWithArg("--header=", "signature,file,startline,startcol,endline,endcol,properties"). |
| 371 | FlagWithOutput("--output=", hiddenAPISingletonPaths(ctx).index). |
| 372 | Inputs(indexes) |
| 373 | rule.Build("platform-bootclasspath-monolithic-hiddenapi-index", "monolithic hidden API index") |
Paul Duffin | 702210b | 2021-04-08 20:12:41 +0100 | [diff] [blame] | 374 | } |
Paul Duffin | 85dee5d | 2021-04-13 00:14:38 +0100 | [diff] [blame] | 375 | |
| 376 | func (b *platformBootclasspathModule) generatedHiddenAPIMetadataRules(ctx android.ModuleContext, modules []hiddenAPISupportingModule) { |
| 377 | metadataCSVFiles := android.Paths{} |
| 378 | for _, module := range modules { |
| 379 | metadataCSVFiles = append(metadataCSVFiles, module.metadataCSV()) |
| 380 | } |
| 381 | |
| 382 | rule := android.NewRuleBuilder(pctx, ctx) |
| 383 | |
| 384 | outputPath := hiddenAPISingletonPaths(ctx).metadata |
| 385 | |
| 386 | rule.Command(). |
| 387 | BuiltTool("merge_csv"). |
| 388 | Flag("--key_field signature"). |
| 389 | FlagWithOutput("--output=", outputPath). |
| 390 | Inputs(metadataCSVFiles) |
| 391 | |
| 392 | rule.Build("platform-bootclasspath-monolithic-hiddenapi-metadata", "monolithic hidden API metadata") |
| 393 | } |