blob: 76b3bcaf2674b042673c8b3be7d9d7f261b93ecc [file] [log] [blame]
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001// 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
15package apex
16
17import (
18 "fmt"
Jooyung Han54aca7b2019-11-20 02:26:02 +090019 "path"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090020 "path/filepath"
Jiyong Parkab3ceb32018-10-10 14:05:29 +090021 "sort"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090022 "strings"
Jooyung Han344d5432019-08-23 11:17:39 +090023 "sync"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090024
25 "android/soong/android"
26 "android/soong/cc"
27 "android/soong/java"
Alex Light778127a2019-02-27 14:19:50 -080028 "android/soong/python"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090029
30 "github.com/google/blueprint"
Alex Light778127a2019-02-27 14:19:50 -080031 "github.com/google/blueprint/bootstrap"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090032 "github.com/google/blueprint/proptools"
33)
34
Jooyung Han72bd2f82019-10-23 16:46:38 +090035const (
36 imageApexSuffix = ".apex"
37 zipApexSuffix = ".zipapex"
Sundong Ahnabb64432019-10-22 13:58:29 +090038 flattenedSuffix = ".flattened"
Alex Light5098a612018-11-29 17:12:15 -080039
Sundong Ahnabb64432019-10-22 13:58:29 +090040 imageApexType = "image"
41 zipApexType = "zip"
42 flattenedApexType = "flattened"
Jooyung Han72bd2f82019-10-23 16:46:38 +090043)
Jiyong Park48ca7dc2018-10-10 14:01:00 +090044
45type dependencyTag struct {
46 blueprint.BaseDependencyTag
47 name string
48}
49
50var (
Jiyong Parkc00cbd92018-10-30 21:20:05 +090051 sharedLibTag = dependencyTag{name: "sharedLib"}
52 executableTag = dependencyTag{name: "executable"}
53 javaLibTag = dependencyTag{name: "javaLib"}
54 prebuiltTag = dependencyTag{name: "prebuilt"}
Roland Levillain630846d2019-06-26 12:48:34 +010055 testTag = dependencyTag{name: "test"}
Jiyong Parkc00cbd92018-10-30 21:20:05 +090056 keyTag = dependencyTag{name: "key"}
57 certificateTag = dependencyTag{name: "certificate"}
Jooyung Han5c998b92019-06-27 11:30:33 +090058 usesTag = dependencyTag{name: "uses"}
Sundong Ahne1f05aa2019-08-27 13:55:42 +090059 androidAppTag = dependencyTag{name: "androidApp"}
Anton Hansson5053c292020-01-10 15:12:39 +000060 apexAvailWl = makeApexAvailableWhitelist()
Jiyong Park48ca7dc2018-10-10 14:01:00 +090061)
62
Anton Hansson5053c292020-01-10 15:12:39 +000063// This is a map from apex to modules, which overrides the
64// apex_available setting for that particular module to make
65// it available for the apex regardless of its setting.
66// TODO(b/147364041): remove this
67func makeApexAvailableWhitelist() map[string][]string {
68 // The "Module separator"s below are employed to minimize merge conflicts.
69 m := make(map[string][]string)
70 //
71 // Module separator
72 //
73 m["com.android.adbd"] = []string{"adbd", "libcrypto"}
74 //
75 // Module separator
76 //
77 m["com.android.art"] = []string{
78 "libadbconnection_server",
79 "libartd-disassembler",
80 "libbacktrace",
81 "libbase",
82 "libc++",
83 "libcrypto",
84 "libdexfile_support",
85 "libexpat",
86 "libicuuc",
87 "liblzma",
88 "libmeminfo",
89 "libprocinfo",
90 "libunwindstack",
91 "libvixl",
92 "libvixld",
93 "libz",
94 "libziparchive",
95 "prebuilt_libclang_rt",
96 }
97 //
98 // Module separator
99 //
100 m["com.android.bluetooth.updatable"] = []string{
101 "android.hardware.audio.common@5.0",
102 "android.hardware.bluetooth@1.0",
103 "android.hardware.bluetooth@1.1",
104 "android.hardware.bluetooth.a2dp@1.0",
105 "android.hardware.bluetooth.audio@2.0",
106 "android.hidl.safe_union@1.0",
107 "libbase",
108 "libbinderthreadstate",
109 "libbluetooth",
110 "libbluetooth_jni",
111 "libc++",
112 "libchrome",
113 "libcrypto",
114 "libcutils",
115 "libevent",
116 "libfmq",
117 "libhidlbase",
118 "libprocessgroup",
119 "libprotobuf-cpp-lite",
120 "libstatslog",
121 "libtinyxml2",
122 "libutils",
123 "libz",
124 }
125 //
126 // Module separator
127 //
128 m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"}
129 //
130 // Module separator
131 //
132 m["com.android.conscrypt"] = []string{"boringssl_self_test", "libc++", "libcrypto", "libssl"}
133 //
134 // Module separator
135 //
136 m["com.android.cronet"] = []string{"org.chromium.net.cronet", "prebuilt_libcronet.80.0.3986.0"}
137 //
138 // Module separator
139 //
140 m["com.android.incremental"] = []string{"libc++", "libdataloader", "libincfs"}
141 //
142 // Module separator
143 //
144 m["com.android.media"] = []string{
145 "android.hardware.cas@1.0",
146 "android.hardware.cas.native@1.0",
147 "android.hidl.allocator@1.0",
148 "android.hidl.memory@1.0",
149 "android.hidl.memory.token@1.0",
150 "android.hidl.token@1.0",
151 "android.hidl.token@1.0-utils",
152 "libaacextractor",
153 "libamrextractor",
154 "libaudioutils",
155 "libbase",
156 "libbinderthreadstate",
157 "libc++",
158 "libcrypto",
159 "libcutils",
160 "libflacextractor",
161 "libhidlbase",
162 "libhidlmemory",
163 "libmidiextractor",
164 "libmkvextractor",
165 "libmp3extractor",
166 "libmp4extractor",
167 "libmpeg2extractor",
168 "liboggextractor",
169 "libprocessgroup",
170 "libspeexresampler",
171 "libstagefright_flacdec",
172 "libutils",
173 "libwavextractor",
174 "updatable-media",
175 }
176 //
177 // Module separator
178 //
179 m["com.android.media.swcodec"] = []string{
180 "android.frameworks.bufferhub@1.0",
181 "android.hardware.common-ndk_platform",
182 "android.hardware.graphics.allocator@2.0",
183 "android.hardware.graphics.allocator@3.0",
184 "android.hardware.graphics.allocator@4.0",
185 "android.hardware.graphics.bufferqueue@1.0",
186 "android.hardware.graphics.bufferqueue@2.0",
187 "android.hardware.graphics.common@1.0",
188 "android.hardware.graphics.common@1.1",
189 "android.hardware.graphics.common@1.2",
190 "android.hardware.graphics.common-ndk_platform",
191 "android.hardware.graphics.mapper@2.0",
192 "android.hardware.graphics.mapper@2.1",
193 "android.hardware.graphics.mapper@3.0",
194 "android.hardware.graphics.mapper@4.0",
195 "android.hardware.media@1.0",
196 "android.hardware.media.bufferpool@2.0",
197 "android.hardware.media.c2@1.0",
198 "android.hardware.media.c2@1.1",
199 "android.hardware.media.omx@1.0",
200 "android.hidl.memory@1.0",
201 "android.hidl.memory.token@1.0",
202 "android.hidl.safe_union@1.0",
203 "android.hidl.token@1.0",
204 "android.hidl.token@1.0-utils",
205 "libaudioutils",
206 "libavservices_minijail",
207 "libbase",
208 "libbinderthreadstate",
209 "libc++",
210 "libcap",
211 "libcodec2",
212 "libcodec2_hidl@1.0",
213 "libcodec2_hidl@1.1",
214 "libcodec2_soft_aacdec",
215 "libcodec2_soft_aacenc",
216 "libcodec2_soft_amrnbdec",
217 "libcodec2_soft_amrnbenc",
218 "libcodec2_soft_amrwbdec",
219 "libcodec2_soft_amrwbenc",
220 "libcodec2_soft_av1dec_gav1",
221 "libcodec2_soft_avcdec",
222 "libcodec2_soft_avcenc",
223 "libcodec2_soft_common",
224 "libcodec2_soft_flacdec",
225 "libcodec2_soft_flacenc",
226 "libcodec2_soft_g711alawdec",
227 "libcodec2_soft_g711mlawdec",
228 "libcodec2_soft_gsmdec",
229 "libcodec2_soft_h263dec",
230 "libcodec2_soft_h263enc",
231 "libcodec2_soft_hevcdec",
232 "libcodec2_soft_hevcenc",
233 "libcodec2_soft_mp3dec",
234 "libcodec2_soft_mpeg2dec",
235 "libcodec2_soft_mpeg4dec",
236 "libcodec2_soft_mpeg4enc",
237 "libcodec2_soft_opusdec",
238 "libcodec2_soft_opusenc",
239 "libcodec2_soft_rawdec",
240 "libcodec2_soft_vorbisdec",
241 "libcodec2_soft_vp8dec",
242 "libcodec2_soft_vp8enc",
243 "libcodec2_soft_vp9dec",
244 "libcodec2_soft_vp9enc",
245 "libcodec2_vndk",
246 "libc_scudo",
247 "libcutils",
248 "libfmq",
249 "libgralloctypes",
250 "libhardware",
251 "libhidlbase",
252 "libhidlmemory",
253 "libion",
254 "libmedia_codecserviceregistrant",
255 "libminijail",
256 "libopus",
257 "libprocessgroup",
258 "libscudo_wrapper",
259 "libsfplugin_ccodec_utils",
260 "libspeexresampler",
261 "libstagefright_amrnb_common",
262 "libstagefright_bufferpool@2.0.1",
263 "libstagefright_bufferqueue_helper",
264 "libstagefright_enc_common",
265 "libstagefright_flacdec",
266 "libstagefright_foundation",
267 "libsync",
268 "libui",
269 "libutils",
270 "libvorbisidec",
271 "libvpx",
272 "mediaswcodec",
273 "prebuilt_libclang_rt",
274 }
275 //
276 // Module separator
277 //
278 m["com.android.mediaprovider"] = []string{"libfuse", "MediaProvider", "MediaProviderGoogle"}
279 //
280 // Module separator
281 //
282 m["com.android.permission"] = []string{"GooglePermissionController", "PermissionController"}
283 //
284 // Module separator
285 //
286 m["com.android.runtime"] = []string{
287 "libbase",
288 "libc++",
289 "libdexfile_support",
290 "liblzma",
291 "libunwindstack",
292 "prebuilt_libclang_rt",
293 }
294 //
295 // Module separator
296 //
297 m["com.android.resolv"] = []string{"libcrypto", "libnetd_resolv", "libssl"}
298 //
299 // Module separator
300 //
301 m["com.android.tethering"] = []string{"libbase", "libc++", "libnativehelper_compat_libc++"}
302 //
303 // Module separator
304 //
305 m["com.android.wifi"] = []string{
306 "libbase",
307 "libc++",
308 "libcutils",
309 "libprocessgroup",
310 "libutils",
311 "libwifi-jni",
312 "wifi-service-resources",
313 }
314 //
315 // Module separator
316 //
317 return m
318}
319
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900320func init() {
Jiyong Parkd1063c12019-07-17 20:08:41 +0900321 android.RegisterModuleType("apex", BundleFactory)
Alex Light0851b882019-02-07 13:20:53 -0800322 android.RegisterModuleType("apex_test", testApexBundleFactory)
Jooyung Han344d5432019-08-23 11:17:39 +0900323 android.RegisterModuleType("apex_vndk", vndkApexBundleFactory)
Jiyong Park30ca9372019-02-07 16:27:23 +0900324 android.RegisterModuleType("apex_defaults", defaultsFactory)
Jaewoong Jung939ebd52019-03-26 15:07:36 -0700325 android.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
Jiyong Park5d790c32019-11-15 18:40:32 +0900326 android.RegisterModuleType("override_apex", overrideApexFactory)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900327
Jooyung Han31c470b2019-10-18 16:26:59 +0900328 android.PreDepsMutators(RegisterPreDepsMutators)
Jiyong Parkd1063c12019-07-17 20:08:41 +0900329 android.PostDepsMutators(RegisterPostDepsMutators)
Jooyung Han7a78a922019-10-08 21:59:58 +0900330
331 android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
332 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
333 sort.Strings(*apexFileContextsInfos)
334 ctx.Strict("APEX_FILE_CONTEXTS_INFOS", strings.Join(*apexFileContextsInfos, " "))
335 })
Jiyong Parkd1063c12019-07-17 20:08:41 +0900336}
337
Jooyung Han31c470b2019-10-18 16:26:59 +0900338func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
339 ctx.TopDown("apex_vndk", apexVndkMutator).Parallel()
340 ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel()
341}
342
Jiyong Parkd1063c12019-07-17 20:08:41 +0900343func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
Jiyong Parka308ea12019-11-15 10:38:39 +0900344 ctx.BottomUp("apex_deps", apexDepsMutator)
Jiyong Parkd1063c12019-07-17 20:08:41 +0900345 ctx.BottomUp("apex", apexMutator).Parallel()
346 ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel()
347 ctx.BottomUp("apex_uses", apexUsesMutator).Parallel()
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900348}
349
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900350// Mark the direct and transitive dependencies of apex bundles so that they
351// can be built for the apex bundles.
Jiyong Parka308ea12019-11-15 10:38:39 +0900352func apexDepsMutator(mctx android.BottomUpMutatorContext) {
Alex Lightf98087f2019-02-04 14:45:06 -0800353 if a, ok := mctx.Module().(*apexBundle); ok {
Colin Crossa4925902018-11-16 11:36:28 -0800354 apexBundleName := mctx.ModuleName()
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900355 mctx.WalkDeps(func(child, parent android.Module) bool {
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900356 depName := mctx.OtherModuleName(child)
357 // If the parent is apexBundle, this child is directly depended.
358 _, directDep := parent.(*apexBundle)
Alex Light0851b882019-02-07 13:20:53 -0800359 if a.installable() && !a.testApex {
Alex Lightf98087f2019-02-04 14:45:06 -0800360 // TODO(b/123892969): Workaround for not having any way to annotate test-apexs
361 // non-installable apex's cannot be installed and so should not prevent libraries from being
362 // installed to the system.
363 android.UpdateApexDependency(apexBundleName, depName, directDep)
364 }
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900365
Jiyong Park3ff16992019-12-27 14:11:47 +0900366 if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() &&
367 (directDep || am.DepIsInSameApex(mctx, child)) {
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900368 am.BuildForApex(apexBundleName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900369 return true
370 } else {
371 return false
372 }
373 })
374 }
375}
376
377// Create apex variations if a module is included in APEX(s).
378func apexMutator(mctx android.BottomUpMutatorContext) {
379 if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900380 am.CreateApexVariations(mctx)
Jooyung Han54aca7b2019-11-20 02:26:02 +0900381 } else if _, ok := mctx.Module().(*apexBundle); ok {
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900382 // apex bundle itself is mutated so that it and its modules have same
383 // apex variant.
384 apexBundleName := mctx.ModuleName()
385 mctx.CreateVariations(apexBundleName)
Jiyong Park5d790c32019-11-15 18:40:32 +0900386 } else if o, ok := mctx.Module().(*OverrideApex); ok {
387 apexBundleName := o.GetOverriddenModuleName()
388 if apexBundleName == "" {
389 mctx.ModuleErrorf("base property is not set")
390 return
391 }
392 mctx.CreateVariations(apexBundleName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900393 }
Jiyong Park5d790c32019-11-15 18:40:32 +0900394
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900395}
Sundong Ahne9b55722019-09-06 17:37:42 +0900396
Jooyung Han7a78a922019-10-08 21:59:58 +0900397var (
398 apexFileContextsInfosKey = android.NewOnceKey("apexFileContextsInfosKey")
399 apexFileContextsInfosMutex sync.Mutex
400)
401
402func apexFileContextsInfos(config android.Config) *[]string {
403 return config.Once(apexFileContextsInfosKey, func() interface{} {
404 return &[]string{}
405 }).(*[]string)
406}
407
Jooyung Han54aca7b2019-11-20 02:26:02 +0900408func addFlattenedFileContextsInfos(ctx android.BaseModuleContext, fileContextsInfo string) {
Jooyung Han7a78a922019-10-08 21:59:58 +0900409 apexFileContextsInfosMutex.Lock()
410 defer apexFileContextsInfosMutex.Unlock()
411 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
Jooyung Han54aca7b2019-11-20 02:26:02 +0900412 *apexFileContextsInfos = append(*apexFileContextsInfos, fileContextsInfo)
Jooyung Han7a78a922019-10-08 21:59:58 +0900413}
414
Sundong Ahne9b55722019-09-06 17:37:42 +0900415func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
Sundong Ahne8fb7242019-09-17 13:50:45 +0900416 if ab, ok := mctx.Module().(*apexBundle); ok {
Sundong Ahnabb64432019-10-22 13:58:29 +0900417 var variants []string
418 switch proptools.StringDefault(ab.properties.Payload_type, "image") {
419 case "image":
420 variants = append(variants, imageApexType, flattenedApexType)
421 case "zip":
422 variants = append(variants, zipApexType)
423 case "both":
424 variants = append(variants, imageApexType, zipApexType, flattenedApexType)
425 default:
Sundong Ahnd95aa2d2019-10-08 19:34:03 +0900426 mctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type)
Sundong Ahnabb64432019-10-22 13:58:29 +0900427 return
428 }
429
430 modules := mctx.CreateLocalVariations(variants...)
431
432 for i, v := range variants {
433 switch v {
434 case imageApexType:
435 modules[i].(*apexBundle).properties.ApexType = imageApex
436 case zipApexType:
437 modules[i].(*apexBundle).properties.ApexType = zipApex
438 case flattenedApexType:
439 modules[i].(*apexBundle).properties.ApexType = flattenedApex
Jooyung Han91df2082019-11-20 01:49:42 +0900440 if !mctx.Config().FlattenApex() && ab.Platform() {
Sundong Ahnd95aa2d2019-10-08 19:34:03 +0900441 modules[i].(*apexBundle).MakeAsSystemExt()
442 }
Sundong Ahnabb64432019-10-22 13:58:29 +0900443 }
Sundong Ahne9b55722019-09-06 17:37:42 +0900444 }
Jiyong Park5d790c32019-11-15 18:40:32 +0900445 } else if _, ok := mctx.Module().(*OverrideApex); ok {
446 mctx.CreateVariations(imageApexType, flattenedApexType)
Sundong Ahne9b55722019-09-06 17:37:42 +0900447 }
448}
449
Jooyung Han5c998b92019-06-27 11:30:33 +0900450func apexUsesMutator(mctx android.BottomUpMutatorContext) {
451 if ab, ok := mctx.Module().(*apexBundle); ok {
452 mctx.AddFarVariationDependencies(nil, usesTag, ab.properties.Uses...)
453 }
454}
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900455
Jooyung Handc782442019-11-01 03:14:38 +0900456var (
457 useVendorWhitelistKey = android.NewOnceKey("useVendorWhitelist")
458)
459
460// useVendorWhitelist returns the list of APEXes which are allowed to use_vendor.
461// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__,
462// which may cause compatibility issues. (e.g. libbinder)
463// Even though libbinder restricts its availability via 'apex_available' property and relies on
464// yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules
465// to avoid similar problems.
466func useVendorWhitelist(config android.Config) []string {
467 return config.Once(useVendorWhitelistKey, func() interface{} {
468 return []string{
469 // swcodec uses "vendor" variants for smaller size
470 "com.android.media.swcodec",
471 "test_com.android.media.swcodec",
472 }
473 }).([]string)
474}
475
476// setUseVendorWhitelistForTest overrides useVendorWhitelist and must be
477// called before the first call to useVendorWhitelist()
478func setUseVendorWhitelistForTest(config android.Config, whitelist []string) {
479 config.Once(useVendorWhitelistKey, func() interface{} {
480 return whitelist
481 })
482}
483
Alex Light9670d332019-01-29 18:07:33 -0800484type apexNativeDependencies struct {
485 // List of native libraries
486 Native_shared_libs []string
Jooyung Han344d5432019-08-23 11:17:39 +0900487
Alex Light9670d332019-01-29 18:07:33 -0800488 // List of native executables
489 Binaries []string
Jooyung Han344d5432019-08-23 11:17:39 +0900490
Roland Levillain630846d2019-06-26 12:48:34 +0100491 // List of native tests
492 Tests []string
Alex Light9670d332019-01-29 18:07:33 -0800493}
Jooyung Han344d5432019-08-23 11:17:39 +0900494
Alex Light9670d332019-01-29 18:07:33 -0800495type apexMultilibProperties struct {
496 // Native dependencies whose compile_multilib is "first"
497 First apexNativeDependencies
498
499 // Native dependencies whose compile_multilib is "both"
500 Both apexNativeDependencies
501
502 // Native dependencies whose compile_multilib is "prefer32"
503 Prefer32 apexNativeDependencies
504
505 // Native dependencies whose compile_multilib is "32"
506 Lib32 apexNativeDependencies
507
508 // Native dependencies whose compile_multilib is "64"
509 Lib64 apexNativeDependencies
510}
511
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900512type apexBundleProperties struct {
513 // Json manifest file describing meta info of this APEX bundle. Default:
Dario Freni4abb1dc2018-11-20 18:04:58 +0000514 // "apex_manifest.json"
Colin Cross27b922f2019-03-04 22:35:41 -0800515 Manifest *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900516
Jiyong Park40e26a22019-02-08 02:53:06 +0900517 // AndroidManifest.xml file used for the zip container of this APEX bundle.
518 // If unspecified, a default one is automatically generated.
Colin Cross27b922f2019-03-04 22:35:41 -0800519 AndroidManifest *string `android:"path"`
Jiyong Park40e26a22019-02-08 02:53:06 +0900520
Roland Levillain411c5842019-09-19 16:37:20 +0100521 // Canonical name of the APEX bundle. Used to determine the path to the activated APEX on
522 // device (/apex/<apex_name>).
523 // If unspecified, defaults to the value of name.
Jiyong Park05e70dd2019-03-18 14:26:32 +0900524 Apex_name *string
525
Jiyong Parkd0a65ba2018-11-10 06:37:15 +0900526 // Determines the file contexts file for setting security context to each file in this APEX bundle.
Jooyung Han54aca7b2019-11-20 02:26:02 +0900527 // For platform APEXes, this should points to a file under /system/sepolicy
528 // Default: /system/sepolicy/apex/<module_name>_file_contexts.
529 File_contexts *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900530
531 // List of native shared libs that are embedded inside this APEX bundle
532 Native_shared_libs []string
533
Roland Levillain630846d2019-06-26 12:48:34 +0100534 // List of executables that are embedded inside this APEX bundle
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900535 Binaries []string
536
537 // List of java libraries that are embedded inside this APEX bundle
538 Java_libs []string
539
540 // List of prebuilt files that are embedded inside this APEX bundle
541 Prebuilts []string
Jiyong Parkff1458f2018-10-12 21:49:38 +0900542
Roland Levillain630846d2019-06-26 12:48:34 +0100543 // List of tests that are embedded inside this APEX bundle
544 Tests []string
545
Jiyong Parkff1458f2018-10-12 21:49:38 +0900546 // Name of the apex_key module that provides the private key to sign APEX
547 Key *string
Jiyong Park397e55e2018-10-24 21:09:55 +0900548
Alex Light5098a612018-11-29 17:12:15 -0800549 // The type of APEX to build. Controls what the APEX payload is. Either
550 // 'image', 'zip' or 'both'. Default: 'image'.
551 Payload_type *string
552
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900553 // The name of a certificate in the default certificate directory, blank to use the default product certificate,
554 // or an android_app_certificate module name in the form ":module".
555 Certificate *string
556
Jiyong Park92c0f9c2018-12-13 23:14:57 +0900557 // Whether this APEX is installable to one of the partitions. Default: true.
558 Installable *bool
559
Jiyong Parkda6eb592018-12-19 17:12:36 +0900560 // For native libraries and binaries, use the vendor variant instead of the core (platform) variant.
561 // Default is false.
562 Use_vendor *bool
563
Alex Lightfc0bd7c2019-01-29 18:31:59 -0800564 // For telling the apex to ignore special handling for system libraries such as bionic. Default is false.
565 Ignore_system_library_special_case *bool
566
Alex Light9670d332019-01-29 18:07:33 -0800567 Multilib apexMultilibProperties
Jiyong Park235e67c2019-02-09 11:50:56 +0900568
Jiyong Parkf97782b2019-02-13 20:28:58 +0900569 // List of sanitizer names that this APEX is enabled for
570 SanitizerNames []string `blueprint:"mutated"`
Jooyung Han5c998b92019-06-27 11:30:33 +0900571
Jiyong Parkee9a98d2019-08-09 14:44:36 +0900572 PreventInstall bool `blueprint:"mutated"`
573
574 HideFromMake bool `blueprint:"mutated"`
575
Jooyung Han5c998b92019-06-27 11:30:33 +0900576 // Indicates this APEX provides C++ shared libaries to other APEXes. Default: false.
577 Provide_cpp_shared_libs *bool
578
579 // List of providing APEXes' names so that this APEX can depend on provided shared libraries.
580 Uses []string
Nikita Ioffe5d5ae762019-08-31 14:38:05 +0100581
582 // A txt file containing list of files that are whitelisted to be included in this APEX.
583 Whitelisted_files *string
Sundong Ahne1f05aa2019-08-27 13:55:42 +0900584
Sundong Ahnabb64432019-10-22 13:58:29 +0900585 // package format of this apex variant; could be non-flattened, flattened, or zip.
586 // imageApex, zipApex or flattened
587 ApexType apexPackaging `blueprint:"mutated"`
Sundong Ahne8fb7242019-09-17 13:50:45 +0900588
Jiyong Parkd1063c12019-07-17 20:08:41 +0900589 // List of SDKs that are used to build this APEX. A reference to an SDK should be either
590 // `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current`
591 // is implied. This value affects all modules included in this APEX. In other words, they are
592 // also built with the SDKs specified here.
593 Uses_sdks []string
Jiyong Park5d790c32019-11-15 18:40:32 +0900594
Nikita Ioffec72b5dd2019-12-07 17:30:22 +0000595 // Whenever apex_payload.img of the APEX should include dm-verity hashtree.
596 // Should be only used in tests#.
597 Test_only_no_hashtree *bool
Jooyung Han214bf372019-11-12 13:03:50 +0900598
599 // Whether this APEX should support Android10. Default is false. If this is set true, then apex_manifest.json is bundled as well
600 // because Android10 requires legacy apex_manifest.json instead of apex_manifest.pb
601 Legacy_android10_support *bool
Jiyong Park956305c2020-01-09 12:32:06 +0900602
603 IsCoverageVariant bool `blueprint:"mutated"`
Alex Light9670d332019-01-29 18:07:33 -0800604}
605
606type apexTargetBundleProperties struct {
607 Target struct {
608 // Multilib properties only for android.
609 Android struct {
610 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +0900611 }
Jooyung Han344d5432019-08-23 11:17:39 +0900612
Alex Light9670d332019-01-29 18:07:33 -0800613 // Multilib properties only for host.
614 Host struct {
615 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +0900616 }
Jooyung Han344d5432019-08-23 11:17:39 +0900617
Alex Light9670d332019-01-29 18:07:33 -0800618 // Multilib properties only for host linux_bionic.
619 Linux_bionic struct {
620 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +0900621 }
Jooyung Han344d5432019-08-23 11:17:39 +0900622
Alex Light9670d332019-01-29 18:07:33 -0800623 // Multilib properties only for host linux_glibc.
624 Linux_glibc struct {
625 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +0900626 }
627 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900628}
629
Jiyong Park5d790c32019-11-15 18:40:32 +0900630type overridableProperties struct {
631 // List of APKs to package inside APEX
632 Apps []string
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -0800633
634 // Names of modules to be overridden. Listed modules can only be other binaries
635 // (in Make or Soong).
636 // This does not completely prevent installation of the overridden binaries, but if both
637 // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
638 // from PRODUCT_PACKAGES.
639 Overrides []string
Jiyong Park5d790c32019-11-15 18:40:32 +0900640}
641
Alex Light5098a612018-11-29 17:12:15 -0800642type apexPackaging int
643
644const (
645 imageApex apexPackaging = iota
646 zipApex
Sundong Ahnabb64432019-10-22 13:58:29 +0900647 flattenedApex
Alex Light5098a612018-11-29 17:12:15 -0800648)
649
Sundong Ahnabb64432019-10-22 13:58:29 +0900650// The suffix for the output "file", not the module
Alex Light5098a612018-11-29 17:12:15 -0800651func (a apexPackaging) suffix() string {
652 switch a {
653 case imageApex:
654 return imageApexSuffix
655 case zipApex:
656 return zipApexSuffix
Alex Light5098a612018-11-29 17:12:15 -0800657 default:
Roland Levillain4644b222019-07-31 14:09:17 +0100658 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -0800659 }
660}
661
662func (a apexPackaging) name() string {
663 switch a {
664 case imageApex:
665 return imageApexType
666 case zipApex:
667 return zipApexType
Alex Light5098a612018-11-29 17:12:15 -0800668 default:
Roland Levillain4644b222019-07-31 14:09:17 +0100669 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -0800670 }
671}
672
Jiyong Parkf653b052019-11-18 15:39:01 +0900673type apexFileClass int
674
675const (
676 etc apexFileClass = iota
677 nativeSharedLib
678 nativeExecutable
679 shBinary
680 pyBinary
681 goBinary
682 javaSharedLib
683 nativeTest
684 app
685)
686
Jiyong Park8fd61922018-11-08 02:50:25 +0900687func (class apexFileClass) NameInMake() string {
688 switch class {
689 case etc:
690 return "ETC"
691 case nativeSharedLib:
692 return "SHARED_LIBRARIES"
Alex Light778127a2019-02-27 14:19:50 -0800693 case nativeExecutable, shBinary, pyBinary, goBinary:
Jiyong Park8fd61922018-11-08 02:50:25 +0900694 return "EXECUTABLES"
695 case javaSharedLib:
696 return "JAVA_LIBRARIES"
Roland Levillain630846d2019-06-26 12:48:34 +0100697 case nativeTest:
698 return "NATIVE_TESTS"
Sundong Ahne1f05aa2019-08-27 13:55:42 +0900699 case app:
Jiyong Parkf383f7c2019-10-11 20:46:25 +0900700 // b/142537672 Why isn't this APP? We want to have full control over
701 // the paths and file names of the apk file under the flattend APEX.
702 // If this is set to APP, then the paths and file names are modified
703 // by the Make build system. For example, it is installed to
704 // /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of
705 // /system/apex/<apexname>/app/<Appname> because the build system automatically
706 // appends module name (which is <apexname>.<Appname> to the path.
707 return "ETC"
Jiyong Park8fd61922018-11-08 02:50:25 +0900708 default:
Roland Levillain4644b222019-07-31 14:09:17 +0100709 panic(fmt.Errorf("unknown class %d", class))
Jiyong Park8fd61922018-11-08 02:50:25 +0900710 }
711}
712
Jiyong Parkf653b052019-11-18 15:39:01 +0900713// apexFile represents a file in an APEX bundle
Jiyong Park8fd61922018-11-08 02:50:25 +0900714type apexFile struct {
715 builtFile android.Path
716 moduleName string
Jiyong Park8fd61922018-11-08 02:50:25 +0900717 installDir string
718 class apexFileClass
Jiyong Parka8894842018-12-19 17:36:39 +0900719 module android.Module
Jiyong Parkf653b052019-11-18 15:39:01 +0900720 // list of symlinks that will be created in installDir that point to this apexFile
721 symlinks []string
722 transitiveDep bool
Jiyong Park1833cef2019-12-13 13:28:36 +0900723 moduleDir string
Jiyong Park7afd1072019-12-30 16:56:33 +0900724
725 requiredModuleNames []string
726 targetRequiredModuleNames []string
727 hostRequiredModuleNames []string
Jiyong Park618922e2020-01-08 13:35:43 +0900728
729 jacocoReportClassesFile android.Path // only for javalibs and apps
Jiyong Parkf653b052019-11-18 15:39:01 +0900730}
731
Jiyong Park1833cef2019-12-13 13:28:36 +0900732func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile {
733 ret := apexFile{
Jiyong Parkf653b052019-11-18 15:39:01 +0900734 builtFile: builtFile,
735 moduleName: moduleName,
736 installDir: installDir,
737 class: class,
738 module: module,
739 }
Jiyong Park1833cef2019-12-13 13:28:36 +0900740 if module != nil {
741 ret.moduleDir = ctx.OtherModuleDir(module)
Jiyong Park7afd1072019-12-30 16:56:33 +0900742 ret.requiredModuleNames = module.RequiredModuleNames()
743 ret.targetRequiredModuleNames = module.TargetRequiredModuleNames()
744 ret.hostRequiredModuleNames = module.HostRequiredModuleNames()
Jiyong Park1833cef2019-12-13 13:28:36 +0900745 }
746 return ret
Jiyong Parkf653b052019-11-18 15:39:01 +0900747}
748
749func (af *apexFile) Ok() bool {
Jiyong Park479321d2019-12-16 11:47:12 +0900750 return af.builtFile != nil && af.builtFile.String() != ""
Jiyong Park8fd61922018-11-08 02:50:25 +0900751}
752
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900753type apexBundle struct {
754 android.ModuleBase
755 android.DefaultableModuleBase
Jiyong Park5d790c32019-11-15 18:40:32 +0900756 android.OverridableModuleBase
Jiyong Parkd1063c12019-07-17 20:08:41 +0900757 android.SdkBase
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900758
Jiyong Park5d790c32019-11-15 18:40:32 +0900759 properties apexBundleProperties
760 targetProperties apexTargetBundleProperties
Jiyong Park5d790c32019-11-15 18:40:32 +0900761 overridableProperties overridableProperties
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900762
Jooyung Hanf21c7972019-12-16 22:32:06 +0900763 // specific to apex_vndk modules
764 vndkProperties apexVndkProperties
765
Colin Crossa4925902018-11-16 11:36:28 -0800766 bundleModuleFile android.WritablePath
Sundong Ahnabb64432019-10-22 13:58:29 +0900767 outputFile android.WritablePath
Colin Cross70dda7e2019-10-01 22:05:35 -0700768 installDir android.InstallPath
Jiyong Park8fd61922018-11-08 02:50:25 +0900769
Jiyong Park03b68dd2019-07-26 23:20:40 +0900770 prebuiltFileToDelete string
771
Jiyong Park42cca6c2019-04-01 11:15:50 +0900772 public_key_file android.Path
773 private_key_file android.Path
Jiyong Park0ca3ce82019-02-18 15:25:04 +0900774
775 container_certificate_file android.Path
776 container_private_key_file android.Path
777
Jooyung Han54aca7b2019-11-20 02:26:02 +0900778 fileContexts android.Path
779
Jiyong Park8fd61922018-11-08 02:50:25 +0900780 // list of files to be included in this apex
781 filesInfo []apexFile
782
Jiyong Park956305c2020-01-09 12:32:06 +0900783 // list of module names that should be installed along with this APEX
784 requiredDeps []string
785
786 // list of module names that this APEX is depending on (to be shown via *-deps-info target)
Jiyong Parkac2bacd2019-02-20 21:49:26 +0900787 externalDeps []string
Jiyong Park956305c2020-01-09 12:32:06 +0900788 // list of module names that this APEX is including (to be shown via *-deps-info target)
789 internalDeps []string
Jiyong Parkac2bacd2019-02-20 21:49:26 +0900790
Sundong Ahnabb64432019-10-22 13:58:29 +0900791 testApex bool
792 vndkApex bool
Ulyana Trafimovichde534412019-11-08 10:51:01 +0000793 artApex bool
Sundong Ahnabb64432019-10-22 13:58:29 +0900794 primaryApexType bool
Jooyung Hane1633032019-08-01 17:41:43 +0900795
Jooyung Han214bf372019-11-12 13:03:50 +0900796 manifestJsonOut android.WritablePath
797 manifestPbOut android.WritablePath
Jooyung Han72bd2f82019-10-23 16:46:38 +0900798
Jooyung Han002ab682020-01-08 01:57:58 +0900799 // list of commands to create symlinks for backward compatibility.
Jooyung Han72bd2f82019-10-23 16:46:38 +0900800 // these commands will be attached as LOCAL_POST_INSTALL_CMD to
Jooyung Han002ab682020-01-08 01:57:58 +0900801 // apex package itself(for unflattened build) or apex_manifest(for flattened build)
Jooyung Han72bd2f82019-10-23 16:46:38 +0900802 // so that compat symlinks are always installed regardless of TARGET_FLATTEN_APEX setting.
803 compatSymlinks []string
Sundong Ahnabb64432019-10-22 13:58:29 +0900804
805 // Suffix of module name in Android.mk
806 // ".flattened", ".apex", ".zipapex", or ""
807 suffix string
Jiyong Park3a1602e2020-01-14 14:39:19 +0900808
809 installedFilesFile android.WritablePath
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900810}
811
Jiyong Park397e55e2018-10-24 21:09:55 +0900812func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
Roland Levillain630846d2019-06-26 12:48:34 +0100813 native_shared_libs []string, binaries []string, tests []string,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700814 target android.Target, imageVariation string) {
Jiyong Park397e55e2018-10-24 21:09:55 +0900815 // Use *FarVariation* to be able to depend on modules having
816 // conflicting variations with this module. This is required since
817 // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64'
818 // for native shared libs.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700819 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Parkda6eb592018-12-19 17:12:36 +0900820 {Mutator: "image", Variation: imageVariation},
Jiyong Park397e55e2018-10-24 21:09:55 +0900821 {Mutator: "link", Variation: "shared"},
Jiyong Park28d395a2018-12-07 22:42:47 +0900822 {Mutator: "version", Variation: ""}, // "" is the non-stub variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700823 }...), sharedLibTag, native_shared_libs...)
Jiyong Park397e55e2018-10-24 21:09:55 +0900824
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700825 ctx.AddFarVariationDependencies(append(target.Variations(),
826 blueprint.Variation{Mutator: "image", Variation: imageVariation}),
827 executableTag, binaries...)
Roland Levillain630846d2019-06-26 12:48:34 +0100828
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700829 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +0100830 {Mutator: "image", Variation: imageVariation},
Roland Levillain9b5fde92019-06-28 15:41:19 +0100831 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700832 }...), testTag, tests...)
Jiyong Park397e55e2018-10-24 21:09:55 +0900833}
834
Alex Light9670d332019-01-29 18:07:33 -0800835func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
836 if ctx.Os().Class == android.Device {
837 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil)
838 } else {
839 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil)
840 if ctx.Os().Bionic() {
841 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil)
842 } else {
843 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil)
844 }
845 }
846}
847
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900848func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
Jooyung Handc782442019-11-01 03:14:38 +0900849 if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorWhitelist(ctx.Config())) {
850 ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
851 }
852
Jiyong Park397e55e2018-10-24 21:09:55 +0900853 targets := ctx.MultiTargets()
Jiyong Park7c1dc612019-01-05 11:15:24 +0900854 config := ctx.DeviceConfig()
Alex Light9670d332019-01-29 18:07:33 -0800855
856 a.combineProperties(ctx)
857
Jiyong Park397e55e2018-10-24 21:09:55 +0900858 has32BitTarget := false
859 for _, target := range targets {
860 if target.Arch.ArchType.Multilib == "lib32" {
861 has32BitTarget = true
862 }
863 }
864 for i, target := range targets {
865 // When multilib.* is omitted for native_shared_libs, it implies
866 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700867 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Park7c1dc612019-01-05 11:15:24 +0900868 {Mutator: "image", Variation: a.getImageVariation(config)},
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900869 {Mutator: "link", Variation: "shared"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700870 }...), sharedLibTag, a.properties.Native_shared_libs...)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900871
Roland Levillain630846d2019-06-26 12:48:34 +0100872 // When multilib.* is omitted for tests, it implies
873 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700874 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +0100875 {Mutator: "image", Variation: a.getImageVariation(config)},
Roland Levillain9b5fde92019-06-28 15:41:19 +0100876 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700877 }...), testTag, a.properties.Tests...)
Roland Levillain630846d2019-06-26 12:48:34 +0100878
Jiyong Park397e55e2018-10-24 21:09:55 +0900879 // Add native modules targetting both ABIs
880 addDependenciesForNativeModules(ctx,
881 a.properties.Multilib.Both.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100882 a.properties.Multilib.Both.Binaries,
883 a.properties.Multilib.Both.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700884 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900885 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900886
Alex Light3d673592019-01-18 14:37:31 -0800887 isPrimaryAbi := i == 0
888 if isPrimaryAbi {
Jiyong Park397e55e2018-10-24 21:09:55 +0900889 // When multilib.* is omitted for binaries, it implies
890 // multilib.first.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700891 ctx.AddFarVariationDependencies(append(target.Variations(),
892 blueprint.Variation{Mutator: "image", Variation: a.getImageVariation(config)}),
893 executableTag, a.properties.Binaries...)
Jiyong Park397e55e2018-10-24 21:09:55 +0900894
895 // Add native modules targetting the first ABI
896 addDependenciesForNativeModules(ctx,
897 a.properties.Multilib.First.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100898 a.properties.Multilib.First.Binaries,
899 a.properties.Multilib.First.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700900 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900901 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900902 }
903
904 switch target.Arch.ArchType.Multilib {
905 case "lib32":
906 // Add native modules targetting 32-bit ABI
907 addDependenciesForNativeModules(ctx,
908 a.properties.Multilib.Lib32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100909 a.properties.Multilib.Lib32.Binaries,
910 a.properties.Multilib.Lib32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700911 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900912 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900913
914 addDependenciesForNativeModules(ctx,
915 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100916 a.properties.Multilib.Prefer32.Binaries,
917 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700918 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900919 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900920 case "lib64":
921 // Add native modules targetting 64-bit ABI
922 addDependenciesForNativeModules(ctx,
923 a.properties.Multilib.Lib64.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100924 a.properties.Multilib.Lib64.Binaries,
925 a.properties.Multilib.Lib64.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700926 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900927 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900928
929 if !has32BitTarget {
930 addDependenciesForNativeModules(ctx,
931 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100932 a.properties.Multilib.Prefer32.Binaries,
933 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700934 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900935 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900936 }
Peter Collingbourne3478bb22019-04-24 14:41:12 -0700937
938 if strings.HasPrefix(ctx.ModuleName(), "com.android.runtime") && target.Os.Class == android.Device {
939 for _, sanitizer := range ctx.Config().SanitizeDevice() {
940 if sanitizer == "hwaddress" {
941 addDependenciesForNativeModules(ctx,
942 []string{"libclang_rt.hwasan-aarch64-android"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700943 nil, nil, target, a.getImageVariation(config))
Peter Collingbourne3478bb22019-04-24 14:41:12 -0700944 break
945 }
946 }
947 }
Jiyong Park397e55e2018-10-24 21:09:55 +0900948 }
949
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900950 }
951
Jiyong Parkce6aadc2019-11-20 13:58:28 +0900952 // For prebuilt_etc, use the first variant (64 on 64/32bit device,
953 // 32 on 32bit device) regardless of the TARGET_PREFER_* setting.
954 // b/144532908
955 archForPrebuiltEtc := config.Arches()[0]
956 for _, arch := range config.Arches() {
957 // Prefer 64-bit arch if there is any
958 if arch.ArchType.Multilib == "lib64" {
959 archForPrebuiltEtc = arch
960 break
961 }
962 }
963 ctx.AddFarVariationDependencies([]blueprint.Variation{
964 {Mutator: "os", Variation: ctx.Os().String()},
965 {Mutator: "arch", Variation: archForPrebuiltEtc.String()},
966 }, prebuiltTag, a.properties.Prebuilts...)
967
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700968 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
969 javaLibTag, a.properties.Java_libs...)
Jiyong Parkff1458f2018-10-12 21:49:38 +0900970
Ulya Trafimovich44561882020-01-03 13:25:54 +0000971 // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
972 if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
973 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
974 javaLibTag, "jacocoagent")
975 }
976
Jiyong Park23c52b02019-02-02 13:13:47 +0900977 if String(a.properties.Key) == "" {
978 ctx.ModuleErrorf("key is missing")
979 return
980 }
981 ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key))
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900982
Jiyong Parkb2742fd2019-02-11 11:38:15 +0900983 cert := android.SrcIsModule(a.getCertString(ctx))
Jiyong Park23c52b02019-02-02 13:13:47 +0900984 if cert != "" {
985 ctx.AddDependency(ctx.Module(), certificateTag, cert)
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900986 }
Jiyong Parkd1063c12019-07-17 20:08:41 +0900987
988 // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks
989 if len(a.properties.Uses_sdks) > 0 {
990 sdkRefs := []android.SdkRef{}
991 for _, str := range a.properties.Uses_sdks {
992 parsed := android.ParseSdkRef(ctx, str, "uses_sdks")
993 sdkRefs = append(sdkRefs, parsed)
994 }
995 a.BuildWithSdks(sdkRefs)
996 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900997}
998
Jiyong Park5d790c32019-11-15 18:40:32 +0900999func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
1000 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1001 androidAppTag, a.overridableProperties.Apps...)
1002}
1003
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09001004func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
1005 // direct deps of an APEX bundle are all part of the APEX bundle
1006 return true
1007}
1008
Colin Cross0ea8ba82019-06-06 14:33:29 -07001009func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
Jooyung Han27151d92019-12-16 17:45:32 +09001010 moduleName := ctx.ModuleName()
1011 // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the OVERRIDE_* list,
1012 // we check with the pseudo module name to see if its certificate is overridden.
1013 if a.vndkApex {
1014 moduleName = vndkApexName
1015 }
1016 certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName)
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001017 if overridden {
Jaewoong Jungacb6db32019-02-28 16:22:30 +00001018 return ":" + certificate
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001019 }
1020 return String(a.properties.Certificate)
1021}
1022
Colin Cross41955e82019-05-29 14:40:35 -07001023func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
1024 switch tag {
1025 case "":
Sundong Ahnabb64432019-10-22 13:58:29 +09001026 return android.Paths{a.outputFile}, nil
Colin Cross41955e82019-05-29 14:40:35 -07001027 default:
1028 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
Jiyong Park5a832022018-12-20 09:54:35 +09001029 }
Jiyong Park74e240b2018-11-27 21:27:08 +09001030}
1031
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001032func (a *apexBundle) installable() bool {
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001033 return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001034}
1035
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001036func (a *apexBundle) testOnlyShouldSkipHashtreeGeneration() bool {
1037 return proptools.Bool(a.properties.Test_only_no_hashtree)
1038}
1039
Jiyong Park7c1dc612019-01-05 11:15:24 +09001040func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
Jooyung Han31c470b2019-10-18 16:26:59 +09001041 if a.vndkApex {
Colin Cross7228ecd2019-11-18 16:00:16 -08001042 return cc.VendorVariationPrefix + a.vndkVersion(config)
Jooyung Han31c470b2019-10-18 16:26:59 +09001043 }
Jiyong Park7c1dc612019-01-05 11:15:24 +09001044 if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) {
Colin Cross7228ecd2019-11-18 16:00:16 -08001045 return cc.VendorVariationPrefix + config.PlatformVndkVersion()
Jiyong Parkda6eb592018-12-19 17:12:36 +09001046 } else {
Colin Cross7228ecd2019-11-18 16:00:16 -08001047 return android.CoreVariation
Jiyong Parkda6eb592018-12-19 17:12:36 +09001048 }
1049}
1050
Jiyong Parkf97782b2019-02-13 20:28:58 +09001051func (a *apexBundle) EnableSanitizer(sanitizerName string) {
1052 if !android.InList(sanitizerName, a.properties.SanitizerNames) {
1053 a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName)
1054 }
1055}
1056
Jiyong Park388ef3f2019-01-28 19:47:32 +09001057func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
Jiyong Parkf97782b2019-02-13 20:28:58 +09001058 if android.InList(sanitizerName, a.properties.SanitizerNames) {
1059 return true
Jiyong Park235e67c2019-02-09 11:50:56 +09001060 }
1061
1062 // Then follow the global setting
Jiyong Park388ef3f2019-01-28 19:47:32 +09001063 globalSanitizerNames := []string{}
1064 if a.Host() {
1065 globalSanitizerNames = ctx.Config().SanitizeHost()
1066 } else {
1067 arches := ctx.Config().SanitizeDeviceArch()
1068 if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
1069 globalSanitizerNames = ctx.Config().SanitizeDevice()
1070 }
1071 }
1072 return android.InList(sanitizerName, globalSanitizerNames)
Jiyong Park379de2f2018-12-19 02:47:14 +09001073}
1074
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001075func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
1076 return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
1077}
1078
1079func (a *apexBundle) PreventInstall() {
1080 a.properties.PreventInstall = true
1081}
1082
1083func (a *apexBundle) HideFromMake() {
1084 a.properties.HideFromMake = true
1085}
1086
Jiyong Park956305c2020-01-09 12:32:06 +09001087func (a *apexBundle) MarkAsCoverageVariant(coverage bool) {
1088 a.properties.IsCoverageVariant = coverage
1089}
1090
Jiyong Parkf653b052019-11-18 15:39:01 +09001091// TODO(jiyong) move apexFileFor* close to the apexFile type definition
Jiyong Park1833cef2019-12-13 13:28:36 +09001092func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001093 // Decide the APEX-local directory by the multilib of the library
1094 // In the future, we may query this to the module.
Jiyong Parkf653b052019-11-18 15:39:01 +09001095 var dirInApex string
Martin Stjernholm279de572019-09-10 23:18:20 +01001096 switch ccMod.Arch().ArchType.Multilib {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001097 case "lib32":
1098 dirInApex = "lib"
1099 case "lib64":
1100 dirInApex = "lib64"
1101 }
Martin Stjernholm279de572019-09-10 23:18:20 +01001102 dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001103 if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
Martin Stjernholm279de572019-09-10 23:18:20 +01001104 dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001105 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001106 if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) {
Martin Stjernholm279de572019-09-10 23:18:20 +01001107 // Special case for Bionic libs and other libs installed with them. This is
1108 // to prevent those libs from being included in the search path
1109 // /apex/com.android.runtime/${LIB}. This exclusion is required because
1110 // those libs in the Runtime APEX are available via the legacy paths in
1111 // /system/lib/. By the init process, the libs in the APEX are bind-mounted
1112 // to the legacy paths and thus will be loaded into the default linker
1113 // namespace (aka "platform" namespace). If the libs are directly in
1114 // /apex/com.android.runtime/${LIB} then the same libs will be loaded again
1115 // into the runtime linker namespace, which will result in double loading of
1116 // them, which isn't supported.
1117 dirInApex = filepath.Join(dirInApex, "bionic")
Jiyong Parkb0788572018-12-20 22:10:17 +09001118 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001119
Jiyong Parkf653b052019-11-18 15:39:01 +09001120 fileToCopy := ccMod.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001121 return newApexFile(ctx, fileToCopy, ccMod.Name(), dirInApex, nativeSharedLib, ccMod)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001122}
1123
Jiyong Park1833cef2019-12-13 13:28:36 +09001124func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001125 dirInApex := filepath.Join("bin", cc.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001126 if cc.Target().NativeBridge == android.NativeBridgeEnabled {
dimitry8d6dde82019-07-11 10:23:53 +02001127 dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
Jiyong Parkacbf6c72019-07-09 16:19:16 +09001128 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001129 fileToCopy := cc.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001130 af := newApexFile(ctx, fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc)
Jiyong Parkf653b052019-11-18 15:39:01 +09001131 af.symlinks = cc.Symlinks()
1132 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001133}
1134
Jiyong Park1833cef2019-12-13 13:28:36 +09001135func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001136 dirInApex := "bin"
1137 fileToCopy := py.HostToolPath().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001138 return newApexFile(ctx, fileToCopy, py.Name(), dirInApex, pyBinary, py)
Alex Light778127a2019-02-27 14:19:50 -08001139}
Jiyong Park1833cef2019-12-13 13:28:36 +09001140func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001141 dirInApex := "bin"
Alex Light778127a2019-02-27 14:19:50 -08001142 s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
1143 if err != nil {
1144 ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001145 return apexFile{}
Alex Light778127a2019-02-27 14:19:50 -08001146 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001147 fileToCopy := android.PathForOutput(ctx, s)
1148 // NB: Since go binaries are static we don't need the module for anything here, which is
1149 // good since the go tool is a blueprint.Module not an android.Module like we would
1150 // normally use.
Jiyong Park1833cef2019-12-13 13:28:36 +09001151 return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil)
Alex Light778127a2019-02-27 14:19:50 -08001152}
1153
Jiyong Park1833cef2019-12-13 13:28:36 +09001154func apexFileForShBinary(ctx android.BaseModuleContext, sh *android.ShBinary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001155 dirInApex := filepath.Join("bin", sh.SubDir())
1156 fileToCopy := sh.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001157 af := newApexFile(ctx, fileToCopy, sh.Name(), dirInApex, shBinary, sh)
Jiyong Parkf653b052019-11-18 15:39:01 +09001158 af.symlinks = sh.Symlinks()
1159 return af
Jiyong Park04480cf2019-02-06 00:16:29 +09001160}
1161
Jooyung Han58f26ab2019-12-18 15:34:32 +09001162// TODO(b/146586360): replace javaLibrary(in apex/apex.go) with java.Dependency
1163type javaLibrary interface {
1164 android.Module
1165 java.Dependency
1166}
1167
1168func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaLibrary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001169 dirInApex := "javalib"
Jooyung Han58f26ab2019-12-18 15:34:32 +09001170 fileToCopy := lib.DexJar()
Jiyong Park618922e2020-01-08 13:35:43 +09001171 af := newApexFile(ctx, fileToCopy, lib.Name(), dirInApex, javaSharedLib, lib)
1172 af.jacocoReportClassesFile = lib.JacocoReportClassesFile()
1173 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001174}
1175
Jiyong Park1833cef2019-12-13 13:28:36 +09001176func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt android.PrebuiltEtcModule, depName string) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001177 dirInApex := filepath.Join("etc", prebuilt.SubDir())
1178 fileToCopy := prebuilt.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001179 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001180}
1181
Jiyong Park1833cef2019-12-13 13:28:36 +09001182func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
Jiyong Parkf653b052019-11-18 15:39:01 +09001183 android.Module
1184 Privileged() bool
1185 OutputFile() android.Path
Jiyong Park618922e2020-01-08 13:35:43 +09001186 JacocoReportClassesFile() android.Path
Jiyong Parkf653b052019-11-18 15:39:01 +09001187}, pkgName string) apexFile {
Jiyong Parkf7487312019-10-17 12:54:30 +09001188 appDir := "app"
Jiyong Parkf653b052019-11-18 15:39:01 +09001189 if aapp.Privileged() {
Jiyong Parkf7487312019-10-17 12:54:30 +09001190 appDir = "priv-app"
1191 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001192 dirInApex := filepath.Join(appDir, pkgName)
1193 fileToCopy := aapp.OutputFile()
Jiyong Park618922e2020-01-08 13:35:43 +09001194 af := newApexFile(ctx, fileToCopy, aapp.Name(), dirInApex, app, aapp)
1195 af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
1196 return af
Dario Frenicde2a032019-10-27 00:29:22 +01001197}
1198
Roland Levillain935639d2019-08-13 14:55:28 +01001199// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
1200type flattenedApexContext struct {
1201 android.ModuleContext
1202}
1203
1204func (c *flattenedApexContext) InstallBypassMake() bool {
1205 return true
1206}
1207
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001208func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Sundong Ahnabb64432019-10-22 13:58:29 +09001209 buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
1210 switch a.properties.ApexType {
1211 case imageApex:
1212 if buildFlattenedAsDefault {
1213 a.suffix = imageApexSuffix
1214 } else {
1215 a.suffix = ""
1216 a.primaryApexType = true
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09001217
1218 if ctx.Config().InstallExtraFlattenedApexes() {
Jiyong Park956305c2020-01-09 12:32:06 +09001219 a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix)
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09001220 }
Sundong Ahnabb64432019-10-22 13:58:29 +09001221 }
1222 case zipApex:
1223 if proptools.String(a.properties.Payload_type) == "zip" {
1224 a.suffix = ""
1225 a.primaryApexType = true
1226 } else {
1227 a.suffix = zipApexSuffix
1228 }
1229 case flattenedApex:
1230 if buildFlattenedAsDefault {
1231 a.suffix = ""
1232 a.primaryApexType = true
1233 } else {
1234 a.suffix = flattenedSuffix
1235 }
Alex Light5098a612018-11-29 17:12:15 -08001236 }
1237
Roland Levillain630846d2019-06-26 12:48:34 +01001238 if len(a.properties.Tests) > 0 && !a.testApex {
1239 ctx.PropertyErrorf("tests", "property not allowed in apex module type")
1240 return
1241 }
1242
Alex Lightfc0bd7c2019-01-29 18:31:59 -08001243 handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
1244
Jooyung Hane1633032019-08-01 17:41:43 +09001245 // native lib dependencies
1246 var provideNativeLibs []string
1247 var requireNativeLibs []string
1248
Jooyung Han5c998b92019-06-27 11:30:33 +09001249 // Check if "uses" requirements are met with dependent apexBundles
1250 var providedNativeSharedLibs []string
1251 useVendor := proptools.Bool(a.properties.Use_vendor)
1252 ctx.VisitDirectDepsBlueprint(func(m blueprint.Module) {
1253 if ctx.OtherModuleDependencyTag(m) != usesTag {
1254 return
1255 }
1256 otherName := ctx.OtherModuleName(m)
1257 other, ok := m.(*apexBundle)
1258 if !ok {
1259 ctx.PropertyErrorf("uses", "%q is not a provider", otherName)
1260 return
1261 }
1262 if proptools.Bool(other.properties.Use_vendor) != useVendor {
1263 ctx.PropertyErrorf("use_vendor", "%q has different value of use_vendor", otherName)
1264 return
1265 }
1266 if !proptools.Bool(other.properties.Provide_cpp_shared_libs) {
1267 ctx.PropertyErrorf("uses", "%q does not provide native_shared_libs", otherName)
1268 return
1269 }
1270 providedNativeSharedLibs = append(providedNativeSharedLibs, other.properties.Native_shared_libs...)
1271 })
1272
Jiyong Parkf653b052019-11-18 15:39:01 +09001273 var filesInfo []apexFile
Alex Light778127a2019-02-27 14:19:50 -08001274 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
Roland Levillainf89cd092019-07-29 16:22:59 +01001275 depTag := ctx.OtherModuleDependencyTag(child)
1276 depName := ctx.OtherModuleName(child)
Jiyong Parkf653b052019-11-18 15:39:01 +09001277 if _, isDirectDep := parent.(*apexBundle); isDirectDep {
Jiyong Park956305c2020-01-09 12:32:06 +09001278 if depTag != keyTag && depTag != certificateTag {
1279 a.internalDeps = append(a.internalDeps, depName)
1280 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001281 switch depTag {
1282 case sharedLibTag:
1283 if cc, ok := child.(*cc.Module); ok {
Jooyung Hane1633032019-08-01 17:41:43 +09001284 if cc.HasStubsVariants() {
1285 provideNativeLibs = append(provideNativeLibs, cc.OutputFile().Path().Base())
1286 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001287 filesInfo = append(filesInfo, apexFileForNativeLibrary(ctx, cc, handleSpecialLibs))
Jiyong Parkf653b052019-11-18 15:39:01 +09001288 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09001289 } else {
1290 ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001291 }
1292 case executableTag:
1293 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001294 filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
Jiyong Parkf653b052019-11-18 15:39:01 +09001295 return true // track transitive dependencies
Jiyong Park04480cf2019-02-06 00:16:29 +09001296 } else if sh, ok := child.(*android.ShBinary); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001297 filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
Alex Light778127a2019-02-27 14:19:50 -08001298 } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
Jiyong Park1833cef2019-12-13 13:28:36 +09001299 filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
Alex Light778127a2019-02-27 14:19:50 -08001300 } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
Jiyong Parkf653b052019-11-18 15:39:01 +09001301 filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb))
Jiyong Parkff1458f2018-10-12 21:49:38 +09001302 } else {
Alex Light778127a2019-02-27 14:19:50 -08001303 ctx.PropertyErrorf("binaries", "%q is neither cc_binary, (embedded) py_binary, (host) blueprint_go_binary, (host) bootstrap_go_binary, nor sh_binary", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001304 }
1305 case javaLibTag:
Jiyong Park9e6c2422019-08-09 20:39:45 +09001306 if javaLib, ok := child.(*java.Library); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001307 af := apexFileForJavaLibrary(ctx, javaLib)
Jiyong Parkf653b052019-11-18 15:39:01 +09001308 if !af.Ok() {
Jiyong Park8fd61922018-11-08 02:50:25 +09001309 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
1310 } else {
Jiyong Parkf653b052019-11-18 15:39:01 +09001311 filesInfo = append(filesInfo, af)
1312 return true // track transitive dependencies
Jiyong Park9e6c2422019-08-09 20:39:45 +09001313 }
Jooyung Han58f26ab2019-12-18 15:34:32 +09001314 } else if sdkLib, ok := child.(*java.SdkLibrary); ok {
1315 af := apexFileForJavaLibrary(ctx, sdkLib)
1316 if !af.Ok() {
1317 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
1318 return false
1319 }
1320 filesInfo = append(filesInfo, af)
1321
Jooyung Han624058e2019-12-24 18:38:06 +09001322 pf, _ := sdkLib.OutputFiles(".xml")
1323 if len(pf) != 1 {
Jooyung Han58f26ab2019-12-18 15:34:32 +09001324 ctx.PropertyErrorf("java_libs", "%q failed to generate permission XML", depName)
1325 return false
1326 }
Jooyung Han624058e2019-12-24 18:38:06 +09001327 filesInfo = append(filesInfo, newApexFile(ctx, pf[0], pf[0].Base(), "etc/permissions", etc, nil))
Jooyung Han58f26ab2019-12-18 15:34:32 +09001328 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09001329 } else {
Jiyong Park9e6c2422019-08-09 20:39:45 +09001330 ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001331 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001332 case androidAppTag:
1333 pkgName := ctx.DeviceConfig().OverridePackageNameFor(depName)
1334 if ap, ok := child.(*java.AndroidApp); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001335 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09001336 return true // track transitive dependencies
1337 } else if ap, ok := child.(*java.AndroidAppImport); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001338 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Dario Freni6f3937c2019-12-20 22:58:03 +00001339 } else if ap, ok := child.(*java.AndroidTestHelperApp); ok {
1340 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09001341 } else {
1342 ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
1343 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001344 case prebuiltTag:
Jooyung Han39edb6c2019-11-06 16:53:07 +09001345 if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001346 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
Jiyong Parkff1458f2018-10-12 21:49:38 +09001347 } else {
1348 ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName)
1349 }
Roland Levillain630846d2019-06-26 12:48:34 +01001350 case testTag:
Roland Levillainf89cd092019-07-29 16:22:59 +01001351 if ccTest, ok := child.(*cc.Module); ok {
1352 if ccTest.IsTestPerSrcAllTestsVariation() {
1353 // Multiple-output test module (where `test_per_src: true`).
1354 //
1355 // `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
1356 // We do not add this variation to `filesInfo`, as it has no output;
1357 // however, we do add the other variations of this module as indirect
1358 // dependencies (see below).
1359 return true
Roland Levillain9b5fde92019-06-28 15:41:19 +01001360 } else {
Roland Levillainf89cd092019-07-29 16:22:59 +01001361 // Single-output test module (where `test_per_src: false`).
Jiyong Park1833cef2019-12-13 13:28:36 +09001362 af := apexFileForExecutable(ctx, ccTest)
Jiyong Parkf653b052019-11-18 15:39:01 +09001363 af.class = nativeTest
1364 filesInfo = append(filesInfo, af)
Roland Levillain9b5fde92019-06-28 15:41:19 +01001365 }
Roland Levillain630846d2019-06-26 12:48:34 +01001366 } else {
1367 ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
1368 }
Jiyong Parkff1458f2018-10-12 21:49:38 +09001369 case keyTag:
1370 if key, ok := child.(*apexKey); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001371 a.private_key_file = key.private_key_file
1372 a.public_key_file = key.public_key_file
Jiyong Parkff1458f2018-10-12 21:49:38 +09001373 } else {
1374 ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001375 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001376 return false
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001377 case certificateTag:
1378 if dep, ok := child.(*java.AndroidAppCertificate); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001379 a.container_certificate_file = dep.Certificate.Pem
1380 a.container_private_key_file = dep.Certificate.Key
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001381 } else {
1382 ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
1383 }
Jiyong Park03b68dd2019-07-26 23:20:40 +09001384 case android.PrebuiltDepTag:
1385 // If the prebuilt is force disabled, remember to delete the prebuilt file
1386 // that might have been installed in the previous builds
1387 if prebuilt, ok := child.(*Prebuilt); ok && prebuilt.isForceDisabled() {
1388 a.prebuiltFileToDelete = prebuilt.InstallFilename()
1389 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001390 }
Jooyung Han8aee2042019-10-29 05:08:31 +09001391 } else if !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001392 // indirect dependencies
Jooyung Han9c80bae2019-08-20 17:30:57 +09001393 if am, ok := child.(android.ApexModule); ok {
Roland Levillainf89cd092019-07-29 16:22:59 +01001394 // We cannot use a switch statement on `depTag` here as the checked
1395 // tags used below are private (e.g. `cc.sharedDepTag`).
Jiyong Park52cd06f2019-11-11 10:14:32 +09001396 if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
Roland Levillainf89cd092019-07-29 16:22:59 +01001397 if cc, ok := child.(*cc.Module); ok {
1398 if android.InList(cc.Name(), providedNativeSharedLibs) {
1399 // If we're using a shared library which is provided from other APEX,
1400 // don't include it in this APEX
1401 return false
Jiyong Parkac2bacd2019-02-20 21:49:26 +09001402 }
Jooyung Han671f1ce2019-12-17 12:47:13 +09001403 if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), ctx.OtherModuleName(cc)) && (cc.IsStubs() || cc.HasStubsVariants()) {
Roland Levillainf89cd092019-07-29 16:22:59 +01001404 // If the dependency is a stubs lib, don't include it in this APEX,
1405 // but make sure that the lib is installed on the device.
1406 // In case no APEX is having the lib, the lib is installed to the system
1407 // partition.
1408 //
1409 // Always include if we are a host-apex however since those won't have any
1410 // system libraries.
Jiyong Park956305c2020-01-09 12:32:06 +09001411 if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.Name(), a.requiredDeps) {
1412 a.requiredDeps = append(a.requiredDeps, cc.Name())
Roland Levillainf89cd092019-07-29 16:22:59 +01001413 }
Jiyong Park956305c2020-01-09 12:32:06 +09001414 a.externalDeps = append(a.externalDeps, depName)
Jooyung Hane1633032019-08-01 17:41:43 +09001415 requireNativeLibs = append(requireNativeLibs, cc.OutputFile().Path().Base())
Roland Levillainf89cd092019-07-29 16:22:59 +01001416 // Don't track further
1417 return false
1418 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001419 af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
Jiyong Parkf653b052019-11-18 15:39:01 +09001420 af.transitiveDep = true
1421 filesInfo = append(filesInfo, af)
Jiyong Park956305c2020-01-09 12:32:06 +09001422 a.internalDeps = append(a.internalDeps, depName)
1423 a.internalDeps = append(a.internalDeps, cc.AllStaticDeps()...)
Jiyong Parkf653b052019-11-18 15:39:01 +09001424 return true // track transitive dependencies
Jiyong Park25fc6a92018-11-18 18:02:45 +09001425 }
Roland Levillainf89cd092019-07-29 16:22:59 +01001426 } else if cc.IsTestPerSrcDepTag(depTag) {
1427 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001428 af := apexFileForExecutable(ctx, cc)
Roland Levillainf89cd092019-07-29 16:22:59 +01001429 // Handle modules created as `test_per_src` variations of a single test module:
1430 // use the name of the generated test binary (`fileToCopy`) instead of the name
1431 // of the original test module (`depName`, shared by all `test_per_src`
1432 // variations of that module).
Jiyong Parkf653b052019-11-18 15:39:01 +09001433 af.moduleName = filepath.Base(af.builtFile.String())
1434 af.transitiveDep = true
1435 filesInfo = append(filesInfo, af)
1436 return true // track transitive dependencies
Roland Levillainf89cd092019-07-29 16:22:59 +01001437 }
Jiyong Park52cd06f2019-11-11 10:14:32 +09001438 } else if java.IsJniDepTag(depTag) {
Jiyong Park956305c2020-01-09 12:32:06 +09001439 a.externalDeps = append(a.externalDeps, depName)
Jiyong Parkf653b052019-11-18 15:39:01 +09001440 return true
Jiyong Park956305c2020-01-09 12:32:06 +09001441 } else if java.IsStaticLibDepTag(depTag) {
1442 a.internalDeps = append(a.internalDeps, depName)
Jooyung Han9c80bae2019-08-20 17:30:57 +09001443 } else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
Roland Levillainf89cd092019-07-29 16:22:59 +01001444 ctx.ModuleErrorf("unexpected tag %q for indirect dependency %q", depTag, depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001445 }
1446 }
1447 }
1448 return false
1449 })
1450
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001451 // Specific to the ART apex: dexpreopt artifacts for libcore Java libraries.
1452 // Build rules are generated by the dexpreopt singleton, and here we access build artifacts
1453 // via the global boot image config.
1454 if a.artApex {
1455 for arch, files := range java.DexpreoptedArtApexJars(ctx) {
1456 dirInApex := filepath.Join("javalib", arch.String())
1457 for _, f := range files {
1458 localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
Jiyong Park1833cef2019-12-13 13:28:36 +09001459 af := newApexFile(ctx, f, localModule, dirInApex, etc, nil)
Jiyong Parkf653b052019-11-18 15:39:01 +09001460 filesInfo = append(filesInfo, af)
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001461 }
1462 }
1463 }
1464
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001465 if a.private_key_file == nil {
Jiyong Parkfa0a3732018-11-09 05:52:26 +09001466 ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
1467 return
1468 }
1469
Jiyong Park8fd61922018-11-08 02:50:25 +09001470 // remove duplicates in filesInfo
1471 removeDup := func(filesInfo []apexFile) []apexFile {
Jooyung Han344d5432019-08-23 11:17:39 +09001472 encountered := make(map[string]bool)
Jiyong Park8fd61922018-11-08 02:50:25 +09001473 result := []apexFile{}
1474 for _, f := range filesInfo {
Jooyung Han344d5432019-08-23 11:17:39 +09001475 dest := filepath.Join(f.installDir, f.builtFile.Base())
1476 if !encountered[dest] {
1477 encountered[dest] = true
Jiyong Park8fd61922018-11-08 02:50:25 +09001478 result = append(result, f)
1479 }
1480 }
1481 return result
1482 }
1483 filesInfo = removeDup(filesInfo)
1484
1485 // to have consistent build rules
1486 sort.Slice(filesInfo, func(i, j int) bool {
1487 return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String()
1488 })
1489
Jiyong Park127b40b2019-09-30 16:04:35 +09001490 // check apex_available requirements
Jiyong Park3814f4d2019-12-02 13:08:53 +09001491 if !ctx.Host() && !a.testApex {
Jiyong Park583a2262019-10-08 20:55:38 +09001492 for _, fi := range filesInfo {
1493 if am, ok := fi.module.(android.ApexModule); ok {
Anton Hansson5053c292020-01-10 15:12:39 +00001494 // vndk {enabled:true} implies visibility to the vndk apex
1495 if ccm, ok := fi.module.(*cc.Module); ok && ccm.IsVndk() && a.vndkApex {
1496 continue
1497 }
1498
1499 if !am.AvailableFor(ctx.ModuleName()) && !whitelistedApexAvailable(ctx.ModuleName(), a.vndkApex, fi.module) {
Jiyong Park583a2262019-10-08 20:55:38 +09001500 ctx.ModuleErrorf("requires %q that is not available for the APEX", fi.module.Name())
Jiyong Park3814f4d2019-12-02 13:08:53 +09001501 // don't stop so that we can report other violations in the same run
Jiyong Park583a2262019-10-08 20:55:38 +09001502 }
Jiyong Park127b40b2019-09-30 16:04:35 +09001503 }
1504 }
1505 }
1506
Jiyong Park8fd61922018-11-08 02:50:25 +09001507 // prepend the name of this APEX to the module names. These names will be the names of
1508 // modules that will be defined if the APEX is flattened.
1509 for i := range filesInfo {
Jaewoong Jung1670ca02019-11-22 14:50:42 -08001510 filesInfo[i].moduleName = filesInfo[i].moduleName + "." + a.Name() + a.suffix
Jiyong Park8fd61922018-11-08 02:50:25 +09001511 }
1512
Jiyong Park8fd61922018-11-08 02:50:25 +09001513 a.installDir = android.PathForModuleInstall(ctx, "apex")
1514 a.filesInfo = filesInfo
Alex Light5098a612018-11-29 17:12:15 -08001515
Jooyung Han54aca7b2019-11-20 02:26:02 +09001516 if a.properties.ApexType != zipApex {
1517 if a.properties.File_contexts == nil {
1518 a.fileContexts = android.PathForSource(ctx, "system/sepolicy/apex", ctx.ModuleName()+"-file_contexts")
1519 } else {
1520 a.fileContexts = android.PathForModuleSrc(ctx, *a.properties.File_contexts)
1521 if a.Platform() {
1522 if matched, err := path.Match("system/sepolicy/**/*", a.fileContexts.String()); err != nil || !matched {
1523 ctx.PropertyErrorf("file_contexts", "should be under system/sepolicy, but %q", a.fileContexts)
1524 }
1525 }
1526 }
1527 if !android.ExistentPathForSource(ctx, a.fileContexts.String()).Valid() {
1528 ctx.PropertyErrorf("file_contexts", "cannot find file_contexts file: %q", a.fileContexts)
1529 return
1530 }
1531 }
1532
Jooyung Hand15aa1f2019-09-27 00:38:03 +09001533 // prepare apex_manifest.json
Jooyung Han01a3ee22019-11-02 02:52:25 +09001534 a.buildManifest(ctx, provideNativeLibs, requireNativeLibs)
1535
1536 a.setCertificateAndPrivateKey(ctx)
1537 if a.properties.ApexType == flattenedApex {
1538 a.buildFlattenedApex(ctx)
1539 } else {
1540 a.buildUnflattenedApex(ctx)
1541 }
1542
Jooyung Han002ab682020-01-08 01:57:58 +09001543 a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
Jiyong Park956305c2020-01-09 12:32:06 +09001544
1545 a.buildApexDependencyInfo(ctx)
Jooyung Han01a3ee22019-11-02 02:52:25 +09001546}
1547
Anton Hansson5053c292020-01-10 15:12:39 +00001548func whitelistedApexAvailable(apex string, is_vndk bool, module android.Module) bool {
1549 key := apex
1550 key = strings.Replace(key, "test_", "", 1)
1551 key = strings.Replace(key, "com.android.art.debug", "com.android.art", 1)
1552 key = strings.Replace(key, "com.android.art.release", "com.android.art", 1)
1553
1554 moduleName := module.Name()
1555 if strings.Contains(moduleName, "prebuilt_libclang_rt") {
1556 // This module has variants that depend on the product being built.
1557 moduleName = "prebuilt_libclang_rt"
1558 }
1559
1560 if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
1561 return true
1562 }
1563
1564 return false
1565}
1566
Jooyung Han344d5432019-08-23 11:17:39 +09001567func newApexBundle() *apexBundle {
Sundong Ahnabb64432019-10-22 13:58:29 +09001568 module := &apexBundle{}
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001569 module.AddProperties(&module.properties)
Alex Light9670d332019-01-29 18:07:33 -08001570 module.AddProperties(&module.targetProperties)
Jiyong Park5d790c32019-11-15 18:40:32 +09001571 module.AddProperties(&module.overridableProperties)
Alex Light5098a612018-11-29 17:12:15 -08001572 module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
Jiyong Park397e55e2018-10-24 21:09:55 +09001573 return class == android.Device && ctx.Config().DevicePrefer32BitExecutables()
1574 })
Alex Light5098a612018-11-29 17:12:15 -08001575 android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001576 android.InitDefaultableModule(module)
Jiyong Parkd1063c12019-07-17 20:08:41 +09001577 android.InitSdkAwareModule(module)
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08001578 android.InitOverridableModule(module, &module.overridableProperties.Overrides)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001579 return module
1580}
Jiyong Park30ca9372019-02-07 16:27:23 +09001581
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001582func ApexBundleFactory(testApex bool, artApex bool) android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09001583 bundle := newApexBundle()
1584 bundle.testApex = testApex
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001585 bundle.artApex = artApex
Jooyung Han344d5432019-08-23 11:17:39 +09001586 return bundle
1587}
1588
1589func testApexBundleFactory() android.Module {
1590 bundle := newApexBundle()
1591 bundle.testApex = true
1592 return bundle
1593}
1594
Jiyong Parkd1063c12019-07-17 20:08:41 +09001595func BundleFactory() android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09001596 return newApexBundle()
1597}
1598
Jiyong Park30ca9372019-02-07 16:27:23 +09001599//
1600// Defaults
1601//
1602type Defaults struct {
1603 android.ModuleBase
1604 android.DefaultsModuleBase
1605}
1606
Jiyong Park30ca9372019-02-07 16:27:23 +09001607func defaultsFactory() android.Module {
1608 return DefaultsFactory()
1609}
1610
1611func DefaultsFactory(props ...interface{}) android.Module {
1612 module := &Defaults{}
1613
1614 module.AddProperties(props...)
1615 module.AddProperties(
1616 &apexBundleProperties{},
1617 &apexTargetBundleProperties{},
Jooyung Hanf21c7972019-12-16 22:32:06 +09001618 &overridableProperties{},
Jiyong Park30ca9372019-02-07 16:27:23 +09001619 )
1620
1621 android.InitDefaultsModule(module)
1622 return module
1623}
Jiyong Park5d790c32019-11-15 18:40:32 +09001624
1625//
1626// OverrideApex
1627//
1628type OverrideApex struct {
1629 android.ModuleBase
1630 android.OverrideModuleBase
1631}
1632
1633func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) {
1634 // All the overrides happen in the base module.
1635}
1636
1637// override_apex is used to create an apex module based on another apex module
1638// by overriding some of its properties.
1639func overrideApexFactory() android.Module {
1640 m := &OverrideApex{}
1641 m.AddProperties(&overridableProperties{})
1642
1643 android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon)
1644 android.InitOverrideModule(m)
1645 return m
1646}