blob: f3eebd40e96879c30edccb80e4280216dac10be1 [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 Park83dc74b2020-01-14 18:38:44 +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 Park83dc74b2020-01-14 18:38:44 +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 Park83dc74b2020-01-14 18:38:44 +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 Park48ca7dc2018-10-10 14:01:00 +0900808}
809
Jiyong Park397e55e2018-10-24 21:09:55 +0900810func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
Roland Levillain630846d2019-06-26 12:48:34 +0100811 native_shared_libs []string, binaries []string, tests []string,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700812 target android.Target, imageVariation string) {
Jiyong Park397e55e2018-10-24 21:09:55 +0900813 // Use *FarVariation* to be able to depend on modules having
814 // conflicting variations with this module. This is required since
815 // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64'
816 // for native shared libs.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700817 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Parkda6eb592018-12-19 17:12:36 +0900818 {Mutator: "image", Variation: imageVariation},
Jiyong Park397e55e2018-10-24 21:09:55 +0900819 {Mutator: "link", Variation: "shared"},
Jiyong Park28d395a2018-12-07 22:42:47 +0900820 {Mutator: "version", Variation: ""}, // "" is the non-stub variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700821 }...), sharedLibTag, native_shared_libs...)
Jiyong Park397e55e2018-10-24 21:09:55 +0900822
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700823 ctx.AddFarVariationDependencies(append(target.Variations(),
824 blueprint.Variation{Mutator: "image", Variation: imageVariation}),
825 executableTag, binaries...)
Roland Levillain630846d2019-06-26 12:48:34 +0100826
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700827 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +0100828 {Mutator: "image", Variation: imageVariation},
Roland Levillain9b5fde92019-06-28 15:41:19 +0100829 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700830 }...), testTag, tests...)
Jiyong Park397e55e2018-10-24 21:09:55 +0900831}
832
Alex Light9670d332019-01-29 18:07:33 -0800833func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
834 if ctx.Os().Class == android.Device {
835 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil)
836 } else {
837 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil)
838 if ctx.Os().Bionic() {
839 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil)
840 } else {
841 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil)
842 }
843 }
844}
845
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900846func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
Jooyung Handc782442019-11-01 03:14:38 +0900847 if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorWhitelist(ctx.Config())) {
848 ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
849 }
850
Jiyong Park397e55e2018-10-24 21:09:55 +0900851 targets := ctx.MultiTargets()
Jiyong Park7c1dc612019-01-05 11:15:24 +0900852 config := ctx.DeviceConfig()
Alex Light9670d332019-01-29 18:07:33 -0800853
854 a.combineProperties(ctx)
855
Jiyong Park397e55e2018-10-24 21:09:55 +0900856 has32BitTarget := false
857 for _, target := range targets {
858 if target.Arch.ArchType.Multilib == "lib32" {
859 has32BitTarget = true
860 }
861 }
862 for i, target := range targets {
863 // When multilib.* is omitted for native_shared_libs, it implies
864 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700865 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Park7c1dc612019-01-05 11:15:24 +0900866 {Mutator: "image", Variation: a.getImageVariation(config)},
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900867 {Mutator: "link", Variation: "shared"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700868 }...), sharedLibTag, a.properties.Native_shared_libs...)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900869
Roland Levillain630846d2019-06-26 12:48:34 +0100870 // When multilib.* is omitted for tests, it implies
871 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700872 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +0100873 {Mutator: "image", Variation: a.getImageVariation(config)},
Roland Levillain9b5fde92019-06-28 15:41:19 +0100874 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700875 }...), testTag, a.properties.Tests...)
Roland Levillain630846d2019-06-26 12:48:34 +0100876
Jiyong Park397e55e2018-10-24 21:09:55 +0900877 // Add native modules targetting both ABIs
878 addDependenciesForNativeModules(ctx,
879 a.properties.Multilib.Both.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100880 a.properties.Multilib.Both.Binaries,
881 a.properties.Multilib.Both.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700882 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900883 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900884
Alex Light3d673592019-01-18 14:37:31 -0800885 isPrimaryAbi := i == 0
886 if isPrimaryAbi {
Jiyong Park397e55e2018-10-24 21:09:55 +0900887 // When multilib.* is omitted for binaries, it implies
888 // multilib.first.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700889 ctx.AddFarVariationDependencies(append(target.Variations(),
890 blueprint.Variation{Mutator: "image", Variation: a.getImageVariation(config)}),
891 executableTag, a.properties.Binaries...)
Jiyong Park397e55e2018-10-24 21:09:55 +0900892
893 // Add native modules targetting the first ABI
894 addDependenciesForNativeModules(ctx,
895 a.properties.Multilib.First.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100896 a.properties.Multilib.First.Binaries,
897 a.properties.Multilib.First.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700898 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900899 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900900 }
901
902 switch target.Arch.ArchType.Multilib {
903 case "lib32":
904 // Add native modules targetting 32-bit ABI
905 addDependenciesForNativeModules(ctx,
906 a.properties.Multilib.Lib32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100907 a.properties.Multilib.Lib32.Binaries,
908 a.properties.Multilib.Lib32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700909 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900910 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900911
912 addDependenciesForNativeModules(ctx,
913 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100914 a.properties.Multilib.Prefer32.Binaries,
915 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700916 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900917 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900918 case "lib64":
919 // Add native modules targetting 64-bit ABI
920 addDependenciesForNativeModules(ctx,
921 a.properties.Multilib.Lib64.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100922 a.properties.Multilib.Lib64.Binaries,
923 a.properties.Multilib.Lib64.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700924 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900925 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900926
927 if !has32BitTarget {
928 addDependenciesForNativeModules(ctx,
929 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100930 a.properties.Multilib.Prefer32.Binaries,
931 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700932 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900933 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900934 }
Peter Collingbourne3478bb22019-04-24 14:41:12 -0700935
936 if strings.HasPrefix(ctx.ModuleName(), "com.android.runtime") && target.Os.Class == android.Device {
937 for _, sanitizer := range ctx.Config().SanitizeDevice() {
938 if sanitizer == "hwaddress" {
939 addDependenciesForNativeModules(ctx,
940 []string{"libclang_rt.hwasan-aarch64-android"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700941 nil, nil, target, a.getImageVariation(config))
Peter Collingbourne3478bb22019-04-24 14:41:12 -0700942 break
943 }
944 }
945 }
Jiyong Park397e55e2018-10-24 21:09:55 +0900946 }
947
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900948 }
949
Jiyong Parkce6aadc2019-11-20 13:58:28 +0900950 // For prebuilt_etc, use the first variant (64 on 64/32bit device,
951 // 32 on 32bit device) regardless of the TARGET_PREFER_* setting.
952 // b/144532908
953 archForPrebuiltEtc := config.Arches()[0]
954 for _, arch := range config.Arches() {
955 // Prefer 64-bit arch if there is any
956 if arch.ArchType.Multilib == "lib64" {
957 archForPrebuiltEtc = arch
958 break
959 }
960 }
961 ctx.AddFarVariationDependencies([]blueprint.Variation{
962 {Mutator: "os", Variation: ctx.Os().String()},
963 {Mutator: "arch", Variation: archForPrebuiltEtc.String()},
964 }, prebuiltTag, a.properties.Prebuilts...)
965
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700966 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
967 javaLibTag, a.properties.Java_libs...)
Jiyong Parkff1458f2018-10-12 21:49:38 +0900968
Ulya Trafimovich44561882020-01-03 13:25:54 +0000969 // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
970 if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
971 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
972 javaLibTag, "jacocoagent")
973 }
974
Jiyong Park23c52b02019-02-02 13:13:47 +0900975 if String(a.properties.Key) == "" {
976 ctx.ModuleErrorf("key is missing")
977 return
978 }
979 ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key))
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900980
Jiyong Parkb2742fd2019-02-11 11:38:15 +0900981 cert := android.SrcIsModule(a.getCertString(ctx))
Jiyong Park23c52b02019-02-02 13:13:47 +0900982 if cert != "" {
983 ctx.AddDependency(ctx.Module(), certificateTag, cert)
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900984 }
Jiyong Parkd1063c12019-07-17 20:08:41 +0900985
986 // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks
987 if len(a.properties.Uses_sdks) > 0 {
988 sdkRefs := []android.SdkRef{}
989 for _, str := range a.properties.Uses_sdks {
990 parsed := android.ParseSdkRef(ctx, str, "uses_sdks")
991 sdkRefs = append(sdkRefs, parsed)
992 }
993 a.BuildWithSdks(sdkRefs)
994 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900995}
996
Jiyong Park5d790c32019-11-15 18:40:32 +0900997func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
998 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
999 androidAppTag, a.overridableProperties.Apps...)
1000}
1001
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09001002func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
1003 // direct deps of an APEX bundle are all part of the APEX bundle
1004 return true
1005}
1006
Colin Cross0ea8ba82019-06-06 14:33:29 -07001007func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
Jooyung Han27151d92019-12-16 17:45:32 +09001008 moduleName := ctx.ModuleName()
1009 // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the OVERRIDE_* list,
1010 // we check with the pseudo module name to see if its certificate is overridden.
1011 if a.vndkApex {
1012 moduleName = vndkApexName
1013 }
1014 certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName)
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001015 if overridden {
Jaewoong Jungacb6db32019-02-28 16:22:30 +00001016 return ":" + certificate
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001017 }
1018 return String(a.properties.Certificate)
1019}
1020
Colin Cross41955e82019-05-29 14:40:35 -07001021func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
1022 switch tag {
1023 case "":
Sundong Ahnabb64432019-10-22 13:58:29 +09001024 return android.Paths{a.outputFile}, nil
Colin Cross41955e82019-05-29 14:40:35 -07001025 default:
1026 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
Jiyong Park5a832022018-12-20 09:54:35 +09001027 }
Jiyong Park74e240b2018-11-27 21:27:08 +09001028}
1029
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001030func (a *apexBundle) installable() bool {
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001031 return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001032}
1033
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001034func (a *apexBundle) testOnlyShouldSkipHashtreeGeneration() bool {
1035 return proptools.Bool(a.properties.Test_only_no_hashtree)
1036}
1037
Jiyong Park7c1dc612019-01-05 11:15:24 +09001038func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
Jooyung Han31c470b2019-10-18 16:26:59 +09001039 if a.vndkApex {
Colin Cross7228ecd2019-11-18 16:00:16 -08001040 return cc.VendorVariationPrefix + a.vndkVersion(config)
Jooyung Han31c470b2019-10-18 16:26:59 +09001041 }
Jiyong Park7c1dc612019-01-05 11:15:24 +09001042 if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) {
Colin Cross7228ecd2019-11-18 16:00:16 -08001043 return cc.VendorVariationPrefix + config.PlatformVndkVersion()
Jiyong Parkda6eb592018-12-19 17:12:36 +09001044 } else {
Colin Cross7228ecd2019-11-18 16:00:16 -08001045 return android.CoreVariation
Jiyong Parkda6eb592018-12-19 17:12:36 +09001046 }
1047}
1048
Jiyong Parkf97782b2019-02-13 20:28:58 +09001049func (a *apexBundle) EnableSanitizer(sanitizerName string) {
1050 if !android.InList(sanitizerName, a.properties.SanitizerNames) {
1051 a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName)
1052 }
1053}
1054
Jiyong Park388ef3f2019-01-28 19:47:32 +09001055func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
Jiyong Parkf97782b2019-02-13 20:28:58 +09001056 if android.InList(sanitizerName, a.properties.SanitizerNames) {
1057 return true
Jiyong Park235e67c2019-02-09 11:50:56 +09001058 }
1059
1060 // Then follow the global setting
Jiyong Park388ef3f2019-01-28 19:47:32 +09001061 globalSanitizerNames := []string{}
1062 if a.Host() {
1063 globalSanitizerNames = ctx.Config().SanitizeHost()
1064 } else {
1065 arches := ctx.Config().SanitizeDeviceArch()
1066 if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
1067 globalSanitizerNames = ctx.Config().SanitizeDevice()
1068 }
1069 }
1070 return android.InList(sanitizerName, globalSanitizerNames)
Jiyong Park379de2f2018-12-19 02:47:14 +09001071}
1072
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001073func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
1074 return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
1075}
1076
1077func (a *apexBundle) PreventInstall() {
1078 a.properties.PreventInstall = true
1079}
1080
1081func (a *apexBundle) HideFromMake() {
1082 a.properties.HideFromMake = true
1083}
1084
Jiyong Park83dc74b2020-01-14 18:38:44 +09001085func (a *apexBundle) MarkAsCoverageVariant(coverage bool) {
1086 a.properties.IsCoverageVariant = coverage
1087}
1088
Jiyong Parkf653b052019-11-18 15:39:01 +09001089// TODO(jiyong) move apexFileFor* close to the apexFile type definition
Jiyong Park1833cef2019-12-13 13:28:36 +09001090func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001091 // Decide the APEX-local directory by the multilib of the library
1092 // In the future, we may query this to the module.
Jiyong Parkf653b052019-11-18 15:39:01 +09001093 var dirInApex string
Martin Stjernholm279de572019-09-10 23:18:20 +01001094 switch ccMod.Arch().ArchType.Multilib {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001095 case "lib32":
1096 dirInApex = "lib"
1097 case "lib64":
1098 dirInApex = "lib64"
1099 }
Martin Stjernholm279de572019-09-10 23:18:20 +01001100 dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001101 if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
Martin Stjernholm279de572019-09-10 23:18:20 +01001102 dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001103 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001104 if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) {
Martin Stjernholm279de572019-09-10 23:18:20 +01001105 // Special case for Bionic libs and other libs installed with them. This is
1106 // to prevent those libs from being included in the search path
1107 // /apex/com.android.runtime/${LIB}. This exclusion is required because
1108 // those libs in the Runtime APEX are available via the legacy paths in
1109 // /system/lib/. By the init process, the libs in the APEX are bind-mounted
1110 // to the legacy paths and thus will be loaded into the default linker
1111 // namespace (aka "platform" namespace). If the libs are directly in
1112 // /apex/com.android.runtime/${LIB} then the same libs will be loaded again
1113 // into the runtime linker namespace, which will result in double loading of
1114 // them, which isn't supported.
1115 dirInApex = filepath.Join(dirInApex, "bionic")
Jiyong Parkb0788572018-12-20 22:10:17 +09001116 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001117
Jiyong Parkf653b052019-11-18 15:39:01 +09001118 fileToCopy := ccMod.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001119 return newApexFile(ctx, fileToCopy, ccMod.Name(), dirInApex, nativeSharedLib, ccMod)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001120}
1121
Jiyong Park1833cef2019-12-13 13:28:36 +09001122func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001123 dirInApex := filepath.Join("bin", cc.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001124 if cc.Target().NativeBridge == android.NativeBridgeEnabled {
dimitry8d6dde82019-07-11 10:23:53 +02001125 dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
Jiyong Parkacbf6c72019-07-09 16:19:16 +09001126 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001127 fileToCopy := cc.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001128 af := newApexFile(ctx, fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc)
Jiyong Parkf653b052019-11-18 15:39:01 +09001129 af.symlinks = cc.Symlinks()
1130 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001131}
1132
Jiyong Park1833cef2019-12-13 13:28:36 +09001133func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001134 dirInApex := "bin"
1135 fileToCopy := py.HostToolPath().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001136 return newApexFile(ctx, fileToCopy, py.Name(), dirInApex, pyBinary, py)
Alex Light778127a2019-02-27 14:19:50 -08001137}
Jiyong Park1833cef2019-12-13 13:28:36 +09001138func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001139 dirInApex := "bin"
Alex Light778127a2019-02-27 14:19:50 -08001140 s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
1141 if err != nil {
1142 ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001143 return apexFile{}
Alex Light778127a2019-02-27 14:19:50 -08001144 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001145 fileToCopy := android.PathForOutput(ctx, s)
1146 // NB: Since go binaries are static we don't need the module for anything here, which is
1147 // good since the go tool is a blueprint.Module not an android.Module like we would
1148 // normally use.
Jiyong Park1833cef2019-12-13 13:28:36 +09001149 return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil)
Alex Light778127a2019-02-27 14:19:50 -08001150}
1151
Jiyong Park1833cef2019-12-13 13:28:36 +09001152func apexFileForShBinary(ctx android.BaseModuleContext, sh *android.ShBinary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001153 dirInApex := filepath.Join("bin", sh.SubDir())
1154 fileToCopy := sh.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001155 af := newApexFile(ctx, fileToCopy, sh.Name(), dirInApex, shBinary, sh)
Jiyong Parkf653b052019-11-18 15:39:01 +09001156 af.symlinks = sh.Symlinks()
1157 return af
Jiyong Park04480cf2019-02-06 00:16:29 +09001158}
1159
Jooyung Han58f26ab2019-12-18 15:34:32 +09001160// TODO(b/146586360): replace javaLibrary(in apex/apex.go) with java.Dependency
1161type javaLibrary interface {
1162 android.Module
1163 java.Dependency
1164}
1165
1166func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaLibrary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001167 dirInApex := "javalib"
Jooyung Han58f26ab2019-12-18 15:34:32 +09001168 fileToCopy := lib.DexJar()
Jiyong Park618922e2020-01-08 13:35:43 +09001169 af := newApexFile(ctx, fileToCopy, lib.Name(), dirInApex, javaSharedLib, lib)
1170 af.jacocoReportClassesFile = lib.JacocoReportClassesFile()
1171 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001172}
1173
Jiyong Park1833cef2019-12-13 13:28:36 +09001174func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt android.PrebuiltEtcModule, depName string) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001175 dirInApex := filepath.Join("etc", prebuilt.SubDir())
1176 fileToCopy := prebuilt.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001177 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001178}
1179
Jiyong Park1833cef2019-12-13 13:28:36 +09001180func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
Jiyong Parkf653b052019-11-18 15:39:01 +09001181 android.Module
1182 Privileged() bool
1183 OutputFile() android.Path
Jiyong Park618922e2020-01-08 13:35:43 +09001184 JacocoReportClassesFile() android.Path
Jiyong Parkf653b052019-11-18 15:39:01 +09001185}, pkgName string) apexFile {
Jiyong Parkf7487312019-10-17 12:54:30 +09001186 appDir := "app"
Jiyong Parkf653b052019-11-18 15:39:01 +09001187 if aapp.Privileged() {
Jiyong Parkf7487312019-10-17 12:54:30 +09001188 appDir = "priv-app"
1189 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001190 dirInApex := filepath.Join(appDir, pkgName)
1191 fileToCopy := aapp.OutputFile()
Jiyong Park618922e2020-01-08 13:35:43 +09001192 af := newApexFile(ctx, fileToCopy, aapp.Name(), dirInApex, app, aapp)
1193 af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
1194 return af
Dario Frenicde2a032019-10-27 00:29:22 +01001195}
1196
Roland Levillain935639d2019-08-13 14:55:28 +01001197// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
1198type flattenedApexContext struct {
1199 android.ModuleContext
1200}
1201
1202func (c *flattenedApexContext) InstallBypassMake() bool {
1203 return true
1204}
1205
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001206func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Sundong Ahnabb64432019-10-22 13:58:29 +09001207 buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
1208 switch a.properties.ApexType {
1209 case imageApex:
1210 if buildFlattenedAsDefault {
1211 a.suffix = imageApexSuffix
1212 } else {
1213 a.suffix = ""
1214 a.primaryApexType = true
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09001215
1216 if ctx.Config().InstallExtraFlattenedApexes() {
Jiyong Park83dc74b2020-01-14 18:38:44 +09001217 a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix)
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09001218 }
Sundong Ahnabb64432019-10-22 13:58:29 +09001219 }
1220 case zipApex:
1221 if proptools.String(a.properties.Payload_type) == "zip" {
1222 a.suffix = ""
1223 a.primaryApexType = true
1224 } else {
1225 a.suffix = zipApexSuffix
1226 }
1227 case flattenedApex:
1228 if buildFlattenedAsDefault {
1229 a.suffix = ""
1230 a.primaryApexType = true
1231 } else {
1232 a.suffix = flattenedSuffix
1233 }
Alex Light5098a612018-11-29 17:12:15 -08001234 }
1235
Roland Levillain630846d2019-06-26 12:48:34 +01001236 if len(a.properties.Tests) > 0 && !a.testApex {
1237 ctx.PropertyErrorf("tests", "property not allowed in apex module type")
1238 return
1239 }
1240
Alex Lightfc0bd7c2019-01-29 18:31:59 -08001241 handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
1242
Jooyung Hane1633032019-08-01 17:41:43 +09001243 // native lib dependencies
1244 var provideNativeLibs []string
1245 var requireNativeLibs []string
1246
Jooyung Han5c998b92019-06-27 11:30:33 +09001247 // Check if "uses" requirements are met with dependent apexBundles
1248 var providedNativeSharedLibs []string
1249 useVendor := proptools.Bool(a.properties.Use_vendor)
1250 ctx.VisitDirectDepsBlueprint(func(m blueprint.Module) {
1251 if ctx.OtherModuleDependencyTag(m) != usesTag {
1252 return
1253 }
1254 otherName := ctx.OtherModuleName(m)
1255 other, ok := m.(*apexBundle)
1256 if !ok {
1257 ctx.PropertyErrorf("uses", "%q is not a provider", otherName)
1258 return
1259 }
1260 if proptools.Bool(other.properties.Use_vendor) != useVendor {
1261 ctx.PropertyErrorf("use_vendor", "%q has different value of use_vendor", otherName)
1262 return
1263 }
1264 if !proptools.Bool(other.properties.Provide_cpp_shared_libs) {
1265 ctx.PropertyErrorf("uses", "%q does not provide native_shared_libs", otherName)
1266 return
1267 }
1268 providedNativeSharedLibs = append(providedNativeSharedLibs, other.properties.Native_shared_libs...)
1269 })
1270
Jiyong Parkf653b052019-11-18 15:39:01 +09001271 var filesInfo []apexFile
Alex Light778127a2019-02-27 14:19:50 -08001272 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
Roland Levillainf89cd092019-07-29 16:22:59 +01001273 depTag := ctx.OtherModuleDependencyTag(child)
1274 depName := ctx.OtherModuleName(child)
Jiyong Parkf653b052019-11-18 15:39:01 +09001275 if _, isDirectDep := parent.(*apexBundle); isDirectDep {
Jiyong Park83dc74b2020-01-14 18:38:44 +09001276 if depTag != keyTag && depTag != certificateTag {
1277 a.internalDeps = append(a.internalDeps, depName)
1278 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001279 switch depTag {
1280 case sharedLibTag:
1281 if cc, ok := child.(*cc.Module); ok {
Jooyung Hane1633032019-08-01 17:41:43 +09001282 if cc.HasStubsVariants() {
1283 provideNativeLibs = append(provideNativeLibs, cc.OutputFile().Path().Base())
1284 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001285 filesInfo = append(filesInfo, apexFileForNativeLibrary(ctx, cc, handleSpecialLibs))
Jiyong Parkf653b052019-11-18 15:39:01 +09001286 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09001287 } else {
1288 ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001289 }
1290 case executableTag:
1291 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001292 filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
Jiyong Parkf653b052019-11-18 15:39:01 +09001293 return true // track transitive dependencies
Jiyong Park04480cf2019-02-06 00:16:29 +09001294 } else if sh, ok := child.(*android.ShBinary); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001295 filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
Alex Light778127a2019-02-27 14:19:50 -08001296 } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
Jiyong Park1833cef2019-12-13 13:28:36 +09001297 filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
Alex Light778127a2019-02-27 14:19:50 -08001298 } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
Jiyong Parkf653b052019-11-18 15:39:01 +09001299 filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb))
Jiyong Parkff1458f2018-10-12 21:49:38 +09001300 } else {
Alex Light778127a2019-02-27 14:19:50 -08001301 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 +09001302 }
1303 case javaLibTag:
Jiyong Park9e6c2422019-08-09 20:39:45 +09001304 if javaLib, ok := child.(*java.Library); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001305 af := apexFileForJavaLibrary(ctx, javaLib)
Jiyong Parkf653b052019-11-18 15:39:01 +09001306 if !af.Ok() {
Jiyong Park8fd61922018-11-08 02:50:25 +09001307 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
1308 } else {
Jiyong Parkf653b052019-11-18 15:39:01 +09001309 filesInfo = append(filesInfo, af)
1310 return true // track transitive dependencies
Jiyong Park9e6c2422019-08-09 20:39:45 +09001311 }
Jooyung Han58f26ab2019-12-18 15:34:32 +09001312 } else if sdkLib, ok := child.(*java.SdkLibrary); ok {
1313 af := apexFileForJavaLibrary(ctx, sdkLib)
1314 if !af.Ok() {
1315 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
1316 return false
1317 }
1318 filesInfo = append(filesInfo, af)
1319
Jooyung Han624058e2019-12-24 18:38:06 +09001320 pf, _ := sdkLib.OutputFiles(".xml")
1321 if len(pf) != 1 {
Jooyung Han58f26ab2019-12-18 15:34:32 +09001322 ctx.PropertyErrorf("java_libs", "%q failed to generate permission XML", depName)
1323 return false
1324 }
Jooyung Han624058e2019-12-24 18:38:06 +09001325 filesInfo = append(filesInfo, newApexFile(ctx, pf[0], pf[0].Base(), "etc/permissions", etc, nil))
Jooyung Han58f26ab2019-12-18 15:34:32 +09001326 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09001327 } else {
Jiyong Park9e6c2422019-08-09 20:39:45 +09001328 ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001329 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001330 case androidAppTag:
1331 pkgName := ctx.DeviceConfig().OverridePackageNameFor(depName)
1332 if ap, ok := child.(*java.AndroidApp); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001333 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09001334 return true // track transitive dependencies
1335 } else if ap, ok := child.(*java.AndroidAppImport); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001336 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Dario Freni6f3937c2019-12-20 22:58:03 +00001337 } else if ap, ok := child.(*java.AndroidTestHelperApp); ok {
1338 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09001339 } else {
1340 ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
1341 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001342 case prebuiltTag:
Jooyung Han39edb6c2019-11-06 16:53:07 +09001343 if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001344 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
Jiyong Parkff1458f2018-10-12 21:49:38 +09001345 } else {
1346 ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName)
1347 }
Roland Levillain630846d2019-06-26 12:48:34 +01001348 case testTag:
Roland Levillainf89cd092019-07-29 16:22:59 +01001349 if ccTest, ok := child.(*cc.Module); ok {
1350 if ccTest.IsTestPerSrcAllTestsVariation() {
1351 // Multiple-output test module (where `test_per_src: true`).
1352 //
1353 // `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
1354 // We do not add this variation to `filesInfo`, as it has no output;
1355 // however, we do add the other variations of this module as indirect
1356 // dependencies (see below).
1357 return true
Roland Levillain9b5fde92019-06-28 15:41:19 +01001358 } else {
Roland Levillainf89cd092019-07-29 16:22:59 +01001359 // Single-output test module (where `test_per_src: false`).
Jiyong Park1833cef2019-12-13 13:28:36 +09001360 af := apexFileForExecutable(ctx, ccTest)
Jiyong Parkf653b052019-11-18 15:39:01 +09001361 af.class = nativeTest
1362 filesInfo = append(filesInfo, af)
Roland Levillain9b5fde92019-06-28 15:41:19 +01001363 }
Roland Levillain630846d2019-06-26 12:48:34 +01001364 } else {
1365 ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
1366 }
Jiyong Parkff1458f2018-10-12 21:49:38 +09001367 case keyTag:
1368 if key, ok := child.(*apexKey); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001369 a.private_key_file = key.private_key_file
1370 a.public_key_file = key.public_key_file
Jiyong Parkff1458f2018-10-12 21:49:38 +09001371 } else {
1372 ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001373 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001374 return false
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001375 case certificateTag:
1376 if dep, ok := child.(*java.AndroidAppCertificate); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001377 a.container_certificate_file = dep.Certificate.Pem
1378 a.container_private_key_file = dep.Certificate.Key
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001379 } else {
1380 ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
1381 }
Jiyong Park03b68dd2019-07-26 23:20:40 +09001382 case android.PrebuiltDepTag:
1383 // If the prebuilt is force disabled, remember to delete the prebuilt file
1384 // that might have been installed in the previous builds
1385 if prebuilt, ok := child.(*Prebuilt); ok && prebuilt.isForceDisabled() {
1386 a.prebuiltFileToDelete = prebuilt.InstallFilename()
1387 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001388 }
Jooyung Han8aee2042019-10-29 05:08:31 +09001389 } else if !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001390 // indirect dependencies
Jooyung Han9c80bae2019-08-20 17:30:57 +09001391 if am, ok := child.(android.ApexModule); ok {
Roland Levillainf89cd092019-07-29 16:22:59 +01001392 // We cannot use a switch statement on `depTag` here as the checked
1393 // tags used below are private (e.g. `cc.sharedDepTag`).
Jiyong Park52cd06f2019-11-11 10:14:32 +09001394 if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
Roland Levillainf89cd092019-07-29 16:22:59 +01001395 if cc, ok := child.(*cc.Module); ok {
1396 if android.InList(cc.Name(), providedNativeSharedLibs) {
1397 // If we're using a shared library which is provided from other APEX,
1398 // don't include it in this APEX
1399 return false
Jiyong Parkac2bacd2019-02-20 21:49:26 +09001400 }
Jooyung Han671f1ce2019-12-17 12:47:13 +09001401 if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), ctx.OtherModuleName(cc)) && (cc.IsStubs() || cc.HasStubsVariants()) {
Roland Levillainf89cd092019-07-29 16:22:59 +01001402 // If the dependency is a stubs lib, don't include it in this APEX,
1403 // but make sure that the lib is installed on the device.
1404 // In case no APEX is having the lib, the lib is installed to the system
1405 // partition.
1406 //
1407 // Always include if we are a host-apex however since those won't have any
1408 // system libraries.
Jiyong Park83dc74b2020-01-14 18:38:44 +09001409 if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.Name(), a.requiredDeps) {
1410 a.requiredDeps = append(a.requiredDeps, cc.Name())
Roland Levillainf89cd092019-07-29 16:22:59 +01001411 }
Jiyong Park83dc74b2020-01-14 18:38:44 +09001412 a.externalDeps = append(a.externalDeps, depName)
Jooyung Hane1633032019-08-01 17:41:43 +09001413 requireNativeLibs = append(requireNativeLibs, cc.OutputFile().Path().Base())
Roland Levillainf89cd092019-07-29 16:22:59 +01001414 // Don't track further
1415 return false
1416 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001417 af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
Jiyong Parkf653b052019-11-18 15:39:01 +09001418 af.transitiveDep = true
1419 filesInfo = append(filesInfo, af)
Jiyong Park83dc74b2020-01-14 18:38:44 +09001420 a.internalDeps = append(a.internalDeps, depName)
1421 a.internalDeps = append(a.internalDeps, cc.AllStaticDeps()...)
Jiyong Parkf653b052019-11-18 15:39:01 +09001422 return true // track transitive dependencies
Jiyong Park25fc6a92018-11-18 18:02:45 +09001423 }
Roland Levillainf89cd092019-07-29 16:22:59 +01001424 } else if cc.IsTestPerSrcDepTag(depTag) {
1425 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001426 af := apexFileForExecutable(ctx, cc)
Roland Levillainf89cd092019-07-29 16:22:59 +01001427 // Handle modules created as `test_per_src` variations of a single test module:
1428 // use the name of the generated test binary (`fileToCopy`) instead of the name
1429 // of the original test module (`depName`, shared by all `test_per_src`
1430 // variations of that module).
Jiyong Parkf653b052019-11-18 15:39:01 +09001431 af.moduleName = filepath.Base(af.builtFile.String())
1432 af.transitiveDep = true
1433 filesInfo = append(filesInfo, af)
1434 return true // track transitive dependencies
Roland Levillainf89cd092019-07-29 16:22:59 +01001435 }
Jiyong Park52cd06f2019-11-11 10:14:32 +09001436 } else if java.IsJniDepTag(depTag) {
Jiyong Park83dc74b2020-01-14 18:38:44 +09001437 a.externalDeps = append(a.externalDeps, depName)
Jiyong Parkf653b052019-11-18 15:39:01 +09001438 return true
Jiyong Park83dc74b2020-01-14 18:38:44 +09001439 } else if java.IsStaticLibDepTag(depTag) {
1440 a.internalDeps = append(a.internalDeps, depName)
Jooyung Han9c80bae2019-08-20 17:30:57 +09001441 } else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
Roland Levillainf89cd092019-07-29 16:22:59 +01001442 ctx.ModuleErrorf("unexpected tag %q for indirect dependency %q", depTag, depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001443 }
1444 }
1445 }
1446 return false
1447 })
1448
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001449 // Specific to the ART apex: dexpreopt artifacts for libcore Java libraries.
1450 // Build rules are generated by the dexpreopt singleton, and here we access build artifacts
1451 // via the global boot image config.
1452 if a.artApex {
1453 for arch, files := range java.DexpreoptedArtApexJars(ctx) {
1454 dirInApex := filepath.Join("javalib", arch.String())
1455 for _, f := range files {
1456 localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
Jiyong Park1833cef2019-12-13 13:28:36 +09001457 af := newApexFile(ctx, f, localModule, dirInApex, etc, nil)
Jiyong Parkf653b052019-11-18 15:39:01 +09001458 filesInfo = append(filesInfo, af)
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001459 }
1460 }
1461 }
1462
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001463 if a.private_key_file == nil {
Jiyong Parkfa0a3732018-11-09 05:52:26 +09001464 ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
1465 return
1466 }
1467
Jiyong Park8fd61922018-11-08 02:50:25 +09001468 // remove duplicates in filesInfo
1469 removeDup := func(filesInfo []apexFile) []apexFile {
Jooyung Han344d5432019-08-23 11:17:39 +09001470 encountered := make(map[string]bool)
Jiyong Park8fd61922018-11-08 02:50:25 +09001471 result := []apexFile{}
1472 for _, f := range filesInfo {
Jooyung Han344d5432019-08-23 11:17:39 +09001473 dest := filepath.Join(f.installDir, f.builtFile.Base())
1474 if !encountered[dest] {
1475 encountered[dest] = true
Jiyong Park8fd61922018-11-08 02:50:25 +09001476 result = append(result, f)
1477 }
1478 }
1479 return result
1480 }
1481 filesInfo = removeDup(filesInfo)
1482
1483 // to have consistent build rules
1484 sort.Slice(filesInfo, func(i, j int) bool {
1485 return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String()
1486 })
1487
Jiyong Park127b40b2019-09-30 16:04:35 +09001488 // check apex_available requirements
Jiyong Park3814f4d2019-12-02 13:08:53 +09001489 if !ctx.Host() && !a.testApex {
Jiyong Park583a2262019-10-08 20:55:38 +09001490 for _, fi := range filesInfo {
1491 if am, ok := fi.module.(android.ApexModule); ok {
Anton Hansson5053c292020-01-10 15:12:39 +00001492 // vndk {enabled:true} implies visibility to the vndk apex
1493 if ccm, ok := fi.module.(*cc.Module); ok && ccm.IsVndk() && a.vndkApex {
1494 continue
1495 }
1496
1497 if !am.AvailableFor(ctx.ModuleName()) && !whitelistedApexAvailable(ctx.ModuleName(), a.vndkApex, fi.module) {
Jiyong Park583a2262019-10-08 20:55:38 +09001498 ctx.ModuleErrorf("requires %q that is not available for the APEX", fi.module.Name())
Jiyong Park3814f4d2019-12-02 13:08:53 +09001499 // don't stop so that we can report other violations in the same run
Jiyong Park583a2262019-10-08 20:55:38 +09001500 }
Jiyong Park127b40b2019-09-30 16:04:35 +09001501 }
1502 }
1503 }
1504
Jiyong Park8fd61922018-11-08 02:50:25 +09001505 // prepend the name of this APEX to the module names. These names will be the names of
1506 // modules that will be defined if the APEX is flattened.
1507 for i := range filesInfo {
Jaewoong Jung1670ca02019-11-22 14:50:42 -08001508 filesInfo[i].moduleName = filesInfo[i].moduleName + "." + a.Name() + a.suffix
Jiyong Park8fd61922018-11-08 02:50:25 +09001509 }
1510
Jiyong Park8fd61922018-11-08 02:50:25 +09001511 a.installDir = android.PathForModuleInstall(ctx, "apex")
1512 a.filesInfo = filesInfo
Alex Light5098a612018-11-29 17:12:15 -08001513
Jooyung Han54aca7b2019-11-20 02:26:02 +09001514 if a.properties.ApexType != zipApex {
1515 if a.properties.File_contexts == nil {
1516 a.fileContexts = android.PathForSource(ctx, "system/sepolicy/apex", ctx.ModuleName()+"-file_contexts")
1517 } else {
1518 a.fileContexts = android.PathForModuleSrc(ctx, *a.properties.File_contexts)
1519 if a.Platform() {
1520 if matched, err := path.Match("system/sepolicy/**/*", a.fileContexts.String()); err != nil || !matched {
1521 ctx.PropertyErrorf("file_contexts", "should be under system/sepolicy, but %q", a.fileContexts)
1522 }
1523 }
1524 }
1525 if !android.ExistentPathForSource(ctx, a.fileContexts.String()).Valid() {
1526 ctx.PropertyErrorf("file_contexts", "cannot find file_contexts file: %q", a.fileContexts)
1527 return
1528 }
1529 }
1530
Jooyung Hand15aa1f2019-09-27 00:38:03 +09001531 // prepare apex_manifest.json
Jooyung Han01a3ee22019-11-02 02:52:25 +09001532 a.buildManifest(ctx, provideNativeLibs, requireNativeLibs)
1533
1534 a.setCertificateAndPrivateKey(ctx)
1535 if a.properties.ApexType == flattenedApex {
1536 a.buildFlattenedApex(ctx)
1537 } else {
1538 a.buildUnflattenedApex(ctx)
1539 }
1540
Jooyung Han002ab682020-01-08 01:57:58 +09001541 a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
Jiyong Park83dc74b2020-01-14 18:38:44 +09001542
1543 a.buildApexDependencyInfo(ctx)
Jooyung Han01a3ee22019-11-02 02:52:25 +09001544}
1545
Anton Hansson5053c292020-01-10 15:12:39 +00001546func whitelistedApexAvailable(apex string, is_vndk bool, module android.Module) bool {
1547 key := apex
1548 key = strings.Replace(key, "test_", "", 1)
1549 key = strings.Replace(key, "com.android.art.debug", "com.android.art", 1)
1550 key = strings.Replace(key, "com.android.art.release", "com.android.art", 1)
1551
1552 moduleName := module.Name()
1553 if strings.Contains(moduleName, "prebuilt_libclang_rt") {
1554 // This module has variants that depend on the product being built.
1555 moduleName = "prebuilt_libclang_rt"
1556 }
1557
1558 if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
1559 return true
1560 }
1561
1562 return false
1563}
1564
Jooyung Han344d5432019-08-23 11:17:39 +09001565func newApexBundle() *apexBundle {
Sundong Ahnabb64432019-10-22 13:58:29 +09001566 module := &apexBundle{}
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001567 module.AddProperties(&module.properties)
Alex Light9670d332019-01-29 18:07:33 -08001568 module.AddProperties(&module.targetProperties)
Jiyong Park5d790c32019-11-15 18:40:32 +09001569 module.AddProperties(&module.overridableProperties)
Alex Light5098a612018-11-29 17:12:15 -08001570 module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
Jiyong Park397e55e2018-10-24 21:09:55 +09001571 return class == android.Device && ctx.Config().DevicePrefer32BitExecutables()
1572 })
Alex Light5098a612018-11-29 17:12:15 -08001573 android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001574 android.InitDefaultableModule(module)
Jiyong Parkd1063c12019-07-17 20:08:41 +09001575 android.InitSdkAwareModule(module)
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08001576 android.InitOverridableModule(module, &module.overridableProperties.Overrides)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001577 return module
1578}
Jiyong Park30ca9372019-02-07 16:27:23 +09001579
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001580func ApexBundleFactory(testApex bool, artApex bool) android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09001581 bundle := newApexBundle()
1582 bundle.testApex = testApex
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001583 bundle.artApex = artApex
Jooyung Han344d5432019-08-23 11:17:39 +09001584 return bundle
1585}
1586
1587func testApexBundleFactory() android.Module {
1588 bundle := newApexBundle()
1589 bundle.testApex = true
1590 return bundle
1591}
1592
Jiyong Parkd1063c12019-07-17 20:08:41 +09001593func BundleFactory() android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09001594 return newApexBundle()
1595}
1596
Jiyong Park30ca9372019-02-07 16:27:23 +09001597//
1598// Defaults
1599//
1600type Defaults struct {
1601 android.ModuleBase
1602 android.DefaultsModuleBase
1603}
1604
Jiyong Park30ca9372019-02-07 16:27:23 +09001605func defaultsFactory() android.Module {
1606 return DefaultsFactory()
1607}
1608
1609func DefaultsFactory(props ...interface{}) android.Module {
1610 module := &Defaults{}
1611
1612 module.AddProperties(props...)
1613 module.AddProperties(
1614 &apexBundleProperties{},
1615 &apexTargetBundleProperties{},
Jooyung Hanf21c7972019-12-16 22:32:06 +09001616 &overridableProperties{},
Jiyong Park30ca9372019-02-07 16:27:23 +09001617 )
1618
1619 android.InitDefaultsModule(module)
1620 return module
1621}
Jiyong Park5d790c32019-11-15 18:40:32 +09001622
1623//
1624// OverrideApex
1625//
1626type OverrideApex struct {
1627 android.ModuleBase
1628 android.OverrideModuleBase
1629}
1630
1631func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) {
1632 // All the overrides happen in the base module.
1633}
1634
1635// override_apex is used to create an apex module based on another apex module
1636// by overriding some of its properties.
1637func overrideApexFactory() android.Module {
1638 m := &OverrideApex{}
1639 m.AddProperties(&overridableProperties{})
1640
1641 android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon)
1642 android.InitOverrideModule(m)
1643 return m
1644}