Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 1 | // Copyright (C) 2019 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 apex |
| 16 | |
| 17 | import ( |
| 18 | "fmt" |
Paul Duffin | c30aea2 | 2021-06-15 19:10:11 +0100 | [diff] [blame] | 19 | "io" |
Colin Cross | 6340ea5 | 2021-11-04 12:01:18 -0700 | [diff] [blame^] | 20 | "path/filepath" |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 21 | "strconv" |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 22 | "strings" |
| 23 | |
| 24 | "android/soong/android" |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 25 | "android/soong/java" |
Colin Cross | 6340ea5 | 2021-11-04 12:01:18 -0700 | [diff] [blame^] | 26 | |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 27 | "github.com/google/blueprint" |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 28 | "github.com/google/blueprint/proptools" |
| 29 | ) |
| 30 | |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 31 | var ( |
| 32 | extractMatchingApex = pctx.StaticRule( |
| 33 | "extractMatchingApex", |
| 34 | blueprint.RuleParams{ |
| 35 | Command: `rm -rf "$out" && ` + |
| 36 | `${extract_apks} -o "${out}" -allow-prereleased=${allow-prereleased} ` + |
| 37 | `-sdk-version=${sdk-version} -abis=${abis} -screen-densities=all -extract-single ` + |
| 38 | `${in}`, |
| 39 | CommandDeps: []string{"${extract_apks}"}, |
| 40 | }, |
| 41 | "abis", "allow-prereleased", "sdk-version") |
| 42 | ) |
| 43 | |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 44 | type prebuilt interface { |
| 45 | isForceDisabled() bool |
| 46 | InstallFilename() string |
| 47 | } |
| 48 | |
| 49 | type prebuiltCommon struct { |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 50 | android.ModuleBase |
Paul Duffin | bb0dc13 | 2021-05-05 16:58:08 +0100 | [diff] [blame] | 51 | prebuilt android.Prebuilt |
Paul Duffin | dfd3326 | 2021-04-06 17:02:08 +0100 | [diff] [blame] | 52 | |
Paul Duffin | bb0dc13 | 2021-05-05 16:58:08 +0100 | [diff] [blame] | 53 | // Properties common to both prebuilt_apex and apex_set. |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 54 | prebuiltCommonProperties *PrebuiltCommonProperties |
| 55 | |
| 56 | installDir android.InstallPath |
| 57 | installFilename string |
Colin Cross | 6340ea5 | 2021-11-04 12:01:18 -0700 | [diff] [blame^] | 58 | installedFile android.InstallPath |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 59 | outputApex android.WritablePath |
| 60 | |
Paul Duffin | c30aea2 | 2021-06-15 19:10:11 +0100 | [diff] [blame] | 61 | // A list of apexFile objects created in prebuiltCommon.initApexFilesForAndroidMk which are used |
| 62 | // to create make modules in prebuiltCommon.AndroidMkEntries. |
| 63 | apexFilesForAndroidMk []apexFile |
| 64 | |
Colin Cross | 6340ea5 | 2021-11-04 12:01:18 -0700 | [diff] [blame^] | 65 | // Installed locations of symlinks for backward compatibility. |
| 66 | compatSymlinks android.InstallPaths |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 67 | |
Colin Cross | 6340ea5 | 2021-11-04 12:01:18 -0700 | [diff] [blame^] | 68 | hostRequired []string |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 69 | } |
| 70 | |
Evgenii Stepanov | 2080bfe | 2020-07-24 15:35:40 -0700 | [diff] [blame] | 71 | type sanitizedPrebuilt interface { |
| 72 | hasSanitizedSource(sanitizer string) bool |
| 73 | } |
| 74 | |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 75 | type PrebuiltCommonProperties struct { |
Paul Duffin | bb0dc13 | 2021-05-05 16:58:08 +0100 | [diff] [blame] | 76 | SelectedApexProperties |
| 77 | |
Martin Stjernholm | d8da28e | 2021-06-24 14:37:13 +0100 | [diff] [blame] | 78 | // Canonical name of this APEX. Used to determine the path to the activated APEX on |
| 79 | // device (/apex/<apex_name>). If unspecified, follows the name property. |
| 80 | Apex_name *string |
| 81 | |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 82 | ForceDisable bool `blueprint:"mutated"` |
Paul Duffin | 3bae068 | 2021-05-05 18:03:47 +0100 | [diff] [blame] | 83 | |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 84 | // whether the extracted apex file is installable. |
| 85 | Installable *bool |
| 86 | |
| 87 | // optional name for the installed apex. If unspecified, name of the |
| 88 | // module is used as the file name |
| 89 | Filename *string |
| 90 | |
| 91 | // names of modules to be overridden. Listed modules can only be other binaries |
| 92 | // (in Make or Soong). |
| 93 | // This does not completely prevent installation of the overridden binaries, but if both |
| 94 | // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed |
| 95 | // from PRODUCT_PACKAGES. |
| 96 | Overrides []string |
| 97 | |
Paul Duffin | 3bae068 | 2021-05-05 18:03:47 +0100 | [diff] [blame] | 98 | // List of java libraries that are embedded inside this prebuilt APEX bundle and for which this |
| 99 | // APEX bundle will create an APEX variant and provide dex implementation jars for use by |
| 100 | // dexpreopt and boot jars package check. |
| 101 | Exported_java_libs []string |
| 102 | |
| 103 | // List of bootclasspath fragments inside this prebuilt APEX bundle and for which this APEX |
| 104 | // bundle will create an APEX variant. |
| 105 | Exported_bootclasspath_fragments []string |
Jiakai Zhang | 774dd30 | 2021-09-26 03:54:25 +0000 | [diff] [blame] | 106 | |
| 107 | // List of systemserverclasspath fragments inside this prebuilt APEX bundle and for which this |
| 108 | // APEX bundle will create an APEX variant. |
| 109 | Exported_systemserverclasspath_fragments []string |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 110 | } |
| 111 | |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 112 | // initPrebuiltCommon initializes the prebuiltCommon structure and performs initialization of the |
| 113 | // module that is common to Prebuilt and ApexSet. |
| 114 | func (p *prebuiltCommon) initPrebuiltCommon(module android.Module, properties *PrebuiltCommonProperties) { |
| 115 | p.prebuiltCommonProperties = properties |
| 116 | android.InitSingleSourcePrebuiltModule(module.(android.PrebuiltInterface), properties, "Selected_apex") |
| 117 | android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 118 | } |
| 119 | |
Martin Stjernholm | d8da28e | 2021-06-24 14:37:13 +0100 | [diff] [blame] | 120 | func (p *prebuiltCommon) ApexVariationName() string { |
| 121 | return proptools.StringDefault(p.prebuiltCommonProperties.Apex_name, p.ModuleBase.BaseModuleName()) |
| 122 | } |
| 123 | |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 124 | func (p *prebuiltCommon) Prebuilt() *android.Prebuilt { |
| 125 | return &p.prebuilt |
| 126 | } |
| 127 | |
| 128 | func (p *prebuiltCommon) isForceDisabled() bool { |
Paul Duffin | bb0dc13 | 2021-05-05 16:58:08 +0100 | [diff] [blame] | 129 | return p.prebuiltCommonProperties.ForceDisable |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | func (p *prebuiltCommon) checkForceDisable(ctx android.ModuleContext) bool { |
| 133 | // If the device is configured to use flattened APEX, force disable the prebuilt because |
| 134 | // the prebuilt is a non-flattened one. |
| 135 | forceDisable := ctx.Config().FlattenApex() |
| 136 | |
| 137 | // Force disable the prebuilts when we are doing unbundled build. We do unbundled build |
| 138 | // to build the prebuilts themselves. |
| 139 | forceDisable = forceDisable || ctx.Config().UnbundledBuild() |
| 140 | |
Evgenii Stepanov | 2080bfe | 2020-07-24 15:35:40 -0700 | [diff] [blame] | 141 | // b/137216042 don't use prebuilts when address sanitizer is on, unless the prebuilt has a sanitized source |
| 142 | sanitized := ctx.Module().(sanitizedPrebuilt) |
| 143 | forceDisable = forceDisable || (android.InList("address", ctx.Config().SanitizeDevice()) && !sanitized.hasSanitizedSource("address")) |
| 144 | forceDisable = forceDisable || (android.InList("hwaddress", ctx.Config().SanitizeDevice()) && !sanitized.hasSanitizedSource("hwaddress")) |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 145 | |
| 146 | if forceDisable && p.prebuilt.SourceExists() { |
Paul Duffin | bb0dc13 | 2021-05-05 16:58:08 +0100 | [diff] [blame] | 147 | p.prebuiltCommonProperties.ForceDisable = true |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 148 | return true |
| 149 | } |
| 150 | return false |
| 151 | } |
| 152 | |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 153 | func (p *prebuiltCommon) InstallFilename() string { |
| 154 | return proptools.StringDefault(p.prebuiltCommonProperties.Filename, p.BaseModuleName()+imageApexSuffix) |
| 155 | } |
| 156 | |
| 157 | func (p *prebuiltCommon) Name() string { |
| 158 | return p.prebuilt.Name(p.ModuleBase.Name()) |
| 159 | } |
| 160 | |
| 161 | func (p *prebuiltCommon) Overrides() []string { |
| 162 | return p.prebuiltCommonProperties.Overrides |
| 163 | } |
| 164 | |
| 165 | func (p *prebuiltCommon) installable() bool { |
| 166 | return proptools.BoolDefault(p.prebuiltCommonProperties.Installable, true) |
| 167 | } |
| 168 | |
Paul Duffin | c30aea2 | 2021-06-15 19:10:11 +0100 | [diff] [blame] | 169 | // initApexFilesForAndroidMk initializes the prebuiltCommon.apexFilesForAndroidMk field from the |
| 170 | // modules that this depends upon. |
| 171 | func (p *prebuiltCommon) initApexFilesForAndroidMk(ctx android.ModuleContext) { |
| 172 | // Walk the dependencies of this module looking for the java modules that it exports. |
| 173 | ctx.WalkDeps(func(child, parent android.Module) bool { |
| 174 | tag := ctx.OtherModuleDependencyTag(child) |
| 175 | |
| 176 | name := android.RemoveOptionalPrebuiltPrefix(ctx.OtherModuleName(child)) |
Jiakai Zhang | 774dd30 | 2021-09-26 03:54:25 +0000 | [diff] [blame] | 177 | if java.IsBootclasspathFragmentContentDepTag(tag) || |
| 178 | java.IsSystemServerClasspathFragmentContentDepTag(tag) || tag == exportedJavaLibTag { |
Paul Duffin | c30aea2 | 2021-06-15 19:10:11 +0100 | [diff] [blame] | 179 | // If the exported java module provides a dex jar path then add it to the list of apexFiles. |
Martin Stjernholm | 8be1e6d | 2021-09-15 03:34:04 +0100 | [diff] [blame] | 180 | path := child.(interface { |
| 181 | DexJarBuildPath() java.OptionalDexJarPath |
| 182 | }).DexJarBuildPath() |
| 183 | if path.IsSet() { |
Jiakai Zhang | 204356f | 2021-09-09 08:12:46 +0000 | [diff] [blame] | 184 | af := apexFile{ |
Paul Duffin | c30aea2 | 2021-06-15 19:10:11 +0100 | [diff] [blame] | 185 | module: child, |
| 186 | moduleDir: ctx.OtherModuleDir(child), |
| 187 | androidMkModuleName: name, |
Martin Stjernholm | 8be1e6d | 2021-09-15 03:34:04 +0100 | [diff] [blame] | 188 | builtFile: path.Path(), |
Paul Duffin | c30aea2 | 2021-06-15 19:10:11 +0100 | [diff] [blame] | 189 | class: javaSharedLib, |
Jiakai Zhang | 204356f | 2021-09-09 08:12:46 +0000 | [diff] [blame] | 190 | } |
| 191 | if module, ok := child.(java.DexpreopterInterface); ok { |
| 192 | for _, install := range module.DexpreoptBuiltInstalledForApex() { |
| 193 | af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName()) |
| 194 | } |
| 195 | } |
| 196 | p.apexFilesForAndroidMk = append(p.apexFilesForAndroidMk, af) |
Paul Duffin | c30aea2 | 2021-06-15 19:10:11 +0100 | [diff] [blame] | 197 | } |
Jiakai Zhang | 774dd30 | 2021-09-26 03:54:25 +0000 | [diff] [blame] | 198 | } else if tag == exportedBootclasspathFragmentTag || |
| 199 | tag == exportedSystemserverclasspathFragmentTag { |
| 200 | // Visit the children of the bootclasspath_fragment and systemserver_fragment. |
Paul Duffin | c30aea2 | 2021-06-15 19:10:11 +0100 | [diff] [blame] | 201 | return true |
| 202 | } |
| 203 | |
| 204 | return false |
| 205 | }) |
| 206 | } |
| 207 | |
Jiakai Zhang | 204356f | 2021-09-09 08:12:46 +0000 | [diff] [blame] | 208 | func (p *prebuiltCommon) addRequiredModules(entries *android.AndroidMkEntries) { |
| 209 | for _, fi := range p.apexFilesForAndroidMk { |
| 210 | entries.AddStrings("LOCAL_REQUIRED_MODULES", fi.requiredModuleNames...) |
| 211 | entries.AddStrings("LOCAL_TARGET_REQUIRED_MODULES", fi.targetRequiredModuleNames...) |
| 212 | entries.AddStrings("LOCAL_HOST_REQUIRED_MODULES", fi.hostRequiredModuleNames...) |
| 213 | } |
| 214 | } |
| 215 | |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 216 | func (p *prebuiltCommon) AndroidMkEntries() []android.AndroidMkEntries { |
Paul Duffin | c30aea2 | 2021-06-15 19:10:11 +0100 | [diff] [blame] | 217 | entriesList := []android.AndroidMkEntries{ |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 218 | { |
| 219 | Class: "ETC", |
| 220 | OutputFile: android.OptionalPathForPath(p.outputApex), |
| 221 | Include: "$(BUILD_PREBUILT)", |
| 222 | Host_required: p.hostRequired, |
| 223 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 224 | func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
| 225 | entries.SetString("LOCAL_MODULE_PATH", p.installDir.ToMakePath().String()) |
| 226 | entries.SetString("LOCAL_MODULE_STEM", p.installFilename) |
Colin Cross | 6340ea5 | 2021-11-04 12:01:18 -0700 | [diff] [blame^] | 227 | entries.SetPath("LOCAL_SOONG_INSTALLED_MODULE", p.installedFile) |
| 228 | entries.SetString("LOCAL_SOONG_INSTALL_PAIRS", p.outputApex.String()+":"+p.installedFile.String()) |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 229 | entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.installable()) |
| 230 | entries.AddStrings("LOCAL_OVERRIDES_MODULES", p.prebuiltCommonProperties.Overrides...) |
Jiakai Zhang | 204356f | 2021-09-09 08:12:46 +0000 | [diff] [blame] | 231 | p.addRequiredModules(entries) |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 232 | }, |
| 233 | }, |
| 234 | }, |
| 235 | } |
Paul Duffin | c30aea2 | 2021-06-15 19:10:11 +0100 | [diff] [blame] | 236 | |
| 237 | // Iterate over the apexFilesForAndroidMk list and create an AndroidMkEntries struct for each |
| 238 | // file. This provides similar behavior to that provided in apexBundle.AndroidMk() as it makes the |
| 239 | // apex specific variants of the exported java modules available for use from within make. |
| 240 | apexName := p.BaseModuleName() |
| 241 | for _, fi := range p.apexFilesForAndroidMk { |
Paul Duffin | 9dc8c54 | 2021-06-17 13:33:09 +0100 | [diff] [blame] | 242 | entries := p.createEntriesForApexFile(fi, apexName) |
Paul Duffin | c30aea2 | 2021-06-15 19:10:11 +0100 | [diff] [blame] | 243 | entriesList = append(entriesList, entries) |
| 244 | } |
| 245 | |
| 246 | return entriesList |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 247 | } |
| 248 | |
Paul Duffin | 9dc8c54 | 2021-06-17 13:33:09 +0100 | [diff] [blame] | 249 | // createEntriesForApexFile creates an AndroidMkEntries for the supplied apexFile |
| 250 | func (p *prebuiltCommon) createEntriesForApexFile(fi apexFile, apexName string) android.AndroidMkEntries { |
| 251 | moduleName := fi.androidMkModuleName + "." + apexName |
| 252 | entries := android.AndroidMkEntries{ |
| 253 | Class: fi.class.nameInMake(), |
| 254 | OverrideName: moduleName, |
| 255 | OutputFile: android.OptionalPathForPath(fi.builtFile), |
| 256 | Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", |
| 257 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 258 | func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
| 259 | entries.SetString("LOCAL_MODULE_PATH", p.installDir.ToMakePath().String()) |
Colin Cross | 6340ea5 | 2021-11-04 12:01:18 -0700 | [diff] [blame^] | 260 | entries.SetString("LOCAL_SOONG_INSTALLED_MODULE :=", filepath.Join(p.installDir.String(), fi.stem())) |
| 261 | entries.SetString("LOCAL_SOONG_INSTALL_PAIRS :=", |
| 262 | fi.builtFile.String()+":"+filepath.Join(p.installDir.String(), fi.stem())) |
Paul Duffin | 9dc8c54 | 2021-06-17 13:33:09 +0100 | [diff] [blame] | 263 | |
| 264 | // soong_java_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .jar Therefore |
| 265 | // we need to remove the suffix from LOCAL_MODULE_STEM, otherwise |
| 266 | // we will have foo.jar.jar |
| 267 | entries.SetString("LOCAL_MODULE_STEM", strings.TrimSuffix(fi.stem(), ".jar")) |
Paul Duffin | 9dc8c54 | 2021-06-17 13:33:09 +0100 | [diff] [blame] | 268 | entries.SetString("LOCAL_SOONG_DEX_JAR", fi.builtFile.String()) |
| 269 | entries.SetString("LOCAL_DEX_PREOPT", "false") |
| 270 | }, |
| 271 | }, |
| 272 | ExtraFooters: []android.AndroidMkExtraFootersFunc{ |
| 273 | func(w io.Writer, name, prefix, moduleDir string) { |
| 274 | // m <module_name> will build <module_name>.<apex_name> as well. |
| 275 | if fi.androidMkModuleName != moduleName { |
| 276 | fmt.Fprintf(w, ".PHONY: %s\n", fi.androidMkModuleName) |
| 277 | fmt.Fprintf(w, "%s: %s\n", fi.androidMkModuleName, moduleName) |
| 278 | } |
| 279 | }, |
| 280 | }, |
| 281 | } |
| 282 | return entries |
| 283 | } |
| 284 | |
Paul Duffin | 5dda3e3 | 2021-05-05 14:13:27 +0100 | [diff] [blame] | 285 | // prebuiltApexModuleCreator defines the methods that need to be implemented by prebuilt_apex and |
| 286 | // apex_set in order to create the modules needed to provide access to the prebuilt .apex file. |
| 287 | type prebuiltApexModuleCreator interface { |
| 288 | createPrebuiltApexModules(ctx android.TopDownMutatorContext) |
| 289 | } |
| 290 | |
| 291 | // prebuiltApexModuleCreatorMutator is the mutator responsible for invoking the |
| 292 | // prebuiltApexModuleCreator's createPrebuiltApexModules method. |
| 293 | // |
| 294 | // It is registered as a pre-arch mutator as it must run after the ComponentDepsMutator because it |
| 295 | // will need to access dependencies added by that (exported modules) but must run before the |
| 296 | // DepsMutator so that the deapexer module it creates can add dependencies onto itself from the |
| 297 | // exported modules. |
| 298 | func prebuiltApexModuleCreatorMutator(ctx android.TopDownMutatorContext) { |
| 299 | module := ctx.Module() |
| 300 | if creator, ok := module.(prebuiltApexModuleCreator); ok { |
| 301 | creator.createPrebuiltApexModules(ctx) |
| 302 | } |
| 303 | } |
| 304 | |
Jiakai Zhang | 774dd30 | 2021-09-26 03:54:25 +0000 | [diff] [blame] | 305 | func (p *prebuiltCommon) getExportedDependencies() map[string]exportedDependencyTag { |
| 306 | dependencies := make(map[string]exportedDependencyTag) |
| 307 | |
| 308 | for _, dep := range p.prebuiltCommonProperties.Exported_java_libs { |
| 309 | dependencies[dep] = exportedJavaLibTag |
| 310 | } |
| 311 | |
| 312 | for _, dep := range p.prebuiltCommonProperties.Exported_bootclasspath_fragments { |
| 313 | dependencies[dep] = exportedBootclasspathFragmentTag |
| 314 | } |
| 315 | |
| 316 | for _, dep := range p.prebuiltCommonProperties.Exported_systemserverclasspath_fragments { |
| 317 | dependencies[dep] = exportedSystemserverclasspathFragmentTag |
| 318 | } |
| 319 | |
| 320 | return dependencies |
| 321 | } |
| 322 | |
Paul Duffin | 57f8359 | 2021-05-05 15:09:44 +0100 | [diff] [blame] | 323 | // prebuiltApexContentsDeps adds dependencies onto the prebuilt apex module's contents. |
| 324 | func (p *prebuiltCommon) prebuiltApexContentsDeps(ctx android.BottomUpMutatorContext) { |
| 325 | module := ctx.Module() |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 326 | |
Jiakai Zhang | 774dd30 | 2021-09-26 03:54:25 +0000 | [diff] [blame] | 327 | for dep, tag := range p.getExportedDependencies() { |
| 328 | prebuiltDep := android.PrebuiltNameFromSource(dep) |
| 329 | ctx.AddDependency(module, tag, prebuiltDep) |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 330 | } |
Paul Duffin | dfd3326 | 2021-04-06 17:02:08 +0100 | [diff] [blame] | 331 | } |
| 332 | |
Paul Duffin | b17d044 | 2021-05-05 12:07:00 +0100 | [diff] [blame] | 333 | // Implements android.DepInInSameApex |
| 334 | func (p *prebuiltCommon) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { |
| 335 | tag := ctx.OtherModuleDependencyTag(dep) |
| 336 | _, ok := tag.(exportedDependencyTag) |
| 337 | return ok |
| 338 | } |
| 339 | |
Paul Duffin | dfd3326 | 2021-04-06 17:02:08 +0100 | [diff] [blame] | 340 | // apexInfoMutator marks any modules for which this apex exports a file as requiring an apex |
| 341 | // specific variant and checks that they are supported. |
| 342 | // |
| 343 | // The apexMutator will ensure that the ApexInfo objects passed to BuildForApex(ApexInfo) are |
| 344 | // associated with the apex specific variant using the ApexInfoProvider for later retrieval. |
| 345 | // |
| 346 | // Unlike the source apex module type the prebuilt_apex module type cannot share compatible variants |
| 347 | // across prebuilt_apex modules. That is because there is no way to determine whether two |
| 348 | // prebuilt_apex modules that export files for the same module are compatible. e.g. they could have |
| 349 | // been built from different source at different times or they could have been built with different |
| 350 | // build options that affect the libraries. |
| 351 | // |
| 352 | // While it may be possible to provide sufficient information to determine whether two prebuilt_apex |
| 353 | // modules were compatible it would be a lot of work and would not provide much benefit for a couple |
| 354 | // of reasons: |
| 355 | // * The number of prebuilt_apex modules that will be exporting files for the same module will be |
| 356 | // low as the prebuilt_apex only exports files for the direct dependencies that require it and |
| 357 | // very few modules are direct dependencies of multiple prebuilt_apex modules, e.g. there are a |
| 358 | // few com.android.art* apex files that contain the same contents and could export files for the |
| 359 | // same modules but only one of them needs to do so. Contrast that with source apex modules which |
| 360 | // need apex specific variants for every module that contributes code to the apex, whether direct |
| 361 | // or indirect. |
| 362 | // * The build cost of a prebuilt_apex variant is generally low as at worst it will involve some |
| 363 | // extra copying of files. Contrast that with source apex modules that has to build each variant |
| 364 | // from source. |
| 365 | func (p *prebuiltCommon) apexInfoMutator(mctx android.TopDownMutatorContext) { |
| 366 | |
| 367 | // Collect direct dependencies into contents. |
| 368 | contents := make(map[string]android.ApexMembership) |
| 369 | |
| 370 | // Collect the list of dependencies. |
| 371 | var dependencies []android.ApexModule |
Paul Duffin | b17d044 | 2021-05-05 12:07:00 +0100 | [diff] [blame] | 372 | mctx.WalkDeps(func(child, parent android.Module) bool { |
| 373 | // If the child is not in the same apex as the parent then exit immediately and do not visit |
| 374 | // any of the child's dependencies. |
| 375 | if !android.IsDepInSameApex(mctx, parent, child) { |
| 376 | return false |
| 377 | } |
| 378 | |
| 379 | tag := mctx.OtherModuleDependencyTag(child) |
| 380 | depName := mctx.OtherModuleName(child) |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 381 | if exportedTag, ok := tag.(exportedDependencyTag); ok { |
| 382 | propertyName := exportedTag.name |
Paul Duffin | dfd3326 | 2021-04-06 17:02:08 +0100 | [diff] [blame] | 383 | |
| 384 | // It is an error if the other module is not a prebuilt. |
Paul Duffin | b17d044 | 2021-05-05 12:07:00 +0100 | [diff] [blame] | 385 | if !android.IsModulePrebuilt(child) { |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 386 | mctx.PropertyErrorf(propertyName, "%q is not a prebuilt module", depName) |
Paul Duffin | b17d044 | 2021-05-05 12:07:00 +0100 | [diff] [blame] | 387 | return false |
Paul Duffin | dfd3326 | 2021-04-06 17:02:08 +0100 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | // It is an error if the other module is not an ApexModule. |
Paul Duffin | b17d044 | 2021-05-05 12:07:00 +0100 | [diff] [blame] | 391 | if _, ok := child.(android.ApexModule); !ok { |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 392 | mctx.PropertyErrorf(propertyName, "%q is not usable within an apex", depName) |
Paul Duffin | b17d044 | 2021-05-05 12:07:00 +0100 | [diff] [blame] | 393 | return false |
Paul Duffin | dfd3326 | 2021-04-06 17:02:08 +0100 | [diff] [blame] | 394 | } |
Paul Duffin | dfd3326 | 2021-04-06 17:02:08 +0100 | [diff] [blame] | 395 | } |
Paul Duffin | b17d044 | 2021-05-05 12:07:00 +0100 | [diff] [blame] | 396 | |
Paul Duffin | fee8cf3 | 2021-06-29 18:38:38 +0100 | [diff] [blame] | 397 | // Ignore any modules that do not implement ApexModule as they cannot have an APEX specific |
| 398 | // variant. |
| 399 | if _, ok := child.(android.ApexModule); !ok { |
| 400 | return false |
| 401 | } |
| 402 | |
Paul Duffin | b17d044 | 2021-05-05 12:07:00 +0100 | [diff] [blame] | 403 | // Strip off the prebuilt_ prefix if present before storing content to ensure consistent |
| 404 | // behavior whether there is a corresponding source module present or not. |
| 405 | depName = android.RemoveOptionalPrebuiltPrefix(depName) |
| 406 | |
| 407 | // Remember if this module was added as a direct dependency. |
| 408 | direct := parent == mctx.Module() |
| 409 | contents[depName] = contents[depName].Add(direct) |
| 410 | |
| 411 | // Add the module to the list of dependencies that need to have an APEX variant. |
| 412 | dependencies = append(dependencies, child.(android.ApexModule)) |
| 413 | |
| 414 | return true |
Paul Duffin | dfd3326 | 2021-04-06 17:02:08 +0100 | [diff] [blame] | 415 | }) |
| 416 | |
| 417 | // Create contents for the prebuilt_apex and store it away for later use. |
| 418 | apexContents := android.NewApexContents(contents) |
| 419 | mctx.SetProvider(ApexBundleInfoProvider, ApexBundleInfo{ |
| 420 | Contents: apexContents, |
| 421 | }) |
| 422 | |
| 423 | // Create an ApexInfo for the prebuilt_apex. |
Martin Stjernholm | d8da28e | 2021-06-24 14:37:13 +0100 | [diff] [blame] | 424 | apexVariationName := p.ApexVariationName() |
Paul Duffin | dfd3326 | 2021-04-06 17:02:08 +0100 | [diff] [blame] | 425 | apexInfo := android.ApexInfo{ |
Martin Stjernholm | c4f4ced | 2021-05-27 11:17:00 +0000 | [diff] [blame] | 426 | ApexVariationName: apexVariationName, |
| 427 | InApexVariants: []string{apexVariationName}, |
Martin Stjernholm | d8da28e | 2021-06-24 14:37:13 +0100 | [diff] [blame] | 428 | InApexModules: []string{p.ModuleBase.BaseModuleName()}, // BaseModuleName() to avoid the prebuilt_ prefix. |
Paul Duffin | dfd3326 | 2021-04-06 17:02:08 +0100 | [diff] [blame] | 429 | ApexContents: []*android.ApexContents{apexContents}, |
| 430 | ForPrebuiltApex: true, |
| 431 | } |
| 432 | |
| 433 | // Mark the dependencies of this module as requiring a variant for this module. |
| 434 | for _, am := range dependencies { |
| 435 | am.BuildForApex(apexInfo) |
| 436 | } |
| 437 | } |
| 438 | |
Paul Duffin | 11216db | 2021-03-01 14:14:52 +0000 | [diff] [blame] | 439 | // prebuiltApexSelectorModule is a private module type that is only created by the prebuilt_apex |
| 440 | // module. It selects the apex to use and makes it available for use by prebuilt_apex and the |
| 441 | // deapexer. |
| 442 | type prebuiltApexSelectorModule struct { |
| 443 | android.ModuleBase |
| 444 | |
| 445 | apexFileProperties ApexFileProperties |
| 446 | |
| 447 | inputApex android.Path |
| 448 | } |
| 449 | |
| 450 | func privateApexSelectorModuleFactory() android.Module { |
| 451 | module := &prebuiltApexSelectorModule{} |
| 452 | module.AddProperties( |
| 453 | &module.apexFileProperties, |
| 454 | ) |
| 455 | android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 456 | return module |
| 457 | } |
| 458 | |
| 459 | func (p *prebuiltApexSelectorModule) Srcs() android.Paths { |
| 460 | return android.Paths{p.inputApex} |
| 461 | } |
| 462 | |
| 463 | func (p *prebuiltApexSelectorModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 464 | p.inputApex = android.SingleSourcePathFromSupplier(ctx, p.apexFileProperties.prebuiltApexSelector, "src") |
| 465 | } |
| 466 | |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 467 | type Prebuilt struct { |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 468 | prebuiltCommon |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 469 | |
Paul Duffin | bb0dc13 | 2021-05-05 16:58:08 +0100 | [diff] [blame] | 470 | properties PrebuiltProperties |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 471 | |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 472 | inputApex android.Path |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 473 | } |
| 474 | |
Colin Cross | 6340ea5 | 2021-11-04 12:01:18 -0700 | [diff] [blame^] | 475 | func (p *Prebuilt) InstallBypassMake() bool { |
| 476 | return true |
| 477 | } |
| 478 | |
Paul Duffin | 851f399 | 2021-01-13 17:03:51 +0000 | [diff] [blame] | 479 | type ApexFileProperties struct { |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 480 | // the path to the prebuilt .apex file to import. |
Paul Duffin | c04fb9e | 2021-03-01 12:25:10 +0000 | [diff] [blame] | 481 | // |
| 482 | // This cannot be marked as `android:"arch_variant"` because the `prebuilt_apex` is only mutated |
| 483 | // for android_common. That is so that it will have the same arch variant as, and so be compatible |
| 484 | // with, the source `apex` module type that it replaces. |
Paul Duffin | 11216db | 2021-03-01 14:14:52 +0000 | [diff] [blame] | 485 | Src *string `android:"path"` |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 486 | Arch struct { |
| 487 | Arm struct { |
Paul Duffin | 11216db | 2021-03-01 14:14:52 +0000 | [diff] [blame] | 488 | Src *string `android:"path"` |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 489 | } |
| 490 | Arm64 struct { |
Paul Duffin | 11216db | 2021-03-01 14:14:52 +0000 | [diff] [blame] | 491 | Src *string `android:"path"` |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 492 | } |
| 493 | X86 struct { |
Paul Duffin | 11216db | 2021-03-01 14:14:52 +0000 | [diff] [blame] | 494 | Src *string `android:"path"` |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 495 | } |
| 496 | X86_64 struct { |
Paul Duffin | 11216db | 2021-03-01 14:14:52 +0000 | [diff] [blame] | 497 | Src *string `android:"path"` |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 498 | } |
| 499 | } |
Paul Duffin | 851f399 | 2021-01-13 17:03:51 +0000 | [diff] [blame] | 500 | } |
| 501 | |
Paul Duffin | c04fb9e | 2021-03-01 12:25:10 +0000 | [diff] [blame] | 502 | // prebuiltApexSelector selects the correct prebuilt APEX file for the build target. |
| 503 | // |
| 504 | // The ctx parameter can be for any module not just the prebuilt module so care must be taken not |
| 505 | // to use methods on it that are specific to the current module. |
| 506 | // |
| 507 | // See the ApexFileProperties.Src property. |
| 508 | func (p *ApexFileProperties) prebuiltApexSelector(ctx android.BaseModuleContext, prebuilt android.Module) []string { |
| 509 | multiTargets := prebuilt.MultiTargets() |
| 510 | if len(multiTargets) != 1 { |
| 511 | ctx.OtherModuleErrorf(prebuilt, "compile_multilib shouldn't be \"both\" for prebuilt_apex") |
| 512 | return nil |
Paul Duffin | 851f399 | 2021-01-13 17:03:51 +0000 | [diff] [blame] | 513 | } |
| 514 | var src string |
Paul Duffin | c04fb9e | 2021-03-01 12:25:10 +0000 | [diff] [blame] | 515 | switch multiTargets[0].Arch.ArchType { |
Paul Duffin | 851f399 | 2021-01-13 17:03:51 +0000 | [diff] [blame] | 516 | case android.Arm: |
| 517 | src = String(p.Arch.Arm.Src) |
| 518 | case android.Arm64: |
| 519 | src = String(p.Arch.Arm64.Src) |
| 520 | case android.X86: |
| 521 | src = String(p.Arch.X86.Src) |
| 522 | case android.X86_64: |
| 523 | src = String(p.Arch.X86_64.Src) |
Paul Duffin | 851f399 | 2021-01-13 17:03:51 +0000 | [diff] [blame] | 524 | } |
| 525 | if src == "" { |
| 526 | src = String(p.Src) |
| 527 | } |
Paul Duffin | 851f399 | 2021-01-13 17:03:51 +0000 | [diff] [blame] | 528 | |
Paul Duffin | c0609c6 | 2021-03-01 17:27:16 +0000 | [diff] [blame] | 529 | if src == "" { |
| 530 | ctx.OtherModuleErrorf(prebuilt, "prebuilt_apex does not support %q", multiTargets[0].Arch.String()) |
| 531 | // Drop through to return an empty string as the src (instead of nil) to avoid the prebuilt |
| 532 | // logic from reporting a more general, less useful message. |
| 533 | } |
| 534 | |
Paul Duffin | c04fb9e | 2021-03-01 12:25:10 +0000 | [diff] [blame] | 535 | return []string{src} |
Paul Duffin | 851f399 | 2021-01-13 17:03:51 +0000 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | type PrebuiltProperties struct { |
| 539 | ApexFileProperties |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 540 | |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 541 | PrebuiltCommonProperties |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 542 | } |
| 543 | |
Evgenii Stepanov | 2080bfe | 2020-07-24 15:35:40 -0700 | [diff] [blame] | 544 | func (a *Prebuilt) hasSanitizedSource(sanitizer string) bool { |
| 545 | return false |
| 546 | } |
| 547 | |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 548 | func (p *Prebuilt) OutputFiles(tag string) (android.Paths, error) { |
| 549 | switch tag { |
| 550 | case "": |
| 551 | return android.Paths{p.outputApex}, nil |
| 552 | default: |
| 553 | return nil, fmt.Errorf("unsupported module reference tag %q", tag) |
| 554 | } |
| 555 | } |
| 556 | |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 557 | // prebuilt_apex imports an `.apex` file into the build graph as if it was built with apex. |
| 558 | func PrebuiltFactory() android.Module { |
| 559 | module := &Prebuilt{} |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 560 | module.AddProperties(&module.properties) |
| 561 | module.initPrebuiltCommon(module, &module.properties.PrebuiltCommonProperties) |
Paul Duffin | 064b70c | 2020-11-02 17:32:38 +0000 | [diff] [blame] | 562 | |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 563 | return module |
| 564 | } |
| 565 | |
Paul Duffin | 5dda3e3 | 2021-05-05 14:13:27 +0100 | [diff] [blame] | 566 | func createApexSelectorModule(ctx android.TopDownMutatorContext, name string, apexFileProperties *ApexFileProperties) { |
Paul Duffin | 11216db | 2021-03-01 14:14:52 +0000 | [diff] [blame] | 567 | props := struct { |
| 568 | Name *string |
| 569 | }{ |
| 570 | Name: proptools.StringPtr(name), |
| 571 | } |
| 572 | |
| 573 | ctx.CreateModule(privateApexSelectorModuleFactory, |
| 574 | &props, |
| 575 | apexFileProperties, |
| 576 | ) |
| 577 | } |
| 578 | |
Paul Duffin | 5dda3e3 | 2021-05-05 14:13:27 +0100 | [diff] [blame] | 579 | // createDeapexerModuleIfNeeded will create a deapexer module if it is needed. |
| 580 | // |
Paul Duffin | 57f8359 | 2021-05-05 15:09:44 +0100 | [diff] [blame] | 581 | // A deapexer module is only needed when the prebuilt apex specifies one or more modules in either |
| 582 | // the `exported_java_libs` or `exported_bootclasspath_fragments` properties as that indicates that |
| 583 | // the listed modules need access to files from within the prebuilt .apex file. |
Jiakai Zhang | 774dd30 | 2021-09-26 03:54:25 +0000 | [diff] [blame] | 584 | func (p *prebuiltCommon) createDeapexerModuleIfNeeded(ctx android.TopDownMutatorContext, deapexerName string, apexFileSource string) { |
Paul Duffin | 5dda3e3 | 2021-05-05 14:13:27 +0100 | [diff] [blame] | 585 | // Only create the deapexer module if it is needed. |
Jiakai Zhang | 774dd30 | 2021-09-26 03:54:25 +0000 | [diff] [blame] | 586 | if len(p.getExportedDependencies()) == 0 { |
Paul Duffin | 5dda3e3 | 2021-05-05 14:13:27 +0100 | [diff] [blame] | 587 | return |
| 588 | } |
| 589 | |
Paul Duffin | 57f8359 | 2021-05-05 15:09:44 +0100 | [diff] [blame] | 590 | // Compute the deapexer properties from the transitive dependencies of this module. |
Paul Duffin | b508405 | 2021-06-07 10:25:31 +0100 | [diff] [blame] | 591 | commonModules := []string{} |
Paul Duffin | 034196d | 2021-06-17 15:59:07 +0100 | [diff] [blame] | 592 | exportedFiles := []string{} |
Paul Duffin | 57f8359 | 2021-05-05 15:09:44 +0100 | [diff] [blame] | 593 | ctx.WalkDeps(func(child, parent android.Module) bool { |
| 594 | tag := ctx.OtherModuleDependencyTag(child) |
| 595 | |
Paul Duffin | 7db57e0 | 2021-06-17 14:56:05 +0100 | [diff] [blame] | 596 | // If the child is not in the same apex as the parent then ignore it and all its children. |
| 597 | if !android.IsDepInSameApex(ctx, parent, child) { |
| 598 | return false |
| 599 | } |
| 600 | |
Paul Duffin | 57f8359 | 2021-05-05 15:09:44 +0100 | [diff] [blame] | 601 | name := android.RemoveOptionalPrebuiltPrefix(ctx.OtherModuleName(child)) |
Paul Duffin | 7db57e0 | 2021-06-17 14:56:05 +0100 | [diff] [blame] | 602 | if _, ok := tag.(android.RequiresFilesFromPrebuiltApexTag); ok { |
Paul Duffin | b508405 | 2021-06-07 10:25:31 +0100 | [diff] [blame] | 603 | commonModules = append(commonModules, name) |
| 604 | |
| 605 | requiredFiles := child.(android.RequiredFilesFromPrebuiltApex).RequiredFilesFromPrebuiltApex(ctx) |
Paul Duffin | 034196d | 2021-06-17 15:59:07 +0100 | [diff] [blame] | 606 | exportedFiles = append(exportedFiles, requiredFiles...) |
Paul Duffin | b508405 | 2021-06-07 10:25:31 +0100 | [diff] [blame] | 607 | |
Paul Duffin | 7db57e0 | 2021-06-17 14:56:05 +0100 | [diff] [blame] | 608 | // Visit the dependencies of this module just in case they also require files from the |
| 609 | // prebuilt apex. |
Paul Duffin | 57f8359 | 2021-05-05 15:09:44 +0100 | [diff] [blame] | 610 | return true |
| 611 | } |
| 612 | |
| 613 | return false |
| 614 | }) |
| 615 | |
Paul Duffin | 3bae068 | 2021-05-05 18:03:47 +0100 | [diff] [blame] | 616 | // Create properties for deapexer module. |
| 617 | deapexerProperties := &DeapexerProperties{ |
Paul Duffin | b508405 | 2021-06-07 10:25:31 +0100 | [diff] [blame] | 618 | // Remove any duplicates from the common modules lists as a module may be included via a direct |
Paul Duffin | 3bae068 | 2021-05-05 18:03:47 +0100 | [diff] [blame] | 619 | // dependency as well as transitive ones. |
Paul Duffin | b508405 | 2021-06-07 10:25:31 +0100 | [diff] [blame] | 620 | CommonModules: android.SortedUniqueStrings(commonModules), |
Paul Duffin | 3bae068 | 2021-05-05 18:03:47 +0100 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | // Populate the exported files property in a fixed order. |
Paul Duffin | 034196d | 2021-06-17 15:59:07 +0100 | [diff] [blame] | 624 | deapexerProperties.ExportedFiles = android.SortedUniqueStrings(exportedFiles) |
Paul Duffin | 57f8359 | 2021-05-05 15:09:44 +0100 | [diff] [blame] | 625 | |
Paul Duffin | 11216db | 2021-03-01 14:14:52 +0000 | [diff] [blame] | 626 | props := struct { |
| 627 | Name *string |
| 628 | Selected_apex *string |
| 629 | }{ |
| 630 | Name: proptools.StringPtr(deapexerName), |
| 631 | Selected_apex: proptools.StringPtr(apexFileSource), |
| 632 | } |
| 633 | ctx.CreateModule(privateDeapexerFactory, |
| 634 | &props, |
| 635 | deapexerProperties, |
| 636 | ) |
| 637 | } |
| 638 | |
Paul Duffin | 11216db | 2021-03-01 14:14:52 +0000 | [diff] [blame] | 639 | func apexSelectorModuleName(baseModuleName string) string { |
| 640 | return baseModuleName + ".apex.selector" |
| 641 | } |
| 642 | |
Paul Duffin | 064b70c | 2020-11-02 17:32:38 +0000 | [diff] [blame] | 643 | func prebuiltApexExportedModuleName(ctx android.BottomUpMutatorContext, name string) string { |
| 644 | // The prebuilt_apex should be depending on prebuilt modules but as this runs after |
| 645 | // prebuilt_rename the prebuilt module may or may not be using the prebuilt_ prefixed named. So, |
| 646 | // check to see if the prefixed name is in use first, if it is then use that, otherwise assume |
| 647 | // the unprefixed name is the one to use. If the unprefixed one turns out to be a source module |
| 648 | // and not a renamed prebuilt module then that will be detected and reported as an error when |
| 649 | // processing the dependency in ApexInfoMutator(). |
Paul Duffin | 864116c | 2021-04-02 10:24:13 +0100 | [diff] [blame] | 650 | prebuiltName := android.PrebuiltNameFromSource(name) |
Paul Duffin | 064b70c | 2020-11-02 17:32:38 +0000 | [diff] [blame] | 651 | if ctx.OtherModuleExists(prebuiltName) { |
| 652 | name = prebuiltName |
| 653 | } |
| 654 | return name |
| 655 | } |
| 656 | |
Paul Duffin | a713942 | 2021-02-08 11:01:58 +0000 | [diff] [blame] | 657 | type exportedDependencyTag struct { |
| 658 | blueprint.BaseDependencyTag |
| 659 | name string |
| 660 | } |
| 661 | |
| 662 | // Mark this tag so dependencies that use it are excluded from visibility enforcement. |
| 663 | // |
| 664 | // This does allow any prebuilt_apex to reference any module which does open up a small window for |
| 665 | // restricted visibility modules to be referenced from the wrong prebuilt_apex. However, doing so |
| 666 | // avoids opening up a much bigger window by widening the visibility of modules that need files |
| 667 | // provided by the prebuilt_apex to include all the possible locations they may be defined, which |
| 668 | // could include everything below vendor/. |
| 669 | // |
| 670 | // A prebuilt_apex that references a module via this tag will have to contain the appropriate files |
| 671 | // corresponding to that module, otherwise it will fail when attempting to retrieve the files from |
| 672 | // the .apex file. It will also have to be included in the module's apex_available property too. |
| 673 | // That makes it highly unlikely that a prebuilt_apex would reference a restricted module |
| 674 | // incorrectly. |
| 675 | func (t exportedDependencyTag) ExcludeFromVisibilityEnforcement() {} |
| 676 | |
Paul Duffin | 7db57e0 | 2021-06-17 14:56:05 +0100 | [diff] [blame] | 677 | func (t exportedDependencyTag) RequiresFilesFromPrebuiltApex() {} |
| 678 | |
| 679 | var _ android.RequiresFilesFromPrebuiltApexTag = exportedDependencyTag{} |
| 680 | |
Paul Duffin | a713942 | 2021-02-08 11:01:58 +0000 | [diff] [blame] | 681 | var ( |
Jiakai Zhang | 774dd30 | 2021-09-26 03:54:25 +0000 | [diff] [blame] | 682 | exportedJavaLibTag = exportedDependencyTag{name: "exported_java_libs"} |
| 683 | exportedBootclasspathFragmentTag = exportedDependencyTag{name: "exported_bootclasspath_fragments"} |
| 684 | exportedSystemserverclasspathFragmentTag = exportedDependencyTag{name: "exported_systemserverclasspath_fragments"} |
Paul Duffin | a713942 | 2021-02-08 11:01:58 +0000 | [diff] [blame] | 685 | ) |
| 686 | |
Paul Duffin | 5dda3e3 | 2021-05-05 14:13:27 +0100 | [diff] [blame] | 687 | var _ prebuiltApexModuleCreator = (*Prebuilt)(nil) |
| 688 | |
| 689 | // createPrebuiltApexModules creates modules necessary to export files from the prebuilt apex to the |
| 690 | // build. |
| 691 | // |
| 692 | // If this needs to make files from within a `.apex` file available for use by other Soong modules, |
| 693 | // e.g. make dex implementation jars available for java_import modules listed in exported_java_libs, |
| 694 | // it does so as follows: |
| 695 | // |
| 696 | // 1. It creates a `deapexer` module that actually extracts the files from the `.apex` file and |
| 697 | // makes them available for use by other modules, at both Soong and ninja levels. |
| 698 | // |
| 699 | // 2. It adds a dependency onto those modules and creates an apex specific variant similar to what |
| 700 | // an `apex` module does. That ensures that code which looks for specific apex variant, e.g. |
| 701 | // dexpreopt, will work the same way from source and prebuilt. |
| 702 | // |
| 703 | // 3. The `deapexer` module adds a dependency from the modules that require the exported files onto |
| 704 | // itself so that they can retrieve the file paths to those files. |
| 705 | // |
| 706 | // It also creates a child module `selector` that is responsible for selecting the appropriate |
| 707 | // input apex for both the prebuilt_apex and the deapexer. That is needed for a couple of reasons: |
| 708 | // 1. To dedup the selection logic so it only runs in one module. |
| 709 | // 2. To allow the deapexer to be wired up to a different source for the input apex, e.g. an |
| 710 | // `apex_set`. |
| 711 | // |
| 712 | // prebuilt_apex |
| 713 | // / | \ |
| 714 | // / | \ |
| 715 | // V V V |
| 716 | // selector <--- deapexer <--- exported java lib |
| 717 | // |
| 718 | func (p *Prebuilt) createPrebuiltApexModules(ctx android.TopDownMutatorContext) { |
| 719 | baseModuleName := p.BaseModuleName() |
| 720 | |
| 721 | apexSelectorModuleName := apexSelectorModuleName(baseModuleName) |
| 722 | createApexSelectorModule(ctx, apexSelectorModuleName, &p.properties.ApexFileProperties) |
| 723 | |
| 724 | apexFileSource := ":" + apexSelectorModuleName |
Jiakai Zhang | 774dd30 | 2021-09-26 03:54:25 +0000 | [diff] [blame] | 725 | p.createDeapexerModuleIfNeeded(ctx, deapexerModuleName(baseModuleName), apexFileSource) |
Paul Duffin | 5dda3e3 | 2021-05-05 14:13:27 +0100 | [diff] [blame] | 726 | |
| 727 | // Add a source reference to retrieve the selected apex from the selector module. |
Paul Duffin | bb0dc13 | 2021-05-05 16:58:08 +0100 | [diff] [blame] | 728 | p.prebuiltCommonProperties.Selected_apex = proptools.StringPtr(apexFileSource) |
Paul Duffin | 5dda3e3 | 2021-05-05 14:13:27 +0100 | [diff] [blame] | 729 | } |
| 730 | |
Paul Duffin | 57f8359 | 2021-05-05 15:09:44 +0100 | [diff] [blame] | 731 | func (p *Prebuilt) ComponentDepsMutator(ctx android.BottomUpMutatorContext) { |
| 732 | p.prebuiltApexContentsDeps(ctx) |
Paul Duffin | 064b70c | 2020-11-02 17:32:38 +0000 | [diff] [blame] | 733 | } |
| 734 | |
| 735 | var _ ApexInfoMutator = (*Prebuilt)(nil) |
| 736 | |
Paul Duffin | 064b70c | 2020-11-02 17:32:38 +0000 | [diff] [blame] | 737 | func (p *Prebuilt) ApexInfoMutator(mctx android.TopDownMutatorContext) { |
Paul Duffin | dfd3326 | 2021-04-06 17:02:08 +0100 | [diff] [blame] | 738 | p.apexInfoMutator(mctx) |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 739 | } |
| 740 | |
| 741 | func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 742 | // TODO(jungjw): Check the key validity. |
Paul Duffin | bb0dc13 | 2021-05-05 16:58:08 +0100 | [diff] [blame] | 743 | p.inputApex = android.OptionalPathForModuleSrc(ctx, p.prebuiltCommonProperties.Selected_apex).Path() |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 744 | p.installDir = android.PathForModuleInstall(ctx, "apex") |
| 745 | p.installFilename = p.InstallFilename() |
| 746 | if !strings.HasSuffix(p.installFilename, imageApexSuffix) { |
| 747 | ctx.ModuleErrorf("filename should end in %s for prebuilt_apex", imageApexSuffix) |
| 748 | } |
| 749 | p.outputApex = android.PathForModuleOut(ctx, p.installFilename) |
| 750 | ctx.Build(pctx, android.BuildParams{ |
| 751 | Rule: android.Cp, |
| 752 | Input: p.inputApex, |
| 753 | Output: p.outputApex, |
| 754 | }) |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 755 | |
| 756 | if p.prebuiltCommon.checkForceDisable(ctx) { |
Colin Cross | a9c8c9f | 2020-12-16 10:20:23 -0800 | [diff] [blame] | 757 | p.HideFromMake() |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 758 | return |
| 759 | } |
| 760 | |
Paul Duffin | c30aea2 | 2021-06-15 19:10:11 +0100 | [diff] [blame] | 761 | // Save the files that need to be made available to Make. |
| 762 | p.initApexFilesForAndroidMk(ctx) |
| 763 | |
Colin Cross | ccba23d | 2021-11-12 19:01:29 +0000 | [diff] [blame] | 764 | // in case that prebuilt_apex replaces source apex (using prefer: prop) |
Colin Cross | 6340ea5 | 2021-11-04 12:01:18 -0700 | [diff] [blame^] | 765 | p.compatSymlinks = makeCompatSymlinks(p.BaseModuleName(), ctx, true) |
Colin Cross | ccba23d | 2021-11-12 19:01:29 +0000 | [diff] [blame] | 766 | // or that prebuilt_apex overrides other apexes (using overrides: prop) |
| 767 | for _, overridden := range p.prebuiltCommonProperties.Overrides { |
Colin Cross | 6340ea5 | 2021-11-04 12:01:18 -0700 | [diff] [blame^] | 768 | p.compatSymlinks = append(p.compatSymlinks, makeCompatSymlinks(overridden, ctx, true)...) |
| 769 | } |
| 770 | |
| 771 | if p.installable() { |
| 772 | p.installedFile = ctx.InstallFile(p.installDir, p.installFilename, p.inputApex, p.compatSymlinks.Paths()...) |
Jooyung Han | 002ab68 | 2020-01-08 01:57:58 +0900 | [diff] [blame] | 773 | } |
Jiyong Park | 09d7752 | 2019-11-18 11:16:27 +0900 | [diff] [blame] | 774 | } |
| 775 | |
Paul Duffin | 2470467 | 2021-04-06 16:09:30 +0100 | [diff] [blame] | 776 | // prebuiltApexExtractorModule is a private module type that is only created by the prebuilt_apex |
| 777 | // module. It extracts the correct apex to use and makes it available for use by apex_set. |
| 778 | type prebuiltApexExtractorModule struct { |
| 779 | android.ModuleBase |
| 780 | |
| 781 | properties ApexExtractorProperties |
| 782 | |
| 783 | extractedApex android.WritablePath |
| 784 | } |
| 785 | |
| 786 | func privateApexExtractorModuleFactory() android.Module { |
| 787 | module := &prebuiltApexExtractorModule{} |
| 788 | module.AddProperties( |
| 789 | &module.properties, |
| 790 | ) |
| 791 | android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon) |
| 792 | return module |
| 793 | } |
| 794 | |
| 795 | func (p *prebuiltApexExtractorModule) Srcs() android.Paths { |
| 796 | return android.Paths{p.extractedApex} |
| 797 | } |
| 798 | |
| 799 | func (p *prebuiltApexExtractorModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 800 | srcsSupplier := func(ctx android.BaseModuleContext, prebuilt android.Module) []string { |
| 801 | return p.properties.prebuiltSrcs(ctx) |
| 802 | } |
| 803 | apexSet := android.SingleSourcePathFromSupplier(ctx, srcsSupplier, "set") |
| 804 | p.extractedApex = android.PathForModuleOut(ctx, "extracted", apexSet.Base()) |
| 805 | ctx.Build(pctx, |
| 806 | android.BuildParams{ |
| 807 | Rule: extractMatchingApex, |
| 808 | Description: "Extract an apex from an apex set", |
| 809 | Inputs: android.Paths{apexSet}, |
| 810 | Output: p.extractedApex, |
| 811 | Args: map[string]string{ |
| 812 | "abis": strings.Join(java.SupportedAbis(ctx), ","), |
| 813 | "allow-prereleased": strconv.FormatBool(proptools.Bool(p.properties.Prerelease)), |
| 814 | "sdk-version": ctx.Config().PlatformSdkVersion().String(), |
| 815 | }, |
| 816 | }) |
| 817 | } |
| 818 | |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 819 | type ApexSet struct { |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 820 | prebuiltCommon |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 821 | |
| 822 | properties ApexSetProperties |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 823 | } |
| 824 | |
Paul Duffin | 2470467 | 2021-04-06 16:09:30 +0100 | [diff] [blame] | 825 | type ApexExtractorProperties struct { |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 826 | // the .apks file path that contains prebuilt apex files to be extracted. |
| 827 | Set *string |
| 828 | |
Evgenii Stepanov | 2080bfe | 2020-07-24 15:35:40 -0700 | [diff] [blame] | 829 | Sanitized struct { |
| 830 | None struct { |
| 831 | Set *string |
| 832 | } |
| 833 | Address struct { |
| 834 | Set *string |
| 835 | } |
| 836 | Hwaddress struct { |
| 837 | Set *string |
| 838 | } |
| 839 | } |
| 840 | |
Paul Duffin | 2470467 | 2021-04-06 16:09:30 +0100 | [diff] [blame] | 841 | // apexes in this set use prerelease SDK version |
| 842 | Prerelease *bool |
| 843 | } |
| 844 | |
| 845 | func (e *ApexExtractorProperties) prebuiltSrcs(ctx android.BaseModuleContext) []string { |
| 846 | var srcs []string |
| 847 | if e.Set != nil { |
| 848 | srcs = append(srcs, *e.Set) |
| 849 | } |
| 850 | |
| 851 | var sanitizers []string |
| 852 | if ctx.Host() { |
| 853 | sanitizers = ctx.Config().SanitizeHost() |
| 854 | } else { |
| 855 | sanitizers = ctx.Config().SanitizeDevice() |
| 856 | } |
| 857 | |
| 858 | if android.InList("address", sanitizers) && e.Sanitized.Address.Set != nil { |
| 859 | srcs = append(srcs, *e.Sanitized.Address.Set) |
| 860 | } else if android.InList("hwaddress", sanitizers) && e.Sanitized.Hwaddress.Set != nil { |
| 861 | srcs = append(srcs, *e.Sanitized.Hwaddress.Set) |
| 862 | } else if e.Sanitized.None.Set != nil { |
| 863 | srcs = append(srcs, *e.Sanitized.None.Set) |
| 864 | } |
| 865 | |
| 866 | return srcs |
| 867 | } |
| 868 | |
| 869 | type ApexSetProperties struct { |
| 870 | ApexExtractorProperties |
| 871 | |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 872 | PrebuiltCommonProperties |
Evgenii Stepanov | 2080bfe | 2020-07-24 15:35:40 -0700 | [diff] [blame] | 873 | } |
| 874 | |
| 875 | func (a *ApexSet) hasSanitizedSource(sanitizer string) bool { |
| 876 | if sanitizer == "address" { |
| 877 | return a.properties.Sanitized.Address.Set != nil |
| 878 | } |
| 879 | if sanitizer == "hwaddress" { |
| 880 | return a.properties.Sanitized.Hwaddress.Set != nil |
| 881 | } |
| 882 | |
| 883 | return false |
| 884 | } |
| 885 | |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 886 | // prebuilt_apex imports an `.apex` file into the build graph as if it was built with apex. |
| 887 | func apexSetFactory() android.Module { |
| 888 | module := &ApexSet{} |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 889 | module.AddProperties(&module.properties) |
| 890 | module.initPrebuiltCommon(module, &module.properties.PrebuiltCommonProperties) |
Paul Duffin | 2470467 | 2021-04-06 16:09:30 +0100 | [diff] [blame] | 891 | |
Paul Duffin | 2470467 | 2021-04-06 16:09:30 +0100 | [diff] [blame] | 892 | return module |
| 893 | } |
| 894 | |
Paul Duffin | 5dda3e3 | 2021-05-05 14:13:27 +0100 | [diff] [blame] | 895 | func createApexExtractorModule(ctx android.TopDownMutatorContext, name string, apexExtractorProperties *ApexExtractorProperties) { |
Paul Duffin | 2470467 | 2021-04-06 16:09:30 +0100 | [diff] [blame] | 896 | props := struct { |
| 897 | Name *string |
| 898 | }{ |
| 899 | Name: proptools.StringPtr(name), |
Evgenii Stepanov | 2080bfe | 2020-07-24 15:35:40 -0700 | [diff] [blame] | 900 | } |
| 901 | |
Paul Duffin | 2470467 | 2021-04-06 16:09:30 +0100 | [diff] [blame] | 902 | ctx.CreateModule(privateApexExtractorModuleFactory, |
| 903 | &props, |
| 904 | apexExtractorProperties, |
| 905 | ) |
| 906 | } |
| 907 | |
| 908 | func apexExtractorModuleName(baseModuleName string) string { |
| 909 | return baseModuleName + ".apex.extractor" |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 910 | } |
| 911 | |
Paul Duffin | 5dda3e3 | 2021-05-05 14:13:27 +0100 | [diff] [blame] | 912 | var _ prebuiltApexModuleCreator = (*ApexSet)(nil) |
| 913 | |
| 914 | // createPrebuiltApexModules creates modules necessary to export files from the apex set to other |
| 915 | // modules. |
| 916 | // |
| 917 | // This effectively does for apex_set what Prebuilt.createPrebuiltApexModules does for a |
| 918 | // prebuilt_apex except that instead of creating a selector module which selects one .apex file |
| 919 | // from those provided this creates an extractor module which extracts the appropriate .apex file |
| 920 | // from the zip file containing them. |
| 921 | func (a *ApexSet) createPrebuiltApexModules(ctx android.TopDownMutatorContext) { |
| 922 | baseModuleName := a.BaseModuleName() |
| 923 | |
| 924 | apexExtractorModuleName := apexExtractorModuleName(baseModuleName) |
| 925 | createApexExtractorModule(ctx, apexExtractorModuleName, &a.properties.ApexExtractorProperties) |
| 926 | |
| 927 | apexFileSource := ":" + apexExtractorModuleName |
Jiakai Zhang | 774dd30 | 2021-09-26 03:54:25 +0000 | [diff] [blame] | 928 | a.createDeapexerModuleIfNeeded(ctx, deapexerModuleName(baseModuleName), apexFileSource) |
Paul Duffin | 5dda3e3 | 2021-05-05 14:13:27 +0100 | [diff] [blame] | 929 | |
| 930 | // After passing the arch specific src properties to the creating the apex selector module |
Paul Duffin | bb0dc13 | 2021-05-05 16:58:08 +0100 | [diff] [blame] | 931 | a.prebuiltCommonProperties.Selected_apex = proptools.StringPtr(apexFileSource) |
Paul Duffin | 5dda3e3 | 2021-05-05 14:13:27 +0100 | [diff] [blame] | 932 | } |
| 933 | |
Paul Duffin | 57f8359 | 2021-05-05 15:09:44 +0100 | [diff] [blame] | 934 | func (a *ApexSet) ComponentDepsMutator(ctx android.BottomUpMutatorContext) { |
| 935 | a.prebuiltApexContentsDeps(ctx) |
Paul Duffin | f58fd9a | 2021-04-06 16:00:22 +0100 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | var _ ApexInfoMutator = (*ApexSet)(nil) |
| 939 | |
| 940 | func (a *ApexSet) ApexInfoMutator(mctx android.TopDownMutatorContext) { |
| 941 | a.apexInfoMutator(mctx) |
| 942 | } |
| 943 | |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 944 | func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 945 | a.installFilename = a.InstallFilename() |
Samiul Islam | 7c02e26 | 2021-09-08 17:48:28 +0100 | [diff] [blame] | 946 | if !strings.HasSuffix(a.installFilename, imageApexSuffix) && !strings.HasSuffix(a.installFilename, imageCapexSuffix) { |
| 947 | ctx.ModuleErrorf("filename should end in %s or %s for apex_set", imageApexSuffix, imageCapexSuffix) |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 948 | } |
| 949 | |
Paul Duffin | bb0dc13 | 2021-05-05 16:58:08 +0100 | [diff] [blame] | 950 | inputApex := android.OptionalPathForModuleSrc(ctx, a.prebuiltCommonProperties.Selected_apex).Path() |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 951 | a.outputApex = android.PathForModuleOut(ctx, a.installFilename) |
Paul Duffin | 2470467 | 2021-04-06 16:09:30 +0100 | [diff] [blame] | 952 | ctx.Build(pctx, android.BuildParams{ |
| 953 | Rule: android.Cp, |
| 954 | Input: inputApex, |
| 955 | Output: a.outputApex, |
| 956 | }) |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 957 | |
| 958 | if a.prebuiltCommon.checkForceDisable(ctx) { |
Colin Cross | a9c8c9f | 2020-12-16 10:20:23 -0800 | [diff] [blame] | 959 | a.HideFromMake() |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 960 | return |
| 961 | } |
| 962 | |
Paul Duffin | c30aea2 | 2021-06-15 19:10:11 +0100 | [diff] [blame] | 963 | // Save the files that need to be made available to Make. |
| 964 | a.initApexFilesForAndroidMk(ctx) |
| 965 | |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 966 | a.installDir = android.PathForModuleInstall(ctx, "apex") |
| 967 | if a.installable() { |
| 968 | ctx.InstallFile(a.installDir, a.installFilename, a.outputApex) |
| 969 | } |
| 970 | |
| 971 | // in case that apex_set replaces source apex (using prefer: prop) |
Colin Cross | 6340ea5 | 2021-11-04 12:01:18 -0700 | [diff] [blame^] | 972 | a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx, true) |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 973 | // or that apex_set overrides other apexes (using overrides: prop) |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 974 | for _, overridden := range a.prebuiltCommonProperties.Overrides { |
Colin Cross | 6340ea5 | 2021-11-04 12:01:18 -0700 | [diff] [blame^] | 975 | a.compatSymlinks = append(a.compatSymlinks, makeCompatSymlinks(overridden, ctx, true)...) |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 976 | } |
| 977 | } |
| 978 | |
Paul Duffin | ef6b695 | 2021-06-15 11:34:01 +0100 | [diff] [blame] | 979 | type systemExtContext struct { |
| 980 | android.ModuleContext |
| 981 | } |
| 982 | |
| 983 | func (*systemExtContext) SystemExtSpecific() bool { |
| 984 | return true |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 985 | } |