blob: 3d1b20e10631e12a724ad9d7f7a9c9d7c6af30b8 [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{
Anton Hanssonf17f2482020-01-16 09:11:57 +000078 "jacocoagent",
Anton Hansson5053c292020-01-10 15:12:39 +000079 "libadbconnection_server",
80 "libartd-disassembler",
81 "libbacktrace",
82 "libbase",
83 "libc++",
84 "libcrypto",
85 "libdexfile_support",
86 "libexpat",
87 "libicuuc",
88 "liblzma",
89 "libmeminfo",
90 "libprocinfo",
91 "libunwindstack",
92 "libvixl",
93 "libvixld",
94 "libz",
95 "libziparchive",
96 "prebuilt_libclang_rt",
97 }
98 //
99 // Module separator
100 //
101 m["com.android.bluetooth.updatable"] = []string{
102 "android.hardware.audio.common@5.0",
103 "android.hardware.bluetooth@1.0",
104 "android.hardware.bluetooth@1.1",
105 "android.hardware.bluetooth.a2dp@1.0",
106 "android.hardware.bluetooth.audio@2.0",
107 "android.hidl.safe_union@1.0",
108 "libbase",
109 "libbinderthreadstate",
110 "libbluetooth",
111 "libbluetooth_jni",
112 "libc++",
113 "libchrome",
114 "libcrypto",
115 "libcutils",
116 "libevent",
117 "libfmq",
118 "libhidlbase",
119 "libprocessgroup",
120 "libprotobuf-cpp-lite",
121 "libstatslog",
122 "libtinyxml2",
123 "libutils",
124 "libz",
125 }
126 //
127 // Module separator
128 //
129 m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"}
130 //
131 // Module separator
132 //
133 m["com.android.conscrypt"] = []string{"boringssl_self_test", "libc++", "libcrypto", "libssl"}
134 //
135 // Module separator
136 //
137 m["com.android.cronet"] = []string{"org.chromium.net.cronet", "prebuilt_libcronet.80.0.3986.0"}
138 //
139 // Module separator
140 //
141 m["com.android.incremental"] = []string{"libc++", "libdataloader", "libincfs"}
142 //
143 // Module separator
144 //
145 m["com.android.media"] = []string{
146 "android.hardware.cas@1.0",
147 "android.hardware.cas.native@1.0",
148 "android.hidl.allocator@1.0",
149 "android.hidl.memory@1.0",
150 "android.hidl.memory.token@1.0",
151 "android.hidl.token@1.0",
152 "android.hidl.token@1.0-utils",
153 "libaacextractor",
154 "libamrextractor",
155 "libaudioutils",
156 "libbase",
157 "libbinderthreadstate",
158 "libc++",
159 "libcrypto",
160 "libcutils",
161 "libflacextractor",
162 "libhidlbase",
163 "libhidlmemory",
164 "libmidiextractor",
165 "libmkvextractor",
166 "libmp3extractor",
167 "libmp4extractor",
168 "libmpeg2extractor",
169 "liboggextractor",
170 "libprocessgroup",
171 "libspeexresampler",
172 "libstagefright_flacdec",
173 "libutils",
174 "libwavextractor",
175 "updatable-media",
176 }
177 //
178 // Module separator
179 //
180 m["com.android.media.swcodec"] = []string{
181 "android.frameworks.bufferhub@1.0",
182 "android.hardware.common-ndk_platform",
183 "android.hardware.graphics.allocator@2.0",
184 "android.hardware.graphics.allocator@3.0",
185 "android.hardware.graphics.allocator@4.0",
186 "android.hardware.graphics.bufferqueue@1.0",
187 "android.hardware.graphics.bufferqueue@2.0",
188 "android.hardware.graphics.common@1.0",
189 "android.hardware.graphics.common@1.1",
190 "android.hardware.graphics.common@1.2",
191 "android.hardware.graphics.common-ndk_platform",
192 "android.hardware.graphics.mapper@2.0",
193 "android.hardware.graphics.mapper@2.1",
194 "android.hardware.graphics.mapper@3.0",
195 "android.hardware.graphics.mapper@4.0",
196 "android.hardware.media@1.0",
197 "android.hardware.media.bufferpool@2.0",
198 "android.hardware.media.c2@1.0",
199 "android.hardware.media.c2@1.1",
200 "android.hardware.media.omx@1.0",
201 "android.hidl.memory@1.0",
202 "android.hidl.memory.token@1.0",
203 "android.hidl.safe_union@1.0",
204 "android.hidl.token@1.0",
205 "android.hidl.token@1.0-utils",
206 "libaudioutils",
207 "libavservices_minijail",
208 "libbase",
209 "libbinderthreadstate",
210 "libc++",
211 "libcap",
212 "libcodec2",
213 "libcodec2_hidl@1.0",
214 "libcodec2_hidl@1.1",
215 "libcodec2_soft_aacdec",
216 "libcodec2_soft_aacenc",
217 "libcodec2_soft_amrnbdec",
218 "libcodec2_soft_amrnbenc",
219 "libcodec2_soft_amrwbdec",
220 "libcodec2_soft_amrwbenc",
221 "libcodec2_soft_av1dec_gav1",
222 "libcodec2_soft_avcdec",
223 "libcodec2_soft_avcenc",
224 "libcodec2_soft_common",
225 "libcodec2_soft_flacdec",
226 "libcodec2_soft_flacenc",
227 "libcodec2_soft_g711alawdec",
228 "libcodec2_soft_g711mlawdec",
229 "libcodec2_soft_gsmdec",
230 "libcodec2_soft_h263dec",
231 "libcodec2_soft_h263enc",
232 "libcodec2_soft_hevcdec",
233 "libcodec2_soft_hevcenc",
234 "libcodec2_soft_mp3dec",
235 "libcodec2_soft_mpeg2dec",
236 "libcodec2_soft_mpeg4dec",
237 "libcodec2_soft_mpeg4enc",
238 "libcodec2_soft_opusdec",
239 "libcodec2_soft_opusenc",
240 "libcodec2_soft_rawdec",
241 "libcodec2_soft_vorbisdec",
242 "libcodec2_soft_vp8dec",
243 "libcodec2_soft_vp8enc",
244 "libcodec2_soft_vp9dec",
245 "libcodec2_soft_vp9enc",
246 "libcodec2_vndk",
247 "libc_scudo",
248 "libcutils",
249 "libfmq",
250 "libgralloctypes",
251 "libhardware",
252 "libhidlbase",
253 "libhidlmemory",
254 "libion",
255 "libmedia_codecserviceregistrant",
256 "libminijail",
257 "libopus",
258 "libprocessgroup",
259 "libscudo_wrapper",
260 "libsfplugin_ccodec_utils",
261 "libspeexresampler",
262 "libstagefright_amrnb_common",
263 "libstagefright_bufferpool@2.0.1",
264 "libstagefright_bufferqueue_helper",
265 "libstagefright_enc_common",
266 "libstagefright_flacdec",
267 "libstagefright_foundation",
268 "libsync",
269 "libui",
270 "libutils",
271 "libvorbisidec",
272 "libvpx",
273 "mediaswcodec",
274 "prebuilt_libclang_rt",
275 }
276 //
277 // Module separator
278 //
279 m["com.android.mediaprovider"] = []string{"libfuse", "MediaProvider", "MediaProviderGoogle"}
280 //
281 // Module separator
282 //
283 m["com.android.permission"] = []string{"GooglePermissionController", "PermissionController"}
284 //
285 // Module separator
286 //
287 m["com.android.runtime"] = []string{
288 "libbase",
289 "libc++",
290 "libdexfile_support",
291 "liblzma",
292 "libunwindstack",
293 "prebuilt_libclang_rt",
294 }
295 //
296 // Module separator
297 //
298 m["com.android.resolv"] = []string{"libcrypto", "libnetd_resolv", "libssl"}
299 //
300 // Module separator
301 //
302 m["com.android.tethering"] = []string{"libbase", "libc++", "libnativehelper_compat_libc++"}
303 //
304 // Module separator
305 //
306 m["com.android.wifi"] = []string{
307 "libbase",
308 "libc++",
309 "libcutils",
310 "libprocessgroup",
311 "libutils",
312 "libwifi-jni",
313 "wifi-service-resources",
314 }
315 //
316 // Module separator
317 //
318 return m
319}
320
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900321func init() {
Jiyong Parkd1063c12019-07-17 20:08:41 +0900322 android.RegisterModuleType("apex", BundleFactory)
Alex Light0851b882019-02-07 13:20:53 -0800323 android.RegisterModuleType("apex_test", testApexBundleFactory)
Jooyung Han344d5432019-08-23 11:17:39 +0900324 android.RegisterModuleType("apex_vndk", vndkApexBundleFactory)
Jiyong Park30ca9372019-02-07 16:27:23 +0900325 android.RegisterModuleType("apex_defaults", defaultsFactory)
Jaewoong Jung939ebd52019-03-26 15:07:36 -0700326 android.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
Jiyong Park5d790c32019-11-15 18:40:32 +0900327 android.RegisterModuleType("override_apex", overrideApexFactory)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900328
Jooyung Han31c470b2019-10-18 16:26:59 +0900329 android.PreDepsMutators(RegisterPreDepsMutators)
Jiyong Parkd1063c12019-07-17 20:08:41 +0900330 android.PostDepsMutators(RegisterPostDepsMutators)
Jooyung Han7a78a922019-10-08 21:59:58 +0900331
332 android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
333 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
334 sort.Strings(*apexFileContextsInfos)
335 ctx.Strict("APEX_FILE_CONTEXTS_INFOS", strings.Join(*apexFileContextsInfos, " "))
336 })
Jiyong Parkd1063c12019-07-17 20:08:41 +0900337}
338
Jooyung Han31c470b2019-10-18 16:26:59 +0900339func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
340 ctx.TopDown("apex_vndk", apexVndkMutator).Parallel()
341 ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel()
342}
343
Jiyong Parkd1063c12019-07-17 20:08:41 +0900344func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
Jiyong Parka308ea12019-11-15 10:38:39 +0900345 ctx.BottomUp("apex_deps", apexDepsMutator)
Jiyong Parkd1063c12019-07-17 20:08:41 +0900346 ctx.BottomUp("apex", apexMutator).Parallel()
347 ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel()
348 ctx.BottomUp("apex_uses", apexUsesMutator).Parallel()
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900349}
350
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900351// Mark the direct and transitive dependencies of apex bundles so that they
352// can be built for the apex bundles.
Jiyong Parka308ea12019-11-15 10:38:39 +0900353func apexDepsMutator(mctx android.BottomUpMutatorContext) {
Alex Lightf98087f2019-02-04 14:45:06 -0800354 if a, ok := mctx.Module().(*apexBundle); ok {
Colin Crossa4925902018-11-16 11:36:28 -0800355 apexBundleName := mctx.ModuleName()
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900356 mctx.WalkDeps(func(child, parent android.Module) bool {
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900357 depName := mctx.OtherModuleName(child)
358 // If the parent is apexBundle, this child is directly depended.
359 _, directDep := parent.(*apexBundle)
Alex Light0851b882019-02-07 13:20:53 -0800360 if a.installable() && !a.testApex {
Alex Lightf98087f2019-02-04 14:45:06 -0800361 // TODO(b/123892969): Workaround for not having any way to annotate test-apexs
362 // non-installable apex's cannot be installed and so should not prevent libraries from being
363 // installed to the system.
364 android.UpdateApexDependency(apexBundleName, depName, directDep)
365 }
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900366
Jiyong Park3ff16992019-12-27 14:11:47 +0900367 if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() &&
368 (directDep || am.DepIsInSameApex(mctx, child)) {
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900369 am.BuildForApex(apexBundleName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900370 return true
371 } else {
372 return false
373 }
374 })
375 }
376}
377
378// Create apex variations if a module is included in APEX(s).
379func apexMutator(mctx android.BottomUpMutatorContext) {
380 if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900381 am.CreateApexVariations(mctx)
Jooyung Han54aca7b2019-11-20 02:26:02 +0900382 } else if _, ok := mctx.Module().(*apexBundle); ok {
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900383 // apex bundle itself is mutated so that it and its modules have same
384 // apex variant.
385 apexBundleName := mctx.ModuleName()
386 mctx.CreateVariations(apexBundleName)
Jiyong Park5d790c32019-11-15 18:40:32 +0900387 } else if o, ok := mctx.Module().(*OverrideApex); ok {
388 apexBundleName := o.GetOverriddenModuleName()
389 if apexBundleName == "" {
390 mctx.ModuleErrorf("base property is not set")
391 return
392 }
393 mctx.CreateVariations(apexBundleName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900394 }
Jiyong Park5d790c32019-11-15 18:40:32 +0900395
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900396}
Sundong Ahne9b55722019-09-06 17:37:42 +0900397
Jooyung Han7a78a922019-10-08 21:59:58 +0900398var (
399 apexFileContextsInfosKey = android.NewOnceKey("apexFileContextsInfosKey")
400 apexFileContextsInfosMutex sync.Mutex
401)
402
403func apexFileContextsInfos(config android.Config) *[]string {
404 return config.Once(apexFileContextsInfosKey, func() interface{} {
405 return &[]string{}
406 }).(*[]string)
407}
408
Jooyung Han54aca7b2019-11-20 02:26:02 +0900409func addFlattenedFileContextsInfos(ctx android.BaseModuleContext, fileContextsInfo string) {
Jooyung Han7a78a922019-10-08 21:59:58 +0900410 apexFileContextsInfosMutex.Lock()
411 defer apexFileContextsInfosMutex.Unlock()
412 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
Jooyung Han54aca7b2019-11-20 02:26:02 +0900413 *apexFileContextsInfos = append(*apexFileContextsInfos, fileContextsInfo)
Jooyung Han7a78a922019-10-08 21:59:58 +0900414}
415
Sundong Ahne9b55722019-09-06 17:37:42 +0900416func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
Sundong Ahne8fb7242019-09-17 13:50:45 +0900417 if ab, ok := mctx.Module().(*apexBundle); ok {
Sundong Ahnabb64432019-10-22 13:58:29 +0900418 var variants []string
419 switch proptools.StringDefault(ab.properties.Payload_type, "image") {
420 case "image":
421 variants = append(variants, imageApexType, flattenedApexType)
422 case "zip":
423 variants = append(variants, zipApexType)
424 case "both":
425 variants = append(variants, imageApexType, zipApexType, flattenedApexType)
426 default:
Sundong Ahnd95aa2d2019-10-08 19:34:03 +0900427 mctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type)
Sundong Ahnabb64432019-10-22 13:58:29 +0900428 return
429 }
430
431 modules := mctx.CreateLocalVariations(variants...)
432
433 for i, v := range variants {
434 switch v {
435 case imageApexType:
436 modules[i].(*apexBundle).properties.ApexType = imageApex
437 case zipApexType:
438 modules[i].(*apexBundle).properties.ApexType = zipApex
439 case flattenedApexType:
440 modules[i].(*apexBundle).properties.ApexType = flattenedApex
Jooyung Han91df2082019-11-20 01:49:42 +0900441 if !mctx.Config().FlattenApex() && ab.Platform() {
Sundong Ahnd95aa2d2019-10-08 19:34:03 +0900442 modules[i].(*apexBundle).MakeAsSystemExt()
443 }
Sundong Ahnabb64432019-10-22 13:58:29 +0900444 }
Sundong Ahne9b55722019-09-06 17:37:42 +0900445 }
Jiyong Park5d790c32019-11-15 18:40:32 +0900446 } else if _, ok := mctx.Module().(*OverrideApex); ok {
447 mctx.CreateVariations(imageApexType, flattenedApexType)
Sundong Ahne9b55722019-09-06 17:37:42 +0900448 }
449}
450
Jooyung Han5c998b92019-06-27 11:30:33 +0900451func apexUsesMutator(mctx android.BottomUpMutatorContext) {
452 if ab, ok := mctx.Module().(*apexBundle); ok {
453 mctx.AddFarVariationDependencies(nil, usesTag, ab.properties.Uses...)
454 }
455}
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900456
Jooyung Handc782442019-11-01 03:14:38 +0900457var (
458 useVendorWhitelistKey = android.NewOnceKey("useVendorWhitelist")
459)
460
461// useVendorWhitelist returns the list of APEXes which are allowed to use_vendor.
462// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__,
463// which may cause compatibility issues. (e.g. libbinder)
464// Even though libbinder restricts its availability via 'apex_available' property and relies on
465// yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules
466// to avoid similar problems.
467func useVendorWhitelist(config android.Config) []string {
468 return config.Once(useVendorWhitelistKey, func() interface{} {
469 return []string{
470 // swcodec uses "vendor" variants for smaller size
471 "com.android.media.swcodec",
472 "test_com.android.media.swcodec",
473 }
474 }).([]string)
475}
476
477// setUseVendorWhitelistForTest overrides useVendorWhitelist and must be
478// called before the first call to useVendorWhitelist()
479func setUseVendorWhitelistForTest(config android.Config, whitelist []string) {
480 config.Once(useVendorWhitelistKey, func() interface{} {
481 return whitelist
482 })
483}
484
Alex Light9670d332019-01-29 18:07:33 -0800485type apexNativeDependencies struct {
486 // List of native libraries
487 Native_shared_libs []string
Jooyung Han344d5432019-08-23 11:17:39 +0900488
Alex Light9670d332019-01-29 18:07:33 -0800489 // List of native executables
490 Binaries []string
Jooyung Han344d5432019-08-23 11:17:39 +0900491
Roland Levillain630846d2019-06-26 12:48:34 +0100492 // List of native tests
493 Tests []string
Alex Light9670d332019-01-29 18:07:33 -0800494}
Jooyung Han344d5432019-08-23 11:17:39 +0900495
Alex Light9670d332019-01-29 18:07:33 -0800496type apexMultilibProperties struct {
497 // Native dependencies whose compile_multilib is "first"
498 First apexNativeDependencies
499
500 // Native dependencies whose compile_multilib is "both"
501 Both apexNativeDependencies
502
503 // Native dependencies whose compile_multilib is "prefer32"
504 Prefer32 apexNativeDependencies
505
506 // Native dependencies whose compile_multilib is "32"
507 Lib32 apexNativeDependencies
508
509 // Native dependencies whose compile_multilib is "64"
510 Lib64 apexNativeDependencies
511}
512
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900513type apexBundleProperties struct {
514 // Json manifest file describing meta info of this APEX bundle. Default:
Dario Freni4abb1dc2018-11-20 18:04:58 +0000515 // "apex_manifest.json"
Colin Cross27b922f2019-03-04 22:35:41 -0800516 Manifest *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900517
Jiyong Park40e26a22019-02-08 02:53:06 +0900518 // AndroidManifest.xml file used for the zip container of this APEX bundle.
519 // If unspecified, a default one is automatically generated.
Colin Cross27b922f2019-03-04 22:35:41 -0800520 AndroidManifest *string `android:"path"`
Jiyong Park40e26a22019-02-08 02:53:06 +0900521
Roland Levillain411c5842019-09-19 16:37:20 +0100522 // Canonical name of the APEX bundle. Used to determine the path to the activated APEX on
523 // device (/apex/<apex_name>).
524 // If unspecified, defaults to the value of name.
Jiyong Park05e70dd2019-03-18 14:26:32 +0900525 Apex_name *string
526
Jiyong Parkd0a65ba2018-11-10 06:37:15 +0900527 // Determines the file contexts file for setting security context to each file in this APEX bundle.
Jooyung Han54aca7b2019-11-20 02:26:02 +0900528 // For platform APEXes, this should points to a file under /system/sepolicy
529 // Default: /system/sepolicy/apex/<module_name>_file_contexts.
530 File_contexts *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900531
532 // List of native shared libs that are embedded inside this APEX bundle
533 Native_shared_libs []string
534
Roland Levillain630846d2019-06-26 12:48:34 +0100535 // List of executables that are embedded inside this APEX bundle
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900536 Binaries []string
537
538 // List of java libraries that are embedded inside this APEX bundle
539 Java_libs []string
540
541 // List of prebuilt files that are embedded inside this APEX bundle
542 Prebuilts []string
Jiyong Parkff1458f2018-10-12 21:49:38 +0900543
Roland Levillain630846d2019-06-26 12:48:34 +0100544 // List of tests that are embedded inside this APEX bundle
545 Tests []string
546
Jiyong Parkff1458f2018-10-12 21:49:38 +0900547 // Name of the apex_key module that provides the private key to sign APEX
548 Key *string
Jiyong Park397e55e2018-10-24 21:09:55 +0900549
Alex Light5098a612018-11-29 17:12:15 -0800550 // The type of APEX to build. Controls what the APEX payload is. Either
551 // 'image', 'zip' or 'both'. Default: 'image'.
552 Payload_type *string
553
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900554 // The name of a certificate in the default certificate directory, blank to use the default product certificate,
555 // or an android_app_certificate module name in the form ":module".
556 Certificate *string
557
Jiyong Park92c0f9c2018-12-13 23:14:57 +0900558 // Whether this APEX is installable to one of the partitions. Default: true.
559 Installable *bool
560
Jiyong Parkda6eb592018-12-19 17:12:36 +0900561 // For native libraries and binaries, use the vendor variant instead of the core (platform) variant.
562 // Default is false.
563 Use_vendor *bool
564
Alex Lightfc0bd7c2019-01-29 18:31:59 -0800565 // For telling the apex to ignore special handling for system libraries such as bionic. Default is false.
566 Ignore_system_library_special_case *bool
567
Alex Light9670d332019-01-29 18:07:33 -0800568 Multilib apexMultilibProperties
Jiyong Park235e67c2019-02-09 11:50:56 +0900569
Jiyong Parkf97782b2019-02-13 20:28:58 +0900570 // List of sanitizer names that this APEX is enabled for
571 SanitizerNames []string `blueprint:"mutated"`
Jooyung Han5c998b92019-06-27 11:30:33 +0900572
Jiyong Parkee9a98d2019-08-09 14:44:36 +0900573 PreventInstall bool `blueprint:"mutated"`
574
575 HideFromMake bool `blueprint:"mutated"`
576
Jooyung Han5c998b92019-06-27 11:30:33 +0900577 // Indicates this APEX provides C++ shared libaries to other APEXes. Default: false.
578 Provide_cpp_shared_libs *bool
579
580 // List of providing APEXes' names so that this APEX can depend on provided shared libraries.
581 Uses []string
Nikita Ioffe5d5ae762019-08-31 14:38:05 +0100582
583 // A txt file containing list of files that are whitelisted to be included in this APEX.
584 Whitelisted_files *string
Sundong Ahne1f05aa2019-08-27 13:55:42 +0900585
Sundong Ahnabb64432019-10-22 13:58:29 +0900586 // package format of this apex variant; could be non-flattened, flattened, or zip.
587 // imageApex, zipApex or flattened
588 ApexType apexPackaging `blueprint:"mutated"`
Sundong Ahne8fb7242019-09-17 13:50:45 +0900589
Jiyong Parkd1063c12019-07-17 20:08:41 +0900590 // List of SDKs that are used to build this APEX. A reference to an SDK should be either
591 // `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current`
592 // is implied. This value affects all modules included in this APEX. In other words, they are
593 // also built with the SDKs specified here.
594 Uses_sdks []string
Jiyong Park5d790c32019-11-15 18:40:32 +0900595
Nikita Ioffec72b5dd2019-12-07 17:30:22 +0000596 // Whenever apex_payload.img of the APEX should include dm-verity hashtree.
597 // Should be only used in tests#.
598 Test_only_no_hashtree *bool
Jooyung Han214bf372019-11-12 13:03:50 +0900599
600 // Whether this APEX should support Android10. Default is false. If this is set true, then apex_manifest.json is bundled as well
601 // because Android10 requires legacy apex_manifest.json instead of apex_manifest.pb
602 Legacy_android10_support *bool
Jiyong Park956305c2020-01-09 12:32:06 +0900603
604 IsCoverageVariant bool `blueprint:"mutated"`
Alex Light9670d332019-01-29 18:07:33 -0800605}
606
607type apexTargetBundleProperties struct {
608 Target struct {
609 // Multilib properties only for android.
610 Android struct {
611 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +0900612 }
Jooyung Han344d5432019-08-23 11:17:39 +0900613
Alex Light9670d332019-01-29 18:07:33 -0800614 // Multilib properties only for host.
615 Host struct {
616 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +0900617 }
Jooyung Han344d5432019-08-23 11:17:39 +0900618
Alex Light9670d332019-01-29 18:07:33 -0800619 // Multilib properties only for host linux_bionic.
620 Linux_bionic struct {
621 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +0900622 }
Jooyung Han344d5432019-08-23 11:17:39 +0900623
Alex Light9670d332019-01-29 18:07:33 -0800624 // Multilib properties only for host linux_glibc.
625 Linux_glibc struct {
626 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +0900627 }
628 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900629}
630
Jiyong Park5d790c32019-11-15 18:40:32 +0900631type overridableProperties struct {
632 // List of APKs to package inside APEX
633 Apps []string
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -0800634
635 // Names of modules to be overridden. Listed modules can only be other binaries
636 // (in Make or Soong).
637 // This does not completely prevent installation of the overridden binaries, but if both
638 // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
639 // from PRODUCT_PACKAGES.
640 Overrides []string
Jiyong Park5d790c32019-11-15 18:40:32 +0900641}
642
Alex Light5098a612018-11-29 17:12:15 -0800643type apexPackaging int
644
645const (
646 imageApex apexPackaging = iota
647 zipApex
Sundong Ahnabb64432019-10-22 13:58:29 +0900648 flattenedApex
Alex Light5098a612018-11-29 17:12:15 -0800649)
650
Sundong Ahnabb64432019-10-22 13:58:29 +0900651// The suffix for the output "file", not the module
Alex Light5098a612018-11-29 17:12:15 -0800652func (a apexPackaging) suffix() string {
653 switch a {
654 case imageApex:
655 return imageApexSuffix
656 case zipApex:
657 return zipApexSuffix
Alex Light5098a612018-11-29 17:12:15 -0800658 default:
Roland Levillain4644b222019-07-31 14:09:17 +0100659 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -0800660 }
661}
662
663func (a apexPackaging) name() string {
664 switch a {
665 case imageApex:
666 return imageApexType
667 case zipApex:
668 return zipApexType
Alex Light5098a612018-11-29 17:12:15 -0800669 default:
Roland Levillain4644b222019-07-31 14:09:17 +0100670 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -0800671 }
672}
673
Jiyong Parkf653b052019-11-18 15:39:01 +0900674type apexFileClass int
675
676const (
677 etc apexFileClass = iota
678 nativeSharedLib
679 nativeExecutable
680 shBinary
681 pyBinary
682 goBinary
683 javaSharedLib
684 nativeTest
685 app
686)
687
Jiyong Park8fd61922018-11-08 02:50:25 +0900688func (class apexFileClass) NameInMake() string {
689 switch class {
690 case etc:
691 return "ETC"
692 case nativeSharedLib:
693 return "SHARED_LIBRARIES"
Alex Light778127a2019-02-27 14:19:50 -0800694 case nativeExecutable, shBinary, pyBinary, goBinary:
Jiyong Park8fd61922018-11-08 02:50:25 +0900695 return "EXECUTABLES"
696 case javaSharedLib:
697 return "JAVA_LIBRARIES"
Roland Levillain630846d2019-06-26 12:48:34 +0100698 case nativeTest:
699 return "NATIVE_TESTS"
Sundong Ahne1f05aa2019-08-27 13:55:42 +0900700 case app:
Jiyong Parkf383f7c2019-10-11 20:46:25 +0900701 // b/142537672 Why isn't this APP? We want to have full control over
702 // the paths and file names of the apk file under the flattend APEX.
703 // If this is set to APP, then the paths and file names are modified
704 // by the Make build system. For example, it is installed to
705 // /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of
706 // /system/apex/<apexname>/app/<Appname> because the build system automatically
707 // appends module name (which is <apexname>.<Appname> to the path.
708 return "ETC"
Jiyong Park8fd61922018-11-08 02:50:25 +0900709 default:
Roland Levillain4644b222019-07-31 14:09:17 +0100710 panic(fmt.Errorf("unknown class %d", class))
Jiyong Park8fd61922018-11-08 02:50:25 +0900711 }
712}
713
Jiyong Parkf653b052019-11-18 15:39:01 +0900714// apexFile represents a file in an APEX bundle
Jiyong Park8fd61922018-11-08 02:50:25 +0900715type apexFile struct {
716 builtFile android.Path
717 moduleName string
Jiyong Park8fd61922018-11-08 02:50:25 +0900718 installDir string
719 class apexFileClass
Jiyong Parka8894842018-12-19 17:36:39 +0900720 module android.Module
Jiyong Parkf653b052019-11-18 15:39:01 +0900721 // list of symlinks that will be created in installDir that point to this apexFile
722 symlinks []string
723 transitiveDep bool
Jiyong Park1833cef2019-12-13 13:28:36 +0900724 moduleDir string
Jiyong Park7afd1072019-12-30 16:56:33 +0900725
726 requiredModuleNames []string
727 targetRequiredModuleNames []string
728 hostRequiredModuleNames []string
Jiyong Park618922e2020-01-08 13:35:43 +0900729
730 jacocoReportClassesFile android.Path // only for javalibs and apps
Jiyong Parkf653b052019-11-18 15:39:01 +0900731}
732
Jiyong Park1833cef2019-12-13 13:28:36 +0900733func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile {
734 ret := apexFile{
Jiyong Parkf653b052019-11-18 15:39:01 +0900735 builtFile: builtFile,
736 moduleName: moduleName,
737 installDir: installDir,
738 class: class,
739 module: module,
740 }
Jiyong Park1833cef2019-12-13 13:28:36 +0900741 if module != nil {
742 ret.moduleDir = ctx.OtherModuleDir(module)
Jiyong Park7afd1072019-12-30 16:56:33 +0900743 ret.requiredModuleNames = module.RequiredModuleNames()
744 ret.targetRequiredModuleNames = module.TargetRequiredModuleNames()
745 ret.hostRequiredModuleNames = module.HostRequiredModuleNames()
Jiyong Park1833cef2019-12-13 13:28:36 +0900746 }
747 return ret
Jiyong Parkf653b052019-11-18 15:39:01 +0900748}
749
750func (af *apexFile) Ok() bool {
Jiyong Park479321d2019-12-16 11:47:12 +0900751 return af.builtFile != nil && af.builtFile.String() != ""
Jiyong Park8fd61922018-11-08 02:50:25 +0900752}
753
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900754type apexBundle struct {
755 android.ModuleBase
756 android.DefaultableModuleBase
Jiyong Park5d790c32019-11-15 18:40:32 +0900757 android.OverridableModuleBase
Jiyong Parkd1063c12019-07-17 20:08:41 +0900758 android.SdkBase
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900759
Jiyong Park5d790c32019-11-15 18:40:32 +0900760 properties apexBundleProperties
761 targetProperties apexTargetBundleProperties
Jiyong Park5d790c32019-11-15 18:40:32 +0900762 overridableProperties overridableProperties
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900763
Jooyung Hanf21c7972019-12-16 22:32:06 +0900764 // specific to apex_vndk modules
765 vndkProperties apexVndkProperties
766
Colin Crossa4925902018-11-16 11:36:28 -0800767 bundleModuleFile android.WritablePath
Sundong Ahnabb64432019-10-22 13:58:29 +0900768 outputFile android.WritablePath
Colin Cross70dda7e2019-10-01 22:05:35 -0700769 installDir android.InstallPath
Jiyong Park8fd61922018-11-08 02:50:25 +0900770
Jiyong Park03b68dd2019-07-26 23:20:40 +0900771 prebuiltFileToDelete string
772
Jiyong Park42cca6c2019-04-01 11:15:50 +0900773 public_key_file android.Path
774 private_key_file android.Path
Jiyong Park0ca3ce82019-02-18 15:25:04 +0900775
776 container_certificate_file android.Path
777 container_private_key_file android.Path
778
Jooyung Han54aca7b2019-11-20 02:26:02 +0900779 fileContexts android.Path
780
Jiyong Park8fd61922018-11-08 02:50:25 +0900781 // list of files to be included in this apex
782 filesInfo []apexFile
783
Jiyong Park956305c2020-01-09 12:32:06 +0900784 // list of module names that should be installed along with this APEX
785 requiredDeps []string
786
787 // list of module names that this APEX is depending on (to be shown via *-deps-info target)
Jiyong Parkac2bacd2019-02-20 21:49:26 +0900788 externalDeps []string
Jiyong Park956305c2020-01-09 12:32:06 +0900789 // list of module names that this APEX is including (to be shown via *-deps-info target)
790 internalDeps []string
Jiyong Parkac2bacd2019-02-20 21:49:26 +0900791
Sundong Ahnabb64432019-10-22 13:58:29 +0900792 testApex bool
793 vndkApex bool
Ulyana Trafimovichde534412019-11-08 10:51:01 +0000794 artApex bool
Sundong Ahnabb64432019-10-22 13:58:29 +0900795 primaryApexType bool
Jooyung Hane1633032019-08-01 17:41:43 +0900796
Jooyung Han214bf372019-11-12 13:03:50 +0900797 manifestJsonOut android.WritablePath
798 manifestPbOut android.WritablePath
Jooyung Han72bd2f82019-10-23 16:46:38 +0900799
Jooyung Han002ab682020-01-08 01:57:58 +0900800 // list of commands to create symlinks for backward compatibility.
Jooyung Han72bd2f82019-10-23 16:46:38 +0900801 // these commands will be attached as LOCAL_POST_INSTALL_CMD to
Jooyung Han002ab682020-01-08 01:57:58 +0900802 // apex package itself(for unflattened build) or apex_manifest(for flattened build)
Jooyung Han72bd2f82019-10-23 16:46:38 +0900803 // so that compat symlinks are always installed regardless of TARGET_FLATTEN_APEX setting.
804 compatSymlinks []string
Sundong Ahnabb64432019-10-22 13:58:29 +0900805
806 // Suffix of module name in Android.mk
807 // ".flattened", ".apex", ".zipapex", or ""
808 suffix string
Jiyong Park3a1602e2020-01-14 14:39:19 +0900809
810 installedFilesFile android.WritablePath
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900811}
812
Jiyong Park397e55e2018-10-24 21:09:55 +0900813func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
Roland Levillain630846d2019-06-26 12:48:34 +0100814 native_shared_libs []string, binaries []string, tests []string,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700815 target android.Target, imageVariation string) {
Jiyong Park397e55e2018-10-24 21:09:55 +0900816 // Use *FarVariation* to be able to depend on modules having
817 // conflicting variations with this module. This is required since
818 // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64'
819 // for native shared libs.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700820 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Parkda6eb592018-12-19 17:12:36 +0900821 {Mutator: "image", Variation: imageVariation},
Jiyong Park397e55e2018-10-24 21:09:55 +0900822 {Mutator: "link", Variation: "shared"},
Jiyong Park28d395a2018-12-07 22:42:47 +0900823 {Mutator: "version", Variation: ""}, // "" is the non-stub variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700824 }...), sharedLibTag, native_shared_libs...)
Jiyong Park397e55e2018-10-24 21:09:55 +0900825
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700826 ctx.AddFarVariationDependencies(append(target.Variations(),
827 blueprint.Variation{Mutator: "image", Variation: imageVariation}),
828 executableTag, binaries...)
Roland Levillain630846d2019-06-26 12:48:34 +0100829
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700830 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +0100831 {Mutator: "image", Variation: imageVariation},
Roland Levillain9b5fde92019-06-28 15:41:19 +0100832 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700833 }...), testTag, tests...)
Jiyong Park397e55e2018-10-24 21:09:55 +0900834}
835
Alex Light9670d332019-01-29 18:07:33 -0800836func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
837 if ctx.Os().Class == android.Device {
838 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil)
839 } else {
840 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil)
841 if ctx.Os().Bionic() {
842 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil)
843 } else {
844 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil)
845 }
846 }
847}
848
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900849func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
Jooyung Handc782442019-11-01 03:14:38 +0900850 if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorWhitelist(ctx.Config())) {
851 ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
852 }
853
Jiyong Park397e55e2018-10-24 21:09:55 +0900854 targets := ctx.MultiTargets()
Jiyong Park7c1dc612019-01-05 11:15:24 +0900855 config := ctx.DeviceConfig()
Alex Light9670d332019-01-29 18:07:33 -0800856
857 a.combineProperties(ctx)
858
Jiyong Park397e55e2018-10-24 21:09:55 +0900859 has32BitTarget := false
860 for _, target := range targets {
861 if target.Arch.ArchType.Multilib == "lib32" {
862 has32BitTarget = true
863 }
864 }
865 for i, target := range targets {
866 // When multilib.* is omitted for native_shared_libs, it implies
867 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700868 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Park7c1dc612019-01-05 11:15:24 +0900869 {Mutator: "image", Variation: a.getImageVariation(config)},
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900870 {Mutator: "link", Variation: "shared"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700871 }...), sharedLibTag, a.properties.Native_shared_libs...)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900872
Roland Levillain630846d2019-06-26 12:48:34 +0100873 // When multilib.* is omitted for tests, it implies
874 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700875 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +0100876 {Mutator: "image", Variation: a.getImageVariation(config)},
Roland Levillain9b5fde92019-06-28 15:41:19 +0100877 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700878 }...), testTag, a.properties.Tests...)
Roland Levillain630846d2019-06-26 12:48:34 +0100879
Jiyong Park397e55e2018-10-24 21:09:55 +0900880 // Add native modules targetting both ABIs
881 addDependenciesForNativeModules(ctx,
882 a.properties.Multilib.Both.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100883 a.properties.Multilib.Both.Binaries,
884 a.properties.Multilib.Both.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700885 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900886 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900887
Alex Light3d673592019-01-18 14:37:31 -0800888 isPrimaryAbi := i == 0
889 if isPrimaryAbi {
Jiyong Park397e55e2018-10-24 21:09:55 +0900890 // When multilib.* is omitted for binaries, it implies
891 // multilib.first.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700892 ctx.AddFarVariationDependencies(append(target.Variations(),
893 blueprint.Variation{Mutator: "image", Variation: a.getImageVariation(config)}),
894 executableTag, a.properties.Binaries...)
Jiyong Park397e55e2018-10-24 21:09:55 +0900895
896 // Add native modules targetting the first ABI
897 addDependenciesForNativeModules(ctx,
898 a.properties.Multilib.First.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100899 a.properties.Multilib.First.Binaries,
900 a.properties.Multilib.First.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700901 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900902 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900903 }
904
905 switch target.Arch.ArchType.Multilib {
906 case "lib32":
907 // Add native modules targetting 32-bit ABI
908 addDependenciesForNativeModules(ctx,
909 a.properties.Multilib.Lib32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100910 a.properties.Multilib.Lib32.Binaries,
911 a.properties.Multilib.Lib32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700912 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900913 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900914
915 addDependenciesForNativeModules(ctx,
916 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100917 a.properties.Multilib.Prefer32.Binaries,
918 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700919 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900920 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900921 case "lib64":
922 // Add native modules targetting 64-bit ABI
923 addDependenciesForNativeModules(ctx,
924 a.properties.Multilib.Lib64.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100925 a.properties.Multilib.Lib64.Binaries,
926 a.properties.Multilib.Lib64.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700927 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900928 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900929
930 if !has32BitTarget {
931 addDependenciesForNativeModules(ctx,
932 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100933 a.properties.Multilib.Prefer32.Binaries,
934 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700935 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900936 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900937 }
Peter Collingbourne3478bb22019-04-24 14:41:12 -0700938
939 if strings.HasPrefix(ctx.ModuleName(), "com.android.runtime") && target.Os.Class == android.Device {
940 for _, sanitizer := range ctx.Config().SanitizeDevice() {
941 if sanitizer == "hwaddress" {
942 addDependenciesForNativeModules(ctx,
943 []string{"libclang_rt.hwasan-aarch64-android"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700944 nil, nil, target, a.getImageVariation(config))
Peter Collingbourne3478bb22019-04-24 14:41:12 -0700945 break
946 }
947 }
948 }
Jiyong Park397e55e2018-10-24 21:09:55 +0900949 }
950
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900951 }
952
Jiyong Parkce6aadc2019-11-20 13:58:28 +0900953 // For prebuilt_etc, use the first variant (64 on 64/32bit device,
954 // 32 on 32bit device) regardless of the TARGET_PREFER_* setting.
955 // b/144532908
956 archForPrebuiltEtc := config.Arches()[0]
957 for _, arch := range config.Arches() {
958 // Prefer 64-bit arch if there is any
959 if arch.ArchType.Multilib == "lib64" {
960 archForPrebuiltEtc = arch
961 break
962 }
963 }
964 ctx.AddFarVariationDependencies([]blueprint.Variation{
965 {Mutator: "os", Variation: ctx.Os().String()},
966 {Mutator: "arch", Variation: archForPrebuiltEtc.String()},
967 }, prebuiltTag, a.properties.Prebuilts...)
968
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700969 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
970 javaLibTag, a.properties.Java_libs...)
Jiyong Parkff1458f2018-10-12 21:49:38 +0900971
Ulya Trafimovich44561882020-01-03 13:25:54 +0000972 // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
973 if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
974 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
975 javaLibTag, "jacocoagent")
976 }
977
Jiyong Park23c52b02019-02-02 13:13:47 +0900978 if String(a.properties.Key) == "" {
979 ctx.ModuleErrorf("key is missing")
980 return
981 }
982 ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key))
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900983
Jiyong Parkb2742fd2019-02-11 11:38:15 +0900984 cert := android.SrcIsModule(a.getCertString(ctx))
Jiyong Park23c52b02019-02-02 13:13:47 +0900985 if cert != "" {
986 ctx.AddDependency(ctx.Module(), certificateTag, cert)
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900987 }
Jiyong Parkd1063c12019-07-17 20:08:41 +0900988
989 // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks
990 if len(a.properties.Uses_sdks) > 0 {
991 sdkRefs := []android.SdkRef{}
992 for _, str := range a.properties.Uses_sdks {
993 parsed := android.ParseSdkRef(ctx, str, "uses_sdks")
994 sdkRefs = append(sdkRefs, parsed)
995 }
996 a.BuildWithSdks(sdkRefs)
997 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900998}
999
Jiyong Park5d790c32019-11-15 18:40:32 +09001000func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
1001 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1002 androidAppTag, a.overridableProperties.Apps...)
1003}
1004
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09001005func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
1006 // direct deps of an APEX bundle are all part of the APEX bundle
1007 return true
1008}
1009
Colin Cross0ea8ba82019-06-06 14:33:29 -07001010func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
Jooyung Han27151d92019-12-16 17:45:32 +09001011 moduleName := ctx.ModuleName()
1012 // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the OVERRIDE_* list,
1013 // we check with the pseudo module name to see if its certificate is overridden.
1014 if a.vndkApex {
1015 moduleName = vndkApexName
1016 }
1017 certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName)
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001018 if overridden {
Jaewoong Jungacb6db32019-02-28 16:22:30 +00001019 return ":" + certificate
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001020 }
1021 return String(a.properties.Certificate)
1022}
1023
Colin Cross41955e82019-05-29 14:40:35 -07001024func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
1025 switch tag {
1026 case "":
Sundong Ahnabb64432019-10-22 13:58:29 +09001027 return android.Paths{a.outputFile}, nil
Colin Cross41955e82019-05-29 14:40:35 -07001028 default:
1029 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
Jiyong Park5a832022018-12-20 09:54:35 +09001030 }
Jiyong Park74e240b2018-11-27 21:27:08 +09001031}
1032
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001033func (a *apexBundle) installable() bool {
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001034 return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001035}
1036
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001037func (a *apexBundle) testOnlyShouldSkipHashtreeGeneration() bool {
1038 return proptools.Bool(a.properties.Test_only_no_hashtree)
1039}
1040
Jiyong Park7c1dc612019-01-05 11:15:24 +09001041func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
Jooyung Han31c470b2019-10-18 16:26:59 +09001042 if a.vndkApex {
Colin Cross7228ecd2019-11-18 16:00:16 -08001043 return cc.VendorVariationPrefix + a.vndkVersion(config)
Jooyung Han31c470b2019-10-18 16:26:59 +09001044 }
Jiyong Park7c1dc612019-01-05 11:15:24 +09001045 if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) {
Colin Cross7228ecd2019-11-18 16:00:16 -08001046 return cc.VendorVariationPrefix + config.PlatformVndkVersion()
Jiyong Parkda6eb592018-12-19 17:12:36 +09001047 } else {
Colin Cross7228ecd2019-11-18 16:00:16 -08001048 return android.CoreVariation
Jiyong Parkda6eb592018-12-19 17:12:36 +09001049 }
1050}
1051
Jiyong Parkf97782b2019-02-13 20:28:58 +09001052func (a *apexBundle) EnableSanitizer(sanitizerName string) {
1053 if !android.InList(sanitizerName, a.properties.SanitizerNames) {
1054 a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName)
1055 }
1056}
1057
Jiyong Park388ef3f2019-01-28 19:47:32 +09001058func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
Jiyong Parkf97782b2019-02-13 20:28:58 +09001059 if android.InList(sanitizerName, a.properties.SanitizerNames) {
1060 return true
Jiyong Park235e67c2019-02-09 11:50:56 +09001061 }
1062
1063 // Then follow the global setting
Jiyong Park388ef3f2019-01-28 19:47:32 +09001064 globalSanitizerNames := []string{}
1065 if a.Host() {
1066 globalSanitizerNames = ctx.Config().SanitizeHost()
1067 } else {
1068 arches := ctx.Config().SanitizeDeviceArch()
1069 if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
1070 globalSanitizerNames = ctx.Config().SanitizeDevice()
1071 }
1072 }
1073 return android.InList(sanitizerName, globalSanitizerNames)
Jiyong Park379de2f2018-12-19 02:47:14 +09001074}
1075
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001076func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
1077 return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
1078}
1079
1080func (a *apexBundle) PreventInstall() {
1081 a.properties.PreventInstall = true
1082}
1083
1084func (a *apexBundle) HideFromMake() {
1085 a.properties.HideFromMake = true
1086}
1087
Jiyong Park956305c2020-01-09 12:32:06 +09001088func (a *apexBundle) MarkAsCoverageVariant(coverage bool) {
1089 a.properties.IsCoverageVariant = coverage
1090}
1091
Jiyong Parkf653b052019-11-18 15:39:01 +09001092// TODO(jiyong) move apexFileFor* close to the apexFile type definition
Jiyong Park1833cef2019-12-13 13:28:36 +09001093func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001094 // Decide the APEX-local directory by the multilib of the library
1095 // In the future, we may query this to the module.
Jiyong Parkf653b052019-11-18 15:39:01 +09001096 var dirInApex string
Martin Stjernholm279de572019-09-10 23:18:20 +01001097 switch ccMod.Arch().ArchType.Multilib {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001098 case "lib32":
1099 dirInApex = "lib"
1100 case "lib64":
1101 dirInApex = "lib64"
1102 }
Martin Stjernholm279de572019-09-10 23:18:20 +01001103 dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001104 if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
Martin Stjernholm279de572019-09-10 23:18:20 +01001105 dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001106 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001107 if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) {
Martin Stjernholm279de572019-09-10 23:18:20 +01001108 // Special case for Bionic libs and other libs installed with them. This is
1109 // to prevent those libs from being included in the search path
1110 // /apex/com.android.runtime/${LIB}. This exclusion is required because
1111 // those libs in the Runtime APEX are available via the legacy paths in
1112 // /system/lib/. By the init process, the libs in the APEX are bind-mounted
1113 // to the legacy paths and thus will be loaded into the default linker
1114 // namespace (aka "platform" namespace). If the libs are directly in
1115 // /apex/com.android.runtime/${LIB} then the same libs will be loaded again
1116 // into the runtime linker namespace, which will result in double loading of
1117 // them, which isn't supported.
1118 dirInApex = filepath.Join(dirInApex, "bionic")
Jiyong Parkb0788572018-12-20 22:10:17 +09001119 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001120
Jiyong Parkf653b052019-11-18 15:39:01 +09001121 fileToCopy := ccMod.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001122 return newApexFile(ctx, fileToCopy, ccMod.Name(), dirInApex, nativeSharedLib, ccMod)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001123}
1124
Jiyong Park1833cef2019-12-13 13:28:36 +09001125func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001126 dirInApex := filepath.Join("bin", cc.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001127 if cc.Target().NativeBridge == android.NativeBridgeEnabled {
dimitry8d6dde82019-07-11 10:23:53 +02001128 dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
Jiyong Parkacbf6c72019-07-09 16:19:16 +09001129 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001130 fileToCopy := cc.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001131 af := newApexFile(ctx, fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc)
Jiyong Parkf653b052019-11-18 15:39:01 +09001132 af.symlinks = cc.Symlinks()
1133 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001134}
1135
Jiyong Park1833cef2019-12-13 13:28:36 +09001136func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001137 dirInApex := "bin"
1138 fileToCopy := py.HostToolPath().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001139 return newApexFile(ctx, fileToCopy, py.Name(), dirInApex, pyBinary, py)
Alex Light778127a2019-02-27 14:19:50 -08001140}
Jiyong Park1833cef2019-12-13 13:28:36 +09001141func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001142 dirInApex := "bin"
Alex Light778127a2019-02-27 14:19:50 -08001143 s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
1144 if err != nil {
1145 ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001146 return apexFile{}
Alex Light778127a2019-02-27 14:19:50 -08001147 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001148 fileToCopy := android.PathForOutput(ctx, s)
1149 // NB: Since go binaries are static we don't need the module for anything here, which is
1150 // good since the go tool is a blueprint.Module not an android.Module like we would
1151 // normally use.
Jiyong Park1833cef2019-12-13 13:28:36 +09001152 return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil)
Alex Light778127a2019-02-27 14:19:50 -08001153}
1154
Jiyong Park1833cef2019-12-13 13:28:36 +09001155func apexFileForShBinary(ctx android.BaseModuleContext, sh *android.ShBinary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001156 dirInApex := filepath.Join("bin", sh.SubDir())
1157 fileToCopy := sh.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001158 af := newApexFile(ctx, fileToCopy, sh.Name(), dirInApex, shBinary, sh)
Jiyong Parkf653b052019-11-18 15:39:01 +09001159 af.symlinks = sh.Symlinks()
1160 return af
Jiyong Park04480cf2019-02-06 00:16:29 +09001161}
1162
Jooyung Han58f26ab2019-12-18 15:34:32 +09001163// TODO(b/146586360): replace javaLibrary(in apex/apex.go) with java.Dependency
1164type javaLibrary interface {
1165 android.Module
1166 java.Dependency
1167}
1168
1169func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaLibrary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001170 dirInApex := "javalib"
Jooyung Han58f26ab2019-12-18 15:34:32 +09001171 fileToCopy := lib.DexJar()
Jiyong Park618922e2020-01-08 13:35:43 +09001172 af := newApexFile(ctx, fileToCopy, lib.Name(), dirInApex, javaSharedLib, lib)
1173 af.jacocoReportClassesFile = lib.JacocoReportClassesFile()
1174 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001175}
1176
Jiyong Park1833cef2019-12-13 13:28:36 +09001177func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt android.PrebuiltEtcModule, depName string) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001178 dirInApex := filepath.Join("etc", prebuilt.SubDir())
1179 fileToCopy := prebuilt.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001180 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001181}
1182
Jiyong Park1833cef2019-12-13 13:28:36 +09001183func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
Jiyong Parkf653b052019-11-18 15:39:01 +09001184 android.Module
1185 Privileged() bool
1186 OutputFile() android.Path
Jiyong Park618922e2020-01-08 13:35:43 +09001187 JacocoReportClassesFile() android.Path
Jiyong Parkf653b052019-11-18 15:39:01 +09001188}, pkgName string) apexFile {
Jiyong Parkf7487312019-10-17 12:54:30 +09001189 appDir := "app"
Jiyong Parkf653b052019-11-18 15:39:01 +09001190 if aapp.Privileged() {
Jiyong Parkf7487312019-10-17 12:54:30 +09001191 appDir = "priv-app"
1192 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001193 dirInApex := filepath.Join(appDir, pkgName)
1194 fileToCopy := aapp.OutputFile()
Jiyong Park618922e2020-01-08 13:35:43 +09001195 af := newApexFile(ctx, fileToCopy, aapp.Name(), dirInApex, app, aapp)
1196 af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
1197 return af
Dario Frenicde2a032019-10-27 00:29:22 +01001198}
1199
Roland Levillain935639d2019-08-13 14:55:28 +01001200// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
1201type flattenedApexContext struct {
1202 android.ModuleContext
1203}
1204
1205func (c *flattenedApexContext) InstallBypassMake() bool {
1206 return true
1207}
1208
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001209func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Sundong Ahnabb64432019-10-22 13:58:29 +09001210 buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
1211 switch a.properties.ApexType {
1212 case imageApex:
1213 if buildFlattenedAsDefault {
1214 a.suffix = imageApexSuffix
1215 } else {
1216 a.suffix = ""
1217 a.primaryApexType = true
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09001218
1219 if ctx.Config().InstallExtraFlattenedApexes() {
Jiyong Park956305c2020-01-09 12:32:06 +09001220 a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix)
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09001221 }
Sundong Ahnabb64432019-10-22 13:58:29 +09001222 }
1223 case zipApex:
1224 if proptools.String(a.properties.Payload_type) == "zip" {
1225 a.suffix = ""
1226 a.primaryApexType = true
1227 } else {
1228 a.suffix = zipApexSuffix
1229 }
1230 case flattenedApex:
1231 if buildFlattenedAsDefault {
1232 a.suffix = ""
1233 a.primaryApexType = true
1234 } else {
1235 a.suffix = flattenedSuffix
1236 }
Alex Light5098a612018-11-29 17:12:15 -08001237 }
1238
Roland Levillain630846d2019-06-26 12:48:34 +01001239 if len(a.properties.Tests) > 0 && !a.testApex {
1240 ctx.PropertyErrorf("tests", "property not allowed in apex module type")
1241 return
1242 }
1243
Alex Lightfc0bd7c2019-01-29 18:31:59 -08001244 handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
1245
Jooyung Hane1633032019-08-01 17:41:43 +09001246 // native lib dependencies
1247 var provideNativeLibs []string
1248 var requireNativeLibs []string
1249
Jooyung Han5c998b92019-06-27 11:30:33 +09001250 // Check if "uses" requirements are met with dependent apexBundles
1251 var providedNativeSharedLibs []string
1252 useVendor := proptools.Bool(a.properties.Use_vendor)
1253 ctx.VisitDirectDepsBlueprint(func(m blueprint.Module) {
1254 if ctx.OtherModuleDependencyTag(m) != usesTag {
1255 return
1256 }
1257 otherName := ctx.OtherModuleName(m)
1258 other, ok := m.(*apexBundle)
1259 if !ok {
1260 ctx.PropertyErrorf("uses", "%q is not a provider", otherName)
1261 return
1262 }
1263 if proptools.Bool(other.properties.Use_vendor) != useVendor {
1264 ctx.PropertyErrorf("use_vendor", "%q has different value of use_vendor", otherName)
1265 return
1266 }
1267 if !proptools.Bool(other.properties.Provide_cpp_shared_libs) {
1268 ctx.PropertyErrorf("uses", "%q does not provide native_shared_libs", otherName)
1269 return
1270 }
1271 providedNativeSharedLibs = append(providedNativeSharedLibs, other.properties.Native_shared_libs...)
1272 })
1273
Jiyong Parkf653b052019-11-18 15:39:01 +09001274 var filesInfo []apexFile
Alex Light778127a2019-02-27 14:19:50 -08001275 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
Roland Levillainf89cd092019-07-29 16:22:59 +01001276 depTag := ctx.OtherModuleDependencyTag(child)
1277 depName := ctx.OtherModuleName(child)
Jiyong Parkf653b052019-11-18 15:39:01 +09001278 if _, isDirectDep := parent.(*apexBundle); isDirectDep {
Jiyong Park956305c2020-01-09 12:32:06 +09001279 if depTag != keyTag && depTag != certificateTag {
1280 a.internalDeps = append(a.internalDeps, depName)
1281 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001282 switch depTag {
1283 case sharedLibTag:
1284 if cc, ok := child.(*cc.Module); ok {
Jooyung Hane1633032019-08-01 17:41:43 +09001285 if cc.HasStubsVariants() {
1286 provideNativeLibs = append(provideNativeLibs, cc.OutputFile().Path().Base())
1287 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001288 filesInfo = append(filesInfo, apexFileForNativeLibrary(ctx, cc, handleSpecialLibs))
Jiyong Parkf653b052019-11-18 15:39:01 +09001289 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09001290 } else {
1291 ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001292 }
1293 case executableTag:
1294 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001295 filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
Jiyong Parkf653b052019-11-18 15:39:01 +09001296 return true // track transitive dependencies
Jiyong Park04480cf2019-02-06 00:16:29 +09001297 } else if sh, ok := child.(*android.ShBinary); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001298 filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
Alex Light778127a2019-02-27 14:19:50 -08001299 } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
Jiyong Park1833cef2019-12-13 13:28:36 +09001300 filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
Alex Light778127a2019-02-27 14:19:50 -08001301 } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
Jiyong Parkf653b052019-11-18 15:39:01 +09001302 filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb))
Jiyong Parkff1458f2018-10-12 21:49:38 +09001303 } else {
Alex Light778127a2019-02-27 14:19:50 -08001304 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 +09001305 }
1306 case javaLibTag:
Jiyong Park9e6c2422019-08-09 20:39:45 +09001307 if javaLib, ok := child.(*java.Library); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001308 af := apexFileForJavaLibrary(ctx, javaLib)
Jiyong Parkf653b052019-11-18 15:39:01 +09001309 if !af.Ok() {
Jiyong Park8fd61922018-11-08 02:50:25 +09001310 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
1311 } else {
Jiyong Parkf653b052019-11-18 15:39:01 +09001312 filesInfo = append(filesInfo, af)
1313 return true // track transitive dependencies
Jiyong Park9e6c2422019-08-09 20:39:45 +09001314 }
Jooyung Han58f26ab2019-12-18 15:34:32 +09001315 } else if sdkLib, ok := child.(*java.SdkLibrary); ok {
1316 af := apexFileForJavaLibrary(ctx, sdkLib)
1317 if !af.Ok() {
1318 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
1319 return false
1320 }
1321 filesInfo = append(filesInfo, af)
1322
Jooyung Han624058e2019-12-24 18:38:06 +09001323 pf, _ := sdkLib.OutputFiles(".xml")
1324 if len(pf) != 1 {
Jooyung Han58f26ab2019-12-18 15:34:32 +09001325 ctx.PropertyErrorf("java_libs", "%q failed to generate permission XML", depName)
1326 return false
1327 }
Jooyung Han624058e2019-12-24 18:38:06 +09001328 filesInfo = append(filesInfo, newApexFile(ctx, pf[0], pf[0].Base(), "etc/permissions", etc, nil))
Jooyung Han58f26ab2019-12-18 15:34:32 +09001329 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09001330 } else {
Jiyong Park9e6c2422019-08-09 20:39:45 +09001331 ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001332 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001333 case androidAppTag:
1334 pkgName := ctx.DeviceConfig().OverridePackageNameFor(depName)
1335 if ap, ok := child.(*java.AndroidApp); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001336 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09001337 return true // track transitive dependencies
1338 } else if ap, ok := child.(*java.AndroidAppImport); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001339 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Dario Freni6f3937c2019-12-20 22:58:03 +00001340 } else if ap, ok := child.(*java.AndroidTestHelperApp); ok {
1341 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09001342 } else {
1343 ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
1344 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001345 case prebuiltTag:
Jooyung Han39edb6c2019-11-06 16:53:07 +09001346 if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001347 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
Jiyong Parkff1458f2018-10-12 21:49:38 +09001348 } else {
1349 ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName)
1350 }
Roland Levillain630846d2019-06-26 12:48:34 +01001351 case testTag:
Roland Levillainf89cd092019-07-29 16:22:59 +01001352 if ccTest, ok := child.(*cc.Module); ok {
1353 if ccTest.IsTestPerSrcAllTestsVariation() {
1354 // Multiple-output test module (where `test_per_src: true`).
1355 //
1356 // `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
1357 // We do not add this variation to `filesInfo`, as it has no output;
1358 // however, we do add the other variations of this module as indirect
1359 // dependencies (see below).
1360 return true
Roland Levillain9b5fde92019-06-28 15:41:19 +01001361 } else {
Roland Levillainf89cd092019-07-29 16:22:59 +01001362 // Single-output test module (where `test_per_src: false`).
Jiyong Park1833cef2019-12-13 13:28:36 +09001363 af := apexFileForExecutable(ctx, ccTest)
Jiyong Parkf653b052019-11-18 15:39:01 +09001364 af.class = nativeTest
1365 filesInfo = append(filesInfo, af)
Roland Levillain9b5fde92019-06-28 15:41:19 +01001366 }
Roland Levillain630846d2019-06-26 12:48:34 +01001367 } else {
1368 ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
1369 }
Jiyong Parkff1458f2018-10-12 21:49:38 +09001370 case keyTag:
1371 if key, ok := child.(*apexKey); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001372 a.private_key_file = key.private_key_file
1373 a.public_key_file = key.public_key_file
Jiyong Parkff1458f2018-10-12 21:49:38 +09001374 } else {
1375 ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001376 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001377 return false
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001378 case certificateTag:
1379 if dep, ok := child.(*java.AndroidAppCertificate); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001380 a.container_certificate_file = dep.Certificate.Pem
1381 a.container_private_key_file = dep.Certificate.Key
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001382 } else {
1383 ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
1384 }
Jiyong Park03b68dd2019-07-26 23:20:40 +09001385 case android.PrebuiltDepTag:
1386 // If the prebuilt is force disabled, remember to delete the prebuilt file
1387 // that might have been installed in the previous builds
1388 if prebuilt, ok := child.(*Prebuilt); ok && prebuilt.isForceDisabled() {
1389 a.prebuiltFileToDelete = prebuilt.InstallFilename()
1390 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001391 }
Jooyung Han8aee2042019-10-29 05:08:31 +09001392 } else if !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001393 // indirect dependencies
Jooyung Han9c80bae2019-08-20 17:30:57 +09001394 if am, ok := child.(android.ApexModule); ok {
Roland Levillainf89cd092019-07-29 16:22:59 +01001395 // We cannot use a switch statement on `depTag` here as the checked
1396 // tags used below are private (e.g. `cc.sharedDepTag`).
Jiyong Park52cd06f2019-11-11 10:14:32 +09001397 if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
Roland Levillainf89cd092019-07-29 16:22:59 +01001398 if cc, ok := child.(*cc.Module); ok {
1399 if android.InList(cc.Name(), providedNativeSharedLibs) {
1400 // If we're using a shared library which is provided from other APEX,
1401 // don't include it in this APEX
1402 return false
Jiyong Parkac2bacd2019-02-20 21:49:26 +09001403 }
Jooyung Han671f1ce2019-12-17 12:47:13 +09001404 if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), ctx.OtherModuleName(cc)) && (cc.IsStubs() || cc.HasStubsVariants()) {
Roland Levillainf89cd092019-07-29 16:22:59 +01001405 // If the dependency is a stubs lib, don't include it in this APEX,
1406 // but make sure that the lib is installed on the device.
1407 // In case no APEX is having the lib, the lib is installed to the system
1408 // partition.
1409 //
1410 // Always include if we are a host-apex however since those won't have any
1411 // system libraries.
Jiyong Park956305c2020-01-09 12:32:06 +09001412 if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.Name(), a.requiredDeps) {
1413 a.requiredDeps = append(a.requiredDeps, cc.Name())
Roland Levillainf89cd092019-07-29 16:22:59 +01001414 }
Jiyong Park956305c2020-01-09 12:32:06 +09001415 a.externalDeps = append(a.externalDeps, depName)
Jooyung Hane1633032019-08-01 17:41:43 +09001416 requireNativeLibs = append(requireNativeLibs, cc.OutputFile().Path().Base())
Roland Levillainf89cd092019-07-29 16:22:59 +01001417 // Don't track further
1418 return false
1419 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001420 af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
Jiyong Parkf653b052019-11-18 15:39:01 +09001421 af.transitiveDep = true
1422 filesInfo = append(filesInfo, af)
Jiyong Park956305c2020-01-09 12:32:06 +09001423 a.internalDeps = append(a.internalDeps, depName)
1424 a.internalDeps = append(a.internalDeps, cc.AllStaticDeps()...)
Jiyong Parkf653b052019-11-18 15:39:01 +09001425 return true // track transitive dependencies
Jiyong Park25fc6a92018-11-18 18:02:45 +09001426 }
Roland Levillainf89cd092019-07-29 16:22:59 +01001427 } else if cc.IsTestPerSrcDepTag(depTag) {
1428 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001429 af := apexFileForExecutable(ctx, cc)
Roland Levillainf89cd092019-07-29 16:22:59 +01001430 // Handle modules created as `test_per_src` variations of a single test module:
1431 // use the name of the generated test binary (`fileToCopy`) instead of the name
1432 // of the original test module (`depName`, shared by all `test_per_src`
1433 // variations of that module).
Jiyong Parkf653b052019-11-18 15:39:01 +09001434 af.moduleName = filepath.Base(af.builtFile.String())
1435 af.transitiveDep = true
1436 filesInfo = append(filesInfo, af)
1437 return true // track transitive dependencies
Roland Levillainf89cd092019-07-29 16:22:59 +01001438 }
Jiyong Park52cd06f2019-11-11 10:14:32 +09001439 } else if java.IsJniDepTag(depTag) {
Jiyong Park956305c2020-01-09 12:32:06 +09001440 a.externalDeps = append(a.externalDeps, depName)
Jiyong Parkf653b052019-11-18 15:39:01 +09001441 return true
Jiyong Park956305c2020-01-09 12:32:06 +09001442 } else if java.IsStaticLibDepTag(depTag) {
1443 a.internalDeps = append(a.internalDeps, depName)
Jooyung Han9c80bae2019-08-20 17:30:57 +09001444 } else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
Roland Levillainf89cd092019-07-29 16:22:59 +01001445 ctx.ModuleErrorf("unexpected tag %q for indirect dependency %q", depTag, depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001446 }
1447 }
1448 }
1449 return false
1450 })
1451
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001452 // Specific to the ART apex: dexpreopt artifacts for libcore Java libraries.
1453 // Build rules are generated by the dexpreopt singleton, and here we access build artifacts
1454 // via the global boot image config.
1455 if a.artApex {
1456 for arch, files := range java.DexpreoptedArtApexJars(ctx) {
1457 dirInApex := filepath.Join("javalib", arch.String())
1458 for _, f := range files {
1459 localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
Jiyong Park1833cef2019-12-13 13:28:36 +09001460 af := newApexFile(ctx, f, localModule, dirInApex, etc, nil)
Jiyong Parkf653b052019-11-18 15:39:01 +09001461 filesInfo = append(filesInfo, af)
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001462 }
1463 }
1464 }
1465
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001466 if a.private_key_file == nil {
Jiyong Parkfa0a3732018-11-09 05:52:26 +09001467 ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
1468 return
1469 }
1470
Jiyong Park8fd61922018-11-08 02:50:25 +09001471 // remove duplicates in filesInfo
1472 removeDup := func(filesInfo []apexFile) []apexFile {
Jooyung Han344d5432019-08-23 11:17:39 +09001473 encountered := make(map[string]bool)
Jiyong Park8fd61922018-11-08 02:50:25 +09001474 result := []apexFile{}
1475 for _, f := range filesInfo {
Jooyung Han344d5432019-08-23 11:17:39 +09001476 dest := filepath.Join(f.installDir, f.builtFile.Base())
1477 if !encountered[dest] {
1478 encountered[dest] = true
Jiyong Park8fd61922018-11-08 02:50:25 +09001479 result = append(result, f)
1480 }
1481 }
1482 return result
1483 }
1484 filesInfo = removeDup(filesInfo)
1485
1486 // to have consistent build rules
1487 sort.Slice(filesInfo, func(i, j int) bool {
1488 return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String()
1489 })
1490
Jiyong Park127b40b2019-09-30 16:04:35 +09001491 // check apex_available requirements
Jiyong Park3814f4d2019-12-02 13:08:53 +09001492 if !ctx.Host() && !a.testApex {
Jiyong Park583a2262019-10-08 20:55:38 +09001493 for _, fi := range filesInfo {
1494 if am, ok := fi.module.(android.ApexModule); ok {
Anton Hansson5053c292020-01-10 15:12:39 +00001495 // vndk {enabled:true} implies visibility to the vndk apex
1496 if ccm, ok := fi.module.(*cc.Module); ok && ccm.IsVndk() && a.vndkApex {
1497 continue
1498 }
1499
1500 if !am.AvailableFor(ctx.ModuleName()) && !whitelistedApexAvailable(ctx.ModuleName(), a.vndkApex, fi.module) {
Jiyong Park583a2262019-10-08 20:55:38 +09001501 ctx.ModuleErrorf("requires %q that is not available for the APEX", fi.module.Name())
Jiyong Park3814f4d2019-12-02 13:08:53 +09001502 // don't stop so that we can report other violations in the same run
Jiyong Park583a2262019-10-08 20:55:38 +09001503 }
Jiyong Park127b40b2019-09-30 16:04:35 +09001504 }
1505 }
1506 }
1507
Jiyong Park8fd61922018-11-08 02:50:25 +09001508 // prepend the name of this APEX to the module names. These names will be the names of
1509 // modules that will be defined if the APEX is flattened.
1510 for i := range filesInfo {
Jaewoong Jung1670ca02019-11-22 14:50:42 -08001511 filesInfo[i].moduleName = filesInfo[i].moduleName + "." + a.Name() + a.suffix
Jiyong Park8fd61922018-11-08 02:50:25 +09001512 }
1513
Jiyong Park8fd61922018-11-08 02:50:25 +09001514 a.installDir = android.PathForModuleInstall(ctx, "apex")
1515 a.filesInfo = filesInfo
Alex Light5098a612018-11-29 17:12:15 -08001516
Jooyung Han54aca7b2019-11-20 02:26:02 +09001517 if a.properties.ApexType != zipApex {
1518 if a.properties.File_contexts == nil {
1519 a.fileContexts = android.PathForSource(ctx, "system/sepolicy/apex", ctx.ModuleName()+"-file_contexts")
1520 } else {
1521 a.fileContexts = android.PathForModuleSrc(ctx, *a.properties.File_contexts)
1522 if a.Platform() {
1523 if matched, err := path.Match("system/sepolicy/**/*", a.fileContexts.String()); err != nil || !matched {
1524 ctx.PropertyErrorf("file_contexts", "should be under system/sepolicy, but %q", a.fileContexts)
1525 }
1526 }
1527 }
1528 if !android.ExistentPathForSource(ctx, a.fileContexts.String()).Valid() {
1529 ctx.PropertyErrorf("file_contexts", "cannot find file_contexts file: %q", a.fileContexts)
1530 return
1531 }
1532 }
1533
Jooyung Hand15aa1f2019-09-27 00:38:03 +09001534 // prepare apex_manifest.json
Jooyung Han01a3ee22019-11-02 02:52:25 +09001535 a.buildManifest(ctx, provideNativeLibs, requireNativeLibs)
1536
1537 a.setCertificateAndPrivateKey(ctx)
1538 if a.properties.ApexType == flattenedApex {
1539 a.buildFlattenedApex(ctx)
1540 } else {
1541 a.buildUnflattenedApex(ctx)
1542 }
1543
Jooyung Han002ab682020-01-08 01:57:58 +09001544 a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
Jiyong Park956305c2020-01-09 12:32:06 +09001545
1546 a.buildApexDependencyInfo(ctx)
Jooyung Han01a3ee22019-11-02 02:52:25 +09001547}
1548
Anton Hansson5053c292020-01-10 15:12:39 +00001549func whitelistedApexAvailable(apex string, is_vndk bool, module android.Module) bool {
1550 key := apex
1551 key = strings.Replace(key, "test_", "", 1)
1552 key = strings.Replace(key, "com.android.art.debug", "com.android.art", 1)
1553 key = strings.Replace(key, "com.android.art.release", "com.android.art", 1)
1554
1555 moduleName := module.Name()
1556 if strings.Contains(moduleName, "prebuilt_libclang_rt") {
1557 // This module has variants that depend on the product being built.
1558 moduleName = "prebuilt_libclang_rt"
1559 }
1560
1561 if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
1562 return true
1563 }
1564
1565 return false
1566}
1567
Jooyung Han344d5432019-08-23 11:17:39 +09001568func newApexBundle() *apexBundle {
Sundong Ahnabb64432019-10-22 13:58:29 +09001569 module := &apexBundle{}
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001570 module.AddProperties(&module.properties)
Alex Light9670d332019-01-29 18:07:33 -08001571 module.AddProperties(&module.targetProperties)
Jiyong Park5d790c32019-11-15 18:40:32 +09001572 module.AddProperties(&module.overridableProperties)
Alex Light5098a612018-11-29 17:12:15 -08001573 module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
Jiyong Park397e55e2018-10-24 21:09:55 +09001574 return class == android.Device && ctx.Config().DevicePrefer32BitExecutables()
1575 })
Alex Light5098a612018-11-29 17:12:15 -08001576 android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001577 android.InitDefaultableModule(module)
Jiyong Parkd1063c12019-07-17 20:08:41 +09001578 android.InitSdkAwareModule(module)
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08001579 android.InitOverridableModule(module, &module.overridableProperties.Overrides)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001580 return module
1581}
Jiyong Park30ca9372019-02-07 16:27:23 +09001582
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001583func ApexBundleFactory(testApex bool, artApex bool) android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09001584 bundle := newApexBundle()
1585 bundle.testApex = testApex
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001586 bundle.artApex = artApex
Jooyung Han344d5432019-08-23 11:17:39 +09001587 return bundle
1588}
1589
1590func testApexBundleFactory() android.Module {
1591 bundle := newApexBundle()
1592 bundle.testApex = true
1593 return bundle
1594}
1595
Jiyong Parkd1063c12019-07-17 20:08:41 +09001596func BundleFactory() android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09001597 return newApexBundle()
1598}
1599
Jiyong Park30ca9372019-02-07 16:27:23 +09001600//
1601// Defaults
1602//
1603type Defaults struct {
1604 android.ModuleBase
1605 android.DefaultsModuleBase
1606}
1607
Jiyong Park30ca9372019-02-07 16:27:23 +09001608func defaultsFactory() android.Module {
1609 return DefaultsFactory()
1610}
1611
1612func DefaultsFactory(props ...interface{}) android.Module {
1613 module := &Defaults{}
1614
1615 module.AddProperties(props...)
1616 module.AddProperties(
1617 &apexBundleProperties{},
1618 &apexTargetBundleProperties{},
Jooyung Hanf21c7972019-12-16 22:32:06 +09001619 &overridableProperties{},
Jiyong Park30ca9372019-02-07 16:27:23 +09001620 )
1621
1622 android.InitDefaultsModule(module)
1623 return module
1624}
Jiyong Park5d790c32019-11-15 18:40:32 +09001625
1626//
1627// OverrideApex
1628//
1629type OverrideApex struct {
1630 android.ModuleBase
1631 android.OverrideModuleBase
1632}
1633
1634func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) {
1635 // All the overrides happen in the base module.
1636}
1637
1638// override_apex is used to create an apex module based on another apex module
1639// by overriding some of its properties.
1640func overrideApexFactory() android.Module {
1641 m := &OverrideApex{}
1642 m.AddProperties(&overridableProperties{})
1643
1644 android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon)
1645 android.InitOverrideModule(m)
1646 return m
1647}