Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 1 | // Copyright (C) 2021 The Android Open Source Project |
| 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 | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 18 | "fmt" |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 19 | "path/filepath" |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 20 | "reflect" |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 21 | "strings" |
| 22 | |
| 23 | "android/soong/android" |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 24 | "android/soong/dexpreopt" |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 25 | "github.com/google/blueprint/proptools" |
Martin Stjernholm | b79c7f1 | 2021-03-17 00:26:25 +0000 | [diff] [blame] | 26 | |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 27 | "github.com/google/blueprint" |
| 28 | ) |
| 29 | |
| 30 | func init() { |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 31 | registerBootclasspathFragmentBuildComponents(android.InitRegistrationContext) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 32 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 33 | android.RegisterSdkMemberType(&bootclasspathFragmentMemberType{ |
Paul Duffin | 4b64ba0 | 2021-03-29 11:02:53 +0100 | [diff] [blame] | 34 | SdkMemberTypeBase: android.SdkMemberTypeBase{ |
Paul Duffin | 2d3da31 | 2021-05-06 12:02:27 +0100 | [diff] [blame] | 35 | PropertyName: "bootclasspath_fragments", |
| 36 | SupportsSdk: true, |
Paul Duffin | 4b64ba0 | 2021-03-29 11:02:53 +0100 | [diff] [blame] | 37 | }, |
| 38 | }) |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 39 | } |
| 40 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 41 | func registerBootclasspathFragmentBuildComponents(ctx android.RegistrationContext) { |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 42 | ctx.RegisterModuleType("bootclasspath_fragment", bootclasspathFragmentFactory) |
| 43 | ctx.RegisterModuleType("prebuilt_bootclasspath_fragment", prebuiltBootclasspathFragmentFactory) |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 44 | } |
| 45 | |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 46 | type bootclasspathFragmentContentDependencyTag struct { |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 47 | blueprint.BaseDependencyTag |
| 48 | } |
| 49 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 50 | // Avoid having to make bootclasspath_fragment content visible to the bootclasspath_fragment. |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 51 | // |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 52 | // This is a temporary workaround to make it easier to migrate to bootclasspath_fragment modules |
| 53 | // with proper dependencies. |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 54 | // TODO(b/177892522): Remove this and add needed visibility. |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 55 | func (b bootclasspathFragmentContentDependencyTag) ExcludeFromVisibilityEnforcement() { |
| 56 | } |
| 57 | |
| 58 | // The bootclasspath_fragment contents must never depend on prebuilts. |
| 59 | func (b bootclasspathFragmentContentDependencyTag) ReplaceSourceWithPrebuilt() bool { |
| 60 | return false |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 61 | } |
| 62 | |
Paul Duffin | e95b53a | 2021-04-23 20:41:23 +0100 | [diff] [blame] | 63 | // SdkMemberType causes dependencies added with this tag to be automatically added to the sdk as if |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 64 | // they were specified using java_boot_libs or java_sdk_libs. |
| 65 | func (b bootclasspathFragmentContentDependencyTag) SdkMemberType(child android.Module) android.SdkMemberType { |
| 66 | // If the module is a java_sdk_library then treat it as if it was specified in the java_sdk_libs |
| 67 | // property, otherwise treat if it was specified in the java_boot_libs property. |
| 68 | if javaSdkLibrarySdkMemberType.IsInstance(child) { |
| 69 | return javaSdkLibrarySdkMemberType |
| 70 | } |
| 71 | |
Paul Duffin | e95b53a | 2021-04-23 20:41:23 +0100 | [diff] [blame] | 72 | return javaBootLibsSdkMemberType |
| 73 | } |
| 74 | |
| 75 | func (b bootclasspathFragmentContentDependencyTag) ExportMember() bool { |
| 76 | return true |
| 77 | } |
| 78 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 79 | // The tag used for the dependency between the bootclasspath_fragment module and its contents. |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 80 | var bootclasspathFragmentContentDepTag = bootclasspathFragmentContentDependencyTag{} |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 81 | |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 82 | var _ android.ExcludeFromVisibilityEnforcementTag = bootclasspathFragmentContentDepTag |
| 83 | var _ android.ReplaceSourceWithPrebuilt = bootclasspathFragmentContentDepTag |
Paul Duffin | e95b53a | 2021-04-23 20:41:23 +0100 | [diff] [blame] | 84 | var _ android.SdkMemberTypeDependencyTag = bootclasspathFragmentContentDepTag |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 85 | |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 86 | func IsBootclasspathFragmentContentDepTag(tag blueprint.DependencyTag) bool { |
| 87 | return tag == bootclasspathFragmentContentDepTag |
Paul Duffin | 4d101b6 | 2021-03-24 15:42:20 +0000 | [diff] [blame] | 88 | } |
| 89 | |
Paul Duffin | c7d1644 | 2021-04-23 13:55:49 +0100 | [diff] [blame] | 90 | // Properties that can be different when coverage is enabled. |
| 91 | type BootclasspathFragmentCoverageAffectedProperties struct { |
| 92 | // The contents of this bootclasspath_fragment, could be either java_library, or java_sdk_library. |
| 93 | // |
Paul Duffin | 34827d4 | 2021-05-13 21:25:05 +0100 | [diff] [blame] | 94 | // A java_sdk_library specified here will also be treated as if it was specified on the stub_libs |
| 95 | // property. |
| 96 | // |
Paul Duffin | c7d1644 | 2021-04-23 13:55:49 +0100 | [diff] [blame] | 97 | // The order of this list matters as it is the order that is used in the bootclasspath. |
| 98 | Contents []string |
Paul Duffin | 1093158 | 2021-04-25 10:13:54 +0100 | [diff] [blame] | 99 | |
| 100 | // The properties for specifying the API stubs provided by this fragment. |
| 101 | BootclasspathAPIProperties |
Paul Duffin | c7d1644 | 2021-04-23 13:55:49 +0100 | [diff] [blame] | 102 | } |
| 103 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 104 | type bootclasspathFragmentProperties struct { |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 105 | // The name of the image this represents. |
| 106 | // |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 107 | // If specified then it must be one of "art" or "boot". |
Paul Duffin | 64be7bb | 2021-03-23 23:06:38 +0000 | [diff] [blame] | 108 | Image_name *string |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 109 | |
Paul Duffin | c7d1644 | 2021-04-23 13:55:49 +0100 | [diff] [blame] | 110 | // Properties whose values need to differ with and without coverage. |
| 111 | BootclasspathFragmentCoverageAffectedProperties |
| 112 | Coverage BootclasspathFragmentCoverageAffectedProperties |
Paul Duffin | 9b381ef | 2021-04-08 23:01:37 +0100 | [diff] [blame] | 113 | |
| 114 | Hidden_api HiddenAPIFlagFileProperties |
Paul Duffin | 70cfdff | 2021-05-15 09:10:42 +0100 | [diff] [blame] | 115 | |
| 116 | // Properties that allow a fragment to depend on other fragments. This is needed for hidden API |
| 117 | // processing as it needs access to all the classes used by a fragment including those provided |
| 118 | // by other fragments. |
| 119 | BootclasspathFragmentsDepsProperties |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 120 | } |
| 121 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 122 | type BootclasspathFragmentModule struct { |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 123 | android.ModuleBase |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 124 | android.ApexModuleBase |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 125 | android.SdkBase |
satayev | 3db3547 | 2021-05-06 23:59:58 +0100 | [diff] [blame] | 126 | ClasspathFragmentBase |
| 127 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 128 | properties bootclasspathFragmentProperties |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 129 | } |
| 130 | |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 131 | // commonBootclasspathFragment defines the methods that are implemented by both source and prebuilt |
| 132 | // bootclasspath fragment modules. |
| 133 | type commonBootclasspathFragment interface { |
| 134 | // produceHiddenAPIAllFlagsFile produces the all-flags.csv and intermediate files. |
| 135 | // |
Paul Duffin | 1352f7c | 2021-05-21 22:18:49 +0100 | [diff] [blame] | 136 | // Updates the supplied hiddenAPIInfo with the paths to the generated files set. |
| 137 | produceHiddenAPIAllFlagsFile(ctx android.ModuleContext, contents []hiddenAPIModule, input HiddenAPIFlagInput) *HiddenAPIFlagOutput |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 138 | } |
| 139 | |
Paul Duffin | 1e6f5c4 | 2021-05-21 16:15:31 +0100 | [diff] [blame] | 140 | var _ commonBootclasspathFragment = (*BootclasspathFragmentModule)(nil) |
| 141 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 142 | func bootclasspathFragmentFactory() android.Module { |
| 143 | m := &BootclasspathFragmentModule{} |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 144 | m.AddProperties(&m.properties) |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 145 | android.InitApexModule(m) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 146 | android.InitSdkAwareModule(m) |
satayev | 3db3547 | 2021-05-06 23:59:58 +0100 | [diff] [blame] | 147 | initClasspathFragment(m, BOOTCLASSPATH) |
Martin Stjernholm | b79c7f1 | 2021-03-17 00:26:25 +0000 | [diff] [blame] | 148 | android.InitAndroidArchModule(m, android.HostAndDeviceSupported, android.MultilibCommon) |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 149 | |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 150 | android.AddLoadHook(m, func(ctx android.LoadHookContext) { |
Paul Duffin | c7d1644 | 2021-04-23 13:55:49 +0100 | [diff] [blame] | 151 | // If code coverage has been enabled for the framework then append the properties with |
| 152 | // coverage specific properties. |
| 153 | if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") { |
| 154 | err := proptools.AppendProperties(&m.properties.BootclasspathFragmentCoverageAffectedProperties, &m.properties.Coverage, nil) |
| 155 | if err != nil { |
| 156 | ctx.PropertyErrorf("coverage", "error trying to append coverage specific properties: %s", err) |
| 157 | return |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | // Initialize the contents property from the image_name. |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 162 | bootclasspathFragmentInitContentsFromImage(ctx, m) |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 163 | }) |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 164 | return m |
| 165 | } |
| 166 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 167 | // bootclasspathFragmentInitContentsFromImage will initialize the contents property from the image_name if |
| 168 | // necessary. |
| 169 | func bootclasspathFragmentInitContentsFromImage(ctx android.EarlyModuleContext, m *BootclasspathFragmentModule) { |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 170 | contents := m.properties.Contents |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 171 | if len(contents) == 0 { |
| 172 | ctx.PropertyErrorf("contents", "required property is missing") |
| 173 | return |
| 174 | } |
| 175 | |
| 176 | if m.properties.Image_name == nil { |
| 177 | // Nothing to do. |
| 178 | return |
Paul Duffin | 82886d6 | 2021-03-24 01:34:57 +0000 | [diff] [blame] | 179 | } |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 180 | |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 181 | imageName := proptools.String(m.properties.Image_name) |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 182 | if imageName != "art" { |
| 183 | ctx.PropertyErrorf("image_name", `unknown image name %q, expected "art"`, imageName) |
| 184 | return |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 185 | } |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 186 | |
| 187 | // TODO(b/177892522): Prebuilts (versioned or not) should not use the image_name property. |
| 188 | if android.IsModuleInVersionedSdk(m) { |
| 189 | // The module is a versioned prebuilt so ignore it. This is done for a couple of reasons: |
| 190 | // 1. There is no way to use this at the moment so ignoring it is safe. |
| 191 | // 2. Attempting to initialize the contents property from the configuration will end up having |
| 192 | // the versioned prebuilt depending on the unversioned prebuilt. That will cause problems |
| 193 | // as the unversioned prebuilt could end up with an APEX variant created for the source |
| 194 | // APEX which will prevent it from having an APEX variant for the prebuilt APEX which in |
| 195 | // turn will prevent it from accessing the dex implementation jar from that which will |
| 196 | // break hidden API processing, amongst others. |
| 197 | return |
| 198 | } |
| 199 | |
| 200 | // Get the configuration for the art apex jars. Do not use getImageConfig(ctx) here as this is |
| 201 | // too early in the Soong processing for that to work. |
| 202 | global := dexpreopt.GetGlobalConfig(ctx) |
| 203 | modules := global.ArtApexJars |
| 204 | |
| 205 | // Make sure that the apex specified in the configuration is consistent and is one for which |
| 206 | // this boot image is available. |
| 207 | commonApex := "" |
| 208 | for i := 0; i < modules.Len(); i++ { |
| 209 | apex := modules.Apex(i) |
| 210 | jar := modules.Jar(i) |
| 211 | if apex == "platform" { |
| 212 | ctx.ModuleErrorf("ArtApexJars is invalid as it requests a platform variant of %q", jar) |
| 213 | continue |
| 214 | } |
| 215 | if !m.AvailableFor(apex) { |
| 216 | ctx.ModuleErrorf("ArtApexJars configuration incompatible with this module, ArtApexJars expects this to be in apex %q but this is only in apexes %q", |
| 217 | apex, m.ApexAvailable()) |
| 218 | continue |
| 219 | } |
| 220 | if commonApex == "" { |
| 221 | commonApex = apex |
| 222 | } else if commonApex != apex { |
| 223 | ctx.ModuleErrorf("ArtApexJars configuration is inconsistent, expected all jars to be in the same apex but it specifies apex %q and %q", |
| 224 | commonApex, apex) |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | if len(contents) != 0 { |
| 229 | // Nothing to do. |
| 230 | return |
| 231 | } |
| 232 | |
| 233 | // Store the jars in the Contents property so that they can be used to add dependencies. |
| 234 | m.properties.Contents = modules.CopyOfJars() |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | // bootclasspathImageNameContentsConsistencyCheck checks that the configuration that applies to this |
| 238 | // module (if any) matches the contents. |
| 239 | // |
| 240 | // This should be a noop as if image_name="art" then the contents will be set from the ArtApexJars |
| 241 | // config by bootclasspathFragmentInitContentsFromImage so it will be guaranteed to match. However, |
| 242 | // in future this will not be the case. |
| 243 | func (b *BootclasspathFragmentModule) bootclasspathImageNameContentsConsistencyCheck(ctx android.BaseModuleContext) { |
| 244 | imageName := proptools.String(b.properties.Image_name) |
| 245 | if imageName == "art" { |
| 246 | // TODO(b/177892522): Prebuilts (versioned or not) should not use the image_name property. |
Paul Duffin | 0c2e083 | 2021-04-28 00:39:52 +0100 | [diff] [blame] | 247 | if android.IsModuleInVersionedSdk(b) { |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 248 | // The module is a versioned prebuilt so ignore it. This is done for a couple of reasons: |
| 249 | // 1. There is no way to use this at the moment so ignoring it is safe. |
| 250 | // 2. Attempting to initialize the contents property from the configuration will end up having |
| 251 | // the versioned prebuilt depending on the unversioned prebuilt. That will cause problems |
| 252 | // as the unversioned prebuilt could end up with an APEX variant created for the source |
| 253 | // APEX which will prevent it from having an APEX variant for the prebuilt APEX which in |
| 254 | // turn will prevent it from accessing the dex implementation jar from that which will |
| 255 | // break hidden API processing, amongst others. |
| 256 | return |
| 257 | } |
| 258 | |
| 259 | // Get the configuration for the art apex jars. |
| 260 | modules := b.getImageConfig(ctx).modules |
| 261 | configuredJars := modules.CopyOfJars() |
| 262 | |
| 263 | // Skip the check if the configured jars list is empty as that is a common configuration when |
| 264 | // building targets that do not result in a system image. |
| 265 | if len(configuredJars) == 0 { |
| 266 | return |
| 267 | } |
| 268 | |
| 269 | contents := b.properties.Contents |
| 270 | if !reflect.DeepEqual(configuredJars, contents) { |
| 271 | ctx.ModuleErrorf("inconsistency in specification of contents. ArtApexJars configuration specifies %#v, contents property specifies %#v", |
| 272 | configuredJars, contents) |
| 273 | } |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 274 | } |
| 275 | } |
| 276 | |
Paul Duffin | e946b32 | 2021-04-25 23:04:00 +0100 | [diff] [blame] | 277 | var BootclasspathFragmentApexContentInfoProvider = blueprint.NewProvider(BootclasspathFragmentApexContentInfo{}) |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 278 | |
Paul Duffin | e946b32 | 2021-04-25 23:04:00 +0100 | [diff] [blame] | 279 | // BootclasspathFragmentApexContentInfo contains the bootclasspath_fragments contributions to the |
| 280 | // apex contents. |
| 281 | type BootclasspathFragmentApexContentInfo struct { |
Paul Duffin | 58e0e76 | 2021-05-21 19:27:58 +0100 | [diff] [blame] | 282 | // The configured modules, will be empty if this is from a bootclasspath_fragment that does not |
| 283 | // set image_name: "art". |
| 284 | modules android.ConfiguredJarList |
| 285 | |
| 286 | // Map from arch type to the boot image files. |
| 287 | bootImageFilesByArch map[android.ArchType]android.OutputPaths |
Paul Duffin | 1a8010a | 2021-05-15 12:39:23 +0100 | [diff] [blame] | 288 | |
| 289 | // Map from the name of the context module (as returned by Name()) to the hidden API encoded dex |
| 290 | // jar path. |
| 291 | contentModuleDexJarPaths map[string]android.Path |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 292 | } |
| 293 | |
Paul Duffin | e946b32 | 2021-04-25 23:04:00 +0100 | [diff] [blame] | 294 | func (i BootclasspathFragmentApexContentInfo) Modules() android.ConfiguredJarList { |
Paul Duffin | 58e0e76 | 2021-05-21 19:27:58 +0100 | [diff] [blame] | 295 | return i.modules |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 296 | } |
| 297 | |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 298 | // Get a map from ArchType to the associated boot image's contents for Android. |
| 299 | // |
| 300 | // Extension boot images only return their own files, not the files of the boot images they extend. |
Paul Duffin | e946b32 | 2021-04-25 23:04:00 +0100 | [diff] [blame] | 301 | func (i BootclasspathFragmentApexContentInfo) AndroidBootImageFilesByArchType() map[android.ArchType]android.OutputPaths { |
Paul Duffin | 58e0e76 | 2021-05-21 19:27:58 +0100 | [diff] [blame] | 302 | return i.bootImageFilesByArch |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 303 | } |
| 304 | |
Paul Duffin | 190fdef | 2021-04-26 10:33:59 +0100 | [diff] [blame] | 305 | // DexBootJarPathForContentModule returns the path to the dex boot jar for specified module. |
| 306 | // |
| 307 | // The dex boot jar is one which has had hidden API encoding performed on it. |
Paul Duffin | 1a8010a | 2021-05-15 12:39:23 +0100 | [diff] [blame] | 308 | func (i BootclasspathFragmentApexContentInfo) DexBootJarPathForContentModule(module android.Module) (android.Path, error) { |
| 309 | name := module.Name() |
| 310 | if dexJar, ok := i.contentModuleDexJarPaths[name]; ok { |
| 311 | return dexJar, nil |
| 312 | } else { |
| 313 | return nil, fmt.Errorf("unknown bootclasspath_fragment content module %s, expected one of %s", |
| 314 | name, strings.Join(android.SortedStringKeys(i.contentModuleDexJarPaths), ", ")) |
| 315 | } |
Paul Duffin | 190fdef | 2021-04-26 10:33:59 +0100 | [diff] [blame] | 316 | } |
| 317 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 318 | func (b *BootclasspathFragmentModule) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 319 | tag := ctx.OtherModuleDependencyTag(dep) |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 320 | if IsBootclasspathFragmentContentDepTag(tag) { |
Paul Duffin | 4d101b6 | 2021-03-24 15:42:20 +0000 | [diff] [blame] | 321 | // Boot image contents are automatically added to apex. |
| 322 | return true |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 323 | } |
Bob Badour | 07065cd | 2021-02-05 19:59:11 -0800 | [diff] [blame] | 324 | if android.IsMetaDependencyTag(tag) { |
| 325 | // Cross-cutting metadata dependencies are metadata. |
| 326 | return false |
| 327 | } |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 328 | panic(fmt.Errorf("boot_image module %q should not have a dependency on %q via tag %s", b, dep, android.PrettyPrintTag(tag))) |
| 329 | } |
| 330 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 331 | func (b *BootclasspathFragmentModule) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error { |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 332 | return nil |
| 333 | } |
| 334 | |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 335 | // ComponentDepsMutator adds dependencies onto modules before any prebuilt modules without a |
| 336 | // corresponding source module are renamed. This means that adding a dependency using a name without |
| 337 | // a prebuilt_ prefix will always resolve to a source module and when using a name with that prefix |
| 338 | // it will always resolve to a prebuilt module. |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 339 | func (b *BootclasspathFragmentModule) ComponentDepsMutator(ctx android.BottomUpMutatorContext) { |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 340 | module := ctx.Module() |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 341 | _, isSourceModule := module.(*BootclasspathFragmentModule) |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 342 | |
| 343 | for _, name := range b.properties.Contents { |
| 344 | // A bootclasspath_fragment must depend only on other source modules, while the |
| 345 | // prebuilt_bootclasspath_fragment must only depend on other prebuilt modules. |
Paul Duffin | a9dd6fa | 2021-04-22 17:25:57 +0100 | [diff] [blame] | 346 | // |
| 347 | // TODO(b/177892522) - avoid special handling of jacocoagent. |
| 348 | if !isSourceModule && name != "jacocoagent" { |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 349 | name = android.PrebuiltNameFromSource(name) |
| 350 | } |
| 351 | ctx.AddDependency(module, bootclasspathFragmentContentDepTag, name) |
| 352 | } |
| 353 | |
| 354 | } |
| 355 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 356 | func (b *BootclasspathFragmentModule) DepsMutator(ctx android.BottomUpMutatorContext) { |
Paul Duffin | 1093158 | 2021-04-25 10:13:54 +0100 | [diff] [blame] | 357 | // Add dependencies onto all the modules that provide the API stubs for classes on this |
| 358 | // bootclasspath fragment. |
| 359 | hiddenAPIAddStubLibDependencies(ctx, b.properties.sdkKindToStubLibs()) |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 360 | |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 361 | if SkipDexpreoptBootJars(ctx) { |
| 362 | return |
| 363 | } |
| 364 | |
| 365 | // Add a dependency onto the dex2oat tool which is needed for creating the boot image. The |
| 366 | // path is retrieved from the dependency by GetGlobalSoongConfig(ctx). |
| 367 | dexpreopt.RegisterToolDeps(ctx) |
| 368 | } |
| 369 | |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 370 | func (b *BootclasspathFragmentModule) BootclasspathDepsMutator(ctx android.BottomUpMutatorContext) { |
| 371 | // Add dependencies on all the fragments. |
| 372 | b.properties.BootclasspathFragmentsDepsProperties.addDependenciesOntoFragments(ctx) |
| 373 | } |
| 374 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 375 | func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Paul Duffin | ba6afd0 | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 376 | // Only perform a consistency check if this module is the active module. That will prevent an |
| 377 | // unused prebuilt that was created without instrumentation from breaking an instrumentation |
| 378 | // build. |
| 379 | if isActiveModule(ctx.Module()) { |
| 380 | b.bootclasspathImageNameContentsConsistencyCheck(ctx) |
| 381 | } |
| 382 | |
satayev | 3db3547 | 2021-05-06 23:59:58 +0100 | [diff] [blame] | 383 | // Generate classpaths.proto config |
| 384 | b.generateClasspathProtoBuildActions(ctx) |
| 385 | |
Paul Duffin | 7ebebfd | 2021-04-27 19:36:57 +0100 | [diff] [blame] | 386 | // Gather the bootclasspath fragment's contents. |
| 387 | var contents []android.Module |
| 388 | ctx.VisitDirectDeps(func(module android.Module) { |
| 389 | tag := ctx.OtherModuleDependencyTag(module) |
| 390 | if IsBootclasspathFragmentContentDepTag(tag) { |
Paul Duffin | 79fd3d7 | 2021-05-14 16:14:17 +0100 | [diff] [blame] | 391 | contents = append(contents, module) |
Paul Duffin | 7ebebfd | 2021-04-27 19:36:57 +0100 | [diff] [blame] | 392 | } |
| 393 | }) |
| 394 | |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 395 | fragments := gatherApexModulePairDepsWithTag(ctx, bootclasspathFragmentDepTag) |
| 396 | |
Paul Duffin | 9b381ef | 2021-04-08 23:01:37 +0100 | [diff] [blame] | 397 | // Perform hidden API processing. |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 398 | hiddenAPIFlagOutput := b.generateHiddenAPIBuildActions(ctx, contents, fragments) |
Paul Duffin | 9b381ef | 2021-04-08 23:01:37 +0100 | [diff] [blame] | 399 | |
Paul Duffin | 1a8010a | 2021-05-15 12:39:23 +0100 | [diff] [blame] | 400 | // Verify that the image_name specified on a bootclasspath_fragment is valid even if this is a |
| 401 | // prebuilt which will not use the image config. |
| 402 | imageConfig := b.getImageConfig(ctx) |
| 403 | |
| 404 | // A prebuilt fragment cannot contribute to the apex. |
| 405 | if !android.IsModulePrebuilt(ctx.Module()) { |
| 406 | // Provide the apex content info. |
Paul Duffin | 1e6f5c4 | 2021-05-21 16:15:31 +0100 | [diff] [blame] | 407 | b.provideApexContentInfo(ctx, imageConfig, contents, hiddenAPIFlagOutput) |
Paul Duffin | 1a8010a | 2021-05-15 12:39:23 +0100 | [diff] [blame] | 408 | } |
| 409 | } |
| 410 | |
| 411 | // provideApexContentInfo creates, initializes and stores the apex content info for use by other |
| 412 | // modules. |
Paul Duffin | 1e6f5c4 | 2021-05-21 16:15:31 +0100 | [diff] [blame] | 413 | func (b *BootclasspathFragmentModule) provideApexContentInfo(ctx android.ModuleContext, imageConfig *bootImageConfig, contents []android.Module, hiddenAPIFlagOutput *HiddenAPIFlagOutput) { |
Paul Duffin | 1a8010a | 2021-05-15 12:39:23 +0100 | [diff] [blame] | 414 | // Construct the apex content info from the config. |
Paul Duffin | 58e0e76 | 2021-05-21 19:27:58 +0100 | [diff] [blame] | 415 | info := BootclasspathFragmentApexContentInfo{} |
Paul Duffin | 1a8010a | 2021-05-15 12:39:23 +0100 | [diff] [blame] | 416 | |
| 417 | // Populate the apex content info with paths to the dex jars. |
Paul Duffin | 1e6f5c4 | 2021-05-21 16:15:31 +0100 | [diff] [blame] | 418 | b.populateApexContentInfoDexJars(ctx, &info, contents, hiddenAPIFlagOutput) |
Paul Duffin | 1a8010a | 2021-05-15 12:39:23 +0100 | [diff] [blame] | 419 | |
Paul Duffin | 58e0e76 | 2021-05-21 19:27:58 +0100 | [diff] [blame] | 420 | if imageConfig != nil { |
| 421 | info.modules = imageConfig.modules |
Paul Duffin | 7ebebfd | 2021-04-27 19:36:57 +0100 | [diff] [blame] | 422 | |
Paul Duffin | 58e0e76 | 2021-05-21 19:27:58 +0100 | [diff] [blame] | 423 | if !SkipDexpreoptBootJars(ctx) { |
| 424 | // Force the GlobalSoongConfig to be created and cached for use by the dex_bootjars |
| 425 | // GenerateSingletonBuildActions method as it cannot create it for itself. |
| 426 | dexpreopt.GetGlobalSoongConfig(ctx) |
| 427 | |
| 428 | // Only generate the boot image if the configuration does not skip it. |
| 429 | if b.generateBootImageBuildActions(ctx, contents, imageConfig) { |
| 430 | // Allow the apex to access the boot image files. |
| 431 | files := map[android.ArchType]android.OutputPaths{} |
| 432 | for _, variant := range imageConfig.variants { |
| 433 | // We also generate boot images for host (for testing), but we don't need those in the apex. |
| 434 | // TODO(b/177892522) - consider changing this to check Os.OsClass = android.Device |
| 435 | if variant.target.Os == android.Android { |
| 436 | files[variant.target.Arch.ArchType] = variant.imagesDeps |
| 437 | } |
| 438 | } |
| 439 | info.bootImageFilesByArch = files |
| 440 | } |
| 441 | } |
Paul Duffin | 1a8010a | 2021-05-15 12:39:23 +0100 | [diff] [blame] | 442 | } |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 443 | |
Paul Duffin | 1a8010a | 2021-05-15 12:39:23 +0100 | [diff] [blame] | 444 | // Make the apex content info available for other modules. |
| 445 | ctx.SetProvider(BootclasspathFragmentApexContentInfoProvider, info) |
| 446 | } |
| 447 | |
| 448 | // populateApexContentInfoDexJars adds paths to the dex jars provided by this fragment to the |
| 449 | // apex content info. |
Paul Duffin | 1e6f5c4 | 2021-05-21 16:15:31 +0100 | [diff] [blame] | 450 | func (b *BootclasspathFragmentModule) populateApexContentInfoDexJars(ctx android.ModuleContext, info *BootclasspathFragmentApexContentInfo, contents []android.Module, hiddenAPIFlagOutput *HiddenAPIFlagOutput) { |
Paul Duffin | 54c98f5 | 2021-05-15 08:54:30 +0100 | [diff] [blame] | 451 | |
Paul Duffin | 1a8010a | 2021-05-15 12:39:23 +0100 | [diff] [blame] | 452 | info.contentModuleDexJarPaths = map[string]android.Path{} |
Paul Duffin | 1e6f5c4 | 2021-05-21 16:15:31 +0100 | [diff] [blame] | 453 | if hiddenAPIFlagOutput != nil { |
Paul Duffin | 54c98f5 | 2021-05-15 08:54:30 +0100 | [diff] [blame] | 454 | // Hidden API encoding has been performed. |
Paul Duffin | 1e6f5c4 | 2021-05-21 16:15:31 +0100 | [diff] [blame] | 455 | flags := hiddenAPIFlagOutput.AllFlagsPath |
Paul Duffin | 54c98f5 | 2021-05-15 08:54:30 +0100 | [diff] [blame] | 456 | for _, m := range contents { |
| 457 | h := m.(hiddenAPIModule) |
| 458 | unencodedDex := h.bootDexJar() |
| 459 | if unencodedDex == nil { |
| 460 | // This is an error. Sometimes Soong will report the error directly, other times it will |
| 461 | // defer the error reporting to happen only when trying to use the missing file in ninja. |
| 462 | // Either way it is handled by extractBootDexJarsFromHiddenAPIModules which must have been |
| 463 | // called before this as it generates the flags that are used to encode these files. |
| 464 | continue |
| 465 | } |
| 466 | |
| 467 | outputDir := android.PathForModuleOut(ctx, "hiddenapi-modular/encoded").OutputPath |
| 468 | encodedDex := hiddenAPIEncodeDex(ctx, unencodedDex, flags, *h.uncompressDex(), outputDir) |
| 469 | info.contentModuleDexJarPaths[m.Name()] = encodedDex |
| 470 | } |
| 471 | } else { |
| 472 | for _, m := range contents { |
| 473 | j := m.(UsesLibraryDependency) |
| 474 | dexJar := j.DexJarBuildPath() |
| 475 | info.contentModuleDexJarPaths[m.Name()] = dexJar |
| 476 | } |
satayev | 14e4913 | 2021-05-17 21:03:07 +0100 | [diff] [blame] | 477 | } |
Paul Duffin | 3451e16 | 2021-01-20 15:16:56 +0000 | [diff] [blame] | 478 | } |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 479 | |
satayev | 3db3547 | 2021-05-06 23:59:58 +0100 | [diff] [blame] | 480 | // generateClasspathProtoBuildActions generates all required build actions for classpath.proto config |
| 481 | func (b *BootclasspathFragmentModule) generateClasspathProtoBuildActions(ctx android.ModuleContext) { |
| 482 | var classpathJars []classpathJar |
| 483 | if "art" == proptools.String(b.properties.Image_name) { |
| 484 | // ART and platform boot jars must have a corresponding entry in DEX2OATBOOTCLASSPATH |
| 485 | classpathJars = configuredJarListToClasspathJars(ctx, b.ClasspathFragmentToConfiguredJarList(ctx), BOOTCLASSPATH, DEX2OATBOOTCLASSPATH) |
| 486 | } else { |
| 487 | classpathJars = configuredJarListToClasspathJars(ctx, b.ClasspathFragmentToConfiguredJarList(ctx), b.classpathType) |
| 488 | } |
| 489 | b.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, classpathJars) |
| 490 | } |
| 491 | |
| 492 | func (b *BootclasspathFragmentModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList { |
satayev | 8fab6f8 | 2021-05-07 00:10:33 +0100 | [diff] [blame] | 493 | if "art" == proptools.String(b.properties.Image_name) { |
| 494 | return b.getImageConfig(ctx).modules |
| 495 | } |
| 496 | |
| 497 | global := dexpreopt.GetGlobalConfig(ctx) |
| 498 | |
satayev | 1c564cc | 2021-05-25 19:50:30 +0100 | [diff] [blame^] | 499 | // Convert content names to their appropriate stems, in case a test library is overriding an actual boot jar |
| 500 | var stems []string |
| 501 | for _, name := range b.properties.Contents { |
| 502 | dep := ctx.GetDirectDepWithTag(name, bootclasspathFragmentContentDepTag) |
| 503 | if m, ok := dep.(ModuleWithStem); ok { |
| 504 | stems = append(stems, m.Stem()) |
| 505 | } else { |
| 506 | ctx.PropertyErrorf("contents", "%v is not a ModuleWithStem", name) |
| 507 | } |
| 508 | } |
| 509 | |
satayev | 8fab6f8 | 2021-05-07 00:10:33 +0100 | [diff] [blame] | 510 | // Only create configs for updatable boot jars. Non-updatable boot jars must be part of the |
| 511 | // platform_bootclasspath's classpath proto config to guarantee that they come before any |
| 512 | // updatable jars at runtime. |
satayev | 1c564cc | 2021-05-25 19:50:30 +0100 | [diff] [blame^] | 513 | return global.UpdatableBootJars.Filter(stems) |
satayev | 3db3547 | 2021-05-06 23:59:58 +0100 | [diff] [blame] | 514 | } |
| 515 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 516 | func (b *BootclasspathFragmentModule) getImageConfig(ctx android.EarlyModuleContext) *bootImageConfig { |
Paul Duffin | 64be7bb | 2021-03-23 23:06:38 +0000 | [diff] [blame] | 517 | // Get a map of the image configs that are supported. |
| 518 | imageConfigs := genBootImageConfigs(ctx) |
| 519 | |
| 520 | // Retrieve the config for this image. |
| 521 | imageNamePtr := b.properties.Image_name |
| 522 | if imageNamePtr == nil { |
| 523 | return nil |
| 524 | } |
| 525 | |
| 526 | imageName := *imageNamePtr |
| 527 | imageConfig := imageConfigs[imageName] |
| 528 | if imageConfig == nil { |
| 529 | ctx.PropertyErrorf("image_name", "Unknown image name %q, expected one of %s", imageName, strings.Join(android.SortedStringKeys(imageConfigs), ", ")) |
| 530 | return nil |
| 531 | } |
| 532 | return imageConfig |
| 533 | } |
| 534 | |
Paul Duffin | 9b381ef | 2021-04-08 23:01:37 +0100 | [diff] [blame] | 535 | // generateHiddenAPIBuildActions generates all the hidden API related build rules. |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 536 | func (b *BootclasspathFragmentModule) generateHiddenAPIBuildActions(ctx android.ModuleContext, contents []android.Module, fragments []android.Module) *HiddenAPIFlagOutput { |
Paul Duffin | 1093158 | 2021-04-25 10:13:54 +0100 | [diff] [blame] | 537 | |
Paul Duffin | 1352f7c | 2021-05-21 22:18:49 +0100 | [diff] [blame] | 538 | // Create hidden API input structure. |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 539 | input := b.createHiddenAPIFlagInput(ctx, contents, fragments) |
Paul Duffin | 1093158 | 2021-04-25 10:13:54 +0100 | [diff] [blame] | 540 | |
Paul Duffin | 6237092 | 2021-05-23 16:55:37 +0100 | [diff] [blame] | 541 | var output *HiddenAPIFlagOutput |
Paul Duffin | 537ea3d | 2021-05-14 10:38:00 +0100 | [diff] [blame] | 542 | |
Paul Duffin | 6237092 | 2021-05-23 16:55:37 +0100 | [diff] [blame] | 543 | // Hidden API processing is conditional as a temporary workaround as not all |
| 544 | // bootclasspath_fragments provide the appropriate information needed for hidden API processing |
| 545 | // which leads to breakages of the build. |
| 546 | // TODO(b/179354495): Stop hidden API processing being conditional once all bootclasspath_fragment |
| 547 | // modules have been updated to support it. |
| 548 | if input.canPerformHiddenAPIProcessing(ctx, b.properties) { |
| 549 | // Get the content modules that contribute to the hidden API processing. |
| 550 | hiddenAPIModules := gatherHiddenAPIModuleFromContents(ctx, contents) |
Paul Duffin | 1e6f5c4 | 2021-05-21 16:15:31 +0100 | [diff] [blame] | 551 | |
Paul Duffin | 6237092 | 2021-05-23 16:55:37 +0100 | [diff] [blame] | 552 | // Delegate the production of the hidden API all-flags.csv file to a module type specific method. |
| 553 | common := ctx.Module().(commonBootclasspathFragment) |
| 554 | output = common.produceHiddenAPIAllFlagsFile(ctx, hiddenAPIModules, input) |
| 555 | } |
| 556 | |
| 557 | // Initialize a HiddenAPIInfo structure. |
Paul Duffin | af99afa | 2021-05-21 22:18:56 +0100 | [diff] [blame] | 558 | hiddenAPIInfo := HiddenAPIInfo{ |
Paul Duffin | 6237092 | 2021-05-23 16:55:37 +0100 | [diff] [blame] | 559 | // The monolithic hidden API processing needs access to the flag files that override the default |
| 560 | // flags from all the fragments whether or not they actually perform their own hidden API flag |
| 561 | // generation. That is because the monolithic hidden API processing uses those flag files to |
| 562 | // perform its own flag generation. |
Paul Duffin | 1352f7c | 2021-05-21 22:18:49 +0100 | [diff] [blame] | 563 | FlagFilesByCategory: input.FlagFilesByCategory, |
Paul Duffin | 18cf197 | 2021-05-21 22:46:59 +0100 | [diff] [blame] | 564 | |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 565 | // Other bootclasspath_fragments that depend on this need the transitive set of stub dex jars |
| 566 | // from this to resolve any references from their code to classes provided by this fragment |
| 567 | // and the fragments this depends upon. |
| 568 | TransitiveStubDexJarsByKind: input.transitiveStubDexJarsByKind(), |
Paul Duffin | 6237092 | 2021-05-23 16:55:37 +0100 | [diff] [blame] | 569 | } |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 570 | |
Paul Duffin | 6237092 | 2021-05-23 16:55:37 +0100 | [diff] [blame] | 571 | if output != nil { |
Paul Duffin | 1352f7c | 2021-05-21 22:18:49 +0100 | [diff] [blame] | 572 | // The monolithic hidden API processing also needs access to all the output files produced by |
| 573 | // hidden API processing of this fragment. |
Paul Duffin | 6237092 | 2021-05-23 16:55:37 +0100 | [diff] [blame] | 574 | hiddenAPIInfo.HiddenAPIFlagOutput = *output |
Paul Duffin | 1352f7c | 2021-05-21 22:18:49 +0100 | [diff] [blame] | 575 | } |
Paul Duffin | 6237092 | 2021-05-23 16:55:37 +0100 | [diff] [blame] | 576 | |
| 577 | // Provide it for use by other modules. |
Paul Duffin | af99afa | 2021-05-21 22:18:56 +0100 | [diff] [blame] | 578 | ctx.SetProvider(HiddenAPIInfoProvider, hiddenAPIInfo) |
Paul Duffin | 54c98f5 | 2021-05-15 08:54:30 +0100 | [diff] [blame] | 579 | |
Paul Duffin | 1e6f5c4 | 2021-05-21 16:15:31 +0100 | [diff] [blame] | 580 | return output |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 581 | } |
| 582 | |
Paul Duffin | 1352f7c | 2021-05-21 22:18:49 +0100 | [diff] [blame] | 583 | // createHiddenAPIFlagInput creates a HiddenAPIFlagInput struct and initializes it with information derived |
| 584 | // from the properties on this module and its dependencies. |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 585 | func (b *BootclasspathFragmentModule) createHiddenAPIFlagInput(ctx android.ModuleContext, contents []android.Module, fragments []android.Module) HiddenAPIFlagInput { |
| 586 | |
| 587 | // Merge the HiddenAPIInfo from all the fragment dependencies. |
| 588 | dependencyHiddenApiInfo := newHiddenAPIInfo() |
| 589 | dependencyHiddenApiInfo.mergeFromFragmentDeps(ctx, fragments) |
| 590 | |
| 591 | // Create hidden API flag input structure. |
Paul Duffin | 1352f7c | 2021-05-21 22:18:49 +0100 | [diff] [blame] | 592 | input := newHiddenAPIFlagInput() |
| 593 | |
| 594 | // Update the input structure with information obtained from the stub libraries. |
| 595 | input.gatherStubLibInfo(ctx, contents) |
| 596 | |
| 597 | // Populate with flag file paths from the properties. |
| 598 | input.extractFlagFilesFromProperties(ctx, &b.properties.Hidden_api) |
| 599 | |
Paul Duffin | f1b358c | 2021-05-17 07:38:47 +0100 | [diff] [blame] | 600 | // Store the stub dex jars from this module's fragment dependencies. |
| 601 | input.DependencyStubDexJarsByKind = dependencyHiddenApiInfo.TransitiveStubDexJarsByKind |
| 602 | |
Paul Duffin | 1352f7c | 2021-05-21 22:18:49 +0100 | [diff] [blame] | 603 | return input |
| 604 | } |
| 605 | |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 606 | // produceHiddenAPIAllFlagsFile produces the hidden API all-flags.csv file (and supporting files) |
| 607 | // for the fragment. |
Paul Duffin | 1352f7c | 2021-05-21 22:18:49 +0100 | [diff] [blame] | 608 | func (b *BootclasspathFragmentModule) produceHiddenAPIAllFlagsFile(ctx android.ModuleContext, contents []hiddenAPIModule, input HiddenAPIFlagInput) *HiddenAPIFlagOutput { |
| 609 | // Generate the rules to create the hidden API flags and update the supplied hiddenAPIInfo with the |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 610 | // paths to the created files. |
Paul Duffin | 1352f7c | 2021-05-21 22:18:49 +0100 | [diff] [blame] | 611 | return hiddenAPIGenerateAllFlagsForBootclasspathFragment(ctx, contents, input) |
Paul Duffin | 9b381ef | 2021-04-08 23:01:37 +0100 | [diff] [blame] | 612 | } |
| 613 | |
Paul Duffin | 7ebebfd | 2021-04-27 19:36:57 +0100 | [diff] [blame] | 614 | // generateBootImageBuildActions generates ninja rules to create the boot image if required for this |
| 615 | // module. |
Paul Duffin | 58e0e76 | 2021-05-21 19:27:58 +0100 | [diff] [blame] | 616 | // |
| 617 | // Returns true if the boot image is created, false otherwise. |
| 618 | func (b *BootclasspathFragmentModule) generateBootImageBuildActions(ctx android.ModuleContext, contents []android.Module, imageConfig *bootImageConfig) bool { |
Paul Duffin | 7ebebfd | 2021-04-27 19:36:57 +0100 | [diff] [blame] | 619 | global := dexpreopt.GetGlobalConfig(ctx) |
| 620 | if !shouldBuildBootImages(ctx.Config(), global) { |
Paul Duffin | 58e0e76 | 2021-05-21 19:27:58 +0100 | [diff] [blame] | 621 | return false |
Paul Duffin | 7ebebfd | 2021-04-27 19:36:57 +0100 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | // Bootclasspath fragment modules that are for the platform do not produce a boot image. |
| 625 | apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo) |
| 626 | if apexInfo.IsForPlatform() { |
Paul Duffin | 58e0e76 | 2021-05-21 19:27:58 +0100 | [diff] [blame] | 627 | return false |
Paul Duffin | 7ebebfd | 2021-04-27 19:36:57 +0100 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | // Bootclasspath fragment modules that are versioned do not produce a boot image. |
| 631 | if android.IsModuleInVersionedSdk(ctx.Module()) { |
Paul Duffin | 58e0e76 | 2021-05-21 19:27:58 +0100 | [diff] [blame] | 632 | return false |
Paul Duffin | 7ebebfd | 2021-04-27 19:36:57 +0100 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | // Copy the dex jars of this fragment's content modules to their predefined locations. |
| 636 | copyBootJarsToPredefinedLocations(ctx, contents, imageConfig.modules, imageConfig.dexPaths) |
Paul Duffin | 2fc82ad | 2021-04-29 23:36:12 +0100 | [diff] [blame] | 637 | |
| 638 | // Build a profile for the image config and then use that to build the boot image. |
| 639 | profile := bootImageProfileRule(ctx, imageConfig) |
| 640 | buildBootImage(ctx, imageConfig, profile) |
Paul Duffin | 58e0e76 | 2021-05-21 19:27:58 +0100 | [diff] [blame] | 641 | |
| 642 | return true |
Paul Duffin | 7ebebfd | 2021-04-27 19:36:57 +0100 | [diff] [blame] | 643 | } |
| 644 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 645 | type bootclasspathFragmentMemberType struct { |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 646 | android.SdkMemberTypeBase |
| 647 | } |
| 648 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 649 | func (b *bootclasspathFragmentMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) { |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 650 | mctx.AddVariationDependencies(nil, dependencyTag, names...) |
| 651 | } |
| 652 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 653 | func (b *bootclasspathFragmentMemberType) IsInstance(module android.Module) bool { |
| 654 | _, ok := module.(*BootclasspathFragmentModule) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 655 | return ok |
| 656 | } |
| 657 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 658 | func (b *bootclasspathFragmentMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule { |
Paul Duffin | 4b64ba0 | 2021-03-29 11:02:53 +0100 | [diff] [blame] | 659 | if b.PropertyName == "boot_images" { |
| 660 | return ctx.SnapshotBuilder().AddPrebuiltModule(member, "prebuilt_boot_image") |
| 661 | } else { |
| 662 | return ctx.SnapshotBuilder().AddPrebuiltModule(member, "prebuilt_bootclasspath_fragment") |
| 663 | } |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 664 | } |
| 665 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 666 | func (b *bootclasspathFragmentMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties { |
| 667 | return &bootclasspathFragmentSdkMemberProperties{} |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 668 | } |
| 669 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 670 | type bootclasspathFragmentSdkMemberProperties struct { |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 671 | android.SdkMemberPropertiesBase |
| 672 | |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 673 | // The image name |
Paul Duffin | 64be7bb | 2021-03-23 23:06:38 +0000 | [diff] [blame] | 674 | Image_name *string |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 675 | |
| 676 | // Contents of the bootclasspath fragment |
| 677 | Contents []string |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 678 | |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 679 | // Stub_libs properties. |
| 680 | Stub_libs []string |
| 681 | Core_platform_stub_libs []string |
| 682 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 683 | // Flag files by *hiddenAPIFlagFileCategory |
Paul Duffin | 438eb57 | 2021-05-21 16:58:23 +0100 | [diff] [blame] | 684 | Flag_files_by_category FlagFilesByCategory |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 685 | |
| 686 | // The path to the generated stub-flags.csv file. |
| 687 | Stub_flags_path android.OptionalPath |
| 688 | |
| 689 | // The path to the generated annotation-flags.csv file. |
| 690 | Annotation_flags_path android.OptionalPath |
| 691 | |
| 692 | // The path to the generated metadata.csv file. |
| 693 | Metadata_path android.OptionalPath |
| 694 | |
| 695 | // The path to the generated index.csv file. |
| 696 | Index_path android.OptionalPath |
| 697 | |
| 698 | // The path to the generated all-flags.csv file. |
| 699 | All_flags_path android.OptionalPath |
| 700 | } |
| 701 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 702 | func (b *bootclasspathFragmentSdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) { |
| 703 | module := variant.(*BootclasspathFragmentModule) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 704 | |
| 705 | b.Image_name = module.properties.Image_name |
Paul Duffin | 2dc665b | 2021-04-23 16:58:51 +0100 | [diff] [blame] | 706 | b.Contents = module.properties.Contents |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 707 | |
Paul Duffin | af99afa | 2021-05-21 22:18:56 +0100 | [diff] [blame] | 708 | // Get the hidden API information from the module. |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 709 | mctx := ctx.SdkModuleContext() |
Paul Duffin | af99afa | 2021-05-21 22:18:56 +0100 | [diff] [blame] | 710 | hiddenAPIInfo := mctx.OtherModuleProvider(module, HiddenAPIInfoProvider).(HiddenAPIInfo) |
| 711 | b.Flag_files_by_category = hiddenAPIInfo.FlagFilesByCategory |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 712 | |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 713 | // Copy all the generated file paths. |
Paul Duffin | af99afa | 2021-05-21 22:18:56 +0100 | [diff] [blame] | 714 | b.Stub_flags_path = android.OptionalPathForPath(hiddenAPIInfo.StubFlagsPath) |
| 715 | b.Annotation_flags_path = android.OptionalPathForPath(hiddenAPIInfo.AnnotationFlagsPath) |
| 716 | b.Metadata_path = android.OptionalPathForPath(hiddenAPIInfo.MetadataPath) |
| 717 | b.Index_path = android.OptionalPathForPath(hiddenAPIInfo.IndexPath) |
| 718 | b.All_flags_path = android.OptionalPathForPath(hiddenAPIInfo.AllFlagsPath) |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 719 | |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 720 | // Copy stub_libs properties. |
| 721 | b.Stub_libs = module.properties.Api.Stub_libs |
| 722 | b.Core_platform_stub_libs = module.properties.Core_platform_api.Stub_libs |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 723 | } |
| 724 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 725 | func (b *bootclasspathFragmentSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) { |
Paul Duffin | 64be7bb | 2021-03-23 23:06:38 +0000 | [diff] [blame] | 726 | if b.Image_name != nil { |
| 727 | propertySet.AddProperty("image_name", *b.Image_name) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 728 | } |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 729 | |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 730 | builder := ctx.SnapshotBuilder() |
| 731 | requiredMemberDependency := builder.SdkMemberReferencePropertyTag(true) |
| 732 | |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 733 | if len(b.Contents) > 0 { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 734 | propertySet.AddPropertyWithTag("contents", b.Contents, requiredMemberDependency) |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 735 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 736 | |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 737 | if len(b.Stub_libs) > 0 { |
| 738 | apiPropertySet := propertySet.AddPropertySet("api") |
| 739 | apiPropertySet.AddPropertyWithTag("stub_libs", b.Stub_libs, requiredMemberDependency) |
| 740 | } |
| 741 | if len(b.Core_platform_stub_libs) > 0 { |
| 742 | corePlatformApiPropertySet := propertySet.AddPropertySet("core_platform_api") |
| 743 | corePlatformApiPropertySet.AddPropertyWithTag("stub_libs", b.Core_platform_stub_libs, requiredMemberDependency) |
| 744 | } |
| 745 | |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 746 | hiddenAPISet := propertySet.AddPropertySet("hidden_api") |
| 747 | hiddenAPIDir := "hiddenapi" |
| 748 | |
| 749 | // Copy manually curated flag files specified on the bootclasspath_fragment. |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 750 | if b.Flag_files_by_category != nil { |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 751 | for _, category := range hiddenAPIFlagFileCategories { |
| 752 | paths := b.Flag_files_by_category[category] |
| 753 | if len(paths) > 0 { |
| 754 | dests := []string{} |
| 755 | for _, p := range paths { |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 756 | dest := filepath.Join(hiddenAPIDir, p.Base()) |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 757 | builder.CopyToSnapshot(p, dest) |
| 758 | dests = append(dests, dest) |
| 759 | } |
| 760 | hiddenAPISet.AddProperty(category.propertyName, dests) |
| 761 | } |
| 762 | } |
| 763 | } |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 764 | |
| 765 | copyOptionalPath := func(path android.OptionalPath, property string) { |
| 766 | if path.Valid() { |
| 767 | p := path.Path() |
| 768 | dest := filepath.Join(hiddenAPIDir, p.Base()) |
| 769 | builder.CopyToSnapshot(p, dest) |
| 770 | hiddenAPISet.AddProperty(property, dest) |
| 771 | } |
| 772 | } |
| 773 | |
| 774 | // Copy all the generated files, if available. |
| 775 | copyOptionalPath(b.Stub_flags_path, "stub_flags") |
| 776 | copyOptionalPath(b.Annotation_flags_path, "annotation_flags") |
| 777 | copyOptionalPath(b.Metadata_path, "metadata") |
| 778 | copyOptionalPath(b.Index_path, "index") |
| 779 | copyOptionalPath(b.All_flags_path, "all_flags") |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 780 | } |
| 781 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 782 | var _ android.SdkMemberType = (*bootclasspathFragmentMemberType)(nil) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 783 | |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 784 | // prebuiltBootclasspathFragmentProperties contains additional prebuilt_bootclasspath_fragment |
| 785 | // specific properties. |
| 786 | type prebuiltBootclasspathFragmentProperties struct { |
| 787 | Hidden_api struct { |
| 788 | // The path to the stub-flags.csv file created by the bootclasspath_fragment. |
| 789 | Stub_flags *string `android:"path"` |
| 790 | |
| 791 | // The path to the annotation-flags.csv file created by the bootclasspath_fragment. |
| 792 | Annotation_flags *string `android:"path"` |
| 793 | |
| 794 | // The path to the metadata.csv file created by the bootclasspath_fragment. |
| 795 | Metadata *string `android:"path"` |
| 796 | |
| 797 | // The path to the index.csv file created by the bootclasspath_fragment. |
| 798 | Index *string `android:"path"` |
| 799 | |
| 800 | // The path to the all-flags.csv file created by the bootclasspath_fragment. |
| 801 | All_flags *string `android:"path"` |
| 802 | } |
| 803 | } |
| 804 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 805 | // A prebuilt version of the bootclasspath_fragment module. |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 806 | // |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 807 | // At the moment this is basically just a bootclasspath_fragment module that can be used as a |
| 808 | // prebuilt. Eventually as more functionality is migrated into the bootclasspath_fragment module |
| 809 | // type from the various singletons then this will diverge. |
| 810 | type prebuiltBootclasspathFragmentModule struct { |
| 811 | BootclasspathFragmentModule |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 812 | prebuilt android.Prebuilt |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 813 | |
| 814 | // Additional prebuilt specific properties. |
| 815 | prebuiltProperties prebuiltBootclasspathFragmentProperties |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 816 | } |
| 817 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 818 | func (module *prebuiltBootclasspathFragmentModule) Prebuilt() *android.Prebuilt { |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 819 | return &module.prebuilt |
| 820 | } |
| 821 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 822 | func (module *prebuiltBootclasspathFragmentModule) Name() string { |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 823 | return module.prebuilt.Name(module.ModuleBase.Name()) |
| 824 | } |
| 825 | |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 826 | // produceHiddenAPIAllFlagsFile returns a path to the prebuilt all-flags.csv or nil if none is |
| 827 | // specified. |
Paul Duffin | 1352f7c | 2021-05-21 22:18:49 +0100 | [diff] [blame] | 828 | func (module *prebuiltBootclasspathFragmentModule) produceHiddenAPIAllFlagsFile(ctx android.ModuleContext, contents []hiddenAPIModule, _ HiddenAPIFlagInput) *HiddenAPIFlagOutput { |
Paul Duffin | 1e6f5c4 | 2021-05-21 16:15:31 +0100 | [diff] [blame] | 829 | pathForOptionalSrc := func(src *string) android.Path { |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 830 | if src == nil { |
| 831 | // TODO(b/179354495): Fail if this is not provided once prebuilts have been updated. |
| 832 | return nil |
| 833 | } |
Paul Duffin | 1e6f5c4 | 2021-05-21 16:15:31 +0100 | [diff] [blame] | 834 | return android.PathForModuleSrc(ctx, *src) |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 835 | } |
| 836 | |
Paul Duffin | 1e6f5c4 | 2021-05-21 16:15:31 +0100 | [diff] [blame] | 837 | output := HiddenAPIFlagOutput{ |
| 838 | StubFlagsPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Stub_flags), |
| 839 | AnnotationFlagsPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Annotation_flags), |
| 840 | MetadataPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Metadata), |
| 841 | IndexPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Index), |
| 842 | AllFlagsPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.All_flags), |
| 843 | } |
| 844 | |
| 845 | return &output |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | var _ commonBootclasspathFragment = (*prebuiltBootclasspathFragmentModule)(nil) |
| 849 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 850 | func prebuiltBootclasspathFragmentFactory() android.Module { |
| 851 | m := &prebuiltBootclasspathFragmentModule{} |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 852 | m.AddProperties(&m.properties, &m.prebuiltProperties) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 853 | // This doesn't actually have any prebuilt files of its own so pass a placeholder for the srcs |
| 854 | // array. |
| 855 | android.InitPrebuiltModule(m, &[]string{"placeholder"}) |
| 856 | android.InitApexModule(m) |
| 857 | android.InitSdkAwareModule(m) |
Martin Stjernholm | b79c7f1 | 2021-03-17 00:26:25 +0000 | [diff] [blame] | 858 | android.InitAndroidArchModule(m, android.HostAndDeviceSupported, android.MultilibCommon) |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 859 | |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 860 | // Initialize the contents property from the image_name. |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 861 | android.AddLoadHook(m, func(ctx android.LoadHookContext) { |
Paul Duffin | 7771eba | 2021-04-23 14:25:28 +0100 | [diff] [blame] | 862 | bootclasspathFragmentInitContentsFromImage(ctx, &m.BootclasspathFragmentModule) |
Paul Duffin | c7ef989 | 2021-03-23 23:21:59 +0000 | [diff] [blame] | 863 | }) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 864 | return m |
| 865 | } |