Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1 | // Copyright (C) 2018 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" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 19 | "path/filepath" |
Jiyong Park | ab3ceb3 | 2018-10-10 14:05:29 +0900 | [diff] [blame] | 20 | "sort" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 21 | "strings" |
| 22 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 23 | "github.com/google/blueprint" |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 24 | "github.com/google/blueprint/bootstrap" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 25 | "github.com/google/blueprint/proptools" |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 26 | |
| 27 | "android/soong/android" |
markchien | 2f59ec9 | 2020-09-02 16:23:38 +0800 | [diff] [blame] | 28 | "android/soong/bpf" |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 29 | "android/soong/cc" |
| 30 | prebuilt_etc "android/soong/etc" |
| 31 | "android/soong/java" |
| 32 | "android/soong/python" |
| 33 | "android/soong/sh" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 34 | ) |
| 35 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame^] | 36 | func init() { |
| 37 | android.RegisterModuleType("apex", BundleFactory) |
| 38 | android.RegisterModuleType("apex_test", testApexBundleFactory) |
| 39 | android.RegisterModuleType("apex_vndk", vndkApexBundleFactory) |
| 40 | android.RegisterModuleType("apex_defaults", defaultsFactory) |
| 41 | android.RegisterModuleType("prebuilt_apex", PrebuiltFactory) |
| 42 | android.RegisterModuleType("override_apex", overrideApexFactory) |
| 43 | android.RegisterModuleType("apex_set", apexSetFactory) |
| 44 | |
| 45 | android.PreDepsMutators(RegisterPreDepsMutators) |
| 46 | android.PostDepsMutators(RegisterPostDepsMutators) |
| 47 | } |
| 48 | |
| 49 | func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) { |
| 50 | ctx.TopDown("apex_vndk", apexVndkMutator).Parallel() |
| 51 | ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel() |
| 52 | } |
| 53 | |
| 54 | func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) { |
| 55 | ctx.TopDown("apex_deps", apexDepsMutator).Parallel() |
| 56 | ctx.BottomUp("apex_unique", apexUniqueVariationsMutator).Parallel() |
| 57 | ctx.BottomUp("apex_test_for_deps", apexTestForDepsMutator).Parallel() |
| 58 | ctx.BottomUp("apex_test_for", apexTestForMutator).Parallel() |
| 59 | ctx.BottomUp("apex", apexMutator).Parallel() |
| 60 | ctx.BottomUp("apex_directly_in_any", apexDirectlyInAnyMutator).Parallel() |
| 61 | ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel() |
| 62 | ctx.BottomUp("mark_platform_availability", markPlatformAvailability).Parallel() |
| 63 | } |
| 64 | |
| 65 | type apexBundleProperties struct { |
| 66 | // Json manifest file describing meta info of this APEX bundle. Default: |
| 67 | // "apex_manifest.json" |
| 68 | Manifest *string `android:"path"` |
| 69 | |
| 70 | // AndroidManifest.xml file used for the zip container of this APEX bundle. |
| 71 | // If unspecified, a default one is automatically generated. |
| 72 | AndroidManifest *string `android:"path"` |
| 73 | |
| 74 | // Canonical name of the APEX bundle. Used to determine the path to the activated APEX on |
| 75 | // device (/apex/<apex_name>). |
| 76 | // If unspecified, defaults to the value of name. |
| 77 | Apex_name *string |
| 78 | |
| 79 | // Determines the file contexts file for setting security context to each file in this APEX bundle. |
| 80 | // For platform APEXes, this should points to a file under /system/sepolicy |
| 81 | // Default: /system/sepolicy/apex/<module_name>_file_contexts. |
| 82 | File_contexts *string `android:"path"` |
| 83 | |
| 84 | ApexNativeDependencies |
| 85 | |
| 86 | // List of java libraries that are embedded inside this APEX bundle |
| 87 | Java_libs []string |
| 88 | |
| 89 | // List of prebuilt files that are embedded inside this APEX bundle |
| 90 | Prebuilts []string |
| 91 | |
| 92 | // List of BPF programs inside APEX |
| 93 | Bpfs []string |
| 94 | |
| 95 | // Name of the apex_key module that provides the private key to sign APEX |
| 96 | Key *string |
| 97 | |
| 98 | // The type of APEX to build. Controls what the APEX payload is. Either |
| 99 | // 'image', 'zip' or 'both'. Default: 'image'. |
| 100 | Payload_type *string |
| 101 | |
| 102 | // The name of a certificate in the default certificate directory, blank to use the default product certificate, |
| 103 | // or an android_app_certificate module name in the form ":module". |
| 104 | Certificate *string |
| 105 | |
| 106 | // Whether this APEX is installable to one of the partitions. Default: true. |
| 107 | Installable *bool |
| 108 | |
| 109 | // For native libraries and binaries, use the vendor variant instead of the core (platform) variant. |
| 110 | // Default is false. |
| 111 | Use_vendor *bool |
| 112 | |
| 113 | // For telling the apex to ignore special handling for system libraries such as bionic. Default is false. |
| 114 | Ignore_system_library_special_case *bool |
| 115 | |
| 116 | Multilib apexMultilibProperties |
| 117 | |
| 118 | // List of sanitizer names that this APEX is enabled for |
| 119 | SanitizerNames []string `blueprint:"mutated"` |
| 120 | |
| 121 | PreventInstall bool `blueprint:"mutated"` |
| 122 | |
| 123 | HideFromMake bool `blueprint:"mutated"` |
| 124 | |
| 125 | // package format of this apex variant; could be non-flattened, flattened, or zip. |
| 126 | // imageApex, zipApex or flattened |
| 127 | ApexType apexPackaging `blueprint:"mutated"` |
| 128 | |
| 129 | // List of SDKs that are used to build this APEX. A reference to an SDK should be either |
| 130 | // `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current` |
| 131 | // is implied. This value affects all modules included in this APEX. In other words, they are |
| 132 | // also built with the SDKs specified here. |
| 133 | Uses_sdks []string |
| 134 | |
| 135 | // Whenever apex_payload.img of the APEX should include dm-verity hashtree. |
| 136 | // Should be only used in tests#. |
| 137 | Test_only_no_hashtree *bool |
| 138 | |
| 139 | // Whenever apex_payload.img of the APEX should not be dm-verity signed. |
| 140 | // Should be only used in tests#. |
| 141 | Test_only_unsigned_payload *bool |
| 142 | |
| 143 | IsCoverageVariant bool `blueprint:"mutated"` |
| 144 | |
| 145 | // Whether this APEX is considered updatable or not. When set to true, this will enforce additional |
| 146 | // rules for making sure that the APEX is truly updatable. |
| 147 | // - To be updatable, min_sdk_version should be set as well |
| 148 | // This will also disable the size optimizations like symlinking to the system libs. |
| 149 | // Default is false. |
| 150 | Updatable *bool |
| 151 | |
| 152 | // The minimum SDK version that this apex must be compatibile with. |
| 153 | Min_sdk_version *string |
| 154 | |
| 155 | // If set true, VNDK libs are considered as stable libs and are not included in this apex. |
| 156 | // Should be only used in non-system apexes (e.g. vendor: true). |
| 157 | // Default is false. |
| 158 | Use_vndk_as_stable *bool |
| 159 | |
| 160 | // The type of filesystem to use for an image apex. Either 'ext4' or 'f2fs'. |
| 161 | // Default 'ext4'. |
| 162 | Payload_fs_type *string |
| 163 | } |
| 164 | |
| 165 | type ApexNativeDependencies struct { |
| 166 | // List of native libraries |
| 167 | Native_shared_libs []string |
| 168 | |
| 169 | // List of JNI libraries |
| 170 | Jni_libs []string |
| 171 | |
| 172 | // List of native executables |
| 173 | Binaries []string |
| 174 | |
| 175 | // List of native tests |
| 176 | Tests []string |
| 177 | } |
| 178 | |
| 179 | type apexMultilibProperties struct { |
| 180 | // Native dependencies whose compile_multilib is "first" |
| 181 | First ApexNativeDependencies |
| 182 | |
| 183 | // Native dependencies whose compile_multilib is "both" |
| 184 | Both ApexNativeDependencies |
| 185 | |
| 186 | // Native dependencies whose compile_multilib is "prefer32" |
| 187 | Prefer32 ApexNativeDependencies |
| 188 | |
| 189 | // Native dependencies whose compile_multilib is "32" |
| 190 | Lib32 ApexNativeDependencies |
| 191 | |
| 192 | // Native dependencies whose compile_multilib is "64" |
| 193 | Lib64 ApexNativeDependencies |
| 194 | } |
| 195 | |
| 196 | type apexTargetBundleProperties struct { |
| 197 | Target struct { |
| 198 | // Multilib properties only for android. |
| 199 | Android struct { |
| 200 | Multilib apexMultilibProperties |
| 201 | } |
| 202 | |
| 203 | // Multilib properties only for host. |
| 204 | Host struct { |
| 205 | Multilib apexMultilibProperties |
| 206 | } |
| 207 | |
| 208 | // Multilib properties only for host linux_bionic. |
| 209 | Linux_bionic struct { |
| 210 | Multilib apexMultilibProperties |
| 211 | } |
| 212 | |
| 213 | // Multilib properties only for host linux_glibc. |
| 214 | Linux_glibc struct { |
| 215 | Multilib apexMultilibProperties |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | type overridableProperties struct { |
| 221 | // List of APKs to package inside APEX |
| 222 | Apps []string |
| 223 | |
| 224 | // List of runtime resource overlays (RROs) inside APEX |
| 225 | Rros []string |
| 226 | |
| 227 | // Names of modules to be overridden. Listed modules can only be other binaries |
| 228 | // (in Make or Soong). |
| 229 | // This does not completely prevent installation of the overridden binaries, but if both |
| 230 | // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed |
| 231 | // from PRODUCT_PACKAGES. |
| 232 | Overrides []string |
| 233 | |
| 234 | // Logging Parent value |
| 235 | Logging_parent string |
| 236 | |
| 237 | // Apex Container Package Name. |
| 238 | // Override value for attribute package:name in AndroidManifest.xml |
| 239 | Package_name string |
| 240 | |
| 241 | // A txt file containing list of files that are allowed to be included in this APEX. |
| 242 | Allowed_files *string `android:"path"` |
| 243 | } |
| 244 | |
| 245 | type apexBundle struct { |
| 246 | android.ModuleBase |
| 247 | android.DefaultableModuleBase |
| 248 | android.OverridableModuleBase |
| 249 | android.SdkBase |
| 250 | |
| 251 | properties apexBundleProperties |
| 252 | targetProperties apexTargetBundleProperties |
| 253 | overridableProperties overridableProperties |
| 254 | |
| 255 | // specific to apex_vndk modules |
| 256 | vndkProperties apexVndkProperties |
| 257 | |
| 258 | bundleModuleFile android.WritablePath |
| 259 | outputFile android.WritablePath |
| 260 | installDir android.InstallPath |
| 261 | |
| 262 | prebuiltFileToDelete string |
| 263 | |
| 264 | public_key_file android.Path |
| 265 | private_key_file android.Path |
| 266 | |
| 267 | container_certificate_file android.Path |
| 268 | container_private_key_file android.Path |
| 269 | |
| 270 | fileContexts android.WritablePath |
| 271 | |
| 272 | // list of files to be included in this apex |
| 273 | filesInfo []apexFile |
| 274 | |
| 275 | // list of module names that should be installed along with this APEX |
| 276 | requiredDeps []string |
| 277 | |
| 278 | // list of module names that this APEX is including (to be shown via *-deps-info target) |
| 279 | android.ApexBundleDepsInfo |
| 280 | |
| 281 | testApex bool |
| 282 | vndkApex bool |
| 283 | artApex bool |
| 284 | primaryApexType bool |
| 285 | |
| 286 | manifestJsonOut android.WritablePath |
| 287 | manifestPbOut android.WritablePath |
| 288 | |
| 289 | // list of commands to create symlinks for backward compatibility. |
| 290 | // these commands will be attached as LOCAL_POST_INSTALL_CMD to |
| 291 | // apex package itself(for unflattened build) or apex_manifest(for flattened build) |
| 292 | // so that compat symlinks are always installed regardless of TARGET_FLATTEN_APEX setting. |
| 293 | compatSymlinks []string |
| 294 | |
| 295 | // Suffix of module name in Android.mk |
| 296 | // ".flattened", ".apex", ".zipapex", or "" |
| 297 | suffix string |
| 298 | |
| 299 | installedFilesFile android.WritablePath |
| 300 | |
| 301 | // Whether to create symlink to the system file instead of having a file |
| 302 | // inside the apex or not |
| 303 | linkToSystemLib bool |
| 304 | |
| 305 | // Struct holding the merged notice file paths in different formats |
| 306 | mergedNotices android.NoticeOutputs |
| 307 | |
| 308 | // Optional list of lint report zip files for apexes that contain java or app modules |
| 309 | lintReports android.Paths |
| 310 | |
| 311 | payloadFsType fsType |
| 312 | |
| 313 | distFiles android.TaggedDistFiles |
| 314 | } |
| 315 | |
| 316 | type apexFileClass int |
| 317 | |
Jooyung Han | 72bd2f8 | 2019-10-23 16:46:38 +0900 | [diff] [blame] | 318 | const ( |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame^] | 319 | etc apexFileClass = iota |
| 320 | nativeSharedLib |
| 321 | nativeExecutable |
| 322 | shBinary |
| 323 | pyBinary |
| 324 | goBinary |
| 325 | javaSharedLib |
| 326 | nativeTest |
| 327 | app |
| 328 | appSet |
Jooyung Han | 72bd2f8 | 2019-10-23 16:46:38 +0900 | [diff] [blame] | 329 | ) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 330 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame^] | 331 | func (class apexFileClass) NameInMake() string { |
| 332 | switch class { |
| 333 | case etc: |
| 334 | return "ETC" |
| 335 | case nativeSharedLib: |
| 336 | return "SHARED_LIBRARIES" |
| 337 | case nativeExecutable, shBinary, pyBinary, goBinary: |
| 338 | return "EXECUTABLES" |
| 339 | case javaSharedLib: |
| 340 | return "JAVA_LIBRARIES" |
| 341 | case nativeTest: |
| 342 | return "NATIVE_TESTS" |
| 343 | case app, appSet: |
| 344 | // b/142537672 Why isn't this APP? We want to have full control over |
| 345 | // the paths and file names of the apk file under the flattend APEX. |
| 346 | // If this is set to APP, then the paths and file names are modified |
| 347 | // by the Make build system. For example, it is installed to |
| 348 | // /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of |
| 349 | // /system/apex/<apexname>/app/<Appname> because the build system automatically |
| 350 | // appends module name (which is <apexname>.<Appname> to the path. |
| 351 | return "ETC" |
| 352 | default: |
| 353 | panic(fmt.Errorf("unknown class %d", class)) |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | // apexFile represents a file in an APEX bundle |
| 358 | type apexFile struct { |
| 359 | builtFile android.Path |
| 360 | stem string |
| 361 | // Module name of `module` in AndroidMk. Note the generated AndroidMk module for |
| 362 | // apexFile is named something like <AndroidMk module name>.<apex name>[<apex suffix>] |
| 363 | androidMkModuleName string |
| 364 | installDir string |
| 365 | class apexFileClass |
| 366 | module android.Module |
| 367 | // list of symlinks that will be created in installDir that point to this apexFile |
| 368 | symlinks []string |
| 369 | dataPaths []android.DataPath |
| 370 | transitiveDep bool |
| 371 | moduleDir string |
| 372 | |
| 373 | requiredModuleNames []string |
| 374 | targetRequiredModuleNames []string |
| 375 | hostRequiredModuleNames []string |
| 376 | |
| 377 | jacocoReportClassesFile android.Path // only for javalibs and apps |
| 378 | lintDepSets java.LintDepSets // only for javalibs and apps |
| 379 | certificate java.Certificate // only for apps |
| 380 | overriddenPackageName string // only for apps |
| 381 | |
| 382 | isJniLib bool |
| 383 | |
| 384 | noticeFiles android.Paths |
| 385 | } |
| 386 | |
| 387 | func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, androidMkModuleName string, installDir string, class apexFileClass, module android.Module) apexFile { |
| 388 | ret := apexFile{ |
| 389 | builtFile: builtFile, |
| 390 | androidMkModuleName: androidMkModuleName, |
| 391 | installDir: installDir, |
| 392 | class: class, |
| 393 | module: module, |
| 394 | } |
| 395 | if module != nil { |
| 396 | ret.moduleDir = ctx.OtherModuleDir(module) |
| 397 | ret.requiredModuleNames = module.RequiredModuleNames() |
| 398 | ret.targetRequiredModuleNames = module.TargetRequiredModuleNames() |
| 399 | ret.hostRequiredModuleNames = module.HostRequiredModuleNames() |
| 400 | ret.noticeFiles = module.NoticeFiles() |
| 401 | } |
| 402 | return ret |
| 403 | } |
| 404 | |
| 405 | func (af *apexFile) Ok() bool { |
| 406 | return af.builtFile != nil && af.builtFile.String() != "" |
| 407 | } |
| 408 | |
| 409 | func (af *apexFile) apexRelativePath(path string) string { |
| 410 | return filepath.Join(af.installDir, path) |
| 411 | } |
| 412 | |
| 413 | // Path() returns path of this apex file relative to the APEX root |
| 414 | func (af *apexFile) Path() string { |
| 415 | return af.apexRelativePath(af.Stem()) |
| 416 | } |
| 417 | |
| 418 | func (af *apexFile) Stem() string { |
| 419 | if af.stem != "" { |
| 420 | return af.stem |
| 421 | } |
| 422 | return af.builtFile.Base() |
| 423 | } |
| 424 | |
| 425 | // SymlinkPaths() returns paths of the symlinks (if any) relative to the APEX root |
| 426 | func (af *apexFile) SymlinkPaths() []string { |
| 427 | var ret []string |
| 428 | for _, symlink := range af.symlinks { |
| 429 | ret = append(ret, af.apexRelativePath(symlink)) |
| 430 | } |
| 431 | return ret |
| 432 | } |
| 433 | |
| 434 | func (af *apexFile) AvailableToPlatform() bool { |
| 435 | if af.module == nil { |
| 436 | return false |
| 437 | } |
| 438 | if am, ok := af.module.(android.ApexModule); ok { |
| 439 | return am.AvailableFor(android.AvailableToPlatform) |
| 440 | } |
| 441 | return false |
| 442 | } |
| 443 | |
| 444 | func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, |
| 445 | nativeModules ApexNativeDependencies, |
| 446 | target android.Target, imageVariation string) { |
| 447 | // Use *FarVariation* to be able to depend on modules having |
| 448 | // conflicting variations with this module. This is required since |
| 449 | // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64' |
| 450 | // for native shared libs. |
| 451 | |
| 452 | binVariations := target.Variations() |
| 453 | libVariations := append(target.Variations(), |
| 454 | blueprint.Variation{Mutator: "link", Variation: "shared"}) |
| 455 | |
| 456 | if ctx.Device() { |
| 457 | binVariations = append(binVariations, |
| 458 | blueprint.Variation{Mutator: "image", Variation: imageVariation}) |
| 459 | libVariations = append(libVariations, |
| 460 | blueprint.Variation{Mutator: "image", Variation: imageVariation}, |
| 461 | blueprint.Variation{Mutator: "version", Variation: ""}) // "" is the non-stub variant |
| 462 | } |
| 463 | |
| 464 | ctx.AddFarVariationDependencies(libVariations, sharedLibTag, nativeModules.Native_shared_libs...) |
| 465 | |
| 466 | ctx.AddFarVariationDependencies(libVariations, jniLibTag, nativeModules.Jni_libs...) |
| 467 | |
| 468 | ctx.AddFarVariationDependencies(binVariations, executableTag, nativeModules.Binaries...) |
| 469 | |
| 470 | ctx.AddFarVariationDependencies(binVariations, testTag, nativeModules.Tests...) |
| 471 | } |
| 472 | |
| 473 | func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) { |
| 474 | if ctx.Os().Class == android.Device { |
| 475 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil) |
| 476 | } else { |
| 477 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil) |
| 478 | if ctx.Os().Bionic() { |
| 479 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil) |
| 480 | } else { |
| 481 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil) |
| 482 | } |
| 483 | } |
| 484 | } |
| 485 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 486 | type dependencyTag struct { |
| 487 | blueprint.BaseDependencyTag |
| 488 | name string |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 489 | |
| 490 | // determines if the dependent will be part of the APEX payload |
| 491 | payload bool |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 492 | } |
| 493 | |
| 494 | var ( |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 495 | sharedLibTag = dependencyTag{name: "sharedLib", payload: true} |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 496 | jniLibTag = dependencyTag{name: "jniLib", payload: true} |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 497 | executableTag = dependencyTag{name: "executable", payload: true} |
| 498 | javaLibTag = dependencyTag{name: "javaLib", payload: true} |
| 499 | prebuiltTag = dependencyTag{name: "prebuilt", payload: true} |
| 500 | testTag = dependencyTag{name: "test", payload: true} |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 501 | keyTag = dependencyTag{name: "key"} |
| 502 | certificateTag = dependencyTag{name: "certificate"} |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 503 | androidAppTag = dependencyTag{name: "androidApp", payload: true} |
Jiyong Park | 69aeba9 | 2020-04-24 21:16:36 +0900 | [diff] [blame] | 504 | rroTag = dependencyTag{name: "rro", payload: true} |
markchien | 2f59ec9 | 2020-09-02 16:23:38 +0800 | [diff] [blame] | 505 | bpfTag = dependencyTag{name: "bpf", payload: true} |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 506 | testForTag = dependencyTag{name: "test for"} |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 507 | ) |
| 508 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame^] | 509 | func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 510 | if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorAllowList(ctx.Config())) { |
| 511 | ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true") |
| 512 | } |
| 513 | |
| 514 | targets := ctx.MultiTargets() |
| 515 | config := ctx.DeviceConfig() |
| 516 | imageVariation := a.getImageVariation(ctx) |
| 517 | |
| 518 | a.combineProperties(ctx) |
| 519 | |
| 520 | has32BitTarget := false |
| 521 | for _, target := range targets { |
| 522 | if target.Arch.ArchType.Multilib == "lib32" { |
| 523 | has32BitTarget = true |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 524 | } |
| 525 | } |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame^] | 526 | for i, target := range targets { |
| 527 | if target.HostCross { |
| 528 | // Don't include artifats for the host cross targets because there is no way |
| 529 | // for us to run those artifacts natively on host |
| 530 | continue |
| 531 | } |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 532 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame^] | 533 | // When multilib.* is omitted for native_shared_libs/jni_libs/tests, it implies |
| 534 | // multilib.both |
| 535 | addDependenciesForNativeModules(ctx, |
| 536 | ApexNativeDependencies{ |
| 537 | Native_shared_libs: a.properties.Native_shared_libs, |
| 538 | Tests: a.properties.Tests, |
| 539 | Jni_libs: a.properties.Jni_libs, |
| 540 | Binaries: nil, |
| 541 | }, |
| 542 | target, imageVariation) |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 543 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame^] | 544 | // Add native modules targetting both ABIs |
| 545 | addDependenciesForNativeModules(ctx, |
| 546 | a.properties.Multilib.Both, |
| 547 | target, |
| 548 | imageVariation) |
Jooyung Han | acc7bbe | 2020-05-20 09:06:00 +0900 | [diff] [blame] | 549 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame^] | 550 | isPrimaryAbi := i == 0 |
| 551 | if isPrimaryAbi { |
| 552 | // When multilib.* is omitted for binaries, it implies |
| 553 | // multilib.first |
| 554 | addDependenciesForNativeModules(ctx, |
| 555 | ApexNativeDependencies{ |
| 556 | Native_shared_libs: nil, |
| 557 | Tests: nil, |
| 558 | Jni_libs: nil, |
| 559 | Binaries: a.properties.Binaries, |
| 560 | }, |
| 561 | target, imageVariation) |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 562 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame^] | 563 | // Add native modules targetting the first ABI |
| 564 | addDependenciesForNativeModules(ctx, |
| 565 | a.properties.Multilib.First, |
| 566 | target, |
| 567 | imageVariation) |
| 568 | } |
| 569 | |
| 570 | switch target.Arch.ArchType.Multilib { |
| 571 | case "lib32": |
| 572 | // Add native modules targetting 32-bit ABI |
| 573 | addDependenciesForNativeModules(ctx, |
| 574 | a.properties.Multilib.Lib32, |
| 575 | target, |
| 576 | imageVariation) |
| 577 | |
| 578 | addDependenciesForNativeModules(ctx, |
| 579 | a.properties.Multilib.Prefer32, |
| 580 | target, |
| 581 | imageVariation) |
| 582 | case "lib64": |
| 583 | // Add native modules targetting 64-bit ABI |
| 584 | addDependenciesForNativeModules(ctx, |
| 585 | a.properties.Multilib.Lib64, |
| 586 | target, |
| 587 | imageVariation) |
| 588 | |
| 589 | if !has32BitTarget { |
| 590 | addDependenciesForNativeModules(ctx, |
| 591 | a.properties.Multilib.Prefer32, |
| 592 | target, |
| 593 | imageVariation) |
| 594 | } |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | // For prebuilt_etc, use the first variant (64 on 64/32bit device, |
| 599 | // 32 on 32bit device) regardless of the TARGET_PREFER_* setting. |
| 600 | // b/144532908 |
| 601 | archForPrebuiltEtc := config.Arches()[0] |
| 602 | for _, arch := range config.Arches() { |
| 603 | // Prefer 64-bit arch if there is any |
| 604 | if arch.ArchType.Multilib == "lib64" { |
| 605 | archForPrebuiltEtc = arch |
| 606 | break |
| 607 | } |
| 608 | } |
| 609 | ctx.AddFarVariationDependencies([]blueprint.Variation{ |
| 610 | {Mutator: "os", Variation: ctx.Os().String()}, |
| 611 | {Mutator: "arch", Variation: archForPrebuiltEtc.String()}, |
| 612 | }, prebuiltTag, a.properties.Prebuilts...) |
| 613 | |
| 614 | ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), |
| 615 | javaLibTag, a.properties.Java_libs...) |
| 616 | |
| 617 | ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), |
| 618 | bpfTag, a.properties.Bpfs...) |
| 619 | |
| 620 | // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library. |
| 621 | if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") { |
| 622 | ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), |
| 623 | javaLibTag, "jacocoagent") |
| 624 | } |
| 625 | |
| 626 | if String(a.properties.Key) == "" { |
| 627 | ctx.ModuleErrorf("key is missing") |
| 628 | return |
| 629 | } |
| 630 | ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key)) |
| 631 | |
| 632 | cert := android.SrcIsModule(a.getCertString(ctx)) |
| 633 | if cert != "" { |
| 634 | ctx.AddDependency(ctx.Module(), certificateTag, cert) |
| 635 | } |
| 636 | |
| 637 | // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks |
| 638 | if len(a.properties.Uses_sdks) > 0 { |
| 639 | sdkRefs := []android.SdkRef{} |
| 640 | for _, str := range a.properties.Uses_sdks { |
| 641 | parsed := android.ParseSdkRef(ctx, str, "uses_sdks") |
| 642 | sdkRefs = append(sdkRefs, parsed) |
| 643 | } |
| 644 | a.BuildWithSdks(sdkRefs) |
Andrei Onea | 115e7e7 | 2020-06-05 21:14:03 +0100 | [diff] [blame] | 645 | } |
| 646 | } |
| 647 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame^] | 648 | func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) { |
| 649 | if a.overridableProperties.Allowed_files != nil { |
| 650 | android.ExtractSourceDeps(ctx, a.overridableProperties.Allowed_files) |
Andrei Onea | 115e7e7 | 2020-06-05 21:14:03 +0100 | [diff] [blame] | 651 | } |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame^] | 652 | ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), |
| 653 | androidAppTag, a.overridableProperties.Apps...) |
| 654 | ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), |
| 655 | rroTag, a.overridableProperties.Rros...) |
Andrei Onea | 115e7e7 | 2020-06-05 21:14:03 +0100 | [diff] [blame] | 656 | } |
| 657 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame^] | 658 | type ApexBundleInfo struct { |
| 659 | Contents *android.ApexContents |
Andrei Onea | 115e7e7 | 2020-06-05 21:14:03 +0100 | [diff] [blame] | 660 | } |
| 661 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame^] | 662 | var ApexBundleInfoProvider = blueprint.NewMutatorProvider(ApexBundleInfo{}, "apex_deps") |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 663 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 664 | // Mark the direct and transitive dependencies of apex bundles so that they |
| 665 | // can be built for the apex bundles. |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 666 | func apexDepsMutator(mctx android.TopDownMutatorContext) { |
Jooyung Han | 49f6701 | 2020-04-17 13:43:10 +0900 | [diff] [blame] | 667 | if !mctx.Module().Enabled() { |
| 668 | return |
| 669 | } |
Jooyung Han | 698dd9f | 2020-07-22 15:17:19 +0900 | [diff] [blame] | 670 | a, ok := mctx.Module().(*apexBundle) |
| 671 | if !ok || a.vndkApex { |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 672 | return |
| 673 | } |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 674 | |
| 675 | useVndk := a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && mctx.Config().EnforceProductPartitionInterface()) |
| 676 | excludeVndkLibs := useVndk && proptools.Bool(a.properties.Use_vndk_as_stable) |
| 677 | if !useVndk && proptools.Bool(a.properties.Use_vndk_as_stable) { |
| 678 | mctx.PropertyErrorf("use_vndk_as_stable", "not supported for system/system_ext APEXes") |
| 679 | return |
| 680 | } |
| 681 | |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 682 | contents := make(map[string]android.ApexMembership) |
| 683 | |
| 684 | continueApexDepsWalk := func(child, parent android.Module) bool { |
Jooyung Han | 698dd9f | 2020-07-22 15:17:19 +0900 | [diff] [blame] | 685 | am, ok := child.(android.ApexModule) |
| 686 | if !ok || !am.CanHaveApexVariants() { |
| 687 | return false |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 688 | } |
Paul Duffin | a37eca2 | 2020-07-22 13:00:54 +0100 | [diff] [blame] | 689 | if !parent.(android.DepIsInSameApex).DepIsInSameApex(mctx, child) { |
Jooyung Han | 698dd9f | 2020-07-22 15:17:19 +0900 | [diff] [blame] | 690 | return false |
| 691 | } |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 692 | if excludeVndkLibs { |
| 693 | if c, ok := child.(*cc.Module); ok && c.IsVndk() { |
| 694 | return false |
| 695 | } |
| 696 | } |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 697 | return true |
| 698 | } |
| 699 | |
| 700 | mctx.WalkDeps(func(child, parent android.Module) bool { |
| 701 | if !continueApexDepsWalk(child, parent) { |
| 702 | return false |
| 703 | } |
Jooyung Han | 698dd9f | 2020-07-22 15:17:19 +0900 | [diff] [blame] | 704 | |
| 705 | depName := mctx.OtherModuleName(child) |
| 706 | // If the parent is apexBundle, this child is directly depended. |
| 707 | _, directDep := parent.(*apexBundle) |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 708 | contents[depName] = contents[depName].Add(directDep) |
| 709 | return true |
| 710 | }) |
| 711 | |
| 712 | apexContents := android.NewApexContents(mctx.ModuleName(), contents) |
| 713 | mctx.SetProvider(ApexBundleInfoProvider, ApexBundleInfo{ |
| 714 | Contents: apexContents, |
| 715 | }) |
| 716 | |
| 717 | apexInfo := android.ApexInfo{ |
| 718 | ApexVariationName: mctx.ModuleName(), |
| 719 | MinSdkVersionStr: a.minSdkVersion(mctx).String(), |
| 720 | RequiredSdks: a.RequiredSdks(), |
| 721 | Updatable: a.Updatable(), |
| 722 | InApexes: []string{mctx.ModuleName()}, |
| 723 | ApexContents: []*android.ApexContents{apexContents}, |
| 724 | } |
| 725 | |
| 726 | mctx.WalkDeps(func(child, parent android.Module) bool { |
| 727 | if !continueApexDepsWalk(child, parent) { |
| 728 | return false |
| 729 | } |
| 730 | |
| 731 | child.(android.ApexModule).BuildForApex(apexInfo) |
Jooyung Han | 698dd9f | 2020-07-22 15:17:19 +0900 | [diff] [blame] | 732 | return true |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 733 | }) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 734 | } |
| 735 | |
Colin Cross | aede88c | 2020-08-11 12:17:01 -0700 | [diff] [blame] | 736 | func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) { |
| 737 | if !mctx.Module().Enabled() { |
| 738 | return |
| 739 | } |
| 740 | if am, ok := mctx.Module().(android.ApexModule); ok { |
| 741 | // Check if any dependencies use unique apex variations. If so, use unique apex variations |
| 742 | // for this module. |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 743 | android.UpdateUniqueApexVariationsForDeps(mctx, am) |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) { |
| 748 | if !mctx.Module().Enabled() { |
| 749 | return |
| 750 | } |
| 751 | // Check if this module is a test for an apex. If so, add a dependency on the apex |
| 752 | // in order to retrieve its contents later. |
| 753 | if am, ok := mctx.Module().(android.ApexModule); ok { |
| 754 | if testFor := am.TestFor(); len(testFor) > 0 { |
| 755 | mctx.AddFarVariationDependencies([]blueprint.Variation{ |
| 756 | {Mutator: "os", Variation: am.Target().OsVariation()}, |
| 757 | {"arch", "common"}, |
| 758 | }, testForTag, testFor...) |
| 759 | } |
| 760 | } |
| 761 | } |
| 762 | |
| 763 | func apexTestForMutator(mctx android.BottomUpMutatorContext) { |
| 764 | if !mctx.Module().Enabled() { |
| 765 | return |
| 766 | } |
| 767 | |
| 768 | if _, ok := mctx.Module().(android.ApexModule); ok { |
| 769 | var contents []*android.ApexContents |
| 770 | for _, testFor := range mctx.GetDirectDepsWithTag(testForTag) { |
| 771 | abInfo := mctx.OtherModuleProvider(testFor, ApexBundleInfoProvider).(ApexBundleInfo) |
| 772 | contents = append(contents, abInfo.Contents) |
| 773 | } |
| 774 | mctx.SetProvider(android.ApexTestForInfoProvider, android.ApexTestForInfo{ |
| 775 | ApexContents: contents, |
| 776 | }) |
Colin Cross | aede88c | 2020-08-11 12:17:01 -0700 | [diff] [blame] | 777 | } |
| 778 | } |
| 779 | |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 780 | // mark if a module cannot be available to platform. A module cannot be available |
| 781 | // to platform if 1) it is explicitly marked as not available (i.e. "//apex_available:platform" |
| 782 | // is absent) or 2) it depends on another module that isn't (or can't be) available to platform |
| 783 | func markPlatformAvailability(mctx android.BottomUpMutatorContext) { |
| 784 | // Host and recovery are not considered as platform |
| 785 | if mctx.Host() || mctx.Module().InstallInRecovery() { |
| 786 | return |
| 787 | } |
| 788 | |
| 789 | if am, ok := mctx.Module().(android.ApexModule); ok { |
| 790 | availableToPlatform := am.AvailableFor(android.AvailableToPlatform) |
| 791 | |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 792 | // If any of the dep is not available to platform, this module is also considered |
| 793 | // as being not available to platform even if it has "//apex_available:platform" |
| 794 | mctx.VisitDirectDeps(func(child android.Module) { |
| 795 | if !am.DepIsInSameApex(mctx, child) { |
| 796 | // if the dependency crosses apex boundary, don't consider it |
| 797 | return |
| 798 | } |
| 799 | if dep, ok := child.(android.ApexModule); ok && dep.NotAvailableForPlatform() { |
| 800 | availableToPlatform = false |
| 801 | // TODO(b/154889534) trigger an error when 'am' has "//apex_available:platform" |
| 802 | } |
| 803 | }) |
| 804 | |
| 805 | // Exception 1: stub libraries and native bridge libraries are always available to platform |
| 806 | if cc, ok := mctx.Module().(*cc.Module); ok && |
| 807 | (cc.IsStubs() || cc.Target().NativeBridge == android.NativeBridgeEnabled) { |
| 808 | availableToPlatform = true |
| 809 | } |
| 810 | |
| 811 | // Exception 2: bootstrap bionic libraries are also always available to platform |
| 812 | if cc.InstallToBootstrap(mctx.ModuleName(), mctx.Config()) { |
| 813 | availableToPlatform = true |
| 814 | } |
| 815 | |
| 816 | if !availableToPlatform { |
| 817 | am.SetNotAvailableForPlatform() |
| 818 | } |
| 819 | } |
| 820 | } |
| 821 | |
Paul Duffin | 6534770 | 2020-03-31 15:23:40 +0100 | [diff] [blame] | 822 | // If a module in an APEX depends on a module from an SDK then it needs an APEX |
| 823 | // specific variant created for it. Refer to sdk.sdkDepsReplaceMutator. |
| 824 | func inAnySdk(module android.Module) bool { |
| 825 | if sa, ok := module.(android.SdkAware); ok { |
| 826 | return sa.IsInAnySdk() |
| 827 | } |
| 828 | |
| 829 | return false |
| 830 | } |
| 831 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 832 | // Create apex variations if a module is included in APEX(s). |
| 833 | func apexMutator(mctx android.BottomUpMutatorContext) { |
Jooyung Han | 49f6701 | 2020-04-17 13:43:10 +0900 | [diff] [blame] | 834 | if !mctx.Module().Enabled() { |
| 835 | return |
| 836 | } |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 837 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 838 | if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() { |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 839 | android.CreateApexVariations(mctx, am) |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 840 | } else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 841 | // apex bundle itself is mutated so that it and its modules have same |
| 842 | // apex variant. |
| 843 | apexBundleName := mctx.ModuleName() |
| 844 | mctx.CreateVariations(apexBundleName) |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 845 | } else if o, ok := mctx.Module().(*OverrideApex); ok { |
| 846 | apexBundleName := o.GetOverriddenModuleName() |
| 847 | if apexBundleName == "" { |
| 848 | mctx.ModuleErrorf("base property is not set") |
| 849 | return |
| 850 | } |
| 851 | mctx.CreateVariations(apexBundleName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 852 | } |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 853 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 854 | } |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 855 | |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 856 | func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) { |
| 857 | if !mctx.Module().Enabled() { |
| 858 | return |
| 859 | } |
| 860 | if am, ok := mctx.Module().(android.ApexModule); ok { |
| 861 | android.UpdateDirectlyInAnyApex(mctx, am) |
| 862 | } |
| 863 | } |
| 864 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame^] | 865 | type apexPackaging int |
| 866 | |
| 867 | const ( |
| 868 | imageApex apexPackaging = iota |
| 869 | zipApex |
| 870 | flattenedApex |
| 871 | ) |
| 872 | |
| 873 | const ( |
| 874 | imageApexSuffix = ".apex" |
| 875 | zipApexSuffix = ".zipapex" |
| 876 | flattenedSuffix = ".flattened" |
| 877 | |
| 878 | imageApexType = "image" |
| 879 | zipApexType = "zip" |
| 880 | flattenedApexType = "flattened" |
| 881 | |
| 882 | ext4FsType = "ext4" |
| 883 | f2fsFsType = "f2fs" |
| 884 | ) |
| 885 | |
| 886 | // The suffix for the output "file", not the module |
| 887 | func (a apexPackaging) suffix() string { |
| 888 | switch a { |
| 889 | case imageApex: |
| 890 | return imageApexSuffix |
| 891 | case zipApex: |
| 892 | return zipApexSuffix |
| 893 | default: |
| 894 | panic(fmt.Errorf("unknown APEX type %d", a)) |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | func (a apexPackaging) name() string { |
| 899 | switch a { |
| 900 | case imageApex: |
| 901 | return imageApexType |
| 902 | case zipApex: |
| 903 | return zipApexType |
| 904 | default: |
| 905 | panic(fmt.Errorf("unknown APEX type %d", a)) |
| 906 | } |
| 907 | } |
| 908 | |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 909 | func apexFlattenedMutator(mctx android.BottomUpMutatorContext) { |
Jooyung Han | 49f6701 | 2020-04-17 13:43:10 +0900 | [diff] [blame] | 910 | if !mctx.Module().Enabled() { |
| 911 | return |
| 912 | } |
Sundong Ahn | e8fb724 | 2019-09-17 13:50:45 +0900 | [diff] [blame] | 913 | if ab, ok := mctx.Module().(*apexBundle); ok { |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 914 | var variants []string |
| 915 | switch proptools.StringDefault(ab.properties.Payload_type, "image") { |
| 916 | case "image": |
| 917 | variants = append(variants, imageApexType, flattenedApexType) |
| 918 | case "zip": |
| 919 | variants = append(variants, zipApexType) |
| 920 | case "both": |
| 921 | variants = append(variants, imageApexType, zipApexType, flattenedApexType) |
| 922 | default: |
Sundong Ahn | d95aa2d | 2019-10-08 19:34:03 +0900 | [diff] [blame] | 923 | mctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type) |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 924 | return |
| 925 | } |
| 926 | |
| 927 | modules := mctx.CreateLocalVariations(variants...) |
| 928 | |
| 929 | for i, v := range variants { |
| 930 | switch v { |
| 931 | case imageApexType: |
| 932 | modules[i].(*apexBundle).properties.ApexType = imageApex |
| 933 | case zipApexType: |
| 934 | modules[i].(*apexBundle).properties.ApexType = zipApex |
| 935 | case flattenedApexType: |
| 936 | modules[i].(*apexBundle).properties.ApexType = flattenedApex |
Jooyung Han | 91df208 | 2019-11-20 01:49:42 +0900 | [diff] [blame] | 937 | if !mctx.Config().FlattenApex() && ab.Platform() { |
Sundong Ahn | d95aa2d | 2019-10-08 19:34:03 +0900 | [diff] [blame] | 938 | modules[i].(*apexBundle).MakeAsSystemExt() |
| 939 | } |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 940 | } |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 941 | } |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 942 | } else if _, ok := mctx.Module().(*OverrideApex); ok { |
| 943 | mctx.CreateVariations(imageApexType, flattenedApexType) |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 944 | } |
| 945 | } |
| 946 | |
Jooyung Han | dc78244 | 2019-11-01 03:14:38 +0900 | [diff] [blame] | 947 | var ( |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 948 | useVendorAllowListKey = android.NewOnceKey("useVendorAllowList") |
Jooyung Han | dc78244 | 2019-11-01 03:14:38 +0900 | [diff] [blame] | 949 | ) |
| 950 | |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 951 | // useVendorAllowList returns the list of APEXes which are allowed to use_vendor. |
Jooyung Han | dc78244 | 2019-11-01 03:14:38 +0900 | [diff] [blame] | 952 | // When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__, |
| 953 | // which may cause compatibility issues. (e.g. libbinder) |
| 954 | // Even though libbinder restricts its availability via 'apex_available' property and relies on |
| 955 | // yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules |
| 956 | // to avoid similar problems. |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 957 | func useVendorAllowList(config android.Config) []string { |
| 958 | return config.Once(useVendorAllowListKey, func() interface{} { |
Jooyung Han | dc78244 | 2019-11-01 03:14:38 +0900 | [diff] [blame] | 959 | return []string{ |
| 960 | // swcodec uses "vendor" variants for smaller size |
| 961 | "com.android.media.swcodec", |
| 962 | "test_com.android.media.swcodec", |
| 963 | } |
| 964 | }).([]string) |
| 965 | } |
| 966 | |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 967 | // setUseVendorAllowListForTest overrides useVendorAllowList and must be |
| 968 | // called before the first call to useVendorAllowList() |
| 969 | func setUseVendorAllowListForTest(config android.Config, allowList []string) { |
| 970 | config.Once(useVendorAllowListKey, func() interface{} { |
| 971 | return allowList |
Jooyung Han | dc78244 | 2019-11-01 03:14:38 +0900 | [diff] [blame] | 972 | }) |
| 973 | } |
| 974 | |
Theotime Combes | 4ba38c1 | 2020-06-12 12:46:59 +0000 | [diff] [blame] | 975 | type fsType int |
| 976 | |
| 977 | const ( |
| 978 | ext4 fsType = iota |
| 979 | f2fs |
| 980 | ) |
| 981 | |
| 982 | func (f fsType) string() string { |
| 983 | switch f { |
| 984 | case ext4: |
| 985 | return ext4FsType |
| 986 | case f2fs: |
| 987 | return f2fsFsType |
| 988 | default: |
| 989 | panic(fmt.Errorf("unknown APEX payload type %d", f)) |
| 990 | } |
| 991 | } |
| 992 | |
Jiyong Park | a7bc8ad | 2019-10-15 15:20:07 +0900 | [diff] [blame] | 993 | func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { |
| 994 | // direct deps of an APEX bundle are all part of the APEX bundle |
| 995 | return true |
| 996 | } |
| 997 | |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 998 | func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string { |
Jooyung Han | 27151d9 | 2019-12-16 17:45:32 +0900 | [diff] [blame] | 999 | moduleName := ctx.ModuleName() |
| 1000 | // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the OVERRIDE_* list, |
| 1001 | // we check with the pseudo module name to see if its certificate is overridden. |
| 1002 | if a.vndkApex { |
| 1003 | moduleName = vndkApexName |
| 1004 | } |
| 1005 | certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName) |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 1006 | if overridden { |
Jaewoong Jung | acb6db3 | 2019-02-28 16:22:30 +0000 | [diff] [blame] | 1007 | return ":" + certificate |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 1008 | } |
| 1009 | return String(a.properties.Certificate) |
| 1010 | } |
| 1011 | |
Colin Cross | 41955e8 | 2019-05-29 14:40:35 -0700 | [diff] [blame] | 1012 | func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) { |
| 1013 | switch tag { |
| 1014 | case "": |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1015 | return android.Paths{a.outputFile}, nil |
Colin Cross | 41955e8 | 2019-05-29 14:40:35 -0700 | [diff] [blame] | 1016 | default: |
| 1017 | return nil, fmt.Errorf("unsupported module reference tag %q", tag) |
Jiyong Park | 5a83202 | 2018-12-20 09:54:35 +0900 | [diff] [blame] | 1018 | } |
Jiyong Park | 74e240b | 2018-11-27 21:27:08 +0900 | [diff] [blame] | 1019 | } |
| 1020 | |
Jiyong Park | 92c0f9c | 2018-12-13 23:14:57 +0900 | [diff] [blame] | 1021 | func (a *apexBundle) installable() bool { |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 1022 | return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable)) |
Jiyong Park | 92c0f9c | 2018-12-13 23:14:57 +0900 | [diff] [blame] | 1023 | } |
| 1024 | |
Nikita Ioffe | c72b5dd | 2019-12-07 17:30:22 +0000 | [diff] [blame] | 1025 | func (a *apexBundle) testOnlyShouldSkipHashtreeGeneration() bool { |
| 1026 | return proptools.Bool(a.properties.Test_only_no_hashtree) |
| 1027 | } |
| 1028 | |
Dario Freni | ca91339 | 2020-04-27 18:21:11 +0100 | [diff] [blame] | 1029 | func (a *apexBundle) testOnlyShouldSkipPayloadSign() bool { |
| 1030 | return proptools.Bool(a.properties.Test_only_unsigned_payload) |
| 1031 | } |
| 1032 | |
Jooyung Han | 85d6176 | 2020-06-24 23:50:26 +0900 | [diff] [blame] | 1033 | func (a *apexBundle) getImageVariation(ctx android.BottomUpMutatorContext) string { |
| 1034 | deviceConfig := ctx.DeviceConfig() |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 1035 | if a.vndkApex { |
Jooyung Han | 85d6176 | 2020-06-24 23:50:26 +0900 | [diff] [blame] | 1036 | return cc.VendorVariationPrefix + a.vndkVersion(deviceConfig) |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 1037 | } |
Jooyung Han | 85d6176 | 2020-06-24 23:50:26 +0900 | [diff] [blame] | 1038 | |
| 1039 | var prefix string |
| 1040 | var vndkVersion string |
| 1041 | if deviceConfig.VndkVersion() != "" { |
| 1042 | if proptools.Bool(a.properties.Use_vendor) { |
| 1043 | prefix = cc.VendorVariationPrefix |
| 1044 | vndkVersion = deviceConfig.PlatformVndkVersion() |
| 1045 | } else if a.SocSpecific() || a.DeviceSpecific() { |
| 1046 | prefix = cc.VendorVariationPrefix |
| 1047 | vndkVersion = deviceConfig.VndkVersion() |
| 1048 | } else if a.ProductSpecific() { |
| 1049 | prefix = cc.ProductVariationPrefix |
| 1050 | vndkVersion = deviceConfig.ProductVndkVersion() |
| 1051 | } |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 1052 | } |
Jooyung Han | 85d6176 | 2020-06-24 23:50:26 +0900 | [diff] [blame] | 1053 | if vndkVersion == "current" { |
| 1054 | vndkVersion = deviceConfig.PlatformVndkVersion() |
| 1055 | } |
| 1056 | if vndkVersion != "" { |
| 1057 | return prefix + vndkVersion |
| 1058 | } |
| 1059 | return android.CoreVariation |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 1060 | } |
| 1061 | |
Jiyong Park | f97782b | 2019-02-13 20:28:58 +0900 | [diff] [blame] | 1062 | func (a *apexBundle) EnableSanitizer(sanitizerName string) { |
| 1063 | if !android.InList(sanitizerName, a.properties.SanitizerNames) { |
| 1064 | a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName) |
| 1065 | } |
| 1066 | } |
| 1067 | |
Jiyong Park | 388ef3f | 2019-01-28 19:47:32 +0900 | [diff] [blame] | 1068 | func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool { |
Jiyong Park | f97782b | 2019-02-13 20:28:58 +0900 | [diff] [blame] | 1069 | if android.InList(sanitizerName, a.properties.SanitizerNames) { |
| 1070 | return true |
Jiyong Park | 235e67c | 2019-02-09 11:50:56 +0900 | [diff] [blame] | 1071 | } |
| 1072 | |
| 1073 | // Then follow the global setting |
Jiyong Park | 388ef3f | 2019-01-28 19:47:32 +0900 | [diff] [blame] | 1074 | globalSanitizerNames := []string{} |
| 1075 | if a.Host() { |
| 1076 | globalSanitizerNames = ctx.Config().SanitizeHost() |
| 1077 | } else { |
| 1078 | arches := ctx.Config().SanitizeDeviceArch() |
| 1079 | if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) { |
| 1080 | globalSanitizerNames = ctx.Config().SanitizeDevice() |
| 1081 | } |
| 1082 | } |
| 1083 | return android.InList(sanitizerName, globalSanitizerNames) |
Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 1084 | } |
| 1085 | |
Jooyung Han | 8ce8db9 | 2020-05-15 19:05:05 +0900 | [diff] [blame] | 1086 | func (a *apexBundle) AddSanitizerDependencies(ctx android.BottomUpMutatorContext, sanitizerName string) { |
| 1087 | if ctx.Device() && sanitizerName == "hwaddress" && strings.HasPrefix(a.Name(), "com.android.runtime") { |
| 1088 | for _, target := range ctx.MultiTargets() { |
| 1089 | if target.Arch.ArchType.Multilib == "lib64" { |
| 1090 | ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ |
Jooyung Han | 85d6176 | 2020-06-24 23:50:26 +0900 | [diff] [blame] | 1091 | {Mutator: "image", Variation: a.getImageVariation(ctx)}, |
Jooyung Han | 8ce8db9 | 2020-05-15 19:05:05 +0900 | [diff] [blame] | 1092 | {Mutator: "link", Variation: "shared"}, |
| 1093 | {Mutator: "version", Variation: ""}, // "" is the non-stub variant |
| 1094 | }...), sharedLibTag, "libclang_rt.hwasan-aarch64-android") |
| 1095 | break |
| 1096 | } |
| 1097 | } |
| 1098 | } |
| 1099 | } |
| 1100 | |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 1101 | var _ cc.Coverage = (*apexBundle)(nil) |
| 1102 | |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 1103 | func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool { |
Colin Cross | 1a6acd4 | 2020-06-16 17:51:46 -0700 | [diff] [blame] | 1104 | return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled() |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 1105 | } |
| 1106 | |
| 1107 | func (a *apexBundle) PreventInstall() { |
| 1108 | a.properties.PreventInstall = true |
| 1109 | } |
| 1110 | |
| 1111 | func (a *apexBundle) HideFromMake() { |
| 1112 | a.properties.HideFromMake = true |
| 1113 | } |
| 1114 | |
Jiyong Park | 956305c | 2020-01-09 12:32:06 +0900 | [diff] [blame] | 1115 | func (a *apexBundle) MarkAsCoverageVariant(coverage bool) { |
| 1116 | a.properties.IsCoverageVariant = coverage |
| 1117 | } |
| 1118 | |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 1119 | func (a *apexBundle) EnableCoverageIfNeeded() {} |
| 1120 | |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1121 | // TODO(jiyong) move apexFileFor* close to the apexFile type definition |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1122 | func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1123 | // Decide the APEX-local directory by the multilib of the library |
| 1124 | // In the future, we may query this to the module. |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1125 | var dirInApex string |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 1126 | switch ccMod.Arch().ArchType.Multilib { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1127 | case "lib32": |
| 1128 | dirInApex = "lib" |
| 1129 | case "lib64": |
| 1130 | dirInApex = "lib64" |
| 1131 | } |
Colin Cross | 3b19f5d | 2019-09-17 14:45:31 -0700 | [diff] [blame] | 1132 | if ccMod.Target().NativeBridge == android.NativeBridgeEnabled { |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 1133 | dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1134 | } |
Jooyung Han | 35155c4 | 2020-02-06 17:33:20 +0900 | [diff] [blame] | 1135 | dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath()) |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1136 | if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) { |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 1137 | // Special case for Bionic libs and other libs installed with them. This is |
| 1138 | // to prevent those libs from being included in the search path |
| 1139 | // /apex/com.android.runtime/${LIB}. This exclusion is required because |
| 1140 | // those libs in the Runtime APEX are available via the legacy paths in |
| 1141 | // /system/lib/. By the init process, the libs in the APEX are bind-mounted |
| 1142 | // to the legacy paths and thus will be loaded into the default linker |
| 1143 | // namespace (aka "platform" namespace). If the libs are directly in |
| 1144 | // /apex/com.android.runtime/${LIB} then the same libs will be loaded again |
| 1145 | // into the runtime linker namespace, which will result in double loading of |
| 1146 | // them, which isn't supported. |
| 1147 | dirInApex = filepath.Join(dirInApex, "bionic") |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 1148 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1149 | |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1150 | fileToCopy := ccMod.OutputFile().Path() |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1151 | androidMkModuleName := ccMod.BaseModuleName() + ccMod.Properties.SubName |
| 1152 | return newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeSharedLib, ccMod) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1153 | } |
| 1154 | |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1155 | func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile { |
Jooyung Han | 35155c4 | 2020-02-06 17:33:20 +0900 | [diff] [blame] | 1156 | dirInApex := "bin" |
Colin Cross | 3b19f5d | 2019-09-17 14:45:31 -0700 | [diff] [blame] | 1157 | if cc.Target().NativeBridge == android.NativeBridgeEnabled { |
dimitry | 8d6dde8 | 2019-07-11 10:23:53 +0200 | [diff] [blame] | 1158 | dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath) |
Jiyong Park | acbf6c7 | 2019-07-09 16:19:16 +0900 | [diff] [blame] | 1159 | } |
Jooyung Han | 35155c4 | 2020-02-06 17:33:20 +0900 | [diff] [blame] | 1160 | dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath()) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1161 | fileToCopy := cc.OutputFile().Path() |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1162 | androidMkModuleName := cc.BaseModuleName() + cc.Properties.SubName |
| 1163 | af := newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeExecutable, cc) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1164 | af.symlinks = cc.Symlinks() |
Liz Kammer | 1c14a21 | 2020-05-12 15:26:55 -0700 | [diff] [blame] | 1165 | af.dataPaths = cc.DataPaths() |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1166 | return af |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1167 | } |
| 1168 | |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1169 | func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1170 | dirInApex := "bin" |
| 1171 | fileToCopy := py.HostToolPath().Path() |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1172 | return newApexFile(ctx, fileToCopy, py.BaseModuleName(), dirInApex, pyBinary, py) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1173 | } |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1174 | func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1175 | dirInApex := "bin" |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1176 | s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath()) |
| 1177 | if err != nil { |
| 1178 | ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath()) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1179 | return apexFile{} |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1180 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1181 | fileToCopy := android.PathForOutput(ctx, s) |
| 1182 | // NB: Since go binaries are static we don't need the module for anything here, which is |
| 1183 | // good since the go tool is a blueprint.Module not an android.Module like we would |
| 1184 | // normally use. |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1185 | return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1186 | } |
| 1187 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 1188 | func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFile { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1189 | dirInApex := filepath.Join("bin", sh.SubDir()) |
| 1190 | fileToCopy := sh.OutputFile() |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1191 | af := newApexFile(ctx, fileToCopy, sh.BaseModuleName(), dirInApex, shBinary, sh) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1192 | af.symlinks = sh.Symlinks() |
| 1193 | return af |
Jiyong Park | 04480cf | 2019-02-06 00:16:29 +0900 | [diff] [blame] | 1194 | } |
| 1195 | |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1196 | type javaModule interface { |
| 1197 | android.Module |
| 1198 | BaseModuleName() string |
Ulyana Trafimovich | 5539e7b | 2020-06-04 14:08:17 +0000 | [diff] [blame] | 1199 | DexJarBuildPath() android.Path |
Jiyong Park | 77acec6 | 2020-06-01 21:39:15 +0900 | [diff] [blame] | 1200 | JacocoReportClassesFile() android.Path |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 1201 | LintDepSets() java.LintDepSets |
| 1202 | |
Jiyong Park | a62aa23 | 2020-05-28 23:46:55 +0900 | [diff] [blame] | 1203 | Stem() string |
| 1204 | } |
| 1205 | |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1206 | var _ javaModule = (*java.Library)(nil) |
| 1207 | var _ javaModule = (*java.SdkLibrary)(nil) |
| 1208 | var _ javaModule = (*java.DexImport)(nil) |
| 1209 | var _ javaModule = (*java.SdkLibraryImport)(nil) |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 1210 | |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1211 | func apexFileForJavaLibrary(ctx android.BaseModuleContext, module javaModule) apexFile { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1212 | dirInApex := "javalib" |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1213 | fileToCopy := module.DexJarBuildPath() |
| 1214 | af := newApexFile(ctx, fileToCopy, module.BaseModuleName(), dirInApex, javaSharedLib, module) |
| 1215 | af.jacocoReportClassesFile = module.JacocoReportClassesFile() |
| 1216 | af.lintDepSets = module.LintDepSets() |
| 1217 | af.stem = module.Stem() + ".jar" |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1218 | return af |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1219 | } |
| 1220 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 1221 | func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt prebuilt_etc.PrebuiltEtcModule, depName string) apexFile { |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 1222 | dirInApex := filepath.Join(prebuilt.BaseDir(), prebuilt.SubDir()) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1223 | fileToCopy := prebuilt.OutputFile() |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1224 | return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1225 | } |
| 1226 | |
atrost | 6e12625 | 2020-01-27 17:01:16 +0000 | [diff] [blame] | 1227 | func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile { |
| 1228 | dirInApex := filepath.Join("etc", config.SubDir()) |
| 1229 | fileToCopy := config.CompatConfig() |
| 1230 | return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config) |
| 1231 | } |
| 1232 | |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1233 | func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1234 | android.Module |
| 1235 | Privileged() bool |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1236 | InstallApkName() string |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1237 | OutputFile() android.Path |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1238 | JacocoReportClassesFile() android.Path |
Colin Cross | 503c1d0 | 2020-01-28 14:00:53 -0800 | [diff] [blame] | 1239 | Certificate() java.Certificate |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1240 | BaseModuleName() string |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1241 | }) apexFile { |
Jiyong Park | f748731 | 2019-10-17 12:54:30 +0900 | [diff] [blame] | 1242 | appDir := "app" |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1243 | if aapp.Privileged() { |
Jiyong Park | f748731 | 2019-10-17 12:54:30 +0900 | [diff] [blame] | 1244 | appDir = "priv-app" |
| 1245 | } |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1246 | dirInApex := filepath.Join(appDir, aapp.InstallApkName()) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1247 | fileToCopy := aapp.OutputFile() |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1248 | af := newApexFile(ctx, fileToCopy, aapp.BaseModuleName(), dirInApex, app, aapp) |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1249 | af.jacocoReportClassesFile = aapp.JacocoReportClassesFile() |
Colin Cross | 503c1d0 | 2020-01-28 14:00:53 -0800 | [diff] [blame] | 1250 | af.certificate = aapp.Certificate() |
Jiyong Park | cfaa164 | 2020-02-28 16:51:07 +0900 | [diff] [blame] | 1251 | |
| 1252 | if app, ok := aapp.(interface { |
| 1253 | OverriddenManifestPackageName() string |
| 1254 | }); ok { |
| 1255 | af.overriddenPackageName = app.OverriddenManifestPackageName() |
| 1256 | } |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1257 | return af |
Dario Freni | cde2a03 | 2019-10-27 00:29:22 +0100 | [diff] [blame] | 1258 | } |
| 1259 | |
Jiyong Park | 69aeba9 | 2020-04-24 21:16:36 +0900 | [diff] [blame] | 1260 | func apexFileForRuntimeResourceOverlay(ctx android.BaseModuleContext, rro java.RuntimeResourceOverlayModule) apexFile { |
| 1261 | rroDir := "overlay" |
| 1262 | dirInApex := filepath.Join(rroDir, rro.Theme()) |
| 1263 | fileToCopy := rro.OutputFile() |
| 1264 | af := newApexFile(ctx, fileToCopy, rro.Name(), dirInApex, app, rro) |
| 1265 | af.certificate = rro.Certificate() |
| 1266 | |
| 1267 | if a, ok := rro.(interface { |
| 1268 | OverriddenManifestPackageName() string |
| 1269 | }); ok { |
| 1270 | af.overriddenPackageName = a.OverriddenManifestPackageName() |
| 1271 | } |
| 1272 | return af |
| 1273 | } |
| 1274 | |
markchien | 2f59ec9 | 2020-09-02 16:23:38 +0800 | [diff] [blame] | 1275 | func apexFileForBpfProgram(ctx android.BaseModuleContext, builtFile android.Path, bpfProgram bpf.BpfModule) apexFile { |
| 1276 | dirInApex := filepath.Join("etc", "bpf") |
| 1277 | return newApexFile(ctx, builtFile, builtFile.Base(), dirInApex, etc, bpfProgram) |
| 1278 | } |
| 1279 | |
Roland Levillain | 935639d | 2019-08-13 14:55:28 +0100 | [diff] [blame] | 1280 | // Context "decorator", overriding the InstallBypassMake method to always reply `true`. |
| 1281 | type flattenedApexContext struct { |
| 1282 | android.ModuleContext |
| 1283 | } |
| 1284 | |
| 1285 | func (c *flattenedApexContext) InstallBypassMake() bool { |
| 1286 | return true |
| 1287 | } |
| 1288 | |
Jiyong Park | 201cedd | 2020-02-07 17:25:49 +0900 | [diff] [blame] | 1289 | // Visit dependencies that contributes to the payload of this APEX |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 1290 | func (a *apexBundle) WalkPayloadDeps(ctx android.ModuleContext, do android.PayloadDepsCallback) { |
Paul Duffin | df915ff | 2020-03-30 17:58:21 +0100 | [diff] [blame] | 1291 | ctx.WalkDeps(func(child, parent android.Module) bool { |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1292 | am, ok := child.(android.ApexModule) |
| 1293 | if !ok || !am.CanHaveApexVariants() { |
| 1294 | return false |
| 1295 | } |
| 1296 | |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1297 | childApexInfo := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo) |
| 1298 | |
Martin Stjernholm | 58c33f0 | 2020-07-06 22:56:01 +0100 | [diff] [blame] | 1299 | dt := ctx.OtherModuleDependencyTag(child) |
| 1300 | |
| 1301 | if _, ok := dt.(android.ExcludeFromApexContentsTag); ok { |
| 1302 | return false |
| 1303 | } |
| 1304 | |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1305 | // Check for the direct dependencies that contribute to the payload |
Martin Stjernholm | 58c33f0 | 2020-07-06 22:56:01 +0100 | [diff] [blame] | 1306 | if adt, ok := dt.(dependencyTag); ok { |
| 1307 | if adt.payload { |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1308 | return do(ctx, parent, am, false /* externalDep */) |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1309 | } |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1310 | // As soon as the dependency graph crosses the APEX boundary, don't go further. |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1311 | return false |
| 1312 | } |
| 1313 | |
| 1314 | // Check for the indirect dependencies if it is considered as part of the APEX |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1315 | if android.InList(ctx.ModuleName(), childApexInfo.InApexes) { |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1316 | return do(ctx, parent, am, false /* externalDep */) |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1317 | } |
| 1318 | |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1319 | return do(ctx, parent, am, true /* externalDep */) |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1320 | }) |
| 1321 | } |
| 1322 | |
Dan Albert | c806053 | 2020-07-22 22:32:17 -0700 | [diff] [blame] | 1323 | func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) android.ApiLevel { |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 1324 | ver := proptools.String(a.properties.Min_sdk_version) |
| 1325 | if ver == "" { |
Dan Albert | 0b176c8 | 2020-07-23 16:43:25 -0700 | [diff] [blame] | 1326 | return android.FutureApiLevel |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 1327 | } |
Dan Albert | c806053 | 2020-07-22 22:32:17 -0700 | [diff] [blame] | 1328 | apiLevel, err := android.ApiLevelFromUser(ctx, ver) |
Jooyung Han | aed150d | 2020-04-02 01:41:41 +0900 | [diff] [blame] | 1329 | if err != nil { |
| 1330 | ctx.PropertyErrorf("min_sdk_version", "%s", err.Error()) |
Dan Albert | c806053 | 2020-07-22 22:32:17 -0700 | [diff] [blame] | 1331 | return android.NoneApiLevel |
Jooyung Han | 03b5185 | 2020-02-26 22:45:42 +0900 | [diff] [blame] | 1332 | } |
Dan Albert | c806053 | 2020-07-22 22:32:17 -0700 | [diff] [blame] | 1333 | if apiLevel.IsPreview() { |
| 1334 | // All codenames should build against "current". |
Dan Albert | 0b176c8 | 2020-07-23 16:43:25 -0700 | [diff] [blame] | 1335 | return android.FutureApiLevel |
Dan Albert | c806053 | 2020-07-22 22:32:17 -0700 | [diff] [blame] | 1336 | } |
| 1337 | return apiLevel |
Jooyung Han | 03b5185 | 2020-02-26 22:45:42 +0900 | [diff] [blame] | 1338 | } |
| 1339 | |
Artur Satayev | 849f844 | 2020-04-28 14:57:42 +0100 | [diff] [blame] | 1340 | func (a *apexBundle) Updatable() bool { |
| 1341 | return proptools.Bool(a.properties.Updatable) |
| 1342 | } |
| 1343 | |
| 1344 | var _ android.ApexBundleDepsInfoIntf = (*apexBundle)(nil) |
| 1345 | |
Jiyong Park | 201cedd | 2020-02-07 17:25:49 +0900 | [diff] [blame] | 1346 | // Ensures that the dependencies are marked as available for this APEX |
| 1347 | func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { |
| 1348 | // Let's be practical. Availability for test, host, and the VNDK apex isn't important |
| 1349 | if ctx.Host() || a.testApex || a.vndkApex { |
| 1350 | return |
| 1351 | } |
| 1352 | |
Jooyung Han | 85d6176 | 2020-06-24 23:50:26 +0900 | [diff] [blame] | 1353 | // Because APEXes targeting other than system/system_ext partitions |
| 1354 | // can't set apex_available, we skip checks for these APEXes |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 1355 | if a.SocSpecific() || a.DeviceSpecific() || |
| 1356 | (a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) { |
Jooyung Han | 85d6176 | 2020-06-24 23:50:26 +0900 | [diff] [blame] | 1357 | return |
| 1358 | } |
| 1359 | |
Jiyong Park | 58d1090 | 2020-03-28 14:43:19 +0900 | [diff] [blame] | 1360 | // Coverage build adds additional dependencies for the coverage-only runtime libraries. |
| 1361 | // Requiring them and their transitive depencies with apex_available is not right |
| 1362 | // because they just add noise. |
| 1363 | if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") || a.IsNativeCoverageNeeded(ctx) { |
| 1364 | return |
| 1365 | } |
| 1366 | |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 1367 | a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1368 | if externalDep { |
| 1369 | // As soon as the dependency graph crosses the APEX boundary, don't go further. |
| 1370 | return false |
| 1371 | } |
| 1372 | |
Jiyong Park | 201cedd | 2020-02-07 17:25:49 +0900 | [diff] [blame] | 1373 | apexName := ctx.ModuleName() |
Jooyung Han | 5e9013b | 2020-03-10 06:23:13 +0900 | [diff] [blame] | 1374 | fromName := ctx.OtherModuleName(from) |
| 1375 | toName := ctx.OtherModuleName(to) |
Paul Duffin | 6534770 | 2020-03-31 15:23:40 +0100 | [diff] [blame] | 1376 | |
| 1377 | // If `to` is not actually in the same APEX as `from` then it does not need apex_available and neither |
| 1378 | // do any of its dependencies. |
| 1379 | if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) { |
| 1380 | // As soon as the dependency graph crosses the APEX boundary, don't go further. |
| 1381 | return false |
| 1382 | } |
| 1383 | |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 1384 | if to.AvailableFor(apexName) || baselineApexAvailable(apexName, toName) { |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1385 | return true |
Jiyong Park | 201cedd | 2020-02-07 17:25:49 +0900 | [diff] [blame] | 1386 | } |
Steven Moreland | 6e36cd6 | 2020-10-22 01:08:35 +0000 | [diff] [blame] | 1387 | ctx.ModuleErrorf("%q requires %q that doesn't list the APEX under 'apex_available'. Dependency path:%s", fromName, toName, ctx.GetPathString(true)) |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1388 | // Visit this module's dependencies to check and report any issues with their availability. |
| 1389 | return true |
Jiyong Park | 201cedd | 2020-02-07 17:25:49 +0900 | [diff] [blame] | 1390 | }) |
| 1391 | } |
| 1392 | |
Jooyung Han | 548640b | 2020-04-27 12:10:30 +0900 | [diff] [blame] | 1393 | func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) { |
Artur Satayev | 849f844 | 2020-04-28 14:57:42 +0100 | [diff] [blame] | 1394 | if a.Updatable() { |
Jooyung Han | 548640b | 2020-04-27 12:10:30 +0900 | [diff] [blame] | 1395 | if String(a.properties.Min_sdk_version) == "" { |
| 1396 | ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well") |
| 1397 | } |
Artur Satayev | 8cf899a | 2020-04-15 17:29:42 +0100 | [diff] [blame] | 1398 | |
| 1399 | a.checkJavaStableSdkVersion(ctx) |
Jooyung Han | 548640b | 2020-04-27 12:10:30 +0900 | [diff] [blame] | 1400 | } |
| 1401 | } |
| 1402 | |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 1403 | func (a *apexBundle) checkMinSdkVersion(ctx android.ModuleContext) { |
| 1404 | if a.testApex || a.vndkApex { |
| 1405 | return |
| 1406 | } |
| 1407 | // Meaningless to check min_sdk_version when building use_vendor modules against non-Trebleized targets |
| 1408 | if proptools.Bool(a.properties.Use_vendor) && ctx.DeviceConfig().VndkVersion() == "" { |
| 1409 | return |
| 1410 | } |
Dan Albert | c806053 | 2020-07-22 22:32:17 -0700 | [diff] [blame] | 1411 | // apexBundle::minSdkVersion reports its own errors. |
| 1412 | minSdkVersion := a.minSdkVersion(ctx) |
| 1413 | android.CheckMinSdkVersion(a, ctx, minSdkVersion) |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 1414 | } |
| 1415 | |
Jiyong Park | 7d95a51 | 2020-05-10 15:16:24 +0900 | [diff] [blame] | 1416 | // Ensures that a lib providing stub isn't statically linked |
| 1417 | func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext) { |
| 1418 | // Practically, we only care about regular APEXes on the device. |
| 1419 | if ctx.Host() || a.testApex || a.vndkApex { |
| 1420 | return |
| 1421 | } |
| 1422 | |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1423 | abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo) |
| 1424 | |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 1425 | a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { |
Jiyong Park | 7d95a51 | 2020-05-10 15:16:24 +0900 | [diff] [blame] | 1426 | if ccm, ok := to.(*cc.Module); ok { |
| 1427 | apexName := ctx.ModuleName() |
| 1428 | fromName := ctx.OtherModuleName(from) |
| 1429 | toName := ctx.OtherModuleName(to) |
| 1430 | |
| 1431 | // If `to` is not actually in the same APEX as `from` then it does not need apex_available and neither |
| 1432 | // do any of its dependencies. |
| 1433 | if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) { |
| 1434 | // As soon as the dependency graph crosses the APEX boundary, don't go further. |
| 1435 | return false |
| 1436 | } |
| 1437 | |
Jiyong Park | 7d95a51 | 2020-05-10 15:16:24 +0900 | [diff] [blame] | 1438 | // The dynamic linker and crash_dump tool in the runtime APEX is the only exception to this rule. |
| 1439 | // It can't make the static dependencies dynamic because it can't |
| 1440 | // do the dynamic linking for itself. |
| 1441 | if apexName == "com.android.runtime" && (fromName == "linker" || fromName == "crash_dump") { |
| 1442 | return false |
| 1443 | } |
| 1444 | |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1445 | isStubLibraryFromOtherApex := ccm.HasStubsVariants() && !abInfo.Contents.DirectlyInApex(toName) |
Jiyong Park | 7d95a51 | 2020-05-10 15:16:24 +0900 | [diff] [blame] | 1446 | if isStubLibraryFromOtherApex && !externalDep { |
| 1447 | ctx.ModuleErrorf("%q required by %q is a native library providing stub. "+ |
| 1448 | "It shouldn't be included in this APEX via static linking. Dependency path: %s", to.String(), fromName, ctx.GetPathString(false)) |
| 1449 | } |
| 1450 | |
| 1451 | } |
| 1452 | return true |
| 1453 | }) |
| 1454 | } |
| 1455 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1456 | func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Martin Stjernholm | 56507b4 | 2020-06-24 22:31:36 +0100 | [diff] [blame] | 1457 | buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuildApps() |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1458 | switch a.properties.ApexType { |
| 1459 | case imageApex: |
| 1460 | if buildFlattenedAsDefault { |
| 1461 | a.suffix = imageApexSuffix |
| 1462 | } else { |
| 1463 | a.suffix = "" |
| 1464 | a.primaryApexType = true |
Jooyung Han | 3ab2c3e | 2019-12-05 16:27:44 +0900 | [diff] [blame] | 1465 | |
| 1466 | if ctx.Config().InstallExtraFlattenedApexes() { |
Jiyong Park | 956305c | 2020-01-09 12:32:06 +0900 | [diff] [blame] | 1467 | a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix) |
Jooyung Han | 3ab2c3e | 2019-12-05 16:27:44 +0900 | [diff] [blame] | 1468 | } |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1469 | } |
| 1470 | case zipApex: |
| 1471 | if proptools.String(a.properties.Payload_type) == "zip" { |
| 1472 | a.suffix = "" |
| 1473 | a.primaryApexType = true |
| 1474 | } else { |
| 1475 | a.suffix = zipApexSuffix |
| 1476 | } |
| 1477 | case flattenedApex: |
| 1478 | if buildFlattenedAsDefault { |
| 1479 | a.suffix = "" |
| 1480 | a.primaryApexType = true |
| 1481 | } else { |
| 1482 | a.suffix = flattenedSuffix |
| 1483 | } |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1484 | } |
| 1485 | |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1486 | if len(a.properties.Tests) > 0 && !a.testApex { |
| 1487 | ctx.PropertyErrorf("tests", "property not allowed in apex module type") |
| 1488 | return |
| 1489 | } |
| 1490 | |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1491 | a.checkApexAvailability(ctx) |
Jooyung Han | 548640b | 2020-04-27 12:10:30 +0900 | [diff] [blame] | 1492 | a.checkUpdatable(ctx) |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 1493 | a.checkMinSdkVersion(ctx) |
Jiyong Park | 7d95a51 | 2020-05-10 15:16:24 +0900 | [diff] [blame] | 1494 | a.checkStaticLinkingToStubLibraries(ctx) |
Jiyong Park | 678c881 | 2020-02-07 17:25:49 +0900 | [diff] [blame] | 1495 | |
Alex Light | fc0bd7c | 2019-01-29 18:31:59 -0800 | [diff] [blame] | 1496 | handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case) |
| 1497 | |
Jooyung Han | e163303 | 2019-08-01 17:41:43 +0900 | [diff] [blame] | 1498 | // native lib dependencies |
| 1499 | var provideNativeLibs []string |
| 1500 | var requireNativeLibs []string |
| 1501 | |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1502 | var filesInfo []apexFile |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 1503 | // TODO(jiyong) do this using WalkPayloadDeps |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1504 | ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1505 | depTag := ctx.OtherModuleDependencyTag(child) |
Paul Duffin | dddd546 | 2020-04-07 15:25:44 +0100 | [diff] [blame] | 1506 | if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok { |
| 1507 | return false |
| 1508 | } |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1509 | depName := ctx.OtherModuleName(child) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1510 | if _, isDirectDep := parent.(*apexBundle); isDirectDep { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1511 | switch depTag { |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1512 | case sharedLibTag, jniLibTag: |
| 1513 | isJniLib := depTag == jniLibTag |
Jooyung Han | faa2d5f | 2020-02-06 17:42:40 +0900 | [diff] [blame] | 1514 | if c, ok := child.(*cc.Module); ok { |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1515 | fi := apexFileForNativeLibrary(ctx, c, handleSpecialLibs) |
| 1516 | fi.isJniLib = isJniLib |
| 1517 | filesInfo = append(filesInfo, fi) |
Jooyung Han | 45a9677 | 2020-06-15 14:59:42 +0900 | [diff] [blame] | 1518 | // Collect the list of stub-providing libs except: |
| 1519 | // - VNDK libs are only for vendors |
| 1520 | // - bootstrap bionic libs are treated as provided by system |
| 1521 | if c.HasStubsVariants() && !a.vndkApex && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) { |
Jiyong Park | f1493cc | 2020-05-29 21:29:20 +0900 | [diff] [blame] | 1522 | provideNativeLibs = append(provideNativeLibs, fi.Stem()) |
| 1523 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1524 | return true // track transitive dependencies |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1525 | } else { |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1526 | propertyName := "native_shared_libs" |
| 1527 | if isJniLib { |
| 1528 | propertyName = "jni_libs" |
| 1529 | } |
| 1530 | ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1531 | } |
| 1532 | case executableTag: |
| 1533 | if cc, ok := child.(*cc.Module); ok { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1534 | filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc)) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1535 | return true // track transitive dependencies |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 1536 | } else if sh, ok := child.(*sh.ShBinary); ok { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1537 | filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh)) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1538 | } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1539 | filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py)) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1540 | } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1541 | filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb)) |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1542 | } else { |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1543 | ctx.PropertyErrorf("binaries", "%q is neither cc_binary, (embedded) py_binary, (host) blueprint_go_binary, (host) bootstrap_go_binary, nor sh_binary", depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1544 | } |
| 1545 | case javaLibTag: |
Jiyong Park | 77acec6 | 2020-06-01 21:39:15 +0900 | [diff] [blame] | 1546 | switch child.(type) { |
Paul Duffin | eedc5d5 | 2020-06-12 17:46:39 +0100 | [diff] [blame] | 1547 | case *java.Library, *java.SdkLibrary, *java.DexImport, *java.SdkLibraryImport: |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1548 | af := apexFileForJavaLibrary(ctx, child.(javaModule)) |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 1549 | if !af.Ok() { |
| 1550 | ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName) |
| 1551 | return false |
| 1552 | } |
| 1553 | filesInfo = append(filesInfo, af) |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 1554 | return true // track transitive dependencies |
Jiyong Park | 77acec6 | 2020-06-01 21:39:15 +0900 | [diff] [blame] | 1555 | default: |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 1556 | ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child)) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1557 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1558 | case androidAppTag: |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1559 | if ap, ok := child.(*java.AndroidApp); ok { |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1560 | filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap)) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1561 | return true // track transitive dependencies |
| 1562 | } else if ap, ok := child.(*java.AndroidAppImport); ok { |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1563 | filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap)) |
Dario Freni | 6f3937c | 2019-12-20 22:58:03 +0000 | [diff] [blame] | 1564 | } else if ap, ok := child.(*java.AndroidTestHelperApp); ok { |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1565 | filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap)) |
Sasha Smundak | 18d98bc | 2020-05-27 16:36:07 -0700 | [diff] [blame] | 1566 | } else if ap, ok := child.(*java.AndroidAppSet); ok { |
| 1567 | appDir := "app" |
| 1568 | if ap.Privileged() { |
| 1569 | appDir = "priv-app" |
| 1570 | } |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1571 | af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(), |
Sasha Smundak | 18d98bc | 2020-05-27 16:36:07 -0700 | [diff] [blame] | 1572 | filepath.Join(appDir, ap.BaseModuleName()), appSet, ap) |
| 1573 | af.certificate = java.PresignedCertificate |
| 1574 | filesInfo = append(filesInfo, af) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1575 | } else { |
| 1576 | ctx.PropertyErrorf("apps", "%q is not an android_app module", depName) |
| 1577 | } |
Jiyong Park | 69aeba9 | 2020-04-24 21:16:36 +0900 | [diff] [blame] | 1578 | case rroTag: |
| 1579 | if rro, ok := child.(java.RuntimeResourceOverlayModule); ok { |
| 1580 | filesInfo = append(filesInfo, apexFileForRuntimeResourceOverlay(ctx, rro)) |
| 1581 | } else { |
| 1582 | ctx.PropertyErrorf("rros", "%q is not an runtime_resource_overlay module", depName) |
| 1583 | } |
markchien | 2f59ec9 | 2020-09-02 16:23:38 +0800 | [diff] [blame] | 1584 | case bpfTag: |
| 1585 | if bpfProgram, ok := child.(bpf.BpfModule); ok { |
| 1586 | filesToCopy, _ := bpfProgram.OutputFiles("") |
| 1587 | for _, bpfFile := range filesToCopy { |
| 1588 | filesInfo = append(filesInfo, apexFileForBpfProgram(ctx, bpfFile, bpfProgram)) |
| 1589 | } |
| 1590 | } else { |
| 1591 | ctx.PropertyErrorf("bpfs", "%q is not a bpf module", depName) |
| 1592 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1593 | case prebuiltTag: |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 1594 | if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1595 | filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName)) |
atrost | 6e12625 | 2020-01-27 17:01:16 +0000 | [diff] [blame] | 1596 | } else if prebuilt, ok := child.(java.PlatformCompatConfigIntf); ok { |
| 1597 | filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, prebuilt, depName)) |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1598 | } else { |
atrost | 6e12625 | 2020-01-27 17:01:16 +0000 | [diff] [blame] | 1599 | ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc and not a platform_compat_config module", depName) |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1600 | } |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1601 | case testTag: |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1602 | if ccTest, ok := child.(*cc.Module); ok { |
| 1603 | if ccTest.IsTestPerSrcAllTestsVariation() { |
| 1604 | // Multiple-output test module (where `test_per_src: true`). |
| 1605 | // |
| 1606 | // `ccTest` is the "" ("all tests") variation of a `test_per_src` module. |
| 1607 | // We do not add this variation to `filesInfo`, as it has no output; |
| 1608 | // however, we do add the other variations of this module as indirect |
| 1609 | // dependencies (see below). |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 1610 | } else { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1611 | // Single-output test module (where `test_per_src: false`). |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1612 | af := apexFileForExecutable(ctx, ccTest) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1613 | af.class = nativeTest |
| 1614 | filesInfo = append(filesInfo, af) |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 1615 | } |
Jiyong Park | af9539f | 2020-05-04 10:31:32 +0900 | [diff] [blame] | 1616 | return true // track transitive dependencies |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1617 | } else { |
| 1618 | ctx.PropertyErrorf("tests", "%q is not a cc module", depName) |
| 1619 | } |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1620 | case keyTag: |
| 1621 | if key, ok := child.(*apexKey); ok { |
Jiyong Park | 0ca3ce8 | 2019-02-18 15:25:04 +0900 | [diff] [blame] | 1622 | a.private_key_file = key.private_key_file |
| 1623 | a.public_key_file = key.public_key_file |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1624 | } else { |
| 1625 | ctx.PropertyErrorf("key", "%q is not an apex_key module", depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1626 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1627 | return false |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 1628 | case certificateTag: |
| 1629 | if dep, ok := child.(*java.AndroidAppCertificate); ok { |
Jiyong Park | 0ca3ce8 | 2019-02-18 15:25:04 +0900 | [diff] [blame] | 1630 | a.container_certificate_file = dep.Certificate.Pem |
| 1631 | a.container_private_key_file = dep.Certificate.Key |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 1632 | } else { |
| 1633 | ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName) |
| 1634 | } |
Jiyong Park | 03b68dd | 2019-07-26 23:20:40 +0900 | [diff] [blame] | 1635 | case android.PrebuiltDepTag: |
| 1636 | // If the prebuilt is force disabled, remember to delete the prebuilt file |
| 1637 | // that might have been installed in the previous builds |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 1638 | if prebuilt, ok := child.(prebuilt); ok && prebuilt.isForceDisabled() { |
Jiyong Park | 03b68dd | 2019-07-26 23:20:40 +0900 | [diff] [blame] | 1639 | a.prebuiltFileToDelete = prebuilt.InstallFilename() |
| 1640 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1641 | } |
Jooyung Han | 8aee204 | 2019-10-29 05:08:31 +0900 | [diff] [blame] | 1642 | } else if !a.vndkApex { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1643 | // indirect dependencies |
Jooyung Han | 9c80bae | 2019-08-20 17:30:57 +0900 | [diff] [blame] | 1644 | if am, ok := child.(android.ApexModule); ok { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1645 | // We cannot use a switch statement on `depTag` here as the checked |
| 1646 | // tags used below are private (e.g. `cc.sharedDepTag`). |
Jiyong Park | 52cd06f | 2019-11-11 10:14:32 +0900 | [diff] [blame] | 1647 | if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1648 | if cc, ok := child.(*cc.Module); ok { |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 1649 | if cc.UseVndk() && proptools.Bool(a.properties.Use_vndk_as_stable) && cc.IsVndk() { |
Jooyung Han | 6c4cc9c | 2020-07-29 16:00:54 +0900 | [diff] [blame] | 1650 | requireNativeLibs = append(requireNativeLibs, ":vndk") |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 1651 | return false |
| 1652 | } |
Jiyong Park | f1493cc | 2020-05-29 21:29:20 +0900 | [diff] [blame] | 1653 | af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs) |
| 1654 | af.transitiveDep = true |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1655 | abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo) |
| 1656 | if !a.Host() && !abInfo.Contents.DirectlyInApex(depName) && (cc.IsStubs() || cc.HasStubsVariants()) { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1657 | // If the dependency is a stubs lib, don't include it in this APEX, |
| 1658 | // but make sure that the lib is installed on the device. |
| 1659 | // In case no APEX is having the lib, the lib is installed to the system |
| 1660 | // partition. |
| 1661 | // |
| 1662 | // Always include if we are a host-apex however since those won't have any |
| 1663 | // system libraries. |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1664 | if !am.DirectlyInAnyApex() { |
Jooyung Han | efb184e | 2020-06-25 17:14:25 +0900 | [diff] [blame] | 1665 | // we need a module name for Make |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 1666 | name := cc.ImplementationModuleName(ctx) |
| 1667 | |
| 1668 | if !proptools.Bool(a.properties.Use_vendor) { |
Jooyung Han | efb184e | 2020-06-25 17:14:25 +0900 | [diff] [blame] | 1669 | // we don't use subName(.vendor) for a "use_vendor: true" apex |
| 1670 | // which is supposed to be installed in /system |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 1671 | name += cc.Properties.SubName |
Jooyung Han | efb184e | 2020-06-25 17:14:25 +0900 | [diff] [blame] | 1672 | } |
| 1673 | if !android.InList(name, a.requiredDeps) { |
| 1674 | a.requiredDeps = append(a.requiredDeps, name) |
| 1675 | } |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1676 | } |
Jiyong Park | f1493cc | 2020-05-29 21:29:20 +0900 | [diff] [blame] | 1677 | requireNativeLibs = append(requireNativeLibs, af.Stem()) |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1678 | // Don't track further |
| 1679 | return false |
| 1680 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1681 | filesInfo = append(filesInfo, af) |
| 1682 | return true // track transitive dependencies |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1683 | } |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1684 | } else if cc.IsTestPerSrcDepTag(depTag) { |
| 1685 | if cc, ok := child.(*cc.Module); ok { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1686 | af := apexFileForExecutable(ctx, cc) |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1687 | // Handle modules created as `test_per_src` variations of a single test module: |
| 1688 | // use the name of the generated test binary (`fileToCopy`) instead of the name |
| 1689 | // of the original test module (`depName`, shared by all `test_per_src` |
| 1690 | // variations of that module). |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1691 | af.androidMkModuleName = filepath.Base(af.builtFile.String()) |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 1692 | // these are not considered transitive dep |
| 1693 | af.transitiveDep = false |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1694 | filesInfo = append(filesInfo, af) |
| 1695 | return true // track transitive dependencies |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1696 | } |
Jiyong Park | 52cd06f | 2019-11-11 10:14:32 +0900 | [diff] [blame] | 1697 | } else if java.IsJniDepTag(depTag) { |
Jooyung Han | b7bebe2 | 2020-02-25 16:59:29 +0900 | [diff] [blame] | 1698 | // Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps |
| 1699 | return false |
Jiyong Park | e383388 | 2020-02-17 17:28:10 +0900 | [diff] [blame] | 1700 | } else if java.IsXmlPermissionsFileDepTag(depTag) { |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 1701 | if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok { |
Jiyong Park | e383388 | 2020-02-17 17:28:10 +0900 | [diff] [blame] | 1702 | filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName)) |
| 1703 | } |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1704 | } else if _, ok := depTag.(android.CopyDirectlyInAnyApexTag); ok { |
| 1705 | // nothing |
Jooyung Han | 9c80bae | 2019-08-20 17:30:57 +0900 | [diff] [blame] | 1706 | } else if am.CanHaveApexVariants() && am.IsInstallableToApex() { |
Jiyong Park | 1c7e962 | 2020-05-07 16:12:13 +0900 | [diff] [blame] | 1707 | ctx.ModuleErrorf("unexpected tag %s for indirect dependency %q", android.PrettyPrintTag(depTag), depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1708 | } |
| 1709 | } |
| 1710 | } |
| 1711 | return false |
| 1712 | }) |
| 1713 | |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 1714 | // Specific to the ART apex: dexpreopt artifacts for libcore Java libraries. |
| 1715 | // Build rules are generated by the dexpreopt singleton, and here we access build artifacts |
| 1716 | // via the global boot image config. |
| 1717 | if a.artApex { |
Tim Joines | c1ef1bb | 2020-03-18 18:00:41 +0000 | [diff] [blame] | 1718 | for arch, files := range java.DexpreoptedArtApexJars(ctx) { |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 1719 | dirInApex := filepath.Join("javalib", arch.String()) |
| 1720 | for _, f := range files { |
| 1721 | localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String()) |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1722 | af := newApexFile(ctx, f, localModule, dirInApex, etc, nil) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1723 | filesInfo = append(filesInfo, af) |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 1724 | } |
| 1725 | } |
| 1726 | } |
| 1727 | |
Jiyong Park | 0ca3ce8 | 2019-02-18 15:25:04 +0900 | [diff] [blame] | 1728 | if a.private_key_file == nil { |
Jiyong Park | fa0a373 | 2018-11-09 05:52:26 +0900 | [diff] [blame] | 1729 | ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key)) |
| 1730 | return |
| 1731 | } |
| 1732 | |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1733 | // remove duplicates in filesInfo |
| 1734 | removeDup := func(filesInfo []apexFile) []apexFile { |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 1735 | encountered := make(map[string]apexFile) |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1736 | for _, f := range filesInfo { |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1737 | dest := filepath.Join(f.installDir, f.builtFile.Base()) |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 1738 | if e, ok := encountered[dest]; !ok { |
| 1739 | encountered[dest] = f |
| 1740 | } else { |
| 1741 | // If a module is directly included and also transitively depended on |
| 1742 | // consider it as directly included. |
| 1743 | e.transitiveDep = e.transitiveDep && f.transitiveDep |
| 1744 | encountered[dest] = e |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1745 | } |
| 1746 | } |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 1747 | var result []apexFile |
| 1748 | for _, v := range encountered { |
| 1749 | result = append(result, v) |
| 1750 | } |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1751 | return result |
| 1752 | } |
| 1753 | filesInfo = removeDup(filesInfo) |
| 1754 | |
| 1755 | // to have consistent build rules |
| 1756 | sort.Slice(filesInfo, func(i, j int) bool { |
| 1757 | return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String() |
| 1758 | }) |
| 1759 | |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1760 | a.installDir = android.PathForModuleInstall(ctx, "apex") |
| 1761 | a.filesInfo = filesInfo |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1762 | |
Theotime Combes | 4ba38c1 | 2020-06-12 12:46:59 +0000 | [diff] [blame] | 1763 | switch proptools.StringDefault(a.properties.Payload_fs_type, ext4FsType) { |
| 1764 | case ext4FsType: |
| 1765 | a.payloadFsType = ext4 |
| 1766 | case f2fsFsType: |
| 1767 | a.payloadFsType = f2fs |
| 1768 | default: |
| 1769 | ctx.PropertyErrorf("payload_fs_type", "%q is not a valid filesystem for apex [ext4, f2fs]", *a.properties.Payload_fs_type) |
| 1770 | } |
| 1771 | |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 1772 | // Optimization. If we are building bundled APEX, for the files that are gathered due to the |
| 1773 | // transitive dependencies, don't place them inside the APEX, but place a symlink pointing |
| 1774 | // the same library in the system partition, thus effectively sharing the same libraries |
| 1775 | // across the APEX boundary. For unbundled APEX, all the gathered files are actually placed |
| 1776 | // in the APEX. |
| 1777 | a.linkToSystemLib = !ctx.Config().UnbundledBuild() && |
| 1778 | a.installable() && |
| 1779 | !proptools.Bool(a.properties.Use_vendor) |
Jooyung Han | 54aca7b | 2019-11-20 02:26:02 +0900 | [diff] [blame] | 1780 | |
Jooyung Han | 85d6176 | 2020-06-24 23:50:26 +0900 | [diff] [blame] | 1781 | // APEXes targeting other than system/system_ext partitions use vendor/product variants. |
| 1782 | // So we can't link them to /system/lib libs which are core variants. |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 1783 | if a.SocSpecific() || a.DeviceSpecific() || |
| 1784 | (a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) { |
Jooyung Han | 85d6176 | 2020-06-24 23:50:26 +0900 | [diff] [blame] | 1785 | a.linkToSystemLib = false |
| 1786 | } |
| 1787 | |
Jiyong Park | 9d67720 | 2020-02-19 16:29:35 +0900 | [diff] [blame] | 1788 | // We don't need the optimization for updatable APEXes, as it might give false signal |
| 1789 | // to the system health when the APEXes are still bundled (b/149805758) |
Artur Satayev | 849f844 | 2020-04-28 14:57:42 +0100 | [diff] [blame] | 1790 | if a.Updatable() && a.properties.ApexType == imageApex { |
Jiyong Park | 9d67720 | 2020-02-19 16:29:35 +0900 | [diff] [blame] | 1791 | a.linkToSystemLib = false |
| 1792 | } |
| 1793 | |
Jiyong Park | 638d30e | 2020-02-26 18:27:19 +0900 | [diff] [blame] | 1794 | // We also don't want the optimization for host APEXes, because it doesn't make sense. |
| 1795 | if ctx.Host() { |
| 1796 | a.linkToSystemLib = false |
| 1797 | } |
| 1798 | |
Jooyung Han | d15aa1f | 2019-09-27 00:38:03 +0900 | [diff] [blame] | 1799 | // prepare apex_manifest.json |
Jooyung Han | 01a3ee2 | 2019-11-02 02:52:25 +0900 | [diff] [blame] | 1800 | a.buildManifest(ctx, provideNativeLibs, requireNativeLibs) |
| 1801 | |
Jooyung Han | 580eb4f | 2020-06-24 19:33:06 +0900 | [diff] [blame] | 1802 | a.buildFileContexts(ctx) |
| 1803 | |
Jooyung Han | 01a3ee2 | 2019-11-02 02:52:25 +0900 | [diff] [blame] | 1804 | a.setCertificateAndPrivateKey(ctx) |
| 1805 | if a.properties.ApexType == flattenedApex { |
| 1806 | a.buildFlattenedApex(ctx) |
| 1807 | } else { |
| 1808 | a.buildUnflattenedApex(ctx) |
| 1809 | } |
| 1810 | |
Jooyung Han | 002ab68 | 2020-01-08 01:57:58 +0900 | [diff] [blame] | 1811 | a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx) |
Jiyong Park | 956305c | 2020-01-09 12:32:06 +0900 | [diff] [blame] | 1812 | |
| 1813 | a.buildApexDependencyInfo(ctx) |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 1814 | |
| 1815 | a.buildLintReports(ctx) |
Anton Hansson | 82d502a | 2020-11-11 12:33:14 +0000 | [diff] [blame] | 1816 | |
| 1817 | a.distFiles = a.GenerateTaggedDistFiles(ctx) |
Jooyung Han | 01a3ee2 | 2019-11-02 02:52:25 +0900 | [diff] [blame] | 1818 | } |
| 1819 | |
Artur Satayev | 8cf899a | 2020-04-15 17:29:42 +0100 | [diff] [blame] | 1820 | // Enforce that Java deps of the apex are using stable SDKs to compile |
| 1821 | func (a *apexBundle) checkJavaStableSdkVersion(ctx android.ModuleContext) { |
| 1822 | // Visit direct deps only. As long as we guarantee top-level deps are using |
| 1823 | // stable SDKs, java's checkLinkType guarantees correct usage for transitive deps |
| 1824 | ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) { |
| 1825 | tag := ctx.OtherModuleDependencyTag(module) |
| 1826 | switch tag { |
| 1827 | case javaLibTag, androidAppTag: |
| 1828 | if m, ok := module.(interface{ CheckStableSdkVersion() error }); ok { |
| 1829 | if err := m.CheckStableSdkVersion(); err != nil { |
| 1830 | ctx.ModuleErrorf("cannot depend on \"%v\": %v", ctx.OtherModuleName(module), err) |
| 1831 | } |
| 1832 | } |
| 1833 | } |
| 1834 | }) |
| 1835 | } |
| 1836 | |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 1837 | func baselineApexAvailable(apex, moduleName string) bool { |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 1838 | key := apex |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 1839 | moduleName = normalizeModuleName(moduleName) |
| 1840 | |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 1841 | if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) { |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 1842 | return true |
| 1843 | } |
| 1844 | |
| 1845 | key = android.AvailableToAnyApex |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 1846 | if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) { |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 1847 | return true |
| 1848 | } |
| 1849 | |
| 1850 | return false |
| 1851 | } |
| 1852 | |
| 1853 | func normalizeModuleName(moduleName string) string { |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1854 | // Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build |
| 1855 | // system. Trim the prefix for the check since they are confusing |
| 1856 | moduleName = strings.TrimPrefix(moduleName, "prebuilt_") |
| 1857 | if strings.HasPrefix(moduleName, "libclang_rt.") { |
| 1858 | // This module has many arch variants that depend on the product being built. |
| 1859 | // We don't want to list them all |
| 1860 | moduleName = "libclang_rt" |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 1861 | } |
Jooyung Han | acc7bbe | 2020-05-20 09:06:00 +0900 | [diff] [blame] | 1862 | if strings.HasPrefix(moduleName, "androidx.") { |
| 1863 | // TODO(b/156996905) Set apex_available/min_sdk_version for androidx support libraries |
| 1864 | moduleName = "androidx" |
| 1865 | } |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 1866 | return moduleName |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 1867 | } |
| 1868 | |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1869 | func newApexBundle() *apexBundle { |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1870 | module := &apexBundle{} |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1871 | module.AddProperties(&module.properties) |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 1872 | module.AddProperties(&module.targetProperties) |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 1873 | module.AddProperties(&module.overridableProperties) |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1874 | android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1875 | android.InitDefaultableModule(module) |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 1876 | android.InitSdkAwareModule(module) |
Jaewoong Jung | 7abcf8e | 2019-12-19 17:32:06 -0800 | [diff] [blame] | 1877 | android.InitOverridableModule(module, &module.overridableProperties.Overrides) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1878 | return module |
| 1879 | } |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 1880 | |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 1881 | func ApexBundleFactory(testApex bool, artApex bool) android.Module { |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1882 | bundle := newApexBundle() |
| 1883 | bundle.testApex = testApex |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 1884 | bundle.artApex = artApex |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1885 | return bundle |
| 1886 | } |
| 1887 | |
Jiyong Park | fce0b42 | 2020-02-11 03:56:06 +0900 | [diff] [blame] | 1888 | // apex_test is an APEX for testing. The difference from the ordinary apex module type is that |
| 1889 | // certain compatibility checks such as apex_available are not done for apex_test. |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1890 | func testApexBundleFactory() android.Module { |
| 1891 | bundle := newApexBundle() |
| 1892 | bundle.testApex = true |
| 1893 | return bundle |
| 1894 | } |
| 1895 | |
Jiyong Park | fce0b42 | 2020-02-11 03:56:06 +0900 | [diff] [blame] | 1896 | // apex packages other modules into an APEX file which is a packaging format for system-level |
| 1897 | // components like binaries, shared libraries, etc. |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 1898 | func BundleFactory() android.Module { |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1899 | return newApexBundle() |
| 1900 | } |
| 1901 | |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 1902 | // |
| 1903 | // Defaults |
| 1904 | // |
| 1905 | type Defaults struct { |
| 1906 | android.ModuleBase |
| 1907 | android.DefaultsModuleBase |
| 1908 | } |
| 1909 | |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 1910 | func defaultsFactory() android.Module { |
| 1911 | return DefaultsFactory() |
| 1912 | } |
| 1913 | |
| 1914 | func DefaultsFactory(props ...interface{}) android.Module { |
| 1915 | module := &Defaults{} |
| 1916 | |
| 1917 | module.AddProperties(props...) |
| 1918 | module.AddProperties( |
| 1919 | &apexBundleProperties{}, |
| 1920 | &apexTargetBundleProperties{}, |
Jooyung Han | f21c797 | 2019-12-16 22:32:06 +0900 | [diff] [blame] | 1921 | &overridableProperties{}, |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 1922 | ) |
| 1923 | |
| 1924 | android.InitDefaultsModule(module) |
| 1925 | return module |
| 1926 | } |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 1927 | |
| 1928 | // |
| 1929 | // OverrideApex |
| 1930 | // |
| 1931 | type OverrideApex struct { |
| 1932 | android.ModuleBase |
| 1933 | android.OverrideModuleBase |
| 1934 | } |
| 1935 | |
| 1936 | func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 1937 | // All the overrides happen in the base module. |
| 1938 | } |
| 1939 | |
| 1940 | // override_apex is used to create an apex module based on another apex module |
| 1941 | // by overriding some of its properties. |
| 1942 | func overrideApexFactory() android.Module { |
| 1943 | m := &OverrideApex{} |
| 1944 | m.AddProperties(&overridableProperties{}) |
| 1945 | |
| 1946 | android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 1947 | android.InitOverrideModule(m) |
| 1948 | return m |
| 1949 | } |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame^] | 1950 | |
| 1951 | var ( |
| 1952 | apexAvailBaseline = makeApexAvailableBaseline() |
| 1953 | inverseApexAvailBaseline = invertApexBaseline(apexAvailBaseline) |
| 1954 | ) |
| 1955 | |
| 1956 | // Transform the map of apex -> modules to module -> apexes. |
| 1957 | func invertApexBaseline(m map[string][]string) map[string][]string { |
| 1958 | r := make(map[string][]string) |
| 1959 | for apex, modules := range m { |
| 1960 | for _, module := range modules { |
| 1961 | r[module] = append(r[module], apex) |
| 1962 | } |
| 1963 | } |
| 1964 | return r |
| 1965 | } |
| 1966 | |
| 1967 | // Retrieve the baseline of apexes to which the supplied module belongs. |
| 1968 | func BaselineApexAvailable(moduleName string) []string { |
| 1969 | return inverseApexAvailBaseline[normalizeModuleName(moduleName)] |
| 1970 | } |
| 1971 | |
| 1972 | // This is a map from apex to modules, which overrides the |
| 1973 | // apex_available setting for that particular module to make |
| 1974 | // it available for the apex regardless of its setting. |
| 1975 | // TODO(b/147364041): remove this |
| 1976 | func makeApexAvailableBaseline() map[string][]string { |
| 1977 | // The "Module separator"s below are employed to minimize merge conflicts. |
| 1978 | m := make(map[string][]string) |
| 1979 | // |
| 1980 | // Module separator |
| 1981 | // |
| 1982 | m["com.android.appsearch"] = []string{ |
| 1983 | "icing-java-proto-lite", |
| 1984 | "libprotobuf-java-lite", |
| 1985 | } |
| 1986 | // |
| 1987 | // Module separator |
| 1988 | // |
| 1989 | m["com.android.bluetooth.updatable"] = []string{ |
| 1990 | "android.hardware.audio.common@5.0", |
| 1991 | "android.hardware.bluetooth.a2dp@1.0", |
| 1992 | "android.hardware.bluetooth.audio@2.0", |
| 1993 | "android.hardware.bluetooth@1.0", |
| 1994 | "android.hardware.bluetooth@1.1", |
| 1995 | "android.hardware.graphics.bufferqueue@1.0", |
| 1996 | "android.hardware.graphics.bufferqueue@2.0", |
| 1997 | "android.hardware.graphics.common@1.0", |
| 1998 | "android.hardware.graphics.common@1.1", |
| 1999 | "android.hardware.graphics.common@1.2", |
| 2000 | "android.hardware.media@1.0", |
| 2001 | "android.hidl.safe_union@1.0", |
| 2002 | "android.hidl.token@1.0", |
| 2003 | "android.hidl.token@1.0-utils", |
| 2004 | "avrcp-target-service", |
| 2005 | "avrcp_headers", |
| 2006 | "bluetooth-protos-lite", |
| 2007 | "bluetooth.mapsapi", |
| 2008 | "com.android.vcard", |
| 2009 | "dnsresolver_aidl_interface-V2-java", |
| 2010 | "ipmemorystore-aidl-interfaces-V5-java", |
| 2011 | "ipmemorystore-aidl-interfaces-java", |
| 2012 | "internal_include_headers", |
| 2013 | "lib-bt-packets", |
| 2014 | "lib-bt-packets-avrcp", |
| 2015 | "lib-bt-packets-base", |
| 2016 | "libFraunhoferAAC", |
| 2017 | "libaudio-a2dp-hw-utils", |
| 2018 | "libaudio-hearing-aid-hw-utils", |
| 2019 | "libbinder_headers", |
| 2020 | "libbluetooth", |
| 2021 | "libbluetooth-types", |
| 2022 | "libbluetooth-types-header", |
| 2023 | "libbluetooth_gd", |
| 2024 | "libbluetooth_headers", |
| 2025 | "libbluetooth_jni", |
| 2026 | "libbt-audio-hal-interface", |
| 2027 | "libbt-bta", |
| 2028 | "libbt-common", |
| 2029 | "libbt-hci", |
| 2030 | "libbt-platform-protos-lite", |
| 2031 | "libbt-protos-lite", |
| 2032 | "libbt-sbc-decoder", |
| 2033 | "libbt-sbc-encoder", |
| 2034 | "libbt-stack", |
| 2035 | "libbt-utils", |
| 2036 | "libbtcore", |
| 2037 | "libbtdevice", |
| 2038 | "libbte", |
| 2039 | "libbtif", |
| 2040 | "libchrome", |
| 2041 | "libevent", |
| 2042 | "libfmq", |
| 2043 | "libg722codec", |
| 2044 | "libgui_headers", |
| 2045 | "libmedia_headers", |
| 2046 | "libmodpb64", |
| 2047 | "libosi", |
| 2048 | "libstagefright_foundation_headers", |
| 2049 | "libstagefright_headers", |
| 2050 | "libstatslog", |
| 2051 | "libstatssocket", |
| 2052 | "libtinyxml2", |
| 2053 | "libudrv-uipc", |
| 2054 | "libz", |
| 2055 | "media_plugin_headers", |
| 2056 | "net-utils-services-common", |
| 2057 | "netd_aidl_interface-unstable-java", |
| 2058 | "netd_event_listener_interface-java", |
| 2059 | "netlink-client", |
| 2060 | "networkstack-client", |
| 2061 | "sap-api-java-static", |
| 2062 | "services.net", |
| 2063 | } |
| 2064 | // |
| 2065 | // Module separator |
| 2066 | // |
| 2067 | m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"} |
| 2068 | // |
| 2069 | // Module separator |
| 2070 | // |
| 2071 | m["com.android.extservices"] = []string{ |
| 2072 | "error_prone_annotations", |
| 2073 | "ExtServices-core", |
| 2074 | "ExtServices", |
| 2075 | "libtextclassifier-java", |
| 2076 | "libz_current", |
| 2077 | "textclassifier-statsd", |
| 2078 | "TextClassifierNotificationLibNoManifest", |
| 2079 | "TextClassifierServiceLibNoManifest", |
| 2080 | } |
| 2081 | // |
| 2082 | // Module separator |
| 2083 | // |
| 2084 | m["com.android.neuralnetworks"] = []string{ |
| 2085 | "android.hardware.neuralnetworks@1.0", |
| 2086 | "android.hardware.neuralnetworks@1.1", |
| 2087 | "android.hardware.neuralnetworks@1.2", |
| 2088 | "android.hardware.neuralnetworks@1.3", |
| 2089 | "android.hidl.allocator@1.0", |
| 2090 | "android.hidl.memory.token@1.0", |
| 2091 | "android.hidl.memory@1.0", |
| 2092 | "android.hidl.safe_union@1.0", |
| 2093 | "libarect", |
| 2094 | "libbuildversion", |
| 2095 | "libmath", |
| 2096 | "libprocpartition", |
| 2097 | "libsync", |
| 2098 | } |
| 2099 | // |
| 2100 | // Module separator |
| 2101 | // |
| 2102 | m["com.android.media"] = []string{ |
| 2103 | "android.frameworks.bufferhub@1.0", |
| 2104 | "android.hardware.cas.native@1.0", |
| 2105 | "android.hardware.cas@1.0", |
| 2106 | "android.hardware.configstore-utils", |
| 2107 | "android.hardware.configstore@1.0", |
| 2108 | "android.hardware.configstore@1.1", |
| 2109 | "android.hardware.graphics.allocator@2.0", |
| 2110 | "android.hardware.graphics.allocator@3.0", |
| 2111 | "android.hardware.graphics.bufferqueue@1.0", |
| 2112 | "android.hardware.graphics.bufferqueue@2.0", |
| 2113 | "android.hardware.graphics.common@1.0", |
| 2114 | "android.hardware.graphics.common@1.1", |
| 2115 | "android.hardware.graphics.common@1.2", |
| 2116 | "android.hardware.graphics.mapper@2.0", |
| 2117 | "android.hardware.graphics.mapper@2.1", |
| 2118 | "android.hardware.graphics.mapper@3.0", |
| 2119 | "android.hardware.media.omx@1.0", |
| 2120 | "android.hardware.media@1.0", |
| 2121 | "android.hidl.allocator@1.0", |
| 2122 | "android.hidl.memory.token@1.0", |
| 2123 | "android.hidl.memory@1.0", |
| 2124 | "android.hidl.token@1.0", |
| 2125 | "android.hidl.token@1.0-utils", |
| 2126 | "bionic_libc_platform_headers", |
| 2127 | "exoplayer2-extractor", |
| 2128 | "exoplayer2-extractor-annotation-stubs", |
| 2129 | "gl_headers", |
| 2130 | "jsr305", |
| 2131 | "libEGL", |
| 2132 | "libEGL_blobCache", |
| 2133 | "libEGL_getProcAddress", |
| 2134 | "libFLAC", |
| 2135 | "libFLAC-config", |
| 2136 | "libFLAC-headers", |
| 2137 | "libGLESv2", |
| 2138 | "libaacextractor", |
| 2139 | "libamrextractor", |
| 2140 | "libarect", |
| 2141 | "libaudio_system_headers", |
| 2142 | "libaudioclient", |
| 2143 | "libaudioclient_headers", |
| 2144 | "libaudiofoundation", |
| 2145 | "libaudiofoundation_headers", |
| 2146 | "libaudiomanager", |
| 2147 | "libaudiopolicy", |
| 2148 | "libaudioutils", |
| 2149 | "libaudioutils_fixedfft", |
| 2150 | "libbinder_headers", |
| 2151 | "libbluetooth-types-header", |
| 2152 | "libbufferhub", |
| 2153 | "libbufferhub_headers", |
| 2154 | "libbufferhubqueue", |
| 2155 | "libc_malloc_debug_backtrace", |
| 2156 | "libcamera_client", |
| 2157 | "libcamera_metadata", |
| 2158 | "libdvr_headers", |
| 2159 | "libexpat", |
| 2160 | "libfifo", |
| 2161 | "libflacextractor", |
| 2162 | "libgrallocusage", |
| 2163 | "libgraphicsenv", |
| 2164 | "libgui", |
| 2165 | "libgui_headers", |
| 2166 | "libhardware_headers", |
| 2167 | "libinput", |
| 2168 | "liblzma", |
| 2169 | "libmath", |
| 2170 | "libmedia", |
| 2171 | "libmedia_codeclist", |
| 2172 | "libmedia_headers", |
| 2173 | "libmedia_helper", |
| 2174 | "libmedia_helper_headers", |
| 2175 | "libmedia_midiiowrapper", |
| 2176 | "libmedia_omx", |
| 2177 | "libmediautils", |
| 2178 | "libmidiextractor", |
| 2179 | "libmkvextractor", |
| 2180 | "libmp3extractor", |
| 2181 | "libmp4extractor", |
| 2182 | "libmpeg2extractor", |
| 2183 | "libnativebase_headers", |
| 2184 | "libnativewindow_headers", |
| 2185 | "libnblog", |
| 2186 | "liboggextractor", |
| 2187 | "libpackagelistparser", |
| 2188 | "libpdx", |
| 2189 | "libpdx_default_transport", |
| 2190 | "libpdx_headers", |
| 2191 | "libpdx_uds", |
| 2192 | "libprocinfo", |
| 2193 | "libspeexresampler", |
| 2194 | "libspeexresampler", |
| 2195 | "libstagefright_esds", |
| 2196 | "libstagefright_flacdec", |
| 2197 | "libstagefright_flacdec", |
| 2198 | "libstagefright_foundation", |
| 2199 | "libstagefright_foundation_headers", |
| 2200 | "libstagefright_foundation_without_imemory", |
| 2201 | "libstagefright_headers", |
| 2202 | "libstagefright_id3", |
| 2203 | "libstagefright_metadatautils", |
| 2204 | "libstagefright_mpeg2extractor", |
| 2205 | "libstagefright_mpeg2support", |
| 2206 | "libsync", |
| 2207 | "libui", |
| 2208 | "libui_headers", |
| 2209 | "libunwindstack", |
| 2210 | "libvibrator", |
| 2211 | "libvorbisidec", |
| 2212 | "libwavextractor", |
| 2213 | "libwebm", |
| 2214 | "media_ndk_headers", |
| 2215 | "media_plugin_headers", |
| 2216 | "updatable-media", |
| 2217 | } |
| 2218 | // |
| 2219 | // Module separator |
| 2220 | // |
| 2221 | m["com.android.media.swcodec"] = []string{ |
| 2222 | "android.frameworks.bufferhub@1.0", |
| 2223 | "android.hardware.common-ndk_platform", |
| 2224 | "android.hardware.configstore-utils", |
| 2225 | "android.hardware.configstore@1.0", |
| 2226 | "android.hardware.configstore@1.1", |
| 2227 | "android.hardware.graphics.allocator@2.0", |
| 2228 | "android.hardware.graphics.allocator@3.0", |
| 2229 | "android.hardware.graphics.allocator@4.0", |
| 2230 | "android.hardware.graphics.bufferqueue@1.0", |
| 2231 | "android.hardware.graphics.bufferqueue@2.0", |
| 2232 | "android.hardware.graphics.common-ndk_platform", |
| 2233 | "android.hardware.graphics.common@1.0", |
| 2234 | "android.hardware.graphics.common@1.1", |
| 2235 | "android.hardware.graphics.common@1.2", |
| 2236 | "android.hardware.graphics.mapper@2.0", |
| 2237 | "android.hardware.graphics.mapper@2.1", |
| 2238 | "android.hardware.graphics.mapper@3.0", |
| 2239 | "android.hardware.graphics.mapper@4.0", |
| 2240 | "android.hardware.media.bufferpool@2.0", |
| 2241 | "android.hardware.media.c2@1.0", |
| 2242 | "android.hardware.media.c2@1.1", |
| 2243 | "android.hardware.media.omx@1.0", |
| 2244 | "android.hardware.media@1.0", |
| 2245 | "android.hardware.media@1.0", |
| 2246 | "android.hidl.memory.token@1.0", |
| 2247 | "android.hidl.memory@1.0", |
| 2248 | "android.hidl.safe_union@1.0", |
| 2249 | "android.hidl.token@1.0", |
| 2250 | "android.hidl.token@1.0-utils", |
| 2251 | "libEGL", |
| 2252 | "libFLAC", |
| 2253 | "libFLAC-config", |
| 2254 | "libFLAC-headers", |
| 2255 | "libFraunhoferAAC", |
| 2256 | "libLibGuiProperties", |
| 2257 | "libarect", |
| 2258 | "libaudio_system_headers", |
| 2259 | "libaudioutils", |
| 2260 | "libaudioutils", |
| 2261 | "libaudioutils_fixedfft", |
| 2262 | "libavcdec", |
| 2263 | "libavcenc", |
| 2264 | "libavservices_minijail", |
| 2265 | "libavservices_minijail", |
| 2266 | "libbinder_headers", |
| 2267 | "libbinderthreadstateutils", |
| 2268 | "libbluetooth-types-header", |
| 2269 | "libbufferhub_headers", |
| 2270 | "libcodec2", |
| 2271 | "libcodec2_headers", |
| 2272 | "libcodec2_hidl@1.0", |
| 2273 | "libcodec2_hidl@1.1", |
| 2274 | "libcodec2_internal", |
| 2275 | "libcodec2_soft_aacdec", |
| 2276 | "libcodec2_soft_aacenc", |
| 2277 | "libcodec2_soft_amrnbdec", |
| 2278 | "libcodec2_soft_amrnbenc", |
| 2279 | "libcodec2_soft_amrwbdec", |
| 2280 | "libcodec2_soft_amrwbenc", |
| 2281 | "libcodec2_soft_av1dec_gav1", |
| 2282 | "libcodec2_soft_avcdec", |
| 2283 | "libcodec2_soft_avcenc", |
| 2284 | "libcodec2_soft_common", |
| 2285 | "libcodec2_soft_flacdec", |
| 2286 | "libcodec2_soft_flacenc", |
| 2287 | "libcodec2_soft_g711alawdec", |
| 2288 | "libcodec2_soft_g711mlawdec", |
| 2289 | "libcodec2_soft_gsmdec", |
| 2290 | "libcodec2_soft_h263dec", |
| 2291 | "libcodec2_soft_h263enc", |
| 2292 | "libcodec2_soft_hevcdec", |
| 2293 | "libcodec2_soft_hevcenc", |
| 2294 | "libcodec2_soft_mp3dec", |
| 2295 | "libcodec2_soft_mpeg2dec", |
| 2296 | "libcodec2_soft_mpeg4dec", |
| 2297 | "libcodec2_soft_mpeg4enc", |
| 2298 | "libcodec2_soft_opusdec", |
| 2299 | "libcodec2_soft_opusenc", |
| 2300 | "libcodec2_soft_rawdec", |
| 2301 | "libcodec2_soft_vorbisdec", |
| 2302 | "libcodec2_soft_vp8dec", |
| 2303 | "libcodec2_soft_vp8enc", |
| 2304 | "libcodec2_soft_vp9dec", |
| 2305 | "libcodec2_soft_vp9enc", |
| 2306 | "libcodec2_vndk", |
| 2307 | "libdvr_headers", |
| 2308 | "libfmq", |
| 2309 | "libfmq", |
| 2310 | "libgav1", |
| 2311 | "libgralloctypes", |
| 2312 | "libgrallocusage", |
| 2313 | "libgraphicsenv", |
| 2314 | "libgsm", |
| 2315 | "libgui_bufferqueue_static", |
| 2316 | "libgui_headers", |
| 2317 | "libhardware", |
| 2318 | "libhardware_headers", |
| 2319 | "libhevcdec", |
| 2320 | "libhevcenc", |
| 2321 | "libion", |
| 2322 | "libjpeg", |
| 2323 | "liblzma", |
| 2324 | "libmath", |
| 2325 | "libmedia_codecserviceregistrant", |
| 2326 | "libmedia_headers", |
| 2327 | "libmpeg2dec", |
| 2328 | "libnativebase_headers", |
| 2329 | "libnativewindow_headers", |
| 2330 | "libpdx_headers", |
| 2331 | "libscudo_wrapper", |
| 2332 | "libsfplugin_ccodec_utils", |
| 2333 | "libspeexresampler", |
| 2334 | "libstagefright_amrnb_common", |
| 2335 | "libstagefright_amrnbdec", |
| 2336 | "libstagefright_amrnbenc", |
| 2337 | "libstagefright_amrwbdec", |
| 2338 | "libstagefright_amrwbenc", |
| 2339 | "libstagefright_bufferpool@2.0.1", |
| 2340 | "libstagefright_bufferqueue_helper", |
| 2341 | "libstagefright_enc_common", |
| 2342 | "libstagefright_flacdec", |
| 2343 | "libstagefright_foundation", |
| 2344 | "libstagefright_foundation_headers", |
| 2345 | "libstagefright_headers", |
| 2346 | "libstagefright_m4vh263dec", |
| 2347 | "libstagefright_m4vh263enc", |
| 2348 | "libstagefright_mp3dec", |
| 2349 | "libsync", |
| 2350 | "libui", |
| 2351 | "libui_headers", |
| 2352 | "libunwindstack", |
| 2353 | "libvorbisidec", |
| 2354 | "libvpx", |
| 2355 | "libyuv", |
| 2356 | "libyuv_static", |
| 2357 | "media_ndk_headers", |
| 2358 | "media_plugin_headers", |
| 2359 | "mediaswcodec", |
| 2360 | } |
| 2361 | // |
| 2362 | // Module separator |
| 2363 | // |
| 2364 | m["com.android.mediaprovider"] = []string{ |
| 2365 | "MediaProvider", |
| 2366 | "MediaProviderGoogle", |
| 2367 | "fmtlib_ndk", |
| 2368 | "libbase_ndk", |
| 2369 | "libfuse", |
| 2370 | "libfuse_jni", |
| 2371 | } |
| 2372 | // |
| 2373 | // Module separator |
| 2374 | // |
| 2375 | m["com.android.permission"] = []string{ |
| 2376 | "car-ui-lib", |
| 2377 | "iconloader", |
| 2378 | "kotlin-annotations", |
| 2379 | "kotlin-stdlib", |
| 2380 | "kotlin-stdlib-jdk7", |
| 2381 | "kotlin-stdlib-jdk8", |
| 2382 | "kotlinx-coroutines-android", |
| 2383 | "kotlinx-coroutines-android-nodeps", |
| 2384 | "kotlinx-coroutines-core", |
| 2385 | "kotlinx-coroutines-core-nodeps", |
| 2386 | "permissioncontroller-statsd", |
| 2387 | "GooglePermissionController", |
| 2388 | "PermissionController", |
| 2389 | "SettingsLibActionBarShadow", |
| 2390 | "SettingsLibAppPreference", |
| 2391 | "SettingsLibBarChartPreference", |
| 2392 | "SettingsLibLayoutPreference", |
| 2393 | "SettingsLibProgressBar", |
| 2394 | "SettingsLibSearchWidget", |
| 2395 | "SettingsLibSettingsTheme", |
| 2396 | "SettingsLibRestrictedLockUtils", |
| 2397 | "SettingsLibHelpUtils", |
| 2398 | } |
| 2399 | // |
| 2400 | // Module separator |
| 2401 | // |
| 2402 | m["com.android.runtime"] = []string{ |
| 2403 | "bionic_libc_platform_headers", |
| 2404 | "libarm-optimized-routines-math", |
| 2405 | "libc_aeabi", |
| 2406 | "libc_bionic", |
| 2407 | "libc_bionic_ndk", |
| 2408 | "libc_bootstrap", |
| 2409 | "libc_common", |
| 2410 | "libc_common_shared", |
| 2411 | "libc_common_static", |
| 2412 | "libc_dns", |
| 2413 | "libc_dynamic_dispatch", |
| 2414 | "libc_fortify", |
| 2415 | "libc_freebsd", |
| 2416 | "libc_freebsd_large_stack", |
| 2417 | "libc_gdtoa", |
| 2418 | "libc_init_dynamic", |
| 2419 | "libc_init_static", |
| 2420 | "libc_jemalloc_wrapper", |
| 2421 | "libc_netbsd", |
| 2422 | "libc_nomalloc", |
| 2423 | "libc_nopthread", |
| 2424 | "libc_openbsd", |
| 2425 | "libc_openbsd_large_stack", |
| 2426 | "libc_openbsd_ndk", |
| 2427 | "libc_pthread", |
| 2428 | "libc_static_dispatch", |
| 2429 | "libc_syscalls", |
| 2430 | "libc_tzcode", |
| 2431 | "libc_unwind_static", |
| 2432 | "libdebuggerd", |
| 2433 | "libdebuggerd_common_headers", |
| 2434 | "libdebuggerd_handler_core", |
| 2435 | "libdebuggerd_handler_fallback", |
| 2436 | "libdl_static", |
| 2437 | "libjemalloc5", |
| 2438 | "liblinker_main", |
| 2439 | "liblinker_malloc", |
| 2440 | "liblz4", |
| 2441 | "liblzma", |
| 2442 | "libprocinfo", |
| 2443 | "libpropertyinfoparser", |
| 2444 | "libscudo", |
| 2445 | "libstdc++", |
| 2446 | "libsystemproperties", |
| 2447 | "libtombstoned_client_static", |
| 2448 | "libunwindstack", |
| 2449 | "libz", |
| 2450 | "libziparchive", |
| 2451 | } |
| 2452 | // |
| 2453 | // Module separator |
| 2454 | // |
| 2455 | m["com.android.tethering"] = []string{ |
| 2456 | "android.hardware.tetheroffload.config-V1.0-java", |
| 2457 | "android.hardware.tetheroffload.control-V1.0-java", |
| 2458 | "android.hidl.base-V1.0-java", |
| 2459 | "libcgrouprc", |
| 2460 | "libcgrouprc_format", |
| 2461 | "libtetherutilsjni", |
| 2462 | "libvndksupport", |
| 2463 | "net-utils-framework-common", |
| 2464 | "netd_aidl_interface-V3-java", |
| 2465 | "netlink-client", |
| 2466 | "networkstack-aidl-interfaces-java", |
| 2467 | "tethering-aidl-interfaces-java", |
| 2468 | "TetheringApiCurrentLib", |
| 2469 | } |
| 2470 | // |
| 2471 | // Module separator |
| 2472 | // |
| 2473 | m["com.android.wifi"] = []string{ |
| 2474 | "PlatformProperties", |
| 2475 | "android.hardware.wifi-V1.0-java", |
| 2476 | "android.hardware.wifi-V1.0-java-constants", |
| 2477 | "android.hardware.wifi-V1.1-java", |
| 2478 | "android.hardware.wifi-V1.2-java", |
| 2479 | "android.hardware.wifi-V1.3-java", |
| 2480 | "android.hardware.wifi-V1.4-java", |
| 2481 | "android.hardware.wifi.hostapd-V1.0-java", |
| 2482 | "android.hardware.wifi.hostapd-V1.1-java", |
| 2483 | "android.hardware.wifi.hostapd-V1.2-java", |
| 2484 | "android.hardware.wifi.supplicant-V1.0-java", |
| 2485 | "android.hardware.wifi.supplicant-V1.1-java", |
| 2486 | "android.hardware.wifi.supplicant-V1.2-java", |
| 2487 | "android.hardware.wifi.supplicant-V1.3-java", |
| 2488 | "android.hidl.base-V1.0-java", |
| 2489 | "android.hidl.manager-V1.0-java", |
| 2490 | "android.hidl.manager-V1.1-java", |
| 2491 | "android.hidl.manager-V1.2-java", |
| 2492 | "bouncycastle-unbundled", |
| 2493 | "dnsresolver_aidl_interface-V2-java", |
| 2494 | "error_prone_annotations", |
| 2495 | "framework-wifi-pre-jarjar", |
| 2496 | "framework-wifi-util-lib", |
| 2497 | "ipmemorystore-aidl-interfaces-V3-java", |
| 2498 | "ipmemorystore-aidl-interfaces-java", |
| 2499 | "ksoap2", |
| 2500 | "libnanohttpd", |
| 2501 | "libwifi-jni", |
| 2502 | "net-utils-services-common", |
| 2503 | "netd_aidl_interface-V2-java", |
| 2504 | "netd_aidl_interface-unstable-java", |
| 2505 | "netd_event_listener_interface-java", |
| 2506 | "netlink-client", |
| 2507 | "networkstack-client", |
| 2508 | "services.net", |
| 2509 | "wifi-lite-protos", |
| 2510 | "wifi-nano-protos", |
| 2511 | "wifi-service-pre-jarjar", |
| 2512 | "wifi-service-resources", |
| 2513 | } |
| 2514 | // |
| 2515 | // Module separator |
| 2516 | // |
| 2517 | m["com.android.sdkext"] = []string{ |
| 2518 | "fmtlib_ndk", |
| 2519 | "libbase_ndk", |
| 2520 | "libprotobuf-cpp-lite-ndk", |
| 2521 | } |
| 2522 | // |
| 2523 | // Module separator |
| 2524 | // |
| 2525 | m["com.android.os.statsd"] = []string{ |
| 2526 | "libstatssocket", |
| 2527 | } |
| 2528 | // |
| 2529 | // Module separator |
| 2530 | // |
| 2531 | m[android.AvailableToAnyApex] = []string{ |
| 2532 | // TODO(b/156996905) Set apex_available/min_sdk_version for androidx/extras support libraries |
| 2533 | "androidx", |
| 2534 | "androidx-constraintlayout_constraintlayout", |
| 2535 | "androidx-constraintlayout_constraintlayout-nodeps", |
| 2536 | "androidx-constraintlayout_constraintlayout-solver", |
| 2537 | "androidx-constraintlayout_constraintlayout-solver-nodeps", |
| 2538 | "com.google.android.material_material", |
| 2539 | "com.google.android.material_material-nodeps", |
| 2540 | |
| 2541 | "libatomic", |
| 2542 | "libclang_rt", |
| 2543 | "libgcc_stripped", |
| 2544 | "libprofile-clang-extras", |
| 2545 | "libprofile-clang-extras_ndk", |
| 2546 | "libprofile-extras", |
| 2547 | "libprofile-extras_ndk", |
| 2548 | "libunwind_llvm", |
| 2549 | } |
| 2550 | return m |
| 2551 | } |
| 2552 | |
| 2553 | func init() { |
| 2554 | android.AddNeverAllowRules(createApexPermittedPackagesRules(qModulesPackages())...) |
| 2555 | android.AddNeverAllowRules(createApexPermittedPackagesRules(rModulesPackages())...) |
| 2556 | } |
| 2557 | |
| 2558 | func createApexPermittedPackagesRules(modules_packages map[string][]string) []android.Rule { |
| 2559 | rules := make([]android.Rule, 0, len(modules_packages)) |
| 2560 | for module_name, module_packages := range modules_packages { |
| 2561 | permitted_packages_rule := android.NeverAllow(). |
| 2562 | BootclasspathJar(). |
| 2563 | With("apex_available", module_name). |
| 2564 | WithMatcher("permitted_packages", android.NotInList(module_packages)). |
| 2565 | Because("jars that are part of the " + module_name + |
| 2566 | " module may only allow these packages: " + strings.Join(module_packages, ",") + |
| 2567 | ". Please jarjar or move code around.") |
| 2568 | rules = append(rules, permitted_packages_rule) |
| 2569 | } |
| 2570 | return rules |
| 2571 | } |
| 2572 | |
| 2573 | // DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART. |
| 2574 | // Adding code to the bootclasspath in new packages will cause issues on module update. |
| 2575 | func qModulesPackages() map[string][]string { |
| 2576 | return map[string][]string{ |
| 2577 | "com.android.conscrypt": []string{ |
| 2578 | "android.net.ssl", |
| 2579 | "com.android.org.conscrypt", |
| 2580 | }, |
| 2581 | "com.android.media": []string{ |
| 2582 | "android.media", |
| 2583 | }, |
| 2584 | } |
| 2585 | } |
| 2586 | |
| 2587 | // DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART. |
| 2588 | // Adding code to the bootclasspath in new packages will cause issues on module update. |
| 2589 | func rModulesPackages() map[string][]string { |
| 2590 | return map[string][]string{ |
| 2591 | "com.android.mediaprovider": []string{ |
| 2592 | "android.provider", |
| 2593 | }, |
| 2594 | "com.android.permission": []string{ |
| 2595 | "android.permission", |
| 2596 | "android.app.role", |
| 2597 | "com.android.permission", |
| 2598 | "com.android.role", |
| 2599 | }, |
| 2600 | "com.android.sdkext": []string{ |
| 2601 | "android.os.ext", |
| 2602 | }, |
| 2603 | "com.android.os.statsd": []string{ |
| 2604 | "android.app", |
| 2605 | "android.os", |
| 2606 | "android.util", |
| 2607 | "com.android.internal.statsd", |
| 2608 | "com.android.server.stats", |
| 2609 | }, |
| 2610 | "com.android.wifi": []string{ |
| 2611 | "com.android.server.wifi", |
| 2612 | "com.android.wifi.x", |
| 2613 | "android.hardware.wifi", |
| 2614 | "android.net.wifi", |
| 2615 | }, |
| 2616 | "com.android.tethering": []string{ |
| 2617 | "android.net", |
| 2618 | }, |
| 2619 | } |
| 2620 | } |