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" |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 22 | "sync" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 23 | |
| 24 | "android/soong/android" |
| 25 | "android/soong/cc" |
| 26 | "android/soong/java" |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 27 | "android/soong/python" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 28 | |
| 29 | "github.com/google/blueprint" |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 30 | "github.com/google/blueprint/bootstrap" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 31 | "github.com/google/blueprint/proptools" |
| 32 | ) |
| 33 | |
Jooyung Han | 72bd2f8 | 2019-10-23 16:46:38 +0900 | [diff] [blame] | 34 | const ( |
| 35 | imageApexSuffix = ".apex" |
| 36 | zipApexSuffix = ".zipapex" |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 37 | flattenedSuffix = ".flattened" |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 38 | |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 39 | imageApexType = "image" |
| 40 | zipApexType = "zip" |
| 41 | flattenedApexType = "flattened" |
Jooyung Han | 72bd2f8 | 2019-10-23 16:46:38 +0900 | [diff] [blame] | 42 | ) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 43 | |
| 44 | type dependencyTag struct { |
| 45 | blueprint.BaseDependencyTag |
| 46 | name string |
| 47 | } |
| 48 | |
| 49 | var ( |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 50 | sharedLibTag = dependencyTag{name: "sharedLib"} |
| 51 | executableTag = dependencyTag{name: "executable"} |
| 52 | javaLibTag = dependencyTag{name: "javaLib"} |
| 53 | prebuiltTag = dependencyTag{name: "prebuilt"} |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 54 | testTag = dependencyTag{name: "test"} |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 55 | keyTag = dependencyTag{name: "key"} |
| 56 | certificateTag = dependencyTag{name: "certificate"} |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 57 | usesTag = dependencyTag{name: "uses"} |
Sundong Ahn | e1f05aa | 2019-08-27 13:55:42 +0900 | [diff] [blame] | 58 | androidAppTag = dependencyTag{name: "androidApp"} |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 59 | ) |
| 60 | |
| 61 | func init() { |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 62 | android.RegisterModuleType("apex", BundleFactory) |
Alex Light | 0851b88 | 2019-02-07 13:20:53 -0800 | [diff] [blame] | 63 | android.RegisterModuleType("apex_test", testApexBundleFactory) |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 64 | android.RegisterModuleType("apex_vndk", vndkApexBundleFactory) |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 65 | android.RegisterModuleType("apex_defaults", defaultsFactory) |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 66 | android.RegisterModuleType("prebuilt_apex", PrebuiltFactory) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 67 | |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 68 | android.PreDepsMutators(RegisterPreDepsMutators) |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 69 | android.PostDepsMutators(RegisterPostDepsMutators) |
Jooyung Han | 7a78a92 | 2019-10-08 21:59:58 +0900 | [diff] [blame] | 70 | |
| 71 | android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) { |
| 72 | apexFileContextsInfos := apexFileContextsInfos(ctx.Config()) |
| 73 | sort.Strings(*apexFileContextsInfos) |
| 74 | ctx.Strict("APEX_FILE_CONTEXTS_INFOS", strings.Join(*apexFileContextsInfos, " ")) |
| 75 | }) |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 76 | } |
| 77 | |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 78 | func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) { |
| 79 | ctx.TopDown("apex_vndk", apexVndkMutator).Parallel() |
| 80 | ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel() |
| 81 | } |
| 82 | |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 83 | func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) { |
Jiyong Park | a308ea1 | 2019-11-15 10:38:39 +0900 | [diff] [blame] | 84 | ctx.BottomUp("apex_deps", apexDepsMutator) |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 85 | ctx.BottomUp("apex", apexMutator).Parallel() |
| 86 | ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel() |
| 87 | ctx.BottomUp("apex_uses", apexUsesMutator).Parallel() |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 88 | } |
| 89 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 90 | // Mark the direct and transitive dependencies of apex bundles so that they |
| 91 | // can be built for the apex bundles. |
Jiyong Park | a308ea1 | 2019-11-15 10:38:39 +0900 | [diff] [blame] | 92 | func apexDepsMutator(mctx android.BottomUpMutatorContext) { |
Alex Light | f98087f | 2019-02-04 14:45:06 -0800 | [diff] [blame] | 93 | if a, ok := mctx.Module().(*apexBundle); ok { |
Colin Cross | a492590 | 2018-11-16 11:36:28 -0800 | [diff] [blame] | 94 | apexBundleName := mctx.ModuleName() |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 95 | mctx.WalkDeps(func(child, parent android.Module) bool { |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 96 | depName := mctx.OtherModuleName(child) |
| 97 | // If the parent is apexBundle, this child is directly depended. |
| 98 | _, directDep := parent.(*apexBundle) |
Alex Light | 0851b88 | 2019-02-07 13:20:53 -0800 | [diff] [blame] | 99 | if a.installable() && !a.testApex { |
Alex Light | f98087f | 2019-02-04 14:45:06 -0800 | [diff] [blame] | 100 | // TODO(b/123892969): Workaround for not having any way to annotate test-apexs |
| 101 | // non-installable apex's cannot be installed and so should not prevent libraries from being |
| 102 | // installed to the system. |
| 103 | android.UpdateApexDependency(apexBundleName, depName, directDep) |
| 104 | } |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 105 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 106 | if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() { |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 107 | am.BuildForApex(apexBundleName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 108 | return true |
| 109 | } else { |
| 110 | return false |
| 111 | } |
| 112 | }) |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | // Create apex variations if a module is included in APEX(s). |
| 117 | func apexMutator(mctx android.BottomUpMutatorContext) { |
| 118 | if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() { |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 119 | am.CreateApexVariations(mctx) |
Jooyung Han | 7a78a92 | 2019-10-08 21:59:58 +0900 | [diff] [blame] | 120 | } else if a, ok := mctx.Module().(*apexBundle); ok { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 121 | // apex bundle itself is mutated so that it and its modules have same |
| 122 | // apex variant. |
| 123 | apexBundleName := mctx.ModuleName() |
| 124 | mctx.CreateVariations(apexBundleName) |
Jooyung Han | 7a78a92 | 2019-10-08 21:59:58 +0900 | [diff] [blame] | 125 | |
| 126 | // collects APEX list |
| 127 | if mctx.Device() && a.installable() { |
| 128 | addApexFileContextsInfos(mctx, a) |
| 129 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 130 | } |
| 131 | } |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 132 | |
Jooyung Han | 7a78a92 | 2019-10-08 21:59:58 +0900 | [diff] [blame] | 133 | var ( |
| 134 | apexFileContextsInfosKey = android.NewOnceKey("apexFileContextsInfosKey") |
| 135 | apexFileContextsInfosMutex sync.Mutex |
| 136 | ) |
| 137 | |
| 138 | func apexFileContextsInfos(config android.Config) *[]string { |
| 139 | return config.Once(apexFileContextsInfosKey, func() interface{} { |
| 140 | return &[]string{} |
| 141 | }).(*[]string) |
| 142 | } |
| 143 | |
| 144 | func addApexFileContextsInfos(ctx android.BaseModuleContext, a *apexBundle) { |
| 145 | apexName := proptools.StringDefault(a.properties.Apex_name, ctx.ModuleName()) |
| 146 | fileContextsName := proptools.StringDefault(a.properties.File_contexts, ctx.ModuleName()) |
| 147 | |
| 148 | apexFileContextsInfosMutex.Lock() |
| 149 | defer apexFileContextsInfosMutex.Unlock() |
| 150 | apexFileContextsInfos := apexFileContextsInfos(ctx.Config()) |
| 151 | *apexFileContextsInfos = append(*apexFileContextsInfos, apexName+":"+fileContextsName) |
| 152 | } |
| 153 | |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 154 | func apexFlattenedMutator(mctx android.BottomUpMutatorContext) { |
Sundong Ahn | e8fb724 | 2019-09-17 13:50:45 +0900 | [diff] [blame] | 155 | if ab, ok := mctx.Module().(*apexBundle); ok { |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 156 | var variants []string |
| 157 | switch proptools.StringDefault(ab.properties.Payload_type, "image") { |
| 158 | case "image": |
| 159 | variants = append(variants, imageApexType, flattenedApexType) |
| 160 | case "zip": |
| 161 | variants = append(variants, zipApexType) |
| 162 | case "both": |
| 163 | variants = append(variants, imageApexType, zipApexType, flattenedApexType) |
| 164 | default: |
Sundong Ahn | d95aa2d | 2019-10-08 19:34:03 +0900 | [diff] [blame] | 165 | 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] | 166 | return |
| 167 | } |
| 168 | |
| 169 | modules := mctx.CreateLocalVariations(variants...) |
| 170 | |
| 171 | for i, v := range variants { |
| 172 | switch v { |
| 173 | case imageApexType: |
| 174 | modules[i].(*apexBundle).properties.ApexType = imageApex |
| 175 | case zipApexType: |
| 176 | modules[i].(*apexBundle).properties.ApexType = zipApex |
| 177 | case flattenedApexType: |
| 178 | modules[i].(*apexBundle).properties.ApexType = flattenedApex |
Sundong Ahn | d95aa2d | 2019-10-08 19:34:03 +0900 | [diff] [blame] | 179 | if !mctx.Config().FlattenApex() { |
| 180 | modules[i].(*apexBundle).MakeAsSystemExt() |
| 181 | } |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 182 | } |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 183 | } |
| 184 | } |
| 185 | } |
| 186 | |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 187 | func apexUsesMutator(mctx android.BottomUpMutatorContext) { |
| 188 | if ab, ok := mctx.Module().(*apexBundle); ok { |
| 189 | mctx.AddFarVariationDependencies(nil, usesTag, ab.properties.Uses...) |
| 190 | } |
| 191 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 192 | |
Jooyung Han | dc78244 | 2019-11-01 03:14:38 +0900 | [diff] [blame] | 193 | var ( |
| 194 | useVendorWhitelistKey = android.NewOnceKey("useVendorWhitelist") |
| 195 | ) |
| 196 | |
| 197 | // useVendorWhitelist returns the list of APEXes which are allowed to use_vendor. |
| 198 | // When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__, |
| 199 | // which may cause compatibility issues. (e.g. libbinder) |
| 200 | // Even though libbinder restricts its availability via 'apex_available' property and relies on |
| 201 | // yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules |
| 202 | // to avoid similar problems. |
| 203 | func useVendorWhitelist(config android.Config) []string { |
| 204 | return config.Once(useVendorWhitelistKey, func() interface{} { |
| 205 | return []string{ |
| 206 | // swcodec uses "vendor" variants for smaller size |
| 207 | "com.android.media.swcodec", |
| 208 | "test_com.android.media.swcodec", |
| 209 | } |
| 210 | }).([]string) |
| 211 | } |
| 212 | |
| 213 | // setUseVendorWhitelistForTest overrides useVendorWhitelist and must be |
| 214 | // called before the first call to useVendorWhitelist() |
| 215 | func setUseVendorWhitelistForTest(config android.Config, whitelist []string) { |
| 216 | config.Once(useVendorWhitelistKey, func() interface{} { |
| 217 | return whitelist |
| 218 | }) |
| 219 | } |
| 220 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 221 | type apexNativeDependencies struct { |
| 222 | // List of native libraries |
| 223 | Native_shared_libs []string |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 224 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 225 | // List of native executables |
| 226 | Binaries []string |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 227 | |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 228 | // List of native tests |
| 229 | Tests []string |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 230 | } |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 231 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 232 | type apexMultilibProperties struct { |
| 233 | // Native dependencies whose compile_multilib is "first" |
| 234 | First apexNativeDependencies |
| 235 | |
| 236 | // Native dependencies whose compile_multilib is "both" |
| 237 | Both apexNativeDependencies |
| 238 | |
| 239 | // Native dependencies whose compile_multilib is "prefer32" |
| 240 | Prefer32 apexNativeDependencies |
| 241 | |
| 242 | // Native dependencies whose compile_multilib is "32" |
| 243 | Lib32 apexNativeDependencies |
| 244 | |
| 245 | // Native dependencies whose compile_multilib is "64" |
| 246 | Lib64 apexNativeDependencies |
| 247 | } |
| 248 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 249 | type apexBundleProperties struct { |
| 250 | // Json manifest file describing meta info of this APEX bundle. Default: |
Dario Freni | 4abb1dc | 2018-11-20 18:04:58 +0000 | [diff] [blame] | 251 | // "apex_manifest.json" |
Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 252 | Manifest *string `android:"path"` |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 253 | |
Jiyong Park | 40e26a2 | 2019-02-08 02:53:06 +0900 | [diff] [blame] | 254 | // AndroidManifest.xml file used for the zip container of this APEX bundle. |
| 255 | // If unspecified, a default one is automatically generated. |
Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 256 | AndroidManifest *string `android:"path"` |
Jiyong Park | 40e26a2 | 2019-02-08 02:53:06 +0900 | [diff] [blame] | 257 | |
Roland Levillain | 411c584 | 2019-09-19 16:37:20 +0100 | [diff] [blame] | 258 | // Canonical name of the APEX bundle. Used to determine the path to the activated APEX on |
| 259 | // device (/apex/<apex_name>). |
| 260 | // If unspecified, defaults to the value of name. |
Jiyong Park | 05e70dd | 2019-03-18 14:26:32 +0900 | [diff] [blame] | 261 | Apex_name *string |
| 262 | |
Jiyong Park | d0a65ba | 2018-11-10 06:37:15 +0900 | [diff] [blame] | 263 | // Determines the file contexts file for setting security context to each file in this APEX bundle. |
| 264 | // Specifically, when this is set to <value>, /system/sepolicy/apex/<value>_file_contexts file is |
| 265 | // used. |
| 266 | // Default: <name_of_this_module> |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 267 | File_contexts *string |
| 268 | |
| 269 | // List of native shared libs that are embedded inside this APEX bundle |
| 270 | Native_shared_libs []string |
| 271 | |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 272 | // List of executables that are embedded inside this APEX bundle |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 273 | Binaries []string |
| 274 | |
| 275 | // List of java libraries that are embedded inside this APEX bundle |
| 276 | Java_libs []string |
| 277 | |
| 278 | // List of prebuilt files that are embedded inside this APEX bundle |
| 279 | Prebuilts []string |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 280 | |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 281 | // List of tests that are embedded inside this APEX bundle |
| 282 | Tests []string |
| 283 | |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 284 | // Name of the apex_key module that provides the private key to sign APEX |
| 285 | Key *string |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 286 | |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 287 | // The type of APEX to build. Controls what the APEX payload is. Either |
| 288 | // 'image', 'zip' or 'both'. Default: 'image'. |
| 289 | Payload_type *string |
| 290 | |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 291 | // The name of a certificate in the default certificate directory, blank to use the default product certificate, |
| 292 | // or an android_app_certificate module name in the form ":module". |
| 293 | Certificate *string |
| 294 | |
Jiyong Park | 92c0f9c | 2018-12-13 23:14:57 +0900 | [diff] [blame] | 295 | // Whether this APEX is installable to one of the partitions. Default: true. |
| 296 | Installable *bool |
| 297 | |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 298 | // For native libraries and binaries, use the vendor variant instead of the core (platform) variant. |
| 299 | // Default is false. |
| 300 | Use_vendor *bool |
| 301 | |
Alex Light | fc0bd7c | 2019-01-29 18:31:59 -0800 | [diff] [blame] | 302 | // For telling the apex to ignore special handling for system libraries such as bionic. Default is false. |
| 303 | Ignore_system_library_special_case *bool |
| 304 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 305 | Multilib apexMultilibProperties |
Jiyong Park | 235e67c | 2019-02-09 11:50:56 +0900 | [diff] [blame] | 306 | |
Jiyong Park | f97782b | 2019-02-13 20:28:58 +0900 | [diff] [blame] | 307 | // List of sanitizer names that this APEX is enabled for |
| 308 | SanitizerNames []string `blueprint:"mutated"` |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 309 | |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 310 | PreventInstall bool `blueprint:"mutated"` |
| 311 | |
| 312 | HideFromMake bool `blueprint:"mutated"` |
| 313 | |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 314 | // Indicates this APEX provides C++ shared libaries to other APEXes. Default: false. |
| 315 | Provide_cpp_shared_libs *bool |
| 316 | |
| 317 | // List of providing APEXes' names so that this APEX can depend on provided shared libraries. |
| 318 | Uses []string |
Nikita Ioffe | 5d5ae76 | 2019-08-31 14:38:05 +0100 | [diff] [blame] | 319 | |
| 320 | // A txt file containing list of files that are whitelisted to be included in this APEX. |
| 321 | Whitelisted_files *string |
Sundong Ahn | e1f05aa | 2019-08-27 13:55:42 +0900 | [diff] [blame] | 322 | |
| 323 | // List of APKs to package inside APEX |
| 324 | Apps []string |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 325 | |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 326 | // package format of this apex variant; could be non-flattened, flattened, or zip. |
| 327 | // imageApex, zipApex or flattened |
| 328 | ApexType apexPackaging `blueprint:"mutated"` |
Sundong Ahn | e8fb724 | 2019-09-17 13:50:45 +0900 | [diff] [blame] | 329 | |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 330 | // List of SDKs that are used to build this APEX. A reference to an SDK should be either |
| 331 | // `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current` |
| 332 | // is implied. This value affects all modules included in this APEX. In other words, they are |
| 333 | // also built with the SDKs specified here. |
| 334 | Uses_sdks []string |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | type apexTargetBundleProperties struct { |
| 338 | Target struct { |
| 339 | // Multilib properties only for android. |
| 340 | Android struct { |
| 341 | Multilib apexMultilibProperties |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 342 | } |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 343 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 344 | // Multilib properties only for host. |
| 345 | Host struct { |
| 346 | Multilib apexMultilibProperties |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 347 | } |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 348 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 349 | // Multilib properties only for host linux_bionic. |
| 350 | Linux_bionic struct { |
| 351 | Multilib apexMultilibProperties |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 352 | } |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 353 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 354 | // Multilib properties only for host linux_glibc. |
| 355 | Linux_glibc struct { |
| 356 | Multilib apexMultilibProperties |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 357 | } |
| 358 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 359 | } |
| 360 | |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 361 | type apexFileClass int |
| 362 | |
| 363 | const ( |
| 364 | etc apexFileClass = iota |
| 365 | nativeSharedLib |
| 366 | nativeExecutable |
Jiyong Park | 04480cf | 2019-02-06 00:16:29 +0900 | [diff] [blame] | 367 | shBinary |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 368 | pyBinary |
| 369 | goBinary |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 370 | javaSharedLib |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 371 | nativeTest |
Sundong Ahn | e1f05aa | 2019-08-27 13:55:42 +0900 | [diff] [blame] | 372 | app |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 373 | ) |
| 374 | |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 375 | type apexPackaging int |
| 376 | |
| 377 | const ( |
| 378 | imageApex apexPackaging = iota |
| 379 | zipApex |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 380 | flattenedApex |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 381 | ) |
| 382 | |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 383 | // The suffix for the output "file", not the module |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 384 | func (a apexPackaging) suffix() string { |
| 385 | switch a { |
| 386 | case imageApex: |
| 387 | return imageApexSuffix |
| 388 | case zipApex: |
| 389 | return zipApexSuffix |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 390 | default: |
Roland Levillain | 4644b22 | 2019-07-31 14:09:17 +0100 | [diff] [blame] | 391 | panic(fmt.Errorf("unknown APEX type %d", a)) |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 392 | } |
| 393 | } |
| 394 | |
| 395 | func (a apexPackaging) name() string { |
| 396 | switch a { |
| 397 | case imageApex: |
| 398 | return imageApexType |
| 399 | case zipApex: |
| 400 | return zipApexType |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 401 | default: |
Roland Levillain | 4644b22 | 2019-07-31 14:09:17 +0100 | [diff] [blame] | 402 | panic(fmt.Errorf("unknown APEX type %d", a)) |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 403 | } |
| 404 | } |
| 405 | |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 406 | func (class apexFileClass) NameInMake() string { |
| 407 | switch class { |
| 408 | case etc: |
| 409 | return "ETC" |
| 410 | case nativeSharedLib: |
| 411 | return "SHARED_LIBRARIES" |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 412 | case nativeExecutable, shBinary, pyBinary, goBinary: |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 413 | return "EXECUTABLES" |
| 414 | case javaSharedLib: |
| 415 | return "JAVA_LIBRARIES" |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 416 | case nativeTest: |
| 417 | return "NATIVE_TESTS" |
Sundong Ahn | e1f05aa | 2019-08-27 13:55:42 +0900 | [diff] [blame] | 418 | case app: |
Jiyong Park | f383f7c | 2019-10-11 20:46:25 +0900 | [diff] [blame] | 419 | // b/142537672 Why isn't this APP? We want to have full control over |
| 420 | // the paths and file names of the apk file under the flattend APEX. |
| 421 | // If this is set to APP, then the paths and file names are modified |
| 422 | // by the Make build system. For example, it is installed to |
| 423 | // /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of |
| 424 | // /system/apex/<apexname>/app/<Appname> because the build system automatically |
| 425 | // appends module name (which is <apexname>.<Appname> to the path. |
| 426 | return "ETC" |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 427 | default: |
Roland Levillain | 4644b22 | 2019-07-31 14:09:17 +0100 | [diff] [blame] | 428 | panic(fmt.Errorf("unknown class %d", class)) |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 429 | } |
| 430 | } |
| 431 | |
| 432 | type apexFile struct { |
| 433 | builtFile android.Path |
| 434 | moduleName string |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 435 | installDir string |
| 436 | class apexFileClass |
Jiyong Park | a889484 | 2018-12-19 17:36:39 +0900 | [diff] [blame] | 437 | module android.Module |
Alex Light | 3d67359 | 2019-01-18 14:37:31 -0800 | [diff] [blame] | 438 | symlinks []string |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 439 | } |
| 440 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 441 | type apexBundle struct { |
| 442 | android.ModuleBase |
| 443 | android.DefaultableModuleBase |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 444 | android.SdkBase |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 445 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 446 | properties apexBundleProperties |
| 447 | targetProperties apexTargetBundleProperties |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 448 | vndkProperties apexVndkProperties |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 449 | |
Colin Cross | a492590 | 2018-11-16 11:36:28 -0800 | [diff] [blame] | 450 | bundleModuleFile android.WritablePath |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 451 | outputFile android.WritablePath |
Colin Cross | 70dda7e | 2019-10-01 22:05:35 -0700 | [diff] [blame] | 452 | installDir android.InstallPath |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 453 | |
Jiyong Park | 03b68dd | 2019-07-26 23:20:40 +0900 | [diff] [blame] | 454 | prebuiltFileToDelete string |
| 455 | |
Jiyong Park | 42cca6c | 2019-04-01 11:15:50 +0900 | [diff] [blame] | 456 | public_key_file android.Path |
| 457 | private_key_file android.Path |
Jiyong Park | 0ca3ce8 | 2019-02-18 15:25:04 +0900 | [diff] [blame] | 458 | |
| 459 | container_certificate_file android.Path |
| 460 | container_private_key_file android.Path |
| 461 | |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 462 | // list of files to be included in this apex |
| 463 | filesInfo []apexFile |
| 464 | |
Jiyong Park | ac2bacd | 2019-02-20 21:49:26 +0900 | [diff] [blame] | 465 | // list of module names that this APEX is depending on |
| 466 | externalDeps []string |
| 467 | |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 468 | testApex bool |
| 469 | vndkApex bool |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 470 | artApex bool |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 471 | primaryApexType bool |
Jooyung Han | e163303 | 2019-08-01 17:41:43 +0900 | [diff] [blame] | 472 | |
| 473 | // intermediate path for apex_manifest.json |
Jooyung Han | 01a3ee2 | 2019-11-02 02:52:25 +0900 | [diff] [blame] | 474 | manifestJsonOut android.WritablePath |
| 475 | manifestJsonFullOut android.WritablePath |
| 476 | manifestPbOut android.WritablePath |
Jooyung Han | 72bd2f8 | 2019-10-23 16:46:38 +0900 | [diff] [blame] | 477 | |
| 478 | // list of commands to create symlinks for backward compatibility |
| 479 | // these commands will be attached as LOCAL_POST_INSTALL_CMD to |
| 480 | // apex package itself(for unflattened build) or apex_manifest.json(for flattened build) |
| 481 | // so that compat symlinks are always installed regardless of TARGET_FLATTEN_APEX setting. |
| 482 | compatSymlinks []string |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 483 | |
| 484 | // Suffix of module name in Android.mk |
| 485 | // ".flattened", ".apex", ".zipapex", or "" |
| 486 | suffix string |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 487 | } |
| 488 | |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 489 | func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 490 | native_shared_libs []string, binaries []string, tests []string, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 491 | target android.Target, imageVariation string) { |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 492 | // Use *FarVariation* to be able to depend on modules having |
| 493 | // conflicting variations with this module. This is required since |
| 494 | // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64' |
| 495 | // for native shared libs. |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 496 | ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 497 | {Mutator: "image", Variation: imageVariation}, |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 498 | {Mutator: "link", Variation: "shared"}, |
Jiyong Park | 28d395a | 2018-12-07 22:42:47 +0900 | [diff] [blame] | 499 | {Mutator: "version", Variation: ""}, // "" is the non-stub variant |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 500 | }...), sharedLibTag, native_shared_libs...) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 501 | |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 502 | ctx.AddFarVariationDependencies(append(target.Variations(), |
| 503 | blueprint.Variation{Mutator: "image", Variation: imageVariation}), |
| 504 | executableTag, binaries...) |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 505 | |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 506 | ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 507 | {Mutator: "image", Variation: imageVariation}, |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 508 | {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 509 | }...), testTag, tests...) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 510 | } |
| 511 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 512 | func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) { |
| 513 | if ctx.Os().Class == android.Device { |
| 514 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil) |
| 515 | } else { |
| 516 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil) |
| 517 | if ctx.Os().Bionic() { |
| 518 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil) |
| 519 | } else { |
| 520 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil) |
| 521 | } |
| 522 | } |
| 523 | } |
| 524 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 525 | func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { |
Jooyung Han | dc78244 | 2019-11-01 03:14:38 +0900 | [diff] [blame] | 526 | if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorWhitelist(ctx.Config())) { |
| 527 | ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true") |
| 528 | } |
| 529 | |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 530 | targets := ctx.MultiTargets() |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 531 | config := ctx.DeviceConfig() |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 532 | |
| 533 | a.combineProperties(ctx) |
| 534 | |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 535 | has32BitTarget := false |
| 536 | for _, target := range targets { |
| 537 | if target.Arch.ArchType.Multilib == "lib32" { |
| 538 | has32BitTarget = true |
| 539 | } |
| 540 | } |
| 541 | for i, target := range targets { |
| 542 | // When multilib.* is omitted for native_shared_libs, it implies |
| 543 | // multilib.both. |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 544 | ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 545 | {Mutator: "image", Variation: a.getImageVariation(config)}, |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 546 | {Mutator: "link", Variation: "shared"}, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 547 | }...), sharedLibTag, a.properties.Native_shared_libs...) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 548 | |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 549 | // When multilib.* is omitted for tests, it implies |
| 550 | // multilib.both. |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 551 | ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 552 | {Mutator: "image", Variation: a.getImageVariation(config)}, |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 553 | {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 554 | }...), testTag, a.properties.Tests...) |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 555 | |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 556 | // Add native modules targetting both ABIs |
| 557 | addDependenciesForNativeModules(ctx, |
| 558 | a.properties.Multilib.Both.Native_shared_libs, |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 559 | a.properties.Multilib.Both.Binaries, |
| 560 | a.properties.Multilib.Both.Tests, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 561 | target, |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 562 | a.getImageVariation(config)) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 563 | |
Alex Light | 3d67359 | 2019-01-18 14:37:31 -0800 | [diff] [blame] | 564 | isPrimaryAbi := i == 0 |
| 565 | if isPrimaryAbi { |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 566 | // When multilib.* is omitted for binaries, it implies |
| 567 | // multilib.first. |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 568 | ctx.AddFarVariationDependencies(append(target.Variations(), |
| 569 | blueprint.Variation{Mutator: "image", Variation: a.getImageVariation(config)}), |
| 570 | executableTag, a.properties.Binaries...) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 571 | |
| 572 | // Add native modules targetting the first ABI |
| 573 | addDependenciesForNativeModules(ctx, |
| 574 | a.properties.Multilib.First.Native_shared_libs, |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 575 | a.properties.Multilib.First.Binaries, |
| 576 | a.properties.Multilib.First.Tests, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 577 | target, |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 578 | a.getImageVariation(config)) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | switch target.Arch.ArchType.Multilib { |
| 582 | case "lib32": |
| 583 | // Add native modules targetting 32-bit ABI |
| 584 | addDependenciesForNativeModules(ctx, |
| 585 | a.properties.Multilib.Lib32.Native_shared_libs, |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 586 | a.properties.Multilib.Lib32.Binaries, |
| 587 | a.properties.Multilib.Lib32.Tests, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 588 | target, |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 589 | a.getImageVariation(config)) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 590 | |
| 591 | addDependenciesForNativeModules(ctx, |
| 592 | a.properties.Multilib.Prefer32.Native_shared_libs, |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 593 | a.properties.Multilib.Prefer32.Binaries, |
| 594 | a.properties.Multilib.Prefer32.Tests, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 595 | target, |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 596 | a.getImageVariation(config)) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 597 | case "lib64": |
| 598 | // Add native modules targetting 64-bit ABI |
| 599 | addDependenciesForNativeModules(ctx, |
| 600 | a.properties.Multilib.Lib64.Native_shared_libs, |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 601 | a.properties.Multilib.Lib64.Binaries, |
| 602 | a.properties.Multilib.Lib64.Tests, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 603 | target, |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 604 | a.getImageVariation(config)) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 605 | |
| 606 | if !has32BitTarget { |
| 607 | addDependenciesForNativeModules(ctx, |
| 608 | a.properties.Multilib.Prefer32.Native_shared_libs, |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 609 | a.properties.Multilib.Prefer32.Binaries, |
| 610 | a.properties.Multilib.Prefer32.Tests, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 611 | target, |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 612 | a.getImageVariation(config)) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 613 | } |
Peter Collingbourne | 3478bb2 | 2019-04-24 14:41:12 -0700 | [diff] [blame] | 614 | |
| 615 | if strings.HasPrefix(ctx.ModuleName(), "com.android.runtime") && target.Os.Class == android.Device { |
| 616 | for _, sanitizer := range ctx.Config().SanitizeDevice() { |
| 617 | if sanitizer == "hwaddress" { |
| 618 | addDependenciesForNativeModules(ctx, |
| 619 | []string{"libclang_rt.hwasan-aarch64-android"}, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 620 | nil, nil, target, a.getImageVariation(config)) |
Peter Collingbourne | 3478bb2 | 2019-04-24 14:41:12 -0700 | [diff] [blame] | 621 | break |
| 622 | } |
| 623 | } |
| 624 | } |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 625 | } |
| 626 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 627 | } |
| 628 | |
Jiyong Park | ce6aadc | 2019-11-20 13:58:28 +0900 | [diff] [blame^] | 629 | // For prebuilt_etc, use the first variant (64 on 64/32bit device, |
| 630 | // 32 on 32bit device) regardless of the TARGET_PREFER_* setting. |
| 631 | // b/144532908 |
| 632 | archForPrebuiltEtc := config.Arches()[0] |
| 633 | for _, arch := range config.Arches() { |
| 634 | // Prefer 64-bit arch if there is any |
| 635 | if arch.ArchType.Multilib == "lib64" { |
| 636 | archForPrebuiltEtc = arch |
| 637 | break |
| 638 | } |
| 639 | } |
| 640 | ctx.AddFarVariationDependencies([]blueprint.Variation{ |
| 641 | {Mutator: "os", Variation: ctx.Os().String()}, |
| 642 | {Mutator: "arch", Variation: archForPrebuiltEtc.String()}, |
| 643 | }, prebuiltTag, a.properties.Prebuilts...) |
| 644 | |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 645 | ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), |
| 646 | javaLibTag, a.properties.Java_libs...) |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 647 | |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 648 | ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), |
| 649 | androidAppTag, a.properties.Apps...) |
Sundong Ahn | e1f05aa | 2019-08-27 13:55:42 +0900 | [diff] [blame] | 650 | |
Jiyong Park | 23c52b0 | 2019-02-02 13:13:47 +0900 | [diff] [blame] | 651 | if String(a.properties.Key) == "" { |
| 652 | ctx.ModuleErrorf("key is missing") |
| 653 | return |
| 654 | } |
| 655 | ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key)) |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 656 | |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 657 | cert := android.SrcIsModule(a.getCertString(ctx)) |
Jiyong Park | 23c52b0 | 2019-02-02 13:13:47 +0900 | [diff] [blame] | 658 | if cert != "" { |
| 659 | ctx.AddDependency(ctx.Module(), certificateTag, cert) |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 660 | } |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 661 | |
| 662 | // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks |
| 663 | if len(a.properties.Uses_sdks) > 0 { |
| 664 | sdkRefs := []android.SdkRef{} |
| 665 | for _, str := range a.properties.Uses_sdks { |
| 666 | parsed := android.ParseSdkRef(ctx, str, "uses_sdks") |
| 667 | sdkRefs = append(sdkRefs, parsed) |
| 668 | } |
| 669 | a.BuildWithSdks(sdkRefs) |
| 670 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 671 | } |
| 672 | |
Jiyong Park | a7bc8ad | 2019-10-15 15:20:07 +0900 | [diff] [blame] | 673 | func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { |
| 674 | // direct deps of an APEX bundle are all part of the APEX bundle |
| 675 | return true |
| 676 | } |
| 677 | |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 678 | func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string { |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 679 | certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName()) |
| 680 | if overridden { |
Jaewoong Jung | acb6db3 | 2019-02-28 16:22:30 +0000 | [diff] [blame] | 681 | return ":" + certificate |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 682 | } |
| 683 | return String(a.properties.Certificate) |
| 684 | } |
| 685 | |
Colin Cross | 41955e8 | 2019-05-29 14:40:35 -0700 | [diff] [blame] | 686 | func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) { |
| 687 | switch tag { |
| 688 | case "": |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 689 | return android.Paths{a.outputFile}, nil |
Colin Cross | 41955e8 | 2019-05-29 14:40:35 -0700 | [diff] [blame] | 690 | default: |
| 691 | return nil, fmt.Errorf("unsupported module reference tag %q", tag) |
Jiyong Park | 5a83202 | 2018-12-20 09:54:35 +0900 | [diff] [blame] | 692 | } |
Jiyong Park | 74e240b | 2018-11-27 21:27:08 +0900 | [diff] [blame] | 693 | } |
| 694 | |
Jiyong Park | 92c0f9c | 2018-12-13 23:14:57 +0900 | [diff] [blame] | 695 | func (a *apexBundle) installable() bool { |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 696 | 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] | 697 | } |
| 698 | |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 699 | func (a *apexBundle) getImageVariation(config android.DeviceConfig) string { |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 700 | if a.vndkApex { |
| 701 | return "vendor." + a.vndkVersion(config) |
| 702 | } |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 703 | if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) { |
Inseob Kim | 64c4395 | 2019-08-26 16:52:35 +0900 | [diff] [blame] | 704 | return "vendor." + config.PlatformVndkVersion() |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 705 | } else { |
| 706 | return "core" |
| 707 | } |
| 708 | } |
| 709 | |
Jiyong Park | f97782b | 2019-02-13 20:28:58 +0900 | [diff] [blame] | 710 | func (a *apexBundle) EnableSanitizer(sanitizerName string) { |
| 711 | if !android.InList(sanitizerName, a.properties.SanitizerNames) { |
| 712 | a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName) |
| 713 | } |
| 714 | } |
| 715 | |
Jiyong Park | 388ef3f | 2019-01-28 19:47:32 +0900 | [diff] [blame] | 716 | func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool { |
Jiyong Park | f97782b | 2019-02-13 20:28:58 +0900 | [diff] [blame] | 717 | if android.InList(sanitizerName, a.properties.SanitizerNames) { |
| 718 | return true |
Jiyong Park | 235e67c | 2019-02-09 11:50:56 +0900 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | // Then follow the global setting |
Jiyong Park | 388ef3f | 2019-01-28 19:47:32 +0900 | [diff] [blame] | 722 | globalSanitizerNames := []string{} |
| 723 | if a.Host() { |
| 724 | globalSanitizerNames = ctx.Config().SanitizeHost() |
| 725 | } else { |
| 726 | arches := ctx.Config().SanitizeDeviceArch() |
| 727 | if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) { |
| 728 | globalSanitizerNames = ctx.Config().SanitizeDevice() |
| 729 | } |
| 730 | } |
| 731 | return android.InList(sanitizerName, globalSanitizerNames) |
Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 732 | } |
| 733 | |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 734 | func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool { |
| 735 | return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled() |
| 736 | } |
| 737 | |
| 738 | func (a *apexBundle) PreventInstall() { |
| 739 | a.properties.PreventInstall = true |
| 740 | } |
| 741 | |
| 742 | func (a *apexBundle) HideFromMake() { |
| 743 | a.properties.HideFromMake = true |
| 744 | } |
| 745 | |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 746 | func getCopyManifestForNativeLibrary(ccMod *cc.Module, config android.Config, handleSpecialLibs bool) (fileToCopy android.Path, dirInApex string) { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 747 | // Decide the APEX-local directory by the multilib of the library |
| 748 | // In the future, we may query this to the module. |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 749 | switch ccMod.Arch().ArchType.Multilib { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 750 | case "lib32": |
| 751 | dirInApex = "lib" |
| 752 | case "lib64": |
| 753 | dirInApex = "lib64" |
| 754 | } |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 755 | dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath()) |
Colin Cross | 3b19f5d | 2019-09-17 14:45:31 -0700 | [diff] [blame] | 756 | if ccMod.Target().NativeBridge == android.NativeBridgeEnabled { |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 757 | dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 758 | } |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 759 | if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), config) { |
| 760 | // Special case for Bionic libs and other libs installed with them. This is |
| 761 | // to prevent those libs from being included in the search path |
| 762 | // /apex/com.android.runtime/${LIB}. This exclusion is required because |
| 763 | // those libs in the Runtime APEX are available via the legacy paths in |
| 764 | // /system/lib/. By the init process, the libs in the APEX are bind-mounted |
| 765 | // to the legacy paths and thus will be loaded into the default linker |
| 766 | // namespace (aka "platform" namespace). If the libs are directly in |
| 767 | // /apex/com.android.runtime/${LIB} then the same libs will be loaded again |
| 768 | // into the runtime linker namespace, which will result in double loading of |
| 769 | // them, which isn't supported. |
| 770 | dirInApex = filepath.Join(dirInApex, "bionic") |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 771 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 772 | |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 773 | fileToCopy = ccMod.OutputFile().Path() |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 774 | return |
| 775 | } |
| 776 | |
| 777 | func getCopyManifestForExecutable(cc *cc.Module) (fileToCopy android.Path, dirInApex string) { |
Jiyong Park | bd13e44 | 2019-03-15 18:10:35 +0900 | [diff] [blame] | 778 | dirInApex = filepath.Join("bin", cc.RelativeInstallPath()) |
Colin Cross | 3b19f5d | 2019-09-17 14:45:31 -0700 | [diff] [blame] | 779 | if cc.Target().NativeBridge == android.NativeBridgeEnabled { |
dimitry | 8d6dde8 | 2019-07-11 10:23:53 +0200 | [diff] [blame] | 780 | dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath) |
Jiyong Park | acbf6c7 | 2019-07-09 16:19:16 +0900 | [diff] [blame] | 781 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 782 | fileToCopy = cc.OutputFile().Path() |
| 783 | return |
| 784 | } |
| 785 | |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 786 | func getCopyManifestForPyBinary(py *python.Module) (fileToCopy android.Path, dirInApex string) { |
| 787 | dirInApex = "bin" |
| 788 | fileToCopy = py.HostToolPath().Path() |
| 789 | return |
| 790 | } |
| 791 | func getCopyManifestForGoBinary(ctx android.ModuleContext, gb bootstrap.GoBinaryTool) (fileToCopy android.Path, dirInApex string) { |
| 792 | dirInApex = "bin" |
| 793 | s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath()) |
| 794 | if err != nil { |
| 795 | ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath()) |
| 796 | return |
| 797 | } |
| 798 | fileToCopy = android.PathForOutput(ctx, s) |
| 799 | return |
| 800 | } |
| 801 | |
Jiyong Park | 04480cf | 2019-02-06 00:16:29 +0900 | [diff] [blame] | 802 | func getCopyManifestForShBinary(sh *android.ShBinary) (fileToCopy android.Path, dirInApex string) { |
| 803 | dirInApex = filepath.Join("bin", sh.SubDir()) |
| 804 | fileToCopy = sh.OutputFile() |
| 805 | return |
| 806 | } |
| 807 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 808 | func getCopyManifestForJavaLibrary(java *java.Library) (fileToCopy android.Path, dirInApex string) { |
| 809 | dirInApex = "javalib" |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 810 | fileToCopy = java.DexJarFile() |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 811 | return |
| 812 | } |
| 813 | |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 814 | func getCopyManifestForPrebuiltJavaLibrary(java *java.Import) (fileToCopy android.Path, dirInApex string) { |
| 815 | dirInApex = "javalib" |
| 816 | // The output is only one, but for some reason, ImplementationJars returns Paths, not Path |
| 817 | implJars := java.ImplementationJars() |
| 818 | if len(implJars) != 1 { |
| 819 | panic(fmt.Errorf("java.ImplementationJars() must return single Path, but got: %s", |
| 820 | strings.Join(implJars.Strings(), ", "))) |
| 821 | } |
| 822 | fileToCopy = implJars[0] |
| 823 | return |
| 824 | } |
| 825 | |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 826 | func getCopyManifestForPrebuiltEtc(prebuilt android.PrebuiltEtcModule) (fileToCopy android.Path, dirInApex string) { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 827 | dirInApex = filepath.Join("etc", prebuilt.SubDir()) |
| 828 | fileToCopy = prebuilt.OutputFile() |
| 829 | return |
| 830 | } |
| 831 | |
Sundong Ahn | e1f05aa | 2019-08-27 13:55:42 +0900 | [diff] [blame] | 832 | func getCopyManifestForAndroidApp(app *java.AndroidApp, pkgName string) (fileToCopy android.Path, dirInApex string) { |
Jiyong Park | f748731 | 2019-10-17 12:54:30 +0900 | [diff] [blame] | 833 | appDir := "app" |
| 834 | if app.Privileged() { |
| 835 | appDir = "priv-app" |
| 836 | } |
| 837 | dirInApex = filepath.Join(appDir, pkgName) |
Sundong Ahn | e1f05aa | 2019-08-27 13:55:42 +0900 | [diff] [blame] | 838 | fileToCopy = app.OutputFile() |
| 839 | return |
| 840 | } |
| 841 | |
Dario Freni | cde2a03 | 2019-10-27 00:29:22 +0100 | [diff] [blame] | 842 | func getCopyManifestForAndroidAppImport(app *java.AndroidAppImport, pkgName string) (fileToCopy android.Path, dirInApex string) { |
| 843 | appDir := "app" |
| 844 | if app.Privileged() { |
| 845 | appDir = "priv-app" |
| 846 | } |
| 847 | dirInApex = filepath.Join(appDir, pkgName) |
| 848 | fileToCopy = app.OutputFile() |
| 849 | return |
| 850 | } |
| 851 | |
Roland Levillain | 935639d | 2019-08-13 14:55:28 +0100 | [diff] [blame] | 852 | // Context "decorator", overriding the InstallBypassMake method to always reply `true`. |
| 853 | type flattenedApexContext struct { |
| 854 | android.ModuleContext |
| 855 | } |
| 856 | |
| 857 | func (c *flattenedApexContext) InstallBypassMake() bool { |
| 858 | return true |
| 859 | } |
| 860 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 861 | func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 862 | filesInfo := []apexFile{} |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 863 | |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 864 | buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild() |
| 865 | switch a.properties.ApexType { |
| 866 | case imageApex: |
| 867 | if buildFlattenedAsDefault { |
| 868 | a.suffix = imageApexSuffix |
| 869 | } else { |
| 870 | a.suffix = "" |
| 871 | a.primaryApexType = true |
| 872 | } |
| 873 | case zipApex: |
| 874 | if proptools.String(a.properties.Payload_type) == "zip" { |
| 875 | a.suffix = "" |
| 876 | a.primaryApexType = true |
| 877 | } else { |
| 878 | a.suffix = zipApexSuffix |
| 879 | } |
| 880 | case flattenedApex: |
| 881 | if buildFlattenedAsDefault { |
| 882 | a.suffix = "" |
| 883 | a.primaryApexType = true |
| 884 | } else { |
| 885 | a.suffix = flattenedSuffix |
| 886 | } |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 887 | } |
| 888 | |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 889 | if len(a.properties.Tests) > 0 && !a.testApex { |
| 890 | ctx.PropertyErrorf("tests", "property not allowed in apex module type") |
| 891 | return |
| 892 | } |
| 893 | |
Alex Light | fc0bd7c | 2019-01-29 18:31:59 -0800 | [diff] [blame] | 894 | handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case) |
| 895 | |
Jooyung Han | e163303 | 2019-08-01 17:41:43 +0900 | [diff] [blame] | 896 | // native lib dependencies |
| 897 | var provideNativeLibs []string |
| 898 | var requireNativeLibs []string |
| 899 | |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 900 | // Check if "uses" requirements are met with dependent apexBundles |
| 901 | var providedNativeSharedLibs []string |
| 902 | useVendor := proptools.Bool(a.properties.Use_vendor) |
| 903 | ctx.VisitDirectDepsBlueprint(func(m blueprint.Module) { |
| 904 | if ctx.OtherModuleDependencyTag(m) != usesTag { |
| 905 | return |
| 906 | } |
| 907 | otherName := ctx.OtherModuleName(m) |
| 908 | other, ok := m.(*apexBundle) |
| 909 | if !ok { |
| 910 | ctx.PropertyErrorf("uses", "%q is not a provider", otherName) |
| 911 | return |
| 912 | } |
| 913 | if proptools.Bool(other.properties.Use_vendor) != useVendor { |
| 914 | ctx.PropertyErrorf("use_vendor", "%q has different value of use_vendor", otherName) |
| 915 | return |
| 916 | } |
| 917 | if !proptools.Bool(other.properties.Provide_cpp_shared_libs) { |
| 918 | ctx.PropertyErrorf("uses", "%q does not provide native_shared_libs", otherName) |
| 919 | return |
| 920 | } |
| 921 | providedNativeSharedLibs = append(providedNativeSharedLibs, other.properties.Native_shared_libs...) |
| 922 | }) |
| 923 | |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 924 | ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 925 | depTag := ctx.OtherModuleDependencyTag(child) |
| 926 | depName := ctx.OtherModuleName(child) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 927 | if _, ok := parent.(*apexBundle); ok { |
| 928 | // direct dependencies |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 929 | switch depTag { |
| 930 | case sharedLibTag: |
| 931 | if cc, ok := child.(*cc.Module); ok { |
Jooyung Han | e163303 | 2019-08-01 17:41:43 +0900 | [diff] [blame] | 932 | if cc.HasStubsVariants() { |
| 933 | provideNativeLibs = append(provideNativeLibs, cc.OutputFile().Path().Base()) |
| 934 | } |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 935 | fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc, ctx.Config(), handleSpecialLibs) |
Jiyong Park | 719b446 | 2019-01-13 00:39:51 +0900 | [diff] [blame] | 936 | filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, nativeSharedLib, cc, nil}) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 937 | return true |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 938 | } else { |
| 939 | ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 940 | } |
| 941 | case executableTag: |
| 942 | if cc, ok := child.(*cc.Module); ok { |
| 943 | fileToCopy, dirInApex := getCopyManifestForExecutable(cc) |
Jiyong Park | 719b446 | 2019-01-13 00:39:51 +0900 | [diff] [blame] | 944 | filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, nativeExecutable, cc, cc.Symlinks()}) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 945 | return true |
Jiyong Park | 04480cf | 2019-02-06 00:16:29 +0900 | [diff] [blame] | 946 | } else if sh, ok := child.(*android.ShBinary); ok { |
| 947 | fileToCopy, dirInApex := getCopyManifestForShBinary(sh) |
Rashed Abdel-Tawab | 6a34131 | 2019-10-04 20:38:01 -0700 | [diff] [blame] | 948 | filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, shBinary, sh, sh.Symlinks()}) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 949 | } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() { |
| 950 | fileToCopy, dirInApex := getCopyManifestForPyBinary(py) |
| 951 | filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, pyBinary, py, nil}) |
| 952 | } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() { |
| 953 | fileToCopy, dirInApex := getCopyManifestForGoBinary(ctx, gb) |
| 954 | // NB: Since go binaries are static we don't need the module for anything here, which is |
| 955 | // good since the go tool is a blueprint.Module not an android.Module like we would |
| 956 | // normally use. |
| 957 | filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, goBinary, nil, nil}) |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 958 | } else { |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 959 | 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] | 960 | } |
| 961 | case javaLibTag: |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 962 | if javaLib, ok := child.(*java.Library); ok { |
| 963 | fileToCopy, dirInApex := getCopyManifestForJavaLibrary(javaLib) |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 964 | if fileToCopy == nil { |
| 965 | ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName) |
| 966 | } else { |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 967 | filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, javaSharedLib, javaLib, nil}) |
| 968 | } |
| 969 | return true |
| 970 | } else if javaLib, ok := child.(*java.Import); ok { |
| 971 | fileToCopy, dirInApex := getCopyManifestForPrebuiltJavaLibrary(javaLib) |
| 972 | if fileToCopy == nil { |
| 973 | ctx.PropertyErrorf("java_libs", "%q does not have a jar output", depName) |
| 974 | } else { |
| 975 | filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, javaSharedLib, javaLib, nil}) |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 976 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 977 | return true |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 978 | } else { |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 979 | 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] | 980 | } |
| 981 | case prebuiltTag: |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 982 | if prebuilt, ok := child.(android.PrebuiltEtcModule); ok { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 983 | fileToCopy, dirInApex := getCopyManifestForPrebuiltEtc(prebuilt) |
Jiyong Park | 719b446 | 2019-01-13 00:39:51 +0900 | [diff] [blame] | 984 | filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, etc, prebuilt, nil}) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 985 | return true |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 986 | } else { |
| 987 | ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName) |
| 988 | } |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 989 | case testTag: |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 990 | if ccTest, ok := child.(*cc.Module); ok { |
| 991 | if ccTest.IsTestPerSrcAllTestsVariation() { |
| 992 | // Multiple-output test module (where `test_per_src: true`). |
| 993 | // |
| 994 | // `ccTest` is the "" ("all tests") variation of a `test_per_src` module. |
| 995 | // We do not add this variation to `filesInfo`, as it has no output; |
| 996 | // however, we do add the other variations of this module as indirect |
| 997 | // dependencies (see below). |
| 998 | return true |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 999 | } else { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1000 | // Single-output test module (where `test_per_src: false`). |
| 1001 | fileToCopy, dirInApex := getCopyManifestForExecutable(ccTest) |
| 1002 | filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, nativeTest, ccTest, nil}) |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 1003 | } |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1004 | return true |
| 1005 | } else { |
| 1006 | ctx.PropertyErrorf("tests", "%q is not a cc module", depName) |
| 1007 | } |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1008 | case keyTag: |
| 1009 | if key, ok := child.(*apexKey); ok { |
Jiyong Park | 0ca3ce8 | 2019-02-18 15:25:04 +0900 | [diff] [blame] | 1010 | a.private_key_file = key.private_key_file |
| 1011 | a.public_key_file = key.public_key_file |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1012 | return false |
| 1013 | } else { |
| 1014 | ctx.PropertyErrorf("key", "%q is not an apex_key module", depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1015 | } |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 1016 | case certificateTag: |
| 1017 | if dep, ok := child.(*java.AndroidAppCertificate); ok { |
Jiyong Park | 0ca3ce8 | 2019-02-18 15:25:04 +0900 | [diff] [blame] | 1018 | a.container_certificate_file = dep.Certificate.Pem |
| 1019 | a.container_private_key_file = dep.Certificate.Key |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 1020 | return false |
| 1021 | } else { |
| 1022 | ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName) |
| 1023 | } |
Jiyong Park | 03b68dd | 2019-07-26 23:20:40 +0900 | [diff] [blame] | 1024 | case android.PrebuiltDepTag: |
| 1025 | // If the prebuilt is force disabled, remember to delete the prebuilt file |
| 1026 | // that might have been installed in the previous builds |
| 1027 | if prebuilt, ok := child.(*Prebuilt); ok && prebuilt.isForceDisabled() { |
| 1028 | a.prebuiltFileToDelete = prebuilt.InstallFilename() |
| 1029 | } |
Sundong Ahn | e1f05aa | 2019-08-27 13:55:42 +0900 | [diff] [blame] | 1030 | case androidAppTag: |
| 1031 | if ap, ok := child.(*java.AndroidApp); ok { |
| 1032 | fileToCopy, dirInApex := getCopyManifestForAndroidApp(ap, ctx.DeviceConfig().OverridePackageNameFor(depName)) |
| 1033 | filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, app, ap, nil}) |
| 1034 | return true |
Dario Freni | cde2a03 | 2019-10-27 00:29:22 +0100 | [diff] [blame] | 1035 | } else if ap, ok := child.(*java.AndroidAppImport); ok { |
| 1036 | fileToCopy, dirInApex := getCopyManifestForAndroidAppImport(ap, ctx.DeviceConfig().OverridePackageNameFor(depName)) |
| 1037 | filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, app, ap, nil}) |
Sundong Ahn | e1f05aa | 2019-08-27 13:55:42 +0900 | [diff] [blame] | 1038 | } else { |
| 1039 | ctx.PropertyErrorf("apps", "%q is not an android_app module", depName) |
| 1040 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1041 | } |
Jooyung Han | 8aee204 | 2019-10-29 05:08:31 +0900 | [diff] [blame] | 1042 | } else if !a.vndkApex { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1043 | // indirect dependencies |
Jooyung Han | 9c80bae | 2019-08-20 17:30:57 +0900 | [diff] [blame] | 1044 | if am, ok := child.(android.ApexModule); ok { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1045 | // We cannot use a switch statement on `depTag` here as the checked |
| 1046 | // tags used below are private (e.g. `cc.sharedDepTag`). |
Jiyong Park | 52cd06f | 2019-11-11 10:14:32 +0900 | [diff] [blame] | 1047 | if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1048 | if cc, ok := child.(*cc.Module); ok { |
| 1049 | if android.InList(cc.Name(), providedNativeSharedLibs) { |
| 1050 | // If we're using a shared library which is provided from other APEX, |
| 1051 | // don't include it in this APEX |
| 1052 | return false |
Jiyong Park | ac2bacd | 2019-02-20 21:49:26 +0900 | [diff] [blame] | 1053 | } |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1054 | if !a.Host() && (cc.IsStubs() || cc.HasStubsVariants()) { |
| 1055 | // If the dependency is a stubs lib, don't include it in this APEX, |
| 1056 | // but make sure that the lib is installed on the device. |
| 1057 | // In case no APEX is having the lib, the lib is installed to the system |
| 1058 | // partition. |
| 1059 | // |
| 1060 | // Always include if we are a host-apex however since those won't have any |
| 1061 | // system libraries. |
| 1062 | if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.Name(), a.externalDeps) { |
| 1063 | a.externalDeps = append(a.externalDeps, cc.Name()) |
| 1064 | } |
Jooyung Han | e163303 | 2019-08-01 17:41:43 +0900 | [diff] [blame] | 1065 | requireNativeLibs = append(requireNativeLibs, cc.OutputFile().Path().Base()) |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1066 | // Don't track further |
| 1067 | return false |
| 1068 | } |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 1069 | fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc, ctx.Config(), handleSpecialLibs) |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1070 | filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, nativeSharedLib, cc, nil}) |
| 1071 | return true |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1072 | } |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1073 | } else if cc.IsTestPerSrcDepTag(depTag) { |
| 1074 | if cc, ok := child.(*cc.Module); ok { |
| 1075 | fileToCopy, dirInApex := getCopyManifestForExecutable(cc) |
| 1076 | // Handle modules created as `test_per_src` variations of a single test module: |
| 1077 | // use the name of the generated test binary (`fileToCopy`) instead of the name |
| 1078 | // of the original test module (`depName`, shared by all `test_per_src` |
| 1079 | // variations of that module). |
| 1080 | moduleName := filepath.Base(fileToCopy.String()) |
| 1081 | filesInfo = append(filesInfo, apexFile{fileToCopy, moduleName, dirInApex, nativeTest, cc, nil}) |
| 1082 | return true |
| 1083 | } |
Jiyong Park | 52cd06f | 2019-11-11 10:14:32 +0900 | [diff] [blame] | 1084 | } else if java.IsJniDepTag(depTag) { |
| 1085 | // Do nothing for JNI dep. JNI libraries are always embedded in APK-in-APEX. |
Jooyung Han | 9c80bae | 2019-08-20 17:30:57 +0900 | [diff] [blame] | 1086 | } else if am.CanHaveApexVariants() && am.IsInstallableToApex() { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1087 | ctx.ModuleErrorf("unexpected tag %q for indirect dependency %q", depTag, depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1088 | } |
| 1089 | } |
| 1090 | } |
| 1091 | return false |
| 1092 | }) |
| 1093 | |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 1094 | // Specific to the ART apex: dexpreopt artifacts for libcore Java libraries. |
| 1095 | // Build rules are generated by the dexpreopt singleton, and here we access build artifacts |
| 1096 | // via the global boot image config. |
| 1097 | if a.artApex { |
| 1098 | for arch, files := range java.DexpreoptedArtApexJars(ctx) { |
| 1099 | dirInApex := filepath.Join("javalib", arch.String()) |
| 1100 | for _, f := range files { |
| 1101 | localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String()) |
| 1102 | filesInfo = append(filesInfo, apexFile{f, localModule, dirInApex, etc, nil, nil}) |
| 1103 | } |
| 1104 | } |
| 1105 | } |
| 1106 | |
Jiyong Park | 0ca3ce8 | 2019-02-18 15:25:04 +0900 | [diff] [blame] | 1107 | if a.private_key_file == nil { |
Jiyong Park | fa0a373 | 2018-11-09 05:52:26 +0900 | [diff] [blame] | 1108 | ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key)) |
| 1109 | return |
| 1110 | } |
| 1111 | |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1112 | // remove duplicates in filesInfo |
| 1113 | removeDup := func(filesInfo []apexFile) []apexFile { |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1114 | encountered := make(map[string]bool) |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1115 | result := []apexFile{} |
| 1116 | for _, f := range filesInfo { |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1117 | dest := filepath.Join(f.installDir, f.builtFile.Base()) |
| 1118 | if !encountered[dest] { |
| 1119 | encountered[dest] = true |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1120 | result = append(result, f) |
| 1121 | } |
| 1122 | } |
| 1123 | return result |
| 1124 | } |
| 1125 | filesInfo = removeDup(filesInfo) |
| 1126 | |
| 1127 | // to have consistent build rules |
| 1128 | sort.Slice(filesInfo, func(i, j int) bool { |
| 1129 | return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String() |
| 1130 | }) |
| 1131 | |
Jiyong Park | 127b40b | 2019-09-30 16:04:35 +0900 | [diff] [blame] | 1132 | // check apex_available requirements |
Jiyong Park | 583a226 | 2019-10-08 20:55:38 +0900 | [diff] [blame] | 1133 | if !ctx.Host() { |
| 1134 | for _, fi := range filesInfo { |
| 1135 | if am, ok := fi.module.(android.ApexModule); ok { |
| 1136 | if !am.AvailableFor(ctx.ModuleName()) { |
| 1137 | ctx.ModuleErrorf("requires %q that is not available for the APEX", fi.module.Name()) |
| 1138 | return |
| 1139 | } |
Jiyong Park | 127b40b | 2019-09-30 16:04:35 +0900 | [diff] [blame] | 1140 | } |
| 1141 | } |
| 1142 | } |
| 1143 | |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1144 | // prepend the name of this APEX to the module names. These names will be the names of |
| 1145 | // modules that will be defined if the APEX is flattened. |
| 1146 | for i := range filesInfo { |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1147 | filesInfo[i].moduleName = filesInfo[i].moduleName + "." + ctx.ModuleName() + a.suffix |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1148 | } |
| 1149 | |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1150 | a.installDir = android.PathForModuleInstall(ctx, "apex") |
| 1151 | a.filesInfo = filesInfo |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1152 | |
Jooyung Han | d15aa1f | 2019-09-27 00:38:03 +0900 | [diff] [blame] | 1153 | // prepare apex_manifest.json |
Jooyung Han | 01a3ee2 | 2019-11-02 02:52:25 +0900 | [diff] [blame] | 1154 | a.buildManifest(ctx, provideNativeLibs, requireNativeLibs) |
| 1155 | |
| 1156 | a.setCertificateAndPrivateKey(ctx) |
| 1157 | if a.properties.ApexType == flattenedApex { |
| 1158 | a.buildFlattenedApex(ctx) |
| 1159 | } else { |
| 1160 | a.buildUnflattenedApex(ctx) |
| 1161 | } |
| 1162 | |
| 1163 | apexName := proptools.StringDefault(a.properties.Apex_name, ctx.ModuleName()) |
| 1164 | a.compatSymlinks = makeCompatSymlinks(apexName, ctx) |
| 1165 | } |
| 1166 | |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1167 | func newApexBundle() *apexBundle { |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1168 | module := &apexBundle{} |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1169 | module.AddProperties(&module.properties) |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 1170 | module.AddProperties(&module.targetProperties) |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1171 | module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool { |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1172 | return class == android.Device && ctx.Config().DevicePrefer32BitExecutables() |
| 1173 | }) |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1174 | android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1175 | android.InitDefaultableModule(module) |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 1176 | android.InitSdkAwareModule(module) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1177 | return module |
| 1178 | } |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 1179 | |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 1180 | func ApexBundleFactory(testApex bool, artApex bool) android.Module { |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1181 | bundle := newApexBundle() |
| 1182 | bundle.testApex = testApex |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 1183 | bundle.artApex = artApex |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1184 | return bundle |
| 1185 | } |
| 1186 | |
| 1187 | func testApexBundleFactory() android.Module { |
| 1188 | bundle := newApexBundle() |
| 1189 | bundle.testApex = true |
| 1190 | return bundle |
| 1191 | } |
| 1192 | |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 1193 | func BundleFactory() android.Module { |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1194 | return newApexBundle() |
| 1195 | } |
| 1196 | |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 1197 | // |
| 1198 | // Defaults |
| 1199 | // |
| 1200 | type Defaults struct { |
| 1201 | android.ModuleBase |
| 1202 | android.DefaultsModuleBase |
| 1203 | } |
| 1204 | |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 1205 | func defaultsFactory() android.Module { |
| 1206 | return DefaultsFactory() |
| 1207 | } |
| 1208 | |
| 1209 | func DefaultsFactory(props ...interface{}) android.Module { |
| 1210 | module := &Defaults{} |
| 1211 | |
| 1212 | module.AddProperties(props...) |
| 1213 | module.AddProperties( |
| 1214 | &apexBundleProperties{}, |
| 1215 | &apexTargetBundleProperties{}, |
| 1216 | ) |
| 1217 | |
| 1218 | android.InitDefaultsModule(module) |
| 1219 | return module |
| 1220 | } |