blob: 23dffcb00141aafcf143575ca56da3edea0c430d [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 //
Anton Hansson5053c292020-01-10 15:12:39 +0000283 m["com.android.runtime"] = []string{
284 "libbase",
285 "libc++",
286 "libdexfile_support",
287 "liblzma",
288 "libunwindstack",
289 "prebuilt_libclang_rt",
290 }
291 //
292 // Module separator
293 //
294 m["com.android.resolv"] = []string{"libcrypto", "libnetd_resolv", "libssl"}
295 //
296 // Module separator
297 //
298 m["com.android.tethering"] = []string{"libbase", "libc++", "libnativehelper_compat_libc++"}
299 //
300 // Module separator
301 //
302 m["com.android.wifi"] = []string{
303 "libbase",
304 "libc++",
305 "libcutils",
306 "libprocessgroup",
307 "libutils",
308 "libwifi-jni",
309 "wifi-service-resources",
310 }
311 //
312 // Module separator
313 //
314 return m
315}
316
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900317func init() {
Jiyong Parkd1063c12019-07-17 20:08:41 +0900318 android.RegisterModuleType("apex", BundleFactory)
Alex Light0851b882019-02-07 13:20:53 -0800319 android.RegisterModuleType("apex_test", testApexBundleFactory)
Jooyung Han344d5432019-08-23 11:17:39 +0900320 android.RegisterModuleType("apex_vndk", vndkApexBundleFactory)
Jiyong Park30ca9372019-02-07 16:27:23 +0900321 android.RegisterModuleType("apex_defaults", defaultsFactory)
Jaewoong Jung939ebd52019-03-26 15:07:36 -0700322 android.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
Jiyong Park5d790c32019-11-15 18:40:32 +0900323 android.RegisterModuleType("override_apex", overrideApexFactory)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900324
Jooyung Han31c470b2019-10-18 16:26:59 +0900325 android.PreDepsMutators(RegisterPreDepsMutators)
Jiyong Parkd1063c12019-07-17 20:08:41 +0900326 android.PostDepsMutators(RegisterPostDepsMutators)
Jooyung Han7a78a922019-10-08 21:59:58 +0900327
328 android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
329 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
330 sort.Strings(*apexFileContextsInfos)
331 ctx.Strict("APEX_FILE_CONTEXTS_INFOS", strings.Join(*apexFileContextsInfos, " "))
332 })
Jiyong Parkd1063c12019-07-17 20:08:41 +0900333}
334
Jooyung Han31c470b2019-10-18 16:26:59 +0900335func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
336 ctx.TopDown("apex_vndk", apexVndkMutator).Parallel()
337 ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel()
338}
339
Jiyong Parkd1063c12019-07-17 20:08:41 +0900340func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
Jiyong Parka308ea12019-11-15 10:38:39 +0900341 ctx.BottomUp("apex_deps", apexDepsMutator)
Jiyong Parkd1063c12019-07-17 20:08:41 +0900342 ctx.BottomUp("apex", apexMutator).Parallel()
343 ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel()
344 ctx.BottomUp("apex_uses", apexUsesMutator).Parallel()
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900345}
346
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900347// Mark the direct and transitive dependencies of apex bundles so that they
348// can be built for the apex bundles.
Jiyong Parka308ea12019-11-15 10:38:39 +0900349func apexDepsMutator(mctx android.BottomUpMutatorContext) {
Alex Lightf98087f2019-02-04 14:45:06 -0800350 if a, ok := mctx.Module().(*apexBundle); ok {
Colin Crossa4925902018-11-16 11:36:28 -0800351 apexBundleName := mctx.ModuleName()
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900352 mctx.WalkDeps(func(child, parent android.Module) bool {
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900353 depName := mctx.OtherModuleName(child)
354 // If the parent is apexBundle, this child is directly depended.
355 _, directDep := parent.(*apexBundle)
Alex Light0851b882019-02-07 13:20:53 -0800356 if a.installable() && !a.testApex {
Alex Lightf98087f2019-02-04 14:45:06 -0800357 // TODO(b/123892969): Workaround for not having any way to annotate test-apexs
358 // non-installable apex's cannot be installed and so should not prevent libraries from being
359 // installed to the system.
360 android.UpdateApexDependency(apexBundleName, depName, directDep)
361 }
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900362
Jiyong Park3ff16992019-12-27 14:11:47 +0900363 if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() &&
364 (directDep || am.DepIsInSameApex(mctx, child)) {
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900365 am.BuildForApex(apexBundleName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900366 return true
367 } else {
368 return false
369 }
370 })
371 }
372}
373
374// Create apex variations if a module is included in APEX(s).
375func apexMutator(mctx android.BottomUpMutatorContext) {
376 if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900377 am.CreateApexVariations(mctx)
Jooyung Han54aca7b2019-11-20 02:26:02 +0900378 } else if _, ok := mctx.Module().(*apexBundle); ok {
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900379 // apex bundle itself is mutated so that it and its modules have same
380 // apex variant.
381 apexBundleName := mctx.ModuleName()
382 mctx.CreateVariations(apexBundleName)
Jiyong Park5d790c32019-11-15 18:40:32 +0900383 } else if o, ok := mctx.Module().(*OverrideApex); ok {
384 apexBundleName := o.GetOverriddenModuleName()
385 if apexBundleName == "" {
386 mctx.ModuleErrorf("base property is not set")
387 return
388 }
389 mctx.CreateVariations(apexBundleName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900390 }
Jiyong Park5d790c32019-11-15 18:40:32 +0900391
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900392}
Sundong Ahne9b55722019-09-06 17:37:42 +0900393
Jooyung Han7a78a922019-10-08 21:59:58 +0900394var (
395 apexFileContextsInfosKey = android.NewOnceKey("apexFileContextsInfosKey")
396 apexFileContextsInfosMutex sync.Mutex
397)
398
399func apexFileContextsInfos(config android.Config) *[]string {
400 return config.Once(apexFileContextsInfosKey, func() interface{} {
401 return &[]string{}
402 }).(*[]string)
403}
404
Jooyung Han54aca7b2019-11-20 02:26:02 +0900405func addFlattenedFileContextsInfos(ctx android.BaseModuleContext, fileContextsInfo string) {
Jooyung Han7a78a922019-10-08 21:59:58 +0900406 apexFileContextsInfosMutex.Lock()
407 defer apexFileContextsInfosMutex.Unlock()
408 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
Jooyung Han54aca7b2019-11-20 02:26:02 +0900409 *apexFileContextsInfos = append(*apexFileContextsInfos, fileContextsInfo)
Jooyung Han7a78a922019-10-08 21:59:58 +0900410}
411
Sundong Ahne9b55722019-09-06 17:37:42 +0900412func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
Sundong Ahne8fb7242019-09-17 13:50:45 +0900413 if ab, ok := mctx.Module().(*apexBundle); ok {
Sundong Ahnabb64432019-10-22 13:58:29 +0900414 var variants []string
415 switch proptools.StringDefault(ab.properties.Payload_type, "image") {
416 case "image":
417 variants = append(variants, imageApexType, flattenedApexType)
418 case "zip":
419 variants = append(variants, zipApexType)
420 case "both":
421 variants = append(variants, imageApexType, zipApexType, flattenedApexType)
422 default:
Sundong Ahnd95aa2d2019-10-08 19:34:03 +0900423 mctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type)
Sundong Ahnabb64432019-10-22 13:58:29 +0900424 return
425 }
426
427 modules := mctx.CreateLocalVariations(variants...)
428
429 for i, v := range variants {
430 switch v {
431 case imageApexType:
432 modules[i].(*apexBundle).properties.ApexType = imageApex
433 case zipApexType:
434 modules[i].(*apexBundle).properties.ApexType = zipApex
435 case flattenedApexType:
436 modules[i].(*apexBundle).properties.ApexType = flattenedApex
Jooyung Han91df2082019-11-20 01:49:42 +0900437 if !mctx.Config().FlattenApex() && ab.Platform() {
Sundong Ahnd95aa2d2019-10-08 19:34:03 +0900438 modules[i].(*apexBundle).MakeAsSystemExt()
439 }
Sundong Ahnabb64432019-10-22 13:58:29 +0900440 }
Sundong Ahne9b55722019-09-06 17:37:42 +0900441 }
Jiyong Park5d790c32019-11-15 18:40:32 +0900442 } else if _, ok := mctx.Module().(*OverrideApex); ok {
443 mctx.CreateVariations(imageApexType, flattenedApexType)
Sundong Ahne9b55722019-09-06 17:37:42 +0900444 }
445}
446
Jooyung Han5c998b92019-06-27 11:30:33 +0900447func apexUsesMutator(mctx android.BottomUpMutatorContext) {
448 if ab, ok := mctx.Module().(*apexBundle); ok {
449 mctx.AddFarVariationDependencies(nil, usesTag, ab.properties.Uses...)
450 }
451}
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900452
Jooyung Handc782442019-11-01 03:14:38 +0900453var (
454 useVendorWhitelistKey = android.NewOnceKey("useVendorWhitelist")
455)
456
457// useVendorWhitelist returns the list of APEXes which are allowed to use_vendor.
458// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__,
459// which may cause compatibility issues. (e.g. libbinder)
460// Even though libbinder restricts its availability via 'apex_available' property and relies on
461// yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules
462// to avoid similar problems.
463func useVendorWhitelist(config android.Config) []string {
464 return config.Once(useVendorWhitelistKey, func() interface{} {
465 return []string{
466 // swcodec uses "vendor" variants for smaller size
467 "com.android.media.swcodec",
468 "test_com.android.media.swcodec",
469 }
470 }).([]string)
471}
472
473// setUseVendorWhitelistForTest overrides useVendorWhitelist and must be
474// called before the first call to useVendorWhitelist()
475func setUseVendorWhitelistForTest(config android.Config, whitelist []string) {
476 config.Once(useVendorWhitelistKey, func() interface{} {
477 return whitelist
478 })
479}
480
Alex Light9670d332019-01-29 18:07:33 -0800481type apexNativeDependencies struct {
482 // List of native libraries
483 Native_shared_libs []string
Jooyung Han344d5432019-08-23 11:17:39 +0900484
Alex Light9670d332019-01-29 18:07:33 -0800485 // List of native executables
486 Binaries []string
Jooyung Han344d5432019-08-23 11:17:39 +0900487
Roland Levillain630846d2019-06-26 12:48:34 +0100488 // List of native tests
489 Tests []string
Alex Light9670d332019-01-29 18:07:33 -0800490}
Jooyung Han344d5432019-08-23 11:17:39 +0900491
Alex Light9670d332019-01-29 18:07:33 -0800492type apexMultilibProperties struct {
493 // Native dependencies whose compile_multilib is "first"
494 First apexNativeDependencies
495
496 // Native dependencies whose compile_multilib is "both"
497 Both apexNativeDependencies
498
499 // Native dependencies whose compile_multilib is "prefer32"
500 Prefer32 apexNativeDependencies
501
502 // Native dependencies whose compile_multilib is "32"
503 Lib32 apexNativeDependencies
504
505 // Native dependencies whose compile_multilib is "64"
506 Lib64 apexNativeDependencies
507}
508
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900509type apexBundleProperties struct {
510 // Json manifest file describing meta info of this APEX bundle. Default:
Dario Freni4abb1dc2018-11-20 18:04:58 +0000511 // "apex_manifest.json"
Colin Cross27b922f2019-03-04 22:35:41 -0800512 Manifest *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900513
Jiyong Park40e26a22019-02-08 02:53:06 +0900514 // AndroidManifest.xml file used for the zip container of this APEX bundle.
515 // If unspecified, a default one is automatically generated.
Colin Cross27b922f2019-03-04 22:35:41 -0800516 AndroidManifest *string `android:"path"`
Jiyong Park40e26a22019-02-08 02:53:06 +0900517
Roland Levillain411c5842019-09-19 16:37:20 +0100518 // Canonical name of the APEX bundle. Used to determine the path to the activated APEX on
519 // device (/apex/<apex_name>).
520 // If unspecified, defaults to the value of name.
Jiyong Park05e70dd2019-03-18 14:26:32 +0900521 Apex_name *string
522
Jiyong Parkd0a65ba2018-11-10 06:37:15 +0900523 // Determines the file contexts file for setting security context to each file in this APEX bundle.
Jooyung Han54aca7b2019-11-20 02:26:02 +0900524 // For platform APEXes, this should points to a file under /system/sepolicy
525 // Default: /system/sepolicy/apex/<module_name>_file_contexts.
526 File_contexts *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900527
528 // List of native shared libs that are embedded inside this APEX bundle
529 Native_shared_libs []string
530
Roland Levillain630846d2019-06-26 12:48:34 +0100531 // List of executables that are embedded inside this APEX bundle
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900532 Binaries []string
533
534 // List of java libraries that are embedded inside this APEX bundle
535 Java_libs []string
536
537 // List of prebuilt files that are embedded inside this APEX bundle
538 Prebuilts []string
Jiyong Parkff1458f2018-10-12 21:49:38 +0900539
Roland Levillain630846d2019-06-26 12:48:34 +0100540 // List of tests that are embedded inside this APEX bundle
541 Tests []string
542
Jiyong Parkff1458f2018-10-12 21:49:38 +0900543 // Name of the apex_key module that provides the private key to sign APEX
544 Key *string
Jiyong Park397e55e2018-10-24 21:09:55 +0900545
Alex Light5098a612018-11-29 17:12:15 -0800546 // The type of APEX to build. Controls what the APEX payload is. Either
547 // 'image', 'zip' or 'both'. Default: 'image'.
548 Payload_type *string
549
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900550 // The name of a certificate in the default certificate directory, blank to use the default product certificate,
551 // or an android_app_certificate module name in the form ":module".
552 Certificate *string
553
Jiyong Park92c0f9c2018-12-13 23:14:57 +0900554 // Whether this APEX is installable to one of the partitions. Default: true.
555 Installable *bool
556
Jiyong Parkda6eb592018-12-19 17:12:36 +0900557 // For native libraries and binaries, use the vendor variant instead of the core (platform) variant.
558 // Default is false.
559 Use_vendor *bool
560
Alex Lightfc0bd7c2019-01-29 18:31:59 -0800561 // For telling the apex to ignore special handling for system libraries such as bionic. Default is false.
562 Ignore_system_library_special_case *bool
563
Alex Light9670d332019-01-29 18:07:33 -0800564 Multilib apexMultilibProperties
Jiyong Park235e67c2019-02-09 11:50:56 +0900565
Jiyong Parkf97782b2019-02-13 20:28:58 +0900566 // List of sanitizer names that this APEX is enabled for
567 SanitizerNames []string `blueprint:"mutated"`
Jooyung Han5c998b92019-06-27 11:30:33 +0900568
Jiyong Parkee9a98d2019-08-09 14:44:36 +0900569 PreventInstall bool `blueprint:"mutated"`
570
571 HideFromMake bool `blueprint:"mutated"`
572
Jooyung Han5c998b92019-06-27 11:30:33 +0900573 // Indicates this APEX provides C++ shared libaries to other APEXes. Default: false.
574 Provide_cpp_shared_libs *bool
575
576 // List of providing APEXes' names so that this APEX can depend on provided shared libraries.
577 Uses []string
Nikita Ioffe5d5ae762019-08-31 14:38:05 +0100578
579 // A txt file containing list of files that are whitelisted to be included in this APEX.
580 Whitelisted_files *string
Sundong Ahne1f05aa2019-08-27 13:55:42 +0900581
Sundong Ahnabb64432019-10-22 13:58:29 +0900582 // package format of this apex variant; could be non-flattened, flattened, or zip.
583 // imageApex, zipApex or flattened
584 ApexType apexPackaging `blueprint:"mutated"`
Sundong Ahne8fb7242019-09-17 13:50:45 +0900585
Jiyong Parkd1063c12019-07-17 20:08:41 +0900586 // List of SDKs that are used to build this APEX. A reference to an SDK should be either
587 // `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current`
588 // is implied. This value affects all modules included in this APEX. In other words, they are
589 // also built with the SDKs specified here.
590 Uses_sdks []string
Jiyong Park5d790c32019-11-15 18:40:32 +0900591
Nikita Ioffec72b5dd2019-12-07 17:30:22 +0000592 // Whenever apex_payload.img of the APEX should include dm-verity hashtree.
593 // Should be only used in tests#.
594 Test_only_no_hashtree *bool
Jooyung Han214bf372019-11-12 13:03:50 +0900595
596 // Whether this APEX should support Android10. Default is false. If this is set true, then apex_manifest.json is bundled as well
597 // because Android10 requires legacy apex_manifest.json instead of apex_manifest.pb
598 Legacy_android10_support *bool
Jiyong Park956305c2020-01-09 12:32:06 +0900599
600 IsCoverageVariant bool `blueprint:"mutated"`
Alex Light9670d332019-01-29 18:07:33 -0800601}
602
603type apexTargetBundleProperties struct {
604 Target struct {
605 // Multilib properties only for android.
606 Android struct {
607 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +0900608 }
Jooyung Han344d5432019-08-23 11:17:39 +0900609
Alex Light9670d332019-01-29 18:07:33 -0800610 // Multilib properties only for host.
611 Host struct {
612 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +0900613 }
Jooyung Han344d5432019-08-23 11:17:39 +0900614
Alex Light9670d332019-01-29 18:07:33 -0800615 // Multilib properties only for host linux_bionic.
616 Linux_bionic struct {
617 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +0900618 }
Jooyung Han344d5432019-08-23 11:17:39 +0900619
Alex Light9670d332019-01-29 18:07:33 -0800620 // Multilib properties only for host linux_glibc.
621 Linux_glibc struct {
622 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +0900623 }
624 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900625}
626
Jiyong Park5d790c32019-11-15 18:40:32 +0900627type overridableProperties struct {
628 // List of APKs to package inside APEX
629 Apps []string
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -0800630
631 // Names of modules to be overridden. Listed modules can only be other binaries
632 // (in Make or Soong).
633 // This does not completely prevent installation of the overridden binaries, but if both
634 // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
635 // from PRODUCT_PACKAGES.
636 Overrides []string
Jiyong Park5d790c32019-11-15 18:40:32 +0900637}
638
Alex Light5098a612018-11-29 17:12:15 -0800639type apexPackaging int
640
641const (
642 imageApex apexPackaging = iota
643 zipApex
Sundong Ahnabb64432019-10-22 13:58:29 +0900644 flattenedApex
Alex Light5098a612018-11-29 17:12:15 -0800645)
646
Sundong Ahnabb64432019-10-22 13:58:29 +0900647// The suffix for the output "file", not the module
Alex Light5098a612018-11-29 17:12:15 -0800648func (a apexPackaging) suffix() string {
649 switch a {
650 case imageApex:
651 return imageApexSuffix
652 case zipApex:
653 return zipApexSuffix
Alex Light5098a612018-11-29 17:12:15 -0800654 default:
Roland Levillain4644b222019-07-31 14:09:17 +0100655 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -0800656 }
657}
658
659func (a apexPackaging) name() string {
660 switch a {
661 case imageApex:
662 return imageApexType
663 case zipApex:
664 return zipApexType
Alex Light5098a612018-11-29 17:12:15 -0800665 default:
Roland Levillain4644b222019-07-31 14:09:17 +0100666 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -0800667 }
668}
669
Jiyong Parkf653b052019-11-18 15:39:01 +0900670type apexFileClass int
671
672const (
673 etc apexFileClass = iota
674 nativeSharedLib
675 nativeExecutable
676 shBinary
677 pyBinary
678 goBinary
679 javaSharedLib
680 nativeTest
681 app
682)
683
Jiyong Park8fd61922018-11-08 02:50:25 +0900684func (class apexFileClass) NameInMake() string {
685 switch class {
686 case etc:
687 return "ETC"
688 case nativeSharedLib:
689 return "SHARED_LIBRARIES"
Alex Light778127a2019-02-27 14:19:50 -0800690 case nativeExecutable, shBinary, pyBinary, goBinary:
Jiyong Park8fd61922018-11-08 02:50:25 +0900691 return "EXECUTABLES"
692 case javaSharedLib:
693 return "JAVA_LIBRARIES"
Roland Levillain630846d2019-06-26 12:48:34 +0100694 case nativeTest:
695 return "NATIVE_TESTS"
Sundong Ahne1f05aa2019-08-27 13:55:42 +0900696 case app:
Jiyong Parkf383f7c2019-10-11 20:46:25 +0900697 // b/142537672 Why isn't this APP? We want to have full control over
698 // the paths and file names of the apk file under the flattend APEX.
699 // If this is set to APP, then the paths and file names are modified
700 // by the Make build system. For example, it is installed to
701 // /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of
702 // /system/apex/<apexname>/app/<Appname> because the build system automatically
703 // appends module name (which is <apexname>.<Appname> to the path.
704 return "ETC"
Jiyong Park8fd61922018-11-08 02:50:25 +0900705 default:
Roland Levillain4644b222019-07-31 14:09:17 +0100706 panic(fmt.Errorf("unknown class %d", class))
Jiyong Park8fd61922018-11-08 02:50:25 +0900707 }
708}
709
Jiyong Parkf653b052019-11-18 15:39:01 +0900710// apexFile represents a file in an APEX bundle
Jiyong Park8fd61922018-11-08 02:50:25 +0900711type apexFile struct {
712 builtFile android.Path
713 moduleName string
Jiyong Park8fd61922018-11-08 02:50:25 +0900714 installDir string
715 class apexFileClass
Jiyong Parka8894842018-12-19 17:36:39 +0900716 module android.Module
Jiyong Parkf653b052019-11-18 15:39:01 +0900717 // list of symlinks that will be created in installDir that point to this apexFile
718 symlinks []string
719 transitiveDep bool
Jiyong Park1833cef2019-12-13 13:28:36 +0900720 moduleDir string
Jiyong Park7afd1072019-12-30 16:56:33 +0900721
722 requiredModuleNames []string
723 targetRequiredModuleNames []string
724 hostRequiredModuleNames []string
Jiyong Park618922e2020-01-08 13:35:43 +0900725
726 jacocoReportClassesFile android.Path // only for javalibs and apps
Jiyong Parkf653b052019-11-18 15:39:01 +0900727}
728
Jiyong Park1833cef2019-12-13 13:28:36 +0900729func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile {
730 ret := apexFile{
Jiyong Parkf653b052019-11-18 15:39:01 +0900731 builtFile: builtFile,
732 moduleName: moduleName,
733 installDir: installDir,
734 class: class,
735 module: module,
736 }
Jiyong Park1833cef2019-12-13 13:28:36 +0900737 if module != nil {
738 ret.moduleDir = ctx.OtherModuleDir(module)
Jiyong Park7afd1072019-12-30 16:56:33 +0900739 ret.requiredModuleNames = module.RequiredModuleNames()
740 ret.targetRequiredModuleNames = module.TargetRequiredModuleNames()
741 ret.hostRequiredModuleNames = module.HostRequiredModuleNames()
Jiyong Park1833cef2019-12-13 13:28:36 +0900742 }
743 return ret
Jiyong Parkf653b052019-11-18 15:39:01 +0900744}
745
746func (af *apexFile) Ok() bool {
Jiyong Park479321d2019-12-16 11:47:12 +0900747 return af.builtFile != nil && af.builtFile.String() != ""
Jiyong Park8fd61922018-11-08 02:50:25 +0900748}
749
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900750type apexBundle struct {
751 android.ModuleBase
752 android.DefaultableModuleBase
Jiyong Park5d790c32019-11-15 18:40:32 +0900753 android.OverridableModuleBase
Jiyong Parkd1063c12019-07-17 20:08:41 +0900754 android.SdkBase
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900755
Jiyong Park5d790c32019-11-15 18:40:32 +0900756 properties apexBundleProperties
757 targetProperties apexTargetBundleProperties
Jiyong Park5d790c32019-11-15 18:40:32 +0900758 overridableProperties overridableProperties
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900759
Jooyung Hanf21c7972019-12-16 22:32:06 +0900760 // specific to apex_vndk modules
761 vndkProperties apexVndkProperties
762
Colin Crossa4925902018-11-16 11:36:28 -0800763 bundleModuleFile android.WritablePath
Sundong Ahnabb64432019-10-22 13:58:29 +0900764 outputFile android.WritablePath
Colin Cross70dda7e2019-10-01 22:05:35 -0700765 installDir android.InstallPath
Jiyong Park8fd61922018-11-08 02:50:25 +0900766
Jiyong Park03b68dd2019-07-26 23:20:40 +0900767 prebuiltFileToDelete string
768
Jiyong Park42cca6c2019-04-01 11:15:50 +0900769 public_key_file android.Path
770 private_key_file android.Path
Jiyong Park0ca3ce82019-02-18 15:25:04 +0900771
772 container_certificate_file android.Path
773 container_private_key_file android.Path
774
Jooyung Han54aca7b2019-11-20 02:26:02 +0900775 fileContexts android.Path
776
Jiyong Park8fd61922018-11-08 02:50:25 +0900777 // list of files to be included in this apex
778 filesInfo []apexFile
779
Jiyong Park956305c2020-01-09 12:32:06 +0900780 // list of module names that should be installed along with this APEX
781 requiredDeps []string
782
783 // list of module names that this APEX is depending on (to be shown via *-deps-info target)
Jiyong Parkac2bacd2019-02-20 21:49:26 +0900784 externalDeps []string
Jiyong Park956305c2020-01-09 12:32:06 +0900785 // list of module names that this APEX is including (to be shown via *-deps-info target)
786 internalDeps []string
Jiyong Parkac2bacd2019-02-20 21:49:26 +0900787
Sundong Ahnabb64432019-10-22 13:58:29 +0900788 testApex bool
789 vndkApex bool
Ulyana Trafimovichde534412019-11-08 10:51:01 +0000790 artApex bool
Sundong Ahnabb64432019-10-22 13:58:29 +0900791 primaryApexType bool
Jooyung Hane1633032019-08-01 17:41:43 +0900792
Jooyung Han214bf372019-11-12 13:03:50 +0900793 manifestJsonOut android.WritablePath
794 manifestPbOut android.WritablePath
Jooyung Han72bd2f82019-10-23 16:46:38 +0900795
Jooyung Han002ab682020-01-08 01:57:58 +0900796 // list of commands to create symlinks for backward compatibility.
Jooyung Han72bd2f82019-10-23 16:46:38 +0900797 // these commands will be attached as LOCAL_POST_INSTALL_CMD to
Jooyung Han002ab682020-01-08 01:57:58 +0900798 // apex package itself(for unflattened build) or apex_manifest(for flattened build)
Jooyung Han72bd2f82019-10-23 16:46:38 +0900799 // so that compat symlinks are always installed regardless of TARGET_FLATTEN_APEX setting.
800 compatSymlinks []string
Sundong Ahnabb64432019-10-22 13:58:29 +0900801
802 // Suffix of module name in Android.mk
803 // ".flattened", ".apex", ".zipapex", or ""
804 suffix string
Jiyong Park3a1602e2020-01-14 14:39:19 +0900805
806 installedFilesFile android.WritablePath
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900807}
808
Jiyong Park397e55e2018-10-24 21:09:55 +0900809func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
Roland Levillain630846d2019-06-26 12:48:34 +0100810 native_shared_libs []string, binaries []string, tests []string,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700811 target android.Target, imageVariation string) {
Jiyong Park397e55e2018-10-24 21:09:55 +0900812 // Use *FarVariation* to be able to depend on modules having
813 // conflicting variations with this module. This is required since
814 // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64'
815 // for native shared libs.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700816 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Parkda6eb592018-12-19 17:12:36 +0900817 {Mutator: "image", Variation: imageVariation},
Jiyong Park397e55e2018-10-24 21:09:55 +0900818 {Mutator: "link", Variation: "shared"},
Jiyong Park28d395a2018-12-07 22:42:47 +0900819 {Mutator: "version", Variation: ""}, // "" is the non-stub variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700820 }...), sharedLibTag, native_shared_libs...)
Jiyong Park397e55e2018-10-24 21:09:55 +0900821
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700822 ctx.AddFarVariationDependencies(append(target.Variations(),
823 blueprint.Variation{Mutator: "image", Variation: imageVariation}),
824 executableTag, binaries...)
Roland Levillain630846d2019-06-26 12:48:34 +0100825
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700826 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +0100827 {Mutator: "image", Variation: imageVariation},
Roland Levillain9b5fde92019-06-28 15:41:19 +0100828 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700829 }...), testTag, tests...)
Jiyong Park397e55e2018-10-24 21:09:55 +0900830}
831
Alex Light9670d332019-01-29 18:07:33 -0800832func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
833 if ctx.Os().Class == android.Device {
834 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil)
835 } else {
836 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil)
837 if ctx.Os().Bionic() {
838 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil)
839 } else {
840 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil)
841 }
842 }
843}
844
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900845func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
Jooyung Handc782442019-11-01 03:14:38 +0900846 if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorWhitelist(ctx.Config())) {
847 ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
848 }
849
Jiyong Park397e55e2018-10-24 21:09:55 +0900850 targets := ctx.MultiTargets()
Jiyong Park7c1dc612019-01-05 11:15:24 +0900851 config := ctx.DeviceConfig()
Alex Light9670d332019-01-29 18:07:33 -0800852
853 a.combineProperties(ctx)
854
Jiyong Park397e55e2018-10-24 21:09:55 +0900855 has32BitTarget := false
856 for _, target := range targets {
857 if target.Arch.ArchType.Multilib == "lib32" {
858 has32BitTarget = true
859 }
860 }
861 for i, target := range targets {
862 // When multilib.* is omitted for native_shared_libs, it implies
863 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700864 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Park7c1dc612019-01-05 11:15:24 +0900865 {Mutator: "image", Variation: a.getImageVariation(config)},
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900866 {Mutator: "link", Variation: "shared"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700867 }...), sharedLibTag, a.properties.Native_shared_libs...)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900868
Roland Levillain630846d2019-06-26 12:48:34 +0100869 // When multilib.* is omitted for tests, it implies
870 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700871 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +0100872 {Mutator: "image", Variation: a.getImageVariation(config)},
Roland Levillain9b5fde92019-06-28 15:41:19 +0100873 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700874 }...), testTag, a.properties.Tests...)
Roland Levillain630846d2019-06-26 12:48:34 +0100875
Jiyong Park397e55e2018-10-24 21:09:55 +0900876 // Add native modules targetting both ABIs
877 addDependenciesForNativeModules(ctx,
878 a.properties.Multilib.Both.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100879 a.properties.Multilib.Both.Binaries,
880 a.properties.Multilib.Both.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700881 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900882 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900883
Alex Light3d673592019-01-18 14:37:31 -0800884 isPrimaryAbi := i == 0
885 if isPrimaryAbi {
Jiyong Park397e55e2018-10-24 21:09:55 +0900886 // When multilib.* is omitted for binaries, it implies
887 // multilib.first.
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700888 ctx.AddFarVariationDependencies(append(target.Variations(),
889 blueprint.Variation{Mutator: "image", Variation: a.getImageVariation(config)}),
890 executableTag, a.properties.Binaries...)
Jiyong Park397e55e2018-10-24 21:09:55 +0900891
892 // Add native modules targetting the first ABI
893 addDependenciesForNativeModules(ctx,
894 a.properties.Multilib.First.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100895 a.properties.Multilib.First.Binaries,
896 a.properties.Multilib.First.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700897 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900898 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900899 }
900
901 switch target.Arch.ArchType.Multilib {
902 case "lib32":
903 // Add native modules targetting 32-bit ABI
904 addDependenciesForNativeModules(ctx,
905 a.properties.Multilib.Lib32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100906 a.properties.Multilib.Lib32.Binaries,
907 a.properties.Multilib.Lib32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700908 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900909 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900910
911 addDependenciesForNativeModules(ctx,
912 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100913 a.properties.Multilib.Prefer32.Binaries,
914 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700915 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900916 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900917 case "lib64":
918 // Add native modules targetting 64-bit ABI
919 addDependenciesForNativeModules(ctx,
920 a.properties.Multilib.Lib64.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100921 a.properties.Multilib.Lib64.Binaries,
922 a.properties.Multilib.Lib64.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700923 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900924 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900925
926 if !has32BitTarget {
927 addDependenciesForNativeModules(ctx,
928 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +0100929 a.properties.Multilib.Prefer32.Binaries,
930 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700931 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +0900932 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +0900933 }
Peter Collingbourne3478bb22019-04-24 14:41:12 -0700934
935 if strings.HasPrefix(ctx.ModuleName(), "com.android.runtime") && target.Os.Class == android.Device {
936 for _, sanitizer := range ctx.Config().SanitizeDevice() {
937 if sanitizer == "hwaddress" {
938 addDependenciesForNativeModules(ctx,
939 []string{"libclang_rt.hwasan-aarch64-android"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700940 nil, nil, target, a.getImageVariation(config))
Peter Collingbourne3478bb22019-04-24 14:41:12 -0700941 break
942 }
943 }
944 }
Jiyong Park397e55e2018-10-24 21:09:55 +0900945 }
946
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900947 }
948
Jiyong Parkce6aadc2019-11-20 13:58:28 +0900949 // For prebuilt_etc, use the first variant (64 on 64/32bit device,
950 // 32 on 32bit device) regardless of the TARGET_PREFER_* setting.
951 // b/144532908
952 archForPrebuiltEtc := config.Arches()[0]
953 for _, arch := range config.Arches() {
954 // Prefer 64-bit arch if there is any
955 if arch.ArchType.Multilib == "lib64" {
956 archForPrebuiltEtc = arch
957 break
958 }
959 }
960 ctx.AddFarVariationDependencies([]blueprint.Variation{
961 {Mutator: "os", Variation: ctx.Os().String()},
962 {Mutator: "arch", Variation: archForPrebuiltEtc.String()},
963 }, prebuiltTag, a.properties.Prebuilts...)
964
Colin Cross0f7d2ef2019-10-16 11:03:10 -0700965 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
966 javaLibTag, a.properties.Java_libs...)
Jiyong Parkff1458f2018-10-12 21:49:38 +0900967
Ulya Trafimovich44561882020-01-03 13:25:54 +0000968 // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
969 if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
970 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
971 javaLibTag, "jacocoagent")
972 }
973
Jiyong Park23c52b02019-02-02 13:13:47 +0900974 if String(a.properties.Key) == "" {
975 ctx.ModuleErrorf("key is missing")
976 return
977 }
978 ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key))
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900979
Jiyong Parkb2742fd2019-02-11 11:38:15 +0900980 cert := android.SrcIsModule(a.getCertString(ctx))
Jiyong Park23c52b02019-02-02 13:13:47 +0900981 if cert != "" {
982 ctx.AddDependency(ctx.Module(), certificateTag, cert)
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900983 }
Jiyong Parkd1063c12019-07-17 20:08:41 +0900984
985 // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks
986 if len(a.properties.Uses_sdks) > 0 {
987 sdkRefs := []android.SdkRef{}
988 for _, str := range a.properties.Uses_sdks {
989 parsed := android.ParseSdkRef(ctx, str, "uses_sdks")
990 sdkRefs = append(sdkRefs, parsed)
991 }
992 a.BuildWithSdks(sdkRefs)
993 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900994}
995
Jiyong Park5d790c32019-11-15 18:40:32 +0900996func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
997 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
998 androidAppTag, a.overridableProperties.Apps...)
999}
1000
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09001001func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
1002 // direct deps of an APEX bundle are all part of the APEX bundle
1003 return true
1004}
1005
Colin Cross0ea8ba82019-06-06 14:33:29 -07001006func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
Jooyung Han27151d92019-12-16 17:45:32 +09001007 moduleName := ctx.ModuleName()
1008 // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the OVERRIDE_* list,
1009 // we check with the pseudo module name to see if its certificate is overridden.
1010 if a.vndkApex {
1011 moduleName = vndkApexName
1012 }
1013 certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName)
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001014 if overridden {
Jaewoong Jungacb6db32019-02-28 16:22:30 +00001015 return ":" + certificate
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001016 }
1017 return String(a.properties.Certificate)
1018}
1019
Colin Cross41955e82019-05-29 14:40:35 -07001020func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
1021 switch tag {
1022 case "":
Sundong Ahnabb64432019-10-22 13:58:29 +09001023 return android.Paths{a.outputFile}, nil
Colin Cross41955e82019-05-29 14:40:35 -07001024 default:
1025 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
Jiyong Park5a832022018-12-20 09:54:35 +09001026 }
Jiyong Park74e240b2018-11-27 21:27:08 +09001027}
1028
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001029func (a *apexBundle) installable() bool {
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001030 return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001031}
1032
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001033func (a *apexBundle) testOnlyShouldSkipHashtreeGeneration() bool {
1034 return proptools.Bool(a.properties.Test_only_no_hashtree)
1035}
1036
Jiyong Park7c1dc612019-01-05 11:15:24 +09001037func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
Jooyung Han31c470b2019-10-18 16:26:59 +09001038 if a.vndkApex {
Colin Cross7228ecd2019-11-18 16:00:16 -08001039 return cc.VendorVariationPrefix + a.vndkVersion(config)
Jooyung Han31c470b2019-10-18 16:26:59 +09001040 }
Jiyong Park7c1dc612019-01-05 11:15:24 +09001041 if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) {
Colin Cross7228ecd2019-11-18 16:00:16 -08001042 return cc.VendorVariationPrefix + config.PlatformVndkVersion()
Jiyong Parkda6eb592018-12-19 17:12:36 +09001043 } else {
Colin Cross7228ecd2019-11-18 16:00:16 -08001044 return android.CoreVariation
Jiyong Parkda6eb592018-12-19 17:12:36 +09001045 }
1046}
1047
Jiyong Parkf97782b2019-02-13 20:28:58 +09001048func (a *apexBundle) EnableSanitizer(sanitizerName string) {
1049 if !android.InList(sanitizerName, a.properties.SanitizerNames) {
1050 a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName)
1051 }
1052}
1053
Jiyong Park388ef3f2019-01-28 19:47:32 +09001054func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
Jiyong Parkf97782b2019-02-13 20:28:58 +09001055 if android.InList(sanitizerName, a.properties.SanitizerNames) {
1056 return true
Jiyong Park235e67c2019-02-09 11:50:56 +09001057 }
1058
1059 // Then follow the global setting
Jiyong Park388ef3f2019-01-28 19:47:32 +09001060 globalSanitizerNames := []string{}
1061 if a.Host() {
1062 globalSanitizerNames = ctx.Config().SanitizeHost()
1063 } else {
1064 arches := ctx.Config().SanitizeDeviceArch()
1065 if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
1066 globalSanitizerNames = ctx.Config().SanitizeDevice()
1067 }
1068 }
1069 return android.InList(sanitizerName, globalSanitizerNames)
Jiyong Park379de2f2018-12-19 02:47:14 +09001070}
1071
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001072func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
1073 return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
1074}
1075
1076func (a *apexBundle) PreventInstall() {
1077 a.properties.PreventInstall = true
1078}
1079
1080func (a *apexBundle) HideFromMake() {
1081 a.properties.HideFromMake = true
1082}
1083
Jiyong Park956305c2020-01-09 12:32:06 +09001084func (a *apexBundle) MarkAsCoverageVariant(coverage bool) {
1085 a.properties.IsCoverageVariant = coverage
1086}
1087
Jiyong Parkf653b052019-11-18 15:39:01 +09001088// TODO(jiyong) move apexFileFor* close to the apexFile type definition
Jiyong Park1833cef2019-12-13 13:28:36 +09001089func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001090 // Decide the APEX-local directory by the multilib of the library
1091 // In the future, we may query this to the module.
Jiyong Parkf653b052019-11-18 15:39:01 +09001092 var dirInApex string
Martin Stjernholm279de572019-09-10 23:18:20 +01001093 switch ccMod.Arch().ArchType.Multilib {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001094 case "lib32":
1095 dirInApex = "lib"
1096 case "lib64":
1097 dirInApex = "lib64"
1098 }
Martin Stjernholm279de572019-09-10 23:18:20 +01001099 dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001100 if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
Martin Stjernholm279de572019-09-10 23:18:20 +01001101 dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001102 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001103 if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) {
Martin Stjernholm279de572019-09-10 23:18:20 +01001104 // Special case for Bionic libs and other libs installed with them. This is
1105 // to prevent those libs from being included in the search path
1106 // /apex/com.android.runtime/${LIB}. This exclusion is required because
1107 // those libs in the Runtime APEX are available via the legacy paths in
1108 // /system/lib/. By the init process, the libs in the APEX are bind-mounted
1109 // to the legacy paths and thus will be loaded into the default linker
1110 // namespace (aka "platform" namespace). If the libs are directly in
1111 // /apex/com.android.runtime/${LIB} then the same libs will be loaded again
1112 // into the runtime linker namespace, which will result in double loading of
1113 // them, which isn't supported.
1114 dirInApex = filepath.Join(dirInApex, "bionic")
Jiyong Parkb0788572018-12-20 22:10:17 +09001115 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001116
Jiyong Parkf653b052019-11-18 15:39:01 +09001117 fileToCopy := ccMod.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001118 return newApexFile(ctx, fileToCopy, ccMod.Name(), dirInApex, nativeSharedLib, ccMod)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001119}
1120
Jiyong Park1833cef2019-12-13 13:28:36 +09001121func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001122 dirInApex := filepath.Join("bin", cc.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001123 if cc.Target().NativeBridge == android.NativeBridgeEnabled {
dimitry8d6dde82019-07-11 10:23:53 +02001124 dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
Jiyong Parkacbf6c72019-07-09 16:19:16 +09001125 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001126 fileToCopy := cc.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001127 af := newApexFile(ctx, fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc)
Jiyong Parkf653b052019-11-18 15:39:01 +09001128 af.symlinks = cc.Symlinks()
1129 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001130}
1131
Jiyong Park1833cef2019-12-13 13:28:36 +09001132func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001133 dirInApex := "bin"
1134 fileToCopy := py.HostToolPath().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001135 return newApexFile(ctx, fileToCopy, py.Name(), dirInApex, pyBinary, py)
Alex Light778127a2019-02-27 14:19:50 -08001136}
Jiyong Park1833cef2019-12-13 13:28:36 +09001137func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001138 dirInApex := "bin"
Alex Light778127a2019-02-27 14:19:50 -08001139 s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
1140 if err != nil {
1141 ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001142 return apexFile{}
Alex Light778127a2019-02-27 14:19:50 -08001143 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001144 fileToCopy := android.PathForOutput(ctx, s)
1145 // NB: Since go binaries are static we don't need the module for anything here, which is
1146 // good since the go tool is a blueprint.Module not an android.Module like we would
1147 // normally use.
Jiyong Park1833cef2019-12-13 13:28:36 +09001148 return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil)
Alex Light778127a2019-02-27 14:19:50 -08001149}
1150
Jiyong Park1833cef2019-12-13 13:28:36 +09001151func apexFileForShBinary(ctx android.BaseModuleContext, sh *android.ShBinary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001152 dirInApex := filepath.Join("bin", sh.SubDir())
1153 fileToCopy := sh.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001154 af := newApexFile(ctx, fileToCopy, sh.Name(), dirInApex, shBinary, sh)
Jiyong Parkf653b052019-11-18 15:39:01 +09001155 af.symlinks = sh.Symlinks()
1156 return af
Jiyong Park04480cf2019-02-06 00:16:29 +09001157}
1158
Jooyung Han58f26ab2019-12-18 15:34:32 +09001159// TODO(b/146586360): replace javaLibrary(in apex/apex.go) with java.Dependency
1160type javaLibrary interface {
1161 android.Module
1162 java.Dependency
1163}
1164
1165func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaLibrary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001166 dirInApex := "javalib"
Jooyung Han58f26ab2019-12-18 15:34:32 +09001167 fileToCopy := lib.DexJar()
Jiyong Park618922e2020-01-08 13:35:43 +09001168 af := newApexFile(ctx, fileToCopy, lib.Name(), dirInApex, javaSharedLib, lib)
1169 af.jacocoReportClassesFile = lib.JacocoReportClassesFile()
1170 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001171}
1172
Jiyong Park1833cef2019-12-13 13:28:36 +09001173func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt android.PrebuiltEtcModule, depName string) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001174 dirInApex := filepath.Join("etc", prebuilt.SubDir())
1175 fileToCopy := prebuilt.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001176 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001177}
1178
Jiyong Park1833cef2019-12-13 13:28:36 +09001179func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
Jiyong Parkf653b052019-11-18 15:39:01 +09001180 android.Module
1181 Privileged() bool
1182 OutputFile() android.Path
Jiyong Park618922e2020-01-08 13:35:43 +09001183 JacocoReportClassesFile() android.Path
Jiyong Parkf653b052019-11-18 15:39:01 +09001184}, pkgName string) apexFile {
Jiyong Parkf7487312019-10-17 12:54:30 +09001185 appDir := "app"
Jiyong Parkf653b052019-11-18 15:39:01 +09001186 if aapp.Privileged() {
Jiyong Parkf7487312019-10-17 12:54:30 +09001187 appDir = "priv-app"
1188 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001189 dirInApex := filepath.Join(appDir, pkgName)
1190 fileToCopy := aapp.OutputFile()
Jiyong Park618922e2020-01-08 13:35:43 +09001191 af := newApexFile(ctx, fileToCopy, aapp.Name(), dirInApex, app, aapp)
1192 af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
1193 return af
Dario Frenicde2a032019-10-27 00:29:22 +01001194}
1195
Roland Levillain935639d2019-08-13 14:55:28 +01001196// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
1197type flattenedApexContext struct {
1198 android.ModuleContext
1199}
1200
1201func (c *flattenedApexContext) InstallBypassMake() bool {
1202 return true
1203}
1204
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001205func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Sundong Ahnabb64432019-10-22 13:58:29 +09001206 buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
1207 switch a.properties.ApexType {
1208 case imageApex:
1209 if buildFlattenedAsDefault {
1210 a.suffix = imageApexSuffix
1211 } else {
1212 a.suffix = ""
1213 a.primaryApexType = true
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09001214
1215 if ctx.Config().InstallExtraFlattenedApexes() {
Jiyong Park956305c2020-01-09 12:32:06 +09001216 a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix)
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09001217 }
Sundong Ahnabb64432019-10-22 13:58:29 +09001218 }
1219 case zipApex:
1220 if proptools.String(a.properties.Payload_type) == "zip" {
1221 a.suffix = ""
1222 a.primaryApexType = true
1223 } else {
1224 a.suffix = zipApexSuffix
1225 }
1226 case flattenedApex:
1227 if buildFlattenedAsDefault {
1228 a.suffix = ""
1229 a.primaryApexType = true
1230 } else {
1231 a.suffix = flattenedSuffix
1232 }
Alex Light5098a612018-11-29 17:12:15 -08001233 }
1234
Roland Levillain630846d2019-06-26 12:48:34 +01001235 if len(a.properties.Tests) > 0 && !a.testApex {
1236 ctx.PropertyErrorf("tests", "property not allowed in apex module type")
1237 return
1238 }
1239
Alex Lightfc0bd7c2019-01-29 18:31:59 -08001240 handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
1241
Jooyung Hane1633032019-08-01 17:41:43 +09001242 // native lib dependencies
1243 var provideNativeLibs []string
1244 var requireNativeLibs []string
1245
Jooyung Han5c998b92019-06-27 11:30:33 +09001246 // Check if "uses" requirements are met with dependent apexBundles
1247 var providedNativeSharedLibs []string
1248 useVendor := proptools.Bool(a.properties.Use_vendor)
1249 ctx.VisitDirectDepsBlueprint(func(m blueprint.Module) {
1250 if ctx.OtherModuleDependencyTag(m) != usesTag {
1251 return
1252 }
1253 otherName := ctx.OtherModuleName(m)
1254 other, ok := m.(*apexBundle)
1255 if !ok {
1256 ctx.PropertyErrorf("uses", "%q is not a provider", otherName)
1257 return
1258 }
1259 if proptools.Bool(other.properties.Use_vendor) != useVendor {
1260 ctx.PropertyErrorf("use_vendor", "%q has different value of use_vendor", otherName)
1261 return
1262 }
1263 if !proptools.Bool(other.properties.Provide_cpp_shared_libs) {
1264 ctx.PropertyErrorf("uses", "%q does not provide native_shared_libs", otherName)
1265 return
1266 }
1267 providedNativeSharedLibs = append(providedNativeSharedLibs, other.properties.Native_shared_libs...)
1268 })
1269
Jiyong Parkf653b052019-11-18 15:39:01 +09001270 var filesInfo []apexFile
Alex Light778127a2019-02-27 14:19:50 -08001271 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
Roland Levillainf89cd092019-07-29 16:22:59 +01001272 depTag := ctx.OtherModuleDependencyTag(child)
1273 depName := ctx.OtherModuleName(child)
Jiyong Parkf653b052019-11-18 15:39:01 +09001274 if _, isDirectDep := parent.(*apexBundle); isDirectDep {
Jiyong Park956305c2020-01-09 12:32:06 +09001275 if depTag != keyTag && depTag != certificateTag {
1276 a.internalDeps = append(a.internalDeps, depName)
1277 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001278 switch depTag {
1279 case sharedLibTag:
1280 if cc, ok := child.(*cc.Module); ok {
Jooyung Hane1633032019-08-01 17:41:43 +09001281 if cc.HasStubsVariants() {
1282 provideNativeLibs = append(provideNativeLibs, cc.OutputFile().Path().Base())
1283 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001284 filesInfo = append(filesInfo, apexFileForNativeLibrary(ctx, cc, handleSpecialLibs))
Jiyong Parkf653b052019-11-18 15:39:01 +09001285 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09001286 } else {
1287 ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001288 }
1289 case executableTag:
1290 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001291 filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
Jiyong Parkf653b052019-11-18 15:39:01 +09001292 return true // track transitive dependencies
Jiyong Park04480cf2019-02-06 00:16:29 +09001293 } else if sh, ok := child.(*android.ShBinary); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001294 filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
Alex Light778127a2019-02-27 14:19:50 -08001295 } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
Jiyong Park1833cef2019-12-13 13:28:36 +09001296 filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
Alex Light778127a2019-02-27 14:19:50 -08001297 } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
Jiyong Parkf653b052019-11-18 15:39:01 +09001298 filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb))
Jiyong Parkff1458f2018-10-12 21:49:38 +09001299 } else {
Alex Light778127a2019-02-27 14:19:50 -08001300 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 +09001301 }
1302 case javaLibTag:
Jiyong Park9e6c2422019-08-09 20:39:45 +09001303 if javaLib, ok := child.(*java.Library); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001304 af := apexFileForJavaLibrary(ctx, javaLib)
Jiyong Parkf653b052019-11-18 15:39:01 +09001305 if !af.Ok() {
Jiyong Park8fd61922018-11-08 02:50:25 +09001306 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
1307 } else {
Jiyong Parkf653b052019-11-18 15:39:01 +09001308 filesInfo = append(filesInfo, af)
1309 return true // track transitive dependencies
Jiyong Park9e6c2422019-08-09 20:39:45 +09001310 }
Jooyung Han58f26ab2019-12-18 15:34:32 +09001311 } else if sdkLib, ok := child.(*java.SdkLibrary); ok {
1312 af := apexFileForJavaLibrary(ctx, sdkLib)
1313 if !af.Ok() {
1314 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
1315 return false
1316 }
1317 filesInfo = append(filesInfo, af)
1318
Jooyung Han624058e2019-12-24 18:38:06 +09001319 pf, _ := sdkLib.OutputFiles(".xml")
1320 if len(pf) != 1 {
Jooyung Han58f26ab2019-12-18 15:34:32 +09001321 ctx.PropertyErrorf("java_libs", "%q failed to generate permission XML", depName)
1322 return false
1323 }
Jooyung Han624058e2019-12-24 18:38:06 +09001324 filesInfo = append(filesInfo, newApexFile(ctx, pf[0], pf[0].Base(), "etc/permissions", etc, nil))
Jooyung Han58f26ab2019-12-18 15:34:32 +09001325 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09001326 } else {
Jiyong Park9e6c2422019-08-09 20:39:45 +09001327 ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001328 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001329 case androidAppTag:
1330 pkgName := ctx.DeviceConfig().OverridePackageNameFor(depName)
1331 if ap, ok := child.(*java.AndroidApp); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001332 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09001333 return true // track transitive dependencies
1334 } else if ap, ok := child.(*java.AndroidAppImport); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001335 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Dario Freni6f3937c2019-12-20 22:58:03 +00001336 } else if ap, ok := child.(*java.AndroidTestHelperApp); ok {
1337 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09001338 } else {
1339 ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
1340 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001341 case prebuiltTag:
Jooyung Han39edb6c2019-11-06 16:53:07 +09001342 if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001343 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
Jiyong Parkff1458f2018-10-12 21:49:38 +09001344 } else {
1345 ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName)
1346 }
Roland Levillain630846d2019-06-26 12:48:34 +01001347 case testTag:
Roland Levillainf89cd092019-07-29 16:22:59 +01001348 if ccTest, ok := child.(*cc.Module); ok {
1349 if ccTest.IsTestPerSrcAllTestsVariation() {
1350 // Multiple-output test module (where `test_per_src: true`).
1351 //
1352 // `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
1353 // We do not add this variation to `filesInfo`, as it has no output;
1354 // however, we do add the other variations of this module as indirect
1355 // dependencies (see below).
1356 return true
Roland Levillain9b5fde92019-06-28 15:41:19 +01001357 } else {
Roland Levillainf89cd092019-07-29 16:22:59 +01001358 // Single-output test module (where `test_per_src: false`).
Jiyong Park1833cef2019-12-13 13:28:36 +09001359 af := apexFileForExecutable(ctx, ccTest)
Jiyong Parkf653b052019-11-18 15:39:01 +09001360 af.class = nativeTest
1361 filesInfo = append(filesInfo, af)
Roland Levillain9b5fde92019-06-28 15:41:19 +01001362 }
Roland Levillain630846d2019-06-26 12:48:34 +01001363 } else {
1364 ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
1365 }
Jiyong Parkff1458f2018-10-12 21:49:38 +09001366 case keyTag:
1367 if key, ok := child.(*apexKey); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001368 a.private_key_file = key.private_key_file
1369 a.public_key_file = key.public_key_file
Jiyong Parkff1458f2018-10-12 21:49:38 +09001370 } else {
1371 ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001372 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001373 return false
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001374 case certificateTag:
1375 if dep, ok := child.(*java.AndroidAppCertificate); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001376 a.container_certificate_file = dep.Certificate.Pem
1377 a.container_private_key_file = dep.Certificate.Key
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001378 } else {
1379 ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
1380 }
Jiyong Park03b68dd2019-07-26 23:20:40 +09001381 case android.PrebuiltDepTag:
1382 // If the prebuilt is force disabled, remember to delete the prebuilt file
1383 // that might have been installed in the previous builds
1384 if prebuilt, ok := child.(*Prebuilt); ok && prebuilt.isForceDisabled() {
1385 a.prebuiltFileToDelete = prebuilt.InstallFilename()
1386 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001387 }
Jooyung Han8aee2042019-10-29 05:08:31 +09001388 } else if !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001389 // indirect dependencies
Jooyung Han9c80bae2019-08-20 17:30:57 +09001390 if am, ok := child.(android.ApexModule); ok {
Roland Levillainf89cd092019-07-29 16:22:59 +01001391 // We cannot use a switch statement on `depTag` here as the checked
1392 // tags used below are private (e.g. `cc.sharedDepTag`).
Jiyong Park52cd06f2019-11-11 10:14:32 +09001393 if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
Roland Levillainf89cd092019-07-29 16:22:59 +01001394 if cc, ok := child.(*cc.Module); ok {
1395 if android.InList(cc.Name(), providedNativeSharedLibs) {
1396 // If we're using a shared library which is provided from other APEX,
1397 // don't include it in this APEX
1398 return false
Jiyong Parkac2bacd2019-02-20 21:49:26 +09001399 }
Jooyung Han671f1ce2019-12-17 12:47:13 +09001400 if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), ctx.OtherModuleName(cc)) && (cc.IsStubs() || cc.HasStubsVariants()) {
Roland Levillainf89cd092019-07-29 16:22:59 +01001401 // If the dependency is a stubs lib, don't include it in this APEX,
1402 // but make sure that the lib is installed on the device.
1403 // In case no APEX is having the lib, the lib is installed to the system
1404 // partition.
1405 //
1406 // Always include if we are a host-apex however since those won't have any
1407 // system libraries.
Jiyong Park956305c2020-01-09 12:32:06 +09001408 if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.Name(), a.requiredDeps) {
1409 a.requiredDeps = append(a.requiredDeps, cc.Name())
Roland Levillainf89cd092019-07-29 16:22:59 +01001410 }
Jiyong Park956305c2020-01-09 12:32:06 +09001411 a.externalDeps = append(a.externalDeps, depName)
Jooyung Hane1633032019-08-01 17:41:43 +09001412 requireNativeLibs = append(requireNativeLibs, cc.OutputFile().Path().Base())
Roland Levillainf89cd092019-07-29 16:22:59 +01001413 // Don't track further
1414 return false
1415 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001416 af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
Jiyong Parkf653b052019-11-18 15:39:01 +09001417 af.transitiveDep = true
1418 filesInfo = append(filesInfo, af)
Jiyong Park956305c2020-01-09 12:32:06 +09001419 a.internalDeps = append(a.internalDeps, depName)
1420 a.internalDeps = append(a.internalDeps, cc.AllStaticDeps()...)
Jiyong Parkf653b052019-11-18 15:39:01 +09001421 return true // track transitive dependencies
Jiyong Park25fc6a92018-11-18 18:02:45 +09001422 }
Roland Levillainf89cd092019-07-29 16:22:59 +01001423 } else if cc.IsTestPerSrcDepTag(depTag) {
1424 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001425 af := apexFileForExecutable(ctx, cc)
Roland Levillainf89cd092019-07-29 16:22:59 +01001426 // Handle modules created as `test_per_src` variations of a single test module:
1427 // use the name of the generated test binary (`fileToCopy`) instead of the name
1428 // of the original test module (`depName`, shared by all `test_per_src`
1429 // variations of that module).
Jiyong Parkf653b052019-11-18 15:39:01 +09001430 af.moduleName = filepath.Base(af.builtFile.String())
1431 af.transitiveDep = true
1432 filesInfo = append(filesInfo, af)
1433 return true // track transitive dependencies
Roland Levillainf89cd092019-07-29 16:22:59 +01001434 }
Jiyong Park52cd06f2019-11-11 10:14:32 +09001435 } else if java.IsJniDepTag(depTag) {
Jiyong Park956305c2020-01-09 12:32:06 +09001436 a.externalDeps = append(a.externalDeps, depName)
Jiyong Parkf653b052019-11-18 15:39:01 +09001437 return true
Jiyong Park956305c2020-01-09 12:32:06 +09001438 } else if java.IsStaticLibDepTag(depTag) {
1439 a.internalDeps = append(a.internalDeps, depName)
Jooyung Han9c80bae2019-08-20 17:30:57 +09001440 } else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
Roland Levillainf89cd092019-07-29 16:22:59 +01001441 ctx.ModuleErrorf("unexpected tag %q for indirect dependency %q", depTag, depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001442 }
1443 }
1444 }
1445 return false
1446 })
1447
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001448 // Specific to the ART apex: dexpreopt artifacts for libcore Java libraries.
1449 // Build rules are generated by the dexpreopt singleton, and here we access build artifacts
1450 // via the global boot image config.
1451 if a.artApex {
1452 for arch, files := range java.DexpreoptedArtApexJars(ctx) {
1453 dirInApex := filepath.Join("javalib", arch.String())
1454 for _, f := range files {
1455 localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
Jiyong Park1833cef2019-12-13 13:28:36 +09001456 af := newApexFile(ctx, f, localModule, dirInApex, etc, nil)
Jiyong Parkf653b052019-11-18 15:39:01 +09001457 filesInfo = append(filesInfo, af)
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001458 }
1459 }
1460 }
1461
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001462 if a.private_key_file == nil {
Jiyong Parkfa0a3732018-11-09 05:52:26 +09001463 ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
1464 return
1465 }
1466
Jiyong Park8fd61922018-11-08 02:50:25 +09001467 // remove duplicates in filesInfo
1468 removeDup := func(filesInfo []apexFile) []apexFile {
Jooyung Han344d5432019-08-23 11:17:39 +09001469 encountered := make(map[string]bool)
Jiyong Park8fd61922018-11-08 02:50:25 +09001470 result := []apexFile{}
1471 for _, f := range filesInfo {
Jooyung Han344d5432019-08-23 11:17:39 +09001472 dest := filepath.Join(f.installDir, f.builtFile.Base())
1473 if !encountered[dest] {
1474 encountered[dest] = true
Jiyong Park8fd61922018-11-08 02:50:25 +09001475 result = append(result, f)
1476 }
1477 }
1478 return result
1479 }
1480 filesInfo = removeDup(filesInfo)
1481
1482 // to have consistent build rules
1483 sort.Slice(filesInfo, func(i, j int) bool {
1484 return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String()
1485 })
1486
Jiyong Park127b40b2019-09-30 16:04:35 +09001487 // check apex_available requirements
Jiyong Park3814f4d2019-12-02 13:08:53 +09001488 if !ctx.Host() && !a.testApex {
Jiyong Park583a2262019-10-08 20:55:38 +09001489 for _, fi := range filesInfo {
1490 if am, ok := fi.module.(android.ApexModule); ok {
Anton Hansson5053c292020-01-10 15:12:39 +00001491 // vndk {enabled:true} implies visibility to the vndk apex
1492 if ccm, ok := fi.module.(*cc.Module); ok && ccm.IsVndk() && a.vndkApex {
1493 continue
1494 }
1495
1496 if !am.AvailableFor(ctx.ModuleName()) && !whitelistedApexAvailable(ctx.ModuleName(), a.vndkApex, fi.module) {
Jiyong Park583a2262019-10-08 20:55:38 +09001497 ctx.ModuleErrorf("requires %q that is not available for the APEX", fi.module.Name())
Jiyong Park3814f4d2019-12-02 13:08:53 +09001498 // don't stop so that we can report other violations in the same run
Jiyong Park583a2262019-10-08 20:55:38 +09001499 }
Jiyong Park127b40b2019-09-30 16:04:35 +09001500 }
1501 }
1502 }
1503
Jiyong Park8fd61922018-11-08 02:50:25 +09001504 // prepend the name of this APEX to the module names. These names will be the names of
1505 // modules that will be defined if the APEX is flattened.
1506 for i := range filesInfo {
Jaewoong Jung1670ca02019-11-22 14:50:42 -08001507 filesInfo[i].moduleName = filesInfo[i].moduleName + "." + a.Name() + a.suffix
Jiyong Park8fd61922018-11-08 02:50:25 +09001508 }
1509
Jiyong Park8fd61922018-11-08 02:50:25 +09001510 a.installDir = android.PathForModuleInstall(ctx, "apex")
1511 a.filesInfo = filesInfo
Alex Light5098a612018-11-29 17:12:15 -08001512
Jooyung Han54aca7b2019-11-20 02:26:02 +09001513 if a.properties.ApexType != zipApex {
1514 if a.properties.File_contexts == nil {
1515 a.fileContexts = android.PathForSource(ctx, "system/sepolicy/apex", ctx.ModuleName()+"-file_contexts")
1516 } else {
1517 a.fileContexts = android.PathForModuleSrc(ctx, *a.properties.File_contexts)
1518 if a.Platform() {
1519 if matched, err := path.Match("system/sepolicy/**/*", a.fileContexts.String()); err != nil || !matched {
1520 ctx.PropertyErrorf("file_contexts", "should be under system/sepolicy, but %q", a.fileContexts)
1521 }
1522 }
1523 }
1524 if !android.ExistentPathForSource(ctx, a.fileContexts.String()).Valid() {
1525 ctx.PropertyErrorf("file_contexts", "cannot find file_contexts file: %q", a.fileContexts)
1526 return
1527 }
1528 }
1529
Jooyung Hand15aa1f2019-09-27 00:38:03 +09001530 // prepare apex_manifest.json
Jooyung Han01a3ee22019-11-02 02:52:25 +09001531 a.buildManifest(ctx, provideNativeLibs, requireNativeLibs)
1532
1533 a.setCertificateAndPrivateKey(ctx)
1534 if a.properties.ApexType == flattenedApex {
1535 a.buildFlattenedApex(ctx)
1536 } else {
1537 a.buildUnflattenedApex(ctx)
1538 }
1539
Jooyung Han002ab682020-01-08 01:57:58 +09001540 a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
Jiyong Park956305c2020-01-09 12:32:06 +09001541
1542 a.buildApexDependencyInfo(ctx)
Jooyung Han01a3ee22019-11-02 02:52:25 +09001543}
1544
Anton Hansson5053c292020-01-10 15:12:39 +00001545func whitelistedApexAvailable(apex string, is_vndk bool, module android.Module) bool {
1546 key := apex
1547 key = strings.Replace(key, "test_", "", 1)
1548 key = strings.Replace(key, "com.android.art.debug", "com.android.art", 1)
1549 key = strings.Replace(key, "com.android.art.release", "com.android.art", 1)
1550
1551 moduleName := module.Name()
1552 if strings.Contains(moduleName, "prebuilt_libclang_rt") {
1553 // This module has variants that depend on the product being built.
1554 moduleName = "prebuilt_libclang_rt"
1555 }
1556
1557 if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
1558 return true
1559 }
1560
1561 return false
1562}
1563
Jooyung Han344d5432019-08-23 11:17:39 +09001564func newApexBundle() *apexBundle {
Sundong Ahnabb64432019-10-22 13:58:29 +09001565 module := &apexBundle{}
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001566 module.AddProperties(&module.properties)
Alex Light9670d332019-01-29 18:07:33 -08001567 module.AddProperties(&module.targetProperties)
Jiyong Park5d790c32019-11-15 18:40:32 +09001568 module.AddProperties(&module.overridableProperties)
Alex Light5098a612018-11-29 17:12:15 -08001569 module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
Jiyong Park397e55e2018-10-24 21:09:55 +09001570 return class == android.Device && ctx.Config().DevicePrefer32BitExecutables()
1571 })
Alex Light5098a612018-11-29 17:12:15 -08001572 android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001573 android.InitDefaultableModule(module)
Jiyong Parkd1063c12019-07-17 20:08:41 +09001574 android.InitSdkAwareModule(module)
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08001575 android.InitOverridableModule(module, &module.overridableProperties.Overrides)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001576 return module
1577}
Jiyong Park30ca9372019-02-07 16:27:23 +09001578
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001579func ApexBundleFactory(testApex bool, artApex bool) android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09001580 bundle := newApexBundle()
1581 bundle.testApex = testApex
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001582 bundle.artApex = artApex
Jooyung Han344d5432019-08-23 11:17:39 +09001583 return bundle
1584}
1585
1586func testApexBundleFactory() android.Module {
1587 bundle := newApexBundle()
1588 bundle.testApex = true
1589 return bundle
1590}
1591
Jiyong Parkd1063c12019-07-17 20:08:41 +09001592func BundleFactory() android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09001593 return newApexBundle()
1594}
1595
Jiyong Park30ca9372019-02-07 16:27:23 +09001596//
1597// Defaults
1598//
1599type Defaults struct {
1600 android.ModuleBase
1601 android.DefaultsModuleBase
1602}
1603
Jiyong Park30ca9372019-02-07 16:27:23 +09001604func defaultsFactory() android.Module {
1605 return DefaultsFactory()
1606}
1607
1608func DefaultsFactory(props ...interface{}) android.Module {
1609 module := &Defaults{}
1610
1611 module.AddProperties(props...)
1612 module.AddProperties(
1613 &apexBundleProperties{},
1614 &apexTargetBundleProperties{},
Jooyung Hanf21c7972019-12-16 22:32:06 +09001615 &overridableProperties{},
Jiyong Park30ca9372019-02-07 16:27:23 +09001616 )
1617
1618 android.InitDefaultsModule(module)
1619 return module
1620}
Jiyong Park5d790c32019-11-15 18:40:32 +09001621
1622//
1623// OverrideApex
1624//
1625type OverrideApex struct {
1626 android.ModuleBase
1627 android.OverrideModuleBase
1628}
1629
1630func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) {
1631 // All the overrides happen in the base module.
1632}
1633
1634// override_apex is used to create an apex module based on another apex module
1635// by overriding some of its properties.
1636func overrideApexFactory() android.Module {
1637 m := &OverrideApex{}
1638 m.AddProperties(&overridableProperties{})
1639
1640 android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon)
1641 android.InitOverrideModule(m)
1642 return m
1643}