blob: 73c889f1c8ffeaa24b273abf53f1ea0e6257e085 [file] [log] [blame]
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -04001// Copyright 2021 Google Inc. All rights reserved.
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 bp2build
16
17import (
18 "android/soong/android"
19 "android/soong/apex"
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040020 "android/soong/cc"
Jingwen Chendf165c92022-06-08 16:00:39 +000021 "android/soong/etc"
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040022 "android/soong/java"
Jingwen Chenb07c9012021-12-08 10:05:45 +000023 "android/soong/sh"
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040024
Vinh Tran8f5310f2022-10-07 18:16:47 -040025 "fmt"
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -040026 "testing"
27)
28
Sam Delmerico3177a6e2022-06-21 19:28:33 +000029func runApexTestCase(t *testing.T, tc Bp2buildTestCase) {
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -040030 t.Helper()
Sam Delmerico3177a6e2022-06-21 19:28:33 +000031 RunBp2BuildTestCase(t, registerApexModuleTypes, tc)
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -040032}
33
34func registerApexModuleTypes(ctx android.RegistrationContext) {
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040035 // CC module types needed as they can be APEX dependencies
36 cc.RegisterCCBuildComponents(ctx)
37
Jingwen Chenb07c9012021-12-08 10:05:45 +000038 ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory)
39 ctx.RegisterModuleType("cc_binary", cc.BinaryFactory)
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040040 ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
41 ctx.RegisterModuleType("apex_key", apex.ApexKeyFactory)
42 ctx.RegisterModuleType("android_app_certificate", java.AndroidAppCertificateFactory)
43 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
Jingwen Chen81c67d32022-06-08 16:08:25 +000044 ctx.RegisterModuleType("prebuilt_etc", etc.PrebuiltEtcFactory)
Yu Liu4c212ce2022-10-14 12:20:20 -070045 ctx.RegisterModuleType("cc_test", cc.TestFactory)
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -040046}
47
Sam Delmerico3177a6e2022-06-21 19:28:33 +000048func runOverrideApexTestCase(t *testing.T, tc Bp2buildTestCase) {
Wei Li1c66fc72022-05-09 23:59:14 -070049 t.Helper()
Sam Delmerico3177a6e2022-06-21 19:28:33 +000050 RunBp2BuildTestCase(t, registerOverrideApexModuleTypes, tc)
Wei Li1c66fc72022-05-09 23:59:14 -070051}
52
53func registerOverrideApexModuleTypes(ctx android.RegistrationContext) {
54 // CC module types needed as they can be APEX dependencies
55 cc.RegisterCCBuildComponents(ctx)
56
57 ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory)
58 ctx.RegisterModuleType("cc_binary", cc.BinaryFactory)
59 ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
60 ctx.RegisterModuleType("apex_key", apex.ApexKeyFactory)
61 ctx.RegisterModuleType("android_app_certificate", java.AndroidAppCertificateFactory)
62 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
63 ctx.RegisterModuleType("apex", apex.BundleFactory)
Cole Faust912bc882023-03-08 12:29:50 -080064 ctx.RegisterModuleType("apex_defaults", apex.DefaultsFactory)
Jingwen Chendf165c92022-06-08 16:00:39 +000065 ctx.RegisterModuleType("prebuilt_etc", etc.PrebuiltEtcFactory)
Cole Faust912bc882023-03-08 12:29:50 -080066 ctx.RegisterModuleType("soong_config_module_type", android.SoongConfigModuleTypeFactory)
67 ctx.RegisterModuleType("soong_config_string_variable", android.SoongConfigStringVariableDummyFactory)
Wei Li1c66fc72022-05-09 23:59:14 -070068}
69
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -040070func TestApexBundleSimple(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +000071 runApexTestCase(t, Bp2buildTestCase{
72 Description: "apex - example with all props, file_context is a module in same Android.bp",
73 ModuleTypeUnderTest: "apex",
74 ModuleTypeUnderTestFactory: apex.BundleFactory,
75 Filesystem: map[string]string{},
76 Blueprint: `
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040077apex_key {
Jingwen Chenb07c9012021-12-08 10:05:45 +000078 name: "com.android.apogee.key",
79 public_key: "com.android.apogee.avbpubkey",
80 private_key: "com.android.apogee.pem",
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040081 bazel_module: { bp2build_available: false },
82}
83
84android_app_certificate {
Jingwen Chenb07c9012021-12-08 10:05:45 +000085 name: "com.android.apogee.certificate",
86 certificate: "com.android.apogee",
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040087 bazel_module: { bp2build_available: false },
88}
89
90cc_library {
Jingwen Chenb07c9012021-12-08 10:05:45 +000091 name: "native_shared_lib_1",
92 bazel_module: { bp2build_available: false },
93}
94
95cc_library {
96 name: "native_shared_lib_2",
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -040097 bazel_module: { bp2build_available: false },
98}
99
Jingwen Chen81c67d32022-06-08 16:08:25 +0000100prebuilt_etc {
101 name: "prebuilt_1",
Jingwen Chenb07c9012021-12-08 10:05:45 +0000102 bazel_module: { bp2build_available: false },
Rupert Shuttleworth9447e1e2021-07-28 05:53:42 -0400103}
104
Jingwen Chen81c67d32022-06-08 16:08:25 +0000105prebuilt_etc {
106 name: "prebuilt_2",
Jingwen Chenb07c9012021-12-08 10:05:45 +0000107 bazel_module: { bp2build_available: false },
Rupert Shuttleworth9447e1e2021-07-28 05:53:42 -0400108}
109
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400110filegroup {
111 name: "com.android.apogee-file_contexts",
Jingwen Chenb07c9012021-12-08 10:05:45 +0000112 srcs: [
Wei Li1c66fc72022-05-09 23:59:14 -0700113 "com.android.apogee-file_contexts",
Jingwen Chenb07c9012021-12-08 10:05:45 +0000114 ],
115 bazel_module: { bp2build_available: false },
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400116}
117
Jingwen Chenb07c9012021-12-08 10:05:45 +0000118cc_binary { name: "cc_binary_1", bazel_module: { bp2build_available: false } }
119sh_binary { name: "sh_binary_2", bazel_module: { bp2build_available: false } }
120
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -0400121apex {
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400122 name: "com.android.apogee",
123 manifest: "apogee_manifest.json",
124 androidManifest: "ApogeeAndroidManifest.xml",
Wei Li1c66fc72022-05-09 23:59:14 -0700125 file_contexts: ":com.android.apogee-file_contexts",
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400126 min_sdk_version: "29",
127 key: "com.android.apogee.key",
Jingwen Chenbea58092022-09-29 16:56:02 +0000128 certificate: ":com.android.apogee.certificate",
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400129 updatable: false,
130 installable: false,
Wei Lif034cb42022-01-19 15:54:31 -0800131 compressible: false,
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400132 native_shared_libs: [
133 "native_shared_lib_1",
134 "native_shared_lib_2",
135 ],
136 binaries: [
Jingwen Chenb07c9012021-12-08 10:05:45 +0000137 "cc_binary_1",
138 "sh_binary_2",
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400139 ],
Rupert Shuttleworth9447e1e2021-07-28 05:53:42 -0400140 prebuilts: [
Jingwen Chen81c67d32022-06-08 16:08:25 +0000141 "prebuilt_1",
142 "prebuilt_2",
Rupert Shuttleworth9447e1e2021-07-28 05:53:42 -0400143 ],
Jingwen Chen9b7ebca2022-06-03 09:11:20 +0000144 package_name: "com.android.apogee.test.package",
Jingwen Chenb732d7c2022-06-10 08:14:19 +0000145 logging_parent: "logging.parent",
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -0400146}
147`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000148 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000149 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500150 "android_manifest": `"ApogeeAndroidManifest.xml"`,
151 "binaries": `[
Jingwen Chenb07c9012021-12-08 10:05:45 +0000152 ":cc_binary_1",
153 ":sh_binary_2",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500154 ]`,
155 "certificate": `":com.android.apogee.certificate"`,
156 "file_contexts": `":com.android.apogee-file_contexts"`,
157 "installable": "False",
158 "key": `":com.android.apogee.key"`,
159 "manifest": `"apogee_manifest.json"`,
160 "min_sdk_version": `"29"`,
Vinh Tran8f5310f2022-10-07 18:16:47 -0400161 "native_shared_libs_32": `select({
162 "//build/bazel/platforms/arch:arm": [
163 ":native_shared_lib_1",
164 ":native_shared_lib_2",
165 ],
166 "//build/bazel/platforms/arch:x86": [
167 ":native_shared_lib_1",
168 ":native_shared_lib_2",
169 ],
170 "//conditions:default": [],
171 })`,
Yu Liu4ae55d12022-01-05 17:17:23 -0800172 "native_shared_libs_64": `select({
173 "//build/bazel/platforms/arch:arm64": [
174 ":native_shared_lib_1",
175 ":native_shared_lib_2",
176 ],
177 "//build/bazel/platforms/arch:x86_64": [
178 ":native_shared_lib_1",
179 ":native_shared_lib_2",
180 ],
181 "//conditions:default": [],
182 })`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500183 "prebuilts": `[
Jingwen Chen81c67d32022-06-08 16:08:25 +0000184 ":prebuilt_1",
185 ":prebuilt_2",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500186 ]`,
Jingwen Chenb732d7c2022-06-10 08:14:19 +0000187 "updatable": "False",
188 "compressible": "False",
189 "package_name": `"com.android.apogee.test.package"`,
190 "logging_parent": `"logging.parent"`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500191 }),
192 }})
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400193}
194
Wei Li1c66fc72022-05-09 23:59:14 -0700195func TestApexBundleSimple_fileContextsInAnotherAndroidBp(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000196 runApexTestCase(t, Bp2buildTestCase{
197 Description: "apex - file contexts is a module in another Android.bp",
198 ModuleTypeUnderTest: "apex",
199 ModuleTypeUnderTestFactory: apex.BundleFactory,
200 Filesystem: map[string]string{
Wei Li1c66fc72022-05-09 23:59:14 -0700201 "a/b/Android.bp": `
202filegroup {
203 name: "com.android.apogee-file_contexts",
204 srcs: [
205 "com.android.apogee-file_contexts",
206 ],
207 bazel_module: { bp2build_available: false },
208}
209`,
210 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000211 Blueprint: `
Wei Li1c66fc72022-05-09 23:59:14 -0700212apex {
213 name: "com.android.apogee",
214 file_contexts: ":com.android.apogee-file_contexts",
215}
216`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000217 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000218 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Wei Li1c66fc72022-05-09 23:59:14 -0700219 "file_contexts": `"//a/b:com.android.apogee-file_contexts"`,
Wei Li40f98732022-05-20 22:08:11 -0700220 "manifest": `"apex_manifest.json"`,
Wei Li1c66fc72022-05-09 23:59:14 -0700221 }),
222 }})
223}
224
225func TestApexBundleSimple_fileContextsIsFile(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000226 runApexTestCase(t, Bp2buildTestCase{
227 Description: "apex - file contexts is a file",
228 ModuleTypeUnderTest: "apex",
229 ModuleTypeUnderTestFactory: apex.BundleFactory,
230 Filesystem: map[string]string{},
231 Blueprint: `
Wei Li1c66fc72022-05-09 23:59:14 -0700232apex {
233 name: "com.android.apogee",
234 file_contexts: "file_contexts_file",
235}
236`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000237 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000238 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Wei Li1c66fc72022-05-09 23:59:14 -0700239 "file_contexts": `"file_contexts_file"`,
Wei Li40f98732022-05-20 22:08:11 -0700240 "manifest": `"apex_manifest.json"`,
Wei Li1c66fc72022-05-09 23:59:14 -0700241 }),
242 }})
243}
244
245func TestApexBundleSimple_fileContextsIsNotSpecified(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000246 runApexTestCase(t, Bp2buildTestCase{
247 Description: "apex - file contexts is not specified",
248 ModuleTypeUnderTest: "apex",
249 ModuleTypeUnderTestFactory: apex.BundleFactory,
250 Filesystem: map[string]string{
Wei Li1c66fc72022-05-09 23:59:14 -0700251 "system/sepolicy/apex/Android.bp": `
252filegroup {
253 name: "com.android.apogee-file_contexts",
254 srcs: [
255 "com.android.apogee-file_contexts",
256 ],
257 bazel_module: { bp2build_available: false },
258}
259`,
260 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000261 Blueprint: `
Wei Li1c66fc72022-05-09 23:59:14 -0700262apex {
263 name: "com.android.apogee",
264}
265`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000266 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000267 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Wei Li1c66fc72022-05-09 23:59:14 -0700268 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
Wei Li40f98732022-05-20 22:08:11 -0700269 "manifest": `"apex_manifest.json"`,
Wei Li1c66fc72022-05-09 23:59:14 -0700270 }),
271 }})
272}
273
Yu Liu4ae55d12022-01-05 17:17:23 -0800274func TestApexBundleCompileMultilibBoth(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000275 runApexTestCase(t, Bp2buildTestCase{
276 Description: "apex - example with compile_multilib=both",
277 ModuleTypeUnderTest: "apex",
278 ModuleTypeUnderTestFactory: apex.BundleFactory,
279 Filesystem: map[string]string{
Wei Li1c66fc72022-05-09 23:59:14 -0700280 "system/sepolicy/apex/Android.bp": `
281filegroup {
282 name: "com.android.apogee-file_contexts",
283 srcs: [ "apogee-file_contexts", ],
284 bazel_module: { bp2build_available: false },
285}
286`,
287 },
Vinh Tran8f5310f2022-10-07 18:16:47 -0400288 Blueprint: createMultilibBlueprint(`compile_multilib: "both",`),
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000289 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000290 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Yu Liu4ae55d12022-01-05 17:17:23 -0800291 "native_shared_libs_32": `[
Vinh Tran8f5310f2022-10-07 18:16:47 -0400292 ":unnested_native_shared_lib",
Jingwen Chen34feb142022-10-06 13:02:30 +0000293 ":native_shared_lib_for_both",
294 ":native_shared_lib_for_lib32",
Yu Liu4ae55d12022-01-05 17:17:23 -0800295 ] + select({
Jingwen Chen34feb142022-10-06 13:02:30 +0000296 "//build/bazel/platforms/arch:arm": [":native_shared_lib_for_first"],
297 "//build/bazel/platforms/arch:x86": [":native_shared_lib_for_first"],
Yu Liu4ae55d12022-01-05 17:17:23 -0800298 "//conditions:default": [],
299 })`,
300 "native_shared_libs_64": `select({
301 "//build/bazel/platforms/arch:arm64": [
Vinh Tran8f5310f2022-10-07 18:16:47 -0400302 ":unnested_native_shared_lib",
Jingwen Chen34feb142022-10-06 13:02:30 +0000303 ":native_shared_lib_for_both",
304 ":native_shared_lib_for_lib64",
305 ":native_shared_lib_for_first",
Yu Liu4ae55d12022-01-05 17:17:23 -0800306 ],
307 "//build/bazel/platforms/arch:x86_64": [
Vinh Tran8f5310f2022-10-07 18:16:47 -0400308 ":unnested_native_shared_lib",
Jingwen Chen34feb142022-10-06 13:02:30 +0000309 ":native_shared_lib_for_both",
310 ":native_shared_lib_for_lib64",
311 ":native_shared_lib_for_first",
Yu Liu4ae55d12022-01-05 17:17:23 -0800312 ],
313 "//conditions:default": [],
314 })`,
Wei Li1c66fc72022-05-09 23:59:14 -0700315 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
Wei Li40f98732022-05-20 22:08:11 -0700316 "manifest": `"apex_manifest.json"`,
Yu Liu4ae55d12022-01-05 17:17:23 -0800317 }),
318 }})
319}
320
Vinh Tran8f5310f2022-10-07 18:16:47 -0400321func TestApexBundleCompileMultilibFirstAndDefaultValue(t *testing.T) {
322 expectedBazelTargets := []string{
323 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
324 "native_shared_libs_32": `select({
Yu Liu4ae55d12022-01-05 17:17:23 -0800325 "//build/bazel/platforms/arch:arm": [
Vinh Tran8f5310f2022-10-07 18:16:47 -0400326 ":unnested_native_shared_lib",
Jingwen Chen34feb142022-10-06 13:02:30 +0000327 ":native_shared_lib_for_both",
328 ":native_shared_lib_for_lib32",
329 ":native_shared_lib_for_first",
Yu Liu4ae55d12022-01-05 17:17:23 -0800330 ],
331 "//build/bazel/platforms/arch:x86": [
Vinh Tran8f5310f2022-10-07 18:16:47 -0400332 ":unnested_native_shared_lib",
Jingwen Chen34feb142022-10-06 13:02:30 +0000333 ":native_shared_lib_for_both",
334 ":native_shared_lib_for_lib32",
335 ":native_shared_lib_for_first",
Yu Liu4ae55d12022-01-05 17:17:23 -0800336 ],
337 "//conditions:default": [],
338 })`,
Vinh Tran8f5310f2022-10-07 18:16:47 -0400339 "native_shared_libs_64": `select({
Yu Liu4ae55d12022-01-05 17:17:23 -0800340 "//build/bazel/platforms/arch:arm64": [
Vinh Tran8f5310f2022-10-07 18:16:47 -0400341 ":unnested_native_shared_lib",
Jingwen Chen34feb142022-10-06 13:02:30 +0000342 ":native_shared_lib_for_both",
343 ":native_shared_lib_for_lib64",
344 ":native_shared_lib_for_first",
Yu Liu4ae55d12022-01-05 17:17:23 -0800345 ],
346 "//build/bazel/platforms/arch:x86_64": [
Vinh Tran8f5310f2022-10-07 18:16:47 -0400347 ":unnested_native_shared_lib",
Jingwen Chen34feb142022-10-06 13:02:30 +0000348 ":native_shared_lib_for_both",
349 ":native_shared_lib_for_lib64",
350 ":native_shared_lib_for_first",
Yu Liu4ae55d12022-01-05 17:17:23 -0800351 ],
352 "//conditions:default": [],
353 })`,
Vinh Tran8f5310f2022-10-07 18:16:47 -0400354 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
355 "manifest": `"apex_manifest.json"`,
356 }),
357 }
358
359 // "first" is the default value of compile_multilib prop so `compile_multilib_: "first"` and unset compile_multilib
360 // should result to the same bp2build output
361 compileMultiLibPropValues := []string{`compile_multilib: "first",`, ""}
362 for _, compileMultiLibProp := range compileMultiLibPropValues {
363 descriptionSuffix := compileMultiLibProp
364 if descriptionSuffix == "" {
365 descriptionSuffix = "compile_multilib unset"
366 }
367 runApexTestCase(t, Bp2buildTestCase{
368 Description: "apex - example with " + compileMultiLibProp,
369 ModuleTypeUnderTest: "apex",
370 ModuleTypeUnderTestFactory: apex.BundleFactory,
371 Filesystem: map[string]string{
372 "system/sepolicy/apex/Android.bp": `
373 filegroup {
374 name: "com.android.apogee-file_contexts",
375 srcs: [ "apogee-file_contexts", ],
376 bazel_module: { bp2build_available: false },
377 }
378 `,
379 },
380 Blueprint: createMultilibBlueprint(compileMultiLibProp),
381 ExpectedBazelTargets: expectedBazelTargets,
382 })
383 }
Yu Liu4ae55d12022-01-05 17:17:23 -0800384}
385
386func TestApexBundleCompileMultilib32(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000387 runApexTestCase(t, Bp2buildTestCase{
388 Description: "apex - example with compile_multilib=32",
389 ModuleTypeUnderTest: "apex",
390 ModuleTypeUnderTestFactory: apex.BundleFactory,
391 Filesystem: map[string]string{
Wei Li1c66fc72022-05-09 23:59:14 -0700392 "system/sepolicy/apex/Android.bp": `
393filegroup {
394 name: "com.android.apogee-file_contexts",
395 srcs: [ "apogee-file_contexts", ],
396 bazel_module: { bp2build_available: false },
397}
398`,
399 },
Vinh Tran8f5310f2022-10-07 18:16:47 -0400400 Blueprint: createMultilibBlueprint(`compile_multilib: "32",`),
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000401 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000402 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Yu Liu4ae55d12022-01-05 17:17:23 -0800403 "native_shared_libs_32": `[
Vinh Tran8f5310f2022-10-07 18:16:47 -0400404 ":unnested_native_shared_lib",
Jingwen Chen34feb142022-10-06 13:02:30 +0000405 ":native_shared_lib_for_both",
406 ":native_shared_lib_for_lib32",
Yu Liu4ae55d12022-01-05 17:17:23 -0800407 ] + select({
Jingwen Chen34feb142022-10-06 13:02:30 +0000408 "//build/bazel/platforms/arch:arm": [":native_shared_lib_for_first"],
409 "//build/bazel/platforms/arch:x86": [":native_shared_lib_for_first"],
Yu Liu4ae55d12022-01-05 17:17:23 -0800410 "//conditions:default": [],
411 })`,
Wei Li1c66fc72022-05-09 23:59:14 -0700412 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
Wei Li40f98732022-05-20 22:08:11 -0700413 "manifest": `"apex_manifest.json"`,
Yu Liu4ae55d12022-01-05 17:17:23 -0800414 }),
415 }})
416}
417
418func TestApexBundleCompileMultilib64(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000419 runApexTestCase(t, Bp2buildTestCase{
420 Description: "apex - example with compile_multilib=64",
421 ModuleTypeUnderTest: "apex",
422 ModuleTypeUnderTestFactory: apex.BundleFactory,
423 Filesystem: map[string]string{
Wei Li1c66fc72022-05-09 23:59:14 -0700424 "system/sepolicy/apex/Android.bp": `
425filegroup {
426 name: "com.android.apogee-file_contexts",
427 srcs: [ "apogee-file_contexts", ],
428 bazel_module: { bp2build_available: false },
429}
430`,
431 },
Vinh Tran8f5310f2022-10-07 18:16:47 -0400432 Blueprint: createMultilibBlueprint(`compile_multilib: "64",`),
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000433 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000434 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Yu Liu4ae55d12022-01-05 17:17:23 -0800435 "native_shared_libs_64": `select({
436 "//build/bazel/platforms/arch:arm64": [
Vinh Tran8f5310f2022-10-07 18:16:47 -0400437 ":unnested_native_shared_lib",
Jingwen Chen34feb142022-10-06 13:02:30 +0000438 ":native_shared_lib_for_both",
439 ":native_shared_lib_for_lib64",
440 ":native_shared_lib_for_first",
Yu Liu4ae55d12022-01-05 17:17:23 -0800441 ],
442 "//build/bazel/platforms/arch:x86_64": [
Vinh Tran8f5310f2022-10-07 18:16:47 -0400443 ":unnested_native_shared_lib",
Jingwen Chen34feb142022-10-06 13:02:30 +0000444 ":native_shared_lib_for_both",
445 ":native_shared_lib_for_lib64",
446 ":native_shared_lib_for_first",
Yu Liu4ae55d12022-01-05 17:17:23 -0800447 ],
448 "//conditions:default": [],
449 })`,
Wei Li1c66fc72022-05-09 23:59:14 -0700450 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
Wei Li40f98732022-05-20 22:08:11 -0700451 "manifest": `"apex_manifest.json"`,
Yu Liu4ae55d12022-01-05 17:17:23 -0800452 }),
453 }})
454}
455
Jingwen Chen34feb142022-10-06 13:02:30 +0000456func createMultilibBlueprint(compile_multilib string) string {
Vinh Tran8f5310f2022-10-07 18:16:47 -0400457 return fmt.Sprintf(`
Jingwen Chen34feb142022-10-06 13:02:30 +0000458cc_library {
459 name: "native_shared_lib_for_both",
460 bazel_module: { bp2build_available: false },
461}
462
463cc_library {
464 name: "native_shared_lib_for_first",
465 bazel_module: { bp2build_available: false },
466}
467
468cc_library {
469 name: "native_shared_lib_for_lib32",
470 bazel_module: { bp2build_available: false },
471}
472
473cc_library {
474 name: "native_shared_lib_for_lib64",
475 bazel_module: { bp2build_available: false },
476}
477
Vinh Tran8f5310f2022-10-07 18:16:47 -0400478cc_library {
479 name: "unnested_native_shared_lib",
480 bazel_module: { bp2build_available: false },
481}
482
Jingwen Chen34feb142022-10-06 13:02:30 +0000483apex {
484 name: "com.android.apogee",
Vinh Tran8f5310f2022-10-07 18:16:47 -0400485 %s
486 native_shared_libs: ["unnested_native_shared_lib"],
Jingwen Chen34feb142022-10-06 13:02:30 +0000487 multilib: {
488 both: {
489 native_shared_libs: [
490 "native_shared_lib_for_both",
491 ],
492 },
493 first: {
494 native_shared_libs: [
495 "native_shared_lib_for_first",
496 ],
497 },
498 lib32: {
499 native_shared_libs: [
500 "native_shared_lib_for_lib32",
501 ],
502 },
503 lib64: {
504 native_shared_libs: [
505 "native_shared_lib_for_lib64",
506 ],
507 },
508 },
Vinh Tran8f5310f2022-10-07 18:16:47 -0400509}`, compile_multilib)
Jingwen Chen34feb142022-10-06 13:02:30 +0000510}
511
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400512func TestApexBundleDefaultPropertyValues(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000513 runApexTestCase(t, Bp2buildTestCase{
514 Description: "apex - default property values",
515 ModuleTypeUnderTest: "apex",
516 ModuleTypeUnderTestFactory: apex.BundleFactory,
517 Filesystem: map[string]string{
Wei Li1c66fc72022-05-09 23:59:14 -0700518 "system/sepolicy/apex/Android.bp": `
519filegroup {
520 name: "com.android.apogee-file_contexts",
521 srcs: [ "apogee-file_contexts", ],
522 bazel_module: { bp2build_available: false },
523}
524`,
525 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000526 Blueprint: `
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -0400527apex {
528 name: "com.android.apogee",
529 manifest: "apogee_manifest.json",
530}
531`,
Alixe06d75b2022-08-31 18:28:19 +0000532 ExpectedBazelTargets: []string{MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
Wei Li1c66fc72022-05-09 23:59:14 -0700533 "manifest": `"apogee_manifest.json"`,
534 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500535 }),
536 }})
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -0400537}
Jingwen Chenf59a8e12021-07-16 09:28:53 +0000538
539func TestApexBundleHasBazelModuleProps(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000540 runApexTestCase(t, Bp2buildTestCase{
541 Description: "apex - has bazel module props",
542 ModuleTypeUnderTest: "apex",
543 ModuleTypeUnderTestFactory: apex.BundleFactory,
544 Filesystem: map[string]string{
Wei Li1c66fc72022-05-09 23:59:14 -0700545 "system/sepolicy/apex/Android.bp": `
546filegroup {
547 name: "apogee-file_contexts",
548 srcs: [ "apogee-file_contexts", ],
549 bazel_module: { bp2build_available: false },
550}
551`,
552 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000553 Blueprint: `
Jingwen Chenf59a8e12021-07-16 09:28:53 +0000554apex {
555 name: "apogee",
556 manifest: "manifest.json",
557 bazel_module: { bp2build_available: true },
558}
559`,
Alixe06d75b2022-08-31 18:28:19 +0000560 ExpectedBazelTargets: []string{MakeBazelTarget("apex", "apogee", AttrNameToString{
Wei Li1c66fc72022-05-09 23:59:14 -0700561 "manifest": `"manifest.json"`,
562 "file_contexts": `"//system/sepolicy/apex:apogee-file_contexts"`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500563 }),
564 }})
Jingwen Chenf59a8e12021-07-16 09:28:53 +0000565}
Yu Liu4ae55d12022-01-05 17:17:23 -0800566
Wei Li1c66fc72022-05-09 23:59:14 -0700567func TestBp2BuildOverrideApex(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000568 runOverrideApexTestCase(t, Bp2buildTestCase{
569 Description: "override_apex",
570 ModuleTypeUnderTest: "override_apex",
571 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
572 Filesystem: map[string]string{},
573 Blueprint: `
Wei Li1c66fc72022-05-09 23:59:14 -0700574apex_key {
575 name: "com.android.apogee.key",
576 public_key: "com.android.apogee.avbpubkey",
577 private_key: "com.android.apogee.pem",
578 bazel_module: { bp2build_available: false },
579}
580
581android_app_certificate {
582 name: "com.android.apogee.certificate",
583 certificate: "com.android.apogee",
584 bazel_module: { bp2build_available: false },
585}
586
587cc_library {
588 name: "native_shared_lib_1",
589 bazel_module: { bp2build_available: false },
590}
591
592cc_library {
593 name: "native_shared_lib_2",
594 bazel_module: { bp2build_available: false },
595}
596
Jingwen Chen81c67d32022-06-08 16:08:25 +0000597prebuilt_etc {
598 name: "prebuilt_1",
Wei Li1c66fc72022-05-09 23:59:14 -0700599 bazel_module: { bp2build_available: false },
600}
601
Jingwen Chen81c67d32022-06-08 16:08:25 +0000602prebuilt_etc {
603 name: "prebuilt_2",
Wei Li1c66fc72022-05-09 23:59:14 -0700604 bazel_module: { bp2build_available: false },
605}
606
607filegroup {
608 name: "com.android.apogee-file_contexts",
609 srcs: [
610 "com.android.apogee-file_contexts",
611 ],
612 bazel_module: { bp2build_available: false },
613}
614
615cc_binary { name: "cc_binary_1", bazel_module: { bp2build_available: false } }
616sh_binary { name: "sh_binary_2", bazel_module: { bp2build_available: false } }
617
618apex {
619 name: "com.android.apogee",
620 manifest: "apogee_manifest.json",
621 androidManifest: "ApogeeAndroidManifest.xml",
622 file_contexts: ":com.android.apogee-file_contexts",
623 min_sdk_version: "29",
624 key: "com.android.apogee.key",
Jingwen Chenbea58092022-09-29 16:56:02 +0000625 certificate: ":com.android.apogee.certificate",
Wei Li1c66fc72022-05-09 23:59:14 -0700626 updatable: false,
627 installable: false,
628 compressible: false,
629 native_shared_libs: [
630 "native_shared_lib_1",
631 "native_shared_lib_2",
632 ],
633 binaries: [
634 "cc_binary_1",
635 "sh_binary_2",
636 ],
637 prebuilts: [
Jingwen Chen81c67d32022-06-08 16:08:25 +0000638 "prebuilt_1",
639 "prebuilt_2",
Wei Li1c66fc72022-05-09 23:59:14 -0700640 ],
641 bazel_module: { bp2build_available: false },
642}
643
644apex_key {
645 name: "com.google.android.apogee.key",
646 public_key: "com.google.android.apogee.avbpubkey",
647 private_key: "com.google.android.apogee.pem",
648 bazel_module: { bp2build_available: false },
649}
650
651android_app_certificate {
652 name: "com.google.android.apogee.certificate",
653 certificate: "com.google.android.apogee",
654 bazel_module: { bp2build_available: false },
655}
656
657override_apex {
658 name: "com.google.android.apogee",
659 base: ":com.android.apogee",
660 key: "com.google.android.apogee.key",
Jingwen Chenbea58092022-09-29 16:56:02 +0000661 certificate: ":com.google.android.apogee.certificate",
Wei Li1c66fc72022-05-09 23:59:14 -0700662 prebuilts: [],
663 compressible: true,
664}
665`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000666 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000667 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Wei Li1c66fc72022-05-09 23:59:14 -0700668 "android_manifest": `"ApogeeAndroidManifest.xml"`,
Jingwen Chenc4c34e12022-11-29 12:07:45 +0000669 "base_apex_name": `"com.android.apogee"`,
Wei Li1c66fc72022-05-09 23:59:14 -0700670 "binaries": `[
671 ":cc_binary_1",
672 ":sh_binary_2",
673 ]`,
674 "certificate": `":com.google.android.apogee.certificate"`,
675 "file_contexts": `":com.android.apogee-file_contexts"`,
676 "installable": "False",
677 "key": `":com.google.android.apogee.key"`,
678 "manifest": `"apogee_manifest.json"`,
679 "min_sdk_version": `"29"`,
Vinh Tran8f5310f2022-10-07 18:16:47 -0400680 "native_shared_libs_32": `select({
681 "//build/bazel/platforms/arch:arm": [
682 ":native_shared_lib_1",
683 ":native_shared_lib_2",
684 ],
685 "//build/bazel/platforms/arch:x86": [
686 ":native_shared_lib_1",
687 ":native_shared_lib_2",
688 ],
689 "//conditions:default": [],
690 })`,
Wei Li1c66fc72022-05-09 23:59:14 -0700691 "native_shared_libs_64": `select({
692 "//build/bazel/platforms/arch:arm64": [
693 ":native_shared_lib_1",
694 ":native_shared_lib_2",
695 ],
696 "//build/bazel/platforms/arch:x86_64": [
697 ":native_shared_lib_1",
698 ":native_shared_lib_2",
699 ],
700 "//conditions:default": [],
701 })`,
702 "prebuilts": `[]`,
703 "updatable": "False",
704 "compressible": "True",
705 }),
706 }})
707}
Wei Li40f98732022-05-20 22:08:11 -0700708
709func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInDifferentAndroidBp(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000710 runOverrideApexTestCase(t, Bp2buildTestCase{
711 Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in different Android.bp",
712 ModuleTypeUnderTest: "override_apex",
713 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
714 Filesystem: map[string]string{
Wei Li40f98732022-05-20 22:08:11 -0700715 "system/sepolicy/apex/Android.bp": `
716filegroup {
717 name: "com.android.apogee-file_contexts",
718 srcs: [ "apogee-file_contexts", ],
719 bazel_module: { bp2build_available: false },
720}`,
721 "a/b/Android.bp": `
722apex {
723 name: "com.android.apogee",
724 bazel_module: { bp2build_available: false },
725}
726`,
727 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000728 Blueprint: `
Wei Li40f98732022-05-20 22:08:11 -0700729override_apex {
730 name: "com.google.android.apogee",
731 base: ":com.android.apogee",
732}
733`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000734 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000735 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chenc4c34e12022-11-29 12:07:45 +0000736 "base_apex_name": `"com.android.apogee"`,
737 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
738 "manifest": `"//a/b:apex_manifest.json"`,
Wei Li40f98732022-05-20 22:08:11 -0700739 }),
740 }})
741}
742
743func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInDifferentAndroidBp(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000744 runOverrideApexTestCase(t, Bp2buildTestCase{
745 Description: "override_apex - manifest of base apex is set, base apex and override_apex is in different Android.bp",
746 ModuleTypeUnderTest: "override_apex",
747 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
748 Filesystem: map[string]string{
Wei Li40f98732022-05-20 22:08:11 -0700749 "system/sepolicy/apex/Android.bp": `
750filegroup {
751 name: "com.android.apogee-file_contexts",
752 srcs: [ "apogee-file_contexts", ],
753 bazel_module: { bp2build_available: false },
754}`,
755 "a/b/Android.bp": `
756apex {
757 name: "com.android.apogee",
758 manifest: "apogee_manifest.json",
759 bazel_module: { bp2build_available: false },
760}
761`,
762 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000763 Blueprint: `
Wei Li40f98732022-05-20 22:08:11 -0700764override_apex {
765 name: "com.google.android.apogee",
766 base: ":com.android.apogee",
767}
768`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000769 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000770 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chenc4c34e12022-11-29 12:07:45 +0000771 "base_apex_name": `"com.android.apogee"`,
772 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
773 "manifest": `"//a/b:apogee_manifest.json"`,
Wei Li40f98732022-05-20 22:08:11 -0700774 }),
775 }})
776}
777
778func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInSameAndroidBp(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000779 runOverrideApexTestCase(t, Bp2buildTestCase{
780 Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in same Android.bp",
781 ModuleTypeUnderTest: "override_apex",
782 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
783 Filesystem: map[string]string{
Wei Li40f98732022-05-20 22:08:11 -0700784 "system/sepolicy/apex/Android.bp": `
785filegroup {
786 name: "com.android.apogee-file_contexts",
787 srcs: [ "apogee-file_contexts", ],
788 bazel_module: { bp2build_available: false },
789}`,
790 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000791 Blueprint: `
Wei Li40f98732022-05-20 22:08:11 -0700792apex {
793 name: "com.android.apogee",
794 bazel_module: { bp2build_available: false },
795}
796
797override_apex {
798 name: "com.google.android.apogee",
799 base: ":com.android.apogee",
800}
801`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000802 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000803 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chenc4c34e12022-11-29 12:07:45 +0000804 "base_apex_name": `"com.android.apogee"`,
805 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
806 "manifest": `"apex_manifest.json"`,
Wei Li40f98732022-05-20 22:08:11 -0700807 }),
808 }})
809}
810
811func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInSameAndroidBp(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000812 runOverrideApexTestCase(t, Bp2buildTestCase{
813 Description: "override_apex - manifest of base apex is set, base apex and override_apex is in same Android.bp",
814 ModuleTypeUnderTest: "override_apex",
815 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
816 Filesystem: map[string]string{
Wei Li40f98732022-05-20 22:08:11 -0700817 "system/sepolicy/apex/Android.bp": `
818filegroup {
819 name: "com.android.apogee-file_contexts",
820 srcs: [ "apogee-file_contexts", ],
821 bazel_module: { bp2build_available: false },
822}`,
823 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000824 Blueprint: `
Wei Li40f98732022-05-20 22:08:11 -0700825apex {
826 name: "com.android.apogee",
827 manifest: "apogee_manifest.json",
828 bazel_module: { bp2build_available: false },
829}
830
831override_apex {
832 name: "com.google.android.apogee",
833 base: ":com.android.apogee",
834}
835`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000836 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000837 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chenc4c34e12022-11-29 12:07:45 +0000838 "base_apex_name": `"com.android.apogee"`,
839 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
840 "manifest": `"apogee_manifest.json"`,
Wei Li40f98732022-05-20 22:08:11 -0700841 }),
842 }})
843}
Jingwen Chen9b7ebca2022-06-03 09:11:20 +0000844
845func TestApexBundleSimple_packageNameOverride(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000846 runOverrideApexTestCase(t, Bp2buildTestCase{
847 Description: "override_apex - override package name",
848 ModuleTypeUnderTest: "override_apex",
849 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
850 Filesystem: map[string]string{
Jingwen Chen9b7ebca2022-06-03 09:11:20 +0000851 "system/sepolicy/apex/Android.bp": `
852filegroup {
853 name: "com.android.apogee-file_contexts",
854 srcs: [ "apogee-file_contexts", ],
855 bazel_module: { bp2build_available: false },
856}`,
857 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000858 Blueprint: `
Jingwen Chen9b7ebca2022-06-03 09:11:20 +0000859apex {
860 name: "com.android.apogee",
861 bazel_module: { bp2build_available: false },
862}
863
864override_apex {
865 name: "com.google.android.apogee",
866 base: ":com.android.apogee",
867 package_name: "com.google.android.apogee",
868}
869`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000870 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000871 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chenc4c34e12022-11-29 12:07:45 +0000872 "base_apex_name": `"com.android.apogee"`,
873 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
874 "manifest": `"apex_manifest.json"`,
875 "package_name": `"com.google.android.apogee"`,
Jingwen Chen9b7ebca2022-06-03 09:11:20 +0000876 }),
877 }})
878}
Jingwen Chendf165c92022-06-08 16:00:39 +0000879
880func TestApexBundleSimple_NoPrebuiltsOverride(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000881 runOverrideApexTestCase(t, Bp2buildTestCase{
882 Description: "override_apex - no override",
883 ModuleTypeUnderTest: "override_apex",
884 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
885 Filesystem: map[string]string{
Jingwen Chendf165c92022-06-08 16:00:39 +0000886 "system/sepolicy/apex/Android.bp": `
887filegroup {
888 name: "com.android.apogee-file_contexts",
889 srcs: [ "apogee-file_contexts", ],
890 bazel_module: { bp2build_available: false },
891}`,
892 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000893 Blueprint: `
Jingwen Chendf165c92022-06-08 16:00:39 +0000894prebuilt_etc {
895 name: "prebuilt_file",
896 bazel_module: { bp2build_available: false },
897}
898
899apex {
900 name: "com.android.apogee",
901 bazel_module: { bp2build_available: false },
902 prebuilts: ["prebuilt_file"]
903}
904
905override_apex {
906 name: "com.google.android.apogee",
907 base: ":com.android.apogee",
908}
909`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000910 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000911 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chenc4c34e12022-11-29 12:07:45 +0000912 "base_apex_name": `"com.android.apogee"`,
913 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
914 "manifest": `"apex_manifest.json"`,
915 "prebuilts": `[":prebuilt_file"]`,
Jingwen Chendf165c92022-06-08 16:00:39 +0000916 }),
917 }})
918}
919
920func TestApexBundleSimple_PrebuiltsOverride(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000921 runOverrideApexTestCase(t, Bp2buildTestCase{
922 Description: "override_apex - ooverride",
923 ModuleTypeUnderTest: "override_apex",
924 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
925 Filesystem: map[string]string{
Jingwen Chendf165c92022-06-08 16:00:39 +0000926 "system/sepolicy/apex/Android.bp": `
927filegroup {
928 name: "com.android.apogee-file_contexts",
929 srcs: [ "apogee-file_contexts", ],
930 bazel_module: { bp2build_available: false },
931}`,
932 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000933 Blueprint: `
Jingwen Chendf165c92022-06-08 16:00:39 +0000934prebuilt_etc {
935 name: "prebuilt_file",
936 bazel_module: { bp2build_available: false },
937}
938
939prebuilt_etc {
940 name: "prebuilt_file2",
941 bazel_module: { bp2build_available: false },
942}
943
944apex {
945 name: "com.android.apogee",
946 bazel_module: { bp2build_available: false },
947 prebuilts: ["prebuilt_file"]
948}
949
950override_apex {
951 name: "com.google.android.apogee",
952 base: ":com.android.apogee",
953 prebuilts: ["prebuilt_file2"]
954}
955`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000956 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000957 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chenc4c34e12022-11-29 12:07:45 +0000958 "base_apex_name": `"com.android.apogee"`,
959 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
960 "manifest": `"apex_manifest.json"`,
961 "prebuilts": `[":prebuilt_file2"]`,
Jingwen Chendf165c92022-06-08 16:00:39 +0000962 }),
963 }})
964}
965
966func TestApexBundleSimple_PrebuiltsOverrideEmptyList(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000967 runOverrideApexTestCase(t, Bp2buildTestCase{
968 Description: "override_apex - override with empty list",
969 ModuleTypeUnderTest: "override_apex",
970 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
971 Filesystem: map[string]string{
Jingwen Chendf165c92022-06-08 16:00:39 +0000972 "system/sepolicy/apex/Android.bp": `
973filegroup {
974 name: "com.android.apogee-file_contexts",
975 srcs: [ "apogee-file_contexts", ],
976 bazel_module: { bp2build_available: false },
977}`,
978 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000979 Blueprint: `
Jingwen Chendf165c92022-06-08 16:00:39 +0000980prebuilt_etc {
981 name: "prebuilt_file",
982 bazel_module: { bp2build_available: false },
983}
984
985apex {
986 name: "com.android.apogee",
987 bazel_module: { bp2build_available: false },
988 prebuilts: ["prebuilt_file"]
989}
990
991override_apex {
992 name: "com.google.android.apogee",
993 base: ":com.android.apogee",
994 prebuilts: [],
995}
996`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000997 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000998 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chenc4c34e12022-11-29 12:07:45 +0000999 "base_apex_name": `"com.android.apogee"`,
1000 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
1001 "manifest": `"apex_manifest.json"`,
1002 "prebuilts": `[]`,
Jingwen Chendf165c92022-06-08 16:00:39 +00001003 }),
1004 }})
1005}
Jingwen Chenb732d7c2022-06-10 08:14:19 +00001006
1007func TestApexBundleSimple_NoLoggingParentOverride(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +00001008 runOverrideApexTestCase(t, Bp2buildTestCase{
1009 Description: "override_apex - logging_parent - no override",
1010 ModuleTypeUnderTest: "override_apex",
1011 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
1012 Filesystem: map[string]string{
Jingwen Chenb732d7c2022-06-10 08:14:19 +00001013 "system/sepolicy/apex/Android.bp": `
1014filegroup {
1015 name: "com.android.apogee-file_contexts",
1016 srcs: [ "apogee-file_contexts", ],
1017 bazel_module: { bp2build_available: false },
1018}`,
1019 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +00001020 Blueprint: `
Jingwen Chenb732d7c2022-06-10 08:14:19 +00001021apex {
1022 name: "com.android.apogee",
1023 bazel_module: { bp2build_available: false },
1024 logging_parent: "foo.bar.baz",
1025}
1026
1027override_apex {
1028 name: "com.google.android.apogee",
1029 base: ":com.android.apogee",
1030}
1031`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +00001032 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +00001033 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chenc4c34e12022-11-29 12:07:45 +00001034 "base_apex_name": `"com.android.apogee"`,
Jingwen Chenb732d7c2022-06-10 08:14:19 +00001035 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
1036 "manifest": `"apex_manifest.json"`,
1037 "logging_parent": `"foo.bar.baz"`,
1038 }),
1039 }})
1040}
1041
1042func TestApexBundleSimple_LoggingParentOverride(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +00001043 runOverrideApexTestCase(t, Bp2buildTestCase{
1044 Description: "override_apex - logging_parent - override",
1045 ModuleTypeUnderTest: "override_apex",
1046 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
1047 Filesystem: map[string]string{
Jingwen Chenb732d7c2022-06-10 08:14:19 +00001048 "system/sepolicy/apex/Android.bp": `
1049filegroup {
1050 name: "com.android.apogee-file_contexts",
1051 srcs: [ "apogee-file_contexts", ],
1052 bazel_module: { bp2build_available: false },
1053}`,
1054 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +00001055 Blueprint: `
Jingwen Chenb732d7c2022-06-10 08:14:19 +00001056apex {
1057 name: "com.android.apogee",
1058 bazel_module: { bp2build_available: false },
1059 logging_parent: "foo.bar.baz",
1060}
1061
1062override_apex {
1063 name: "com.google.android.apogee",
1064 base: ":com.android.apogee",
1065 logging_parent: "foo.bar.baz.override",
1066}
1067`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +00001068 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +00001069 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chenc4c34e12022-11-29 12:07:45 +00001070 "base_apex_name": `"com.android.apogee"`,
Jingwen Chenb732d7c2022-06-10 08:14:19 +00001071 "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
1072 "manifest": `"apex_manifest.json"`,
1073 "logging_parent": `"foo.bar.baz.override"`,
1074 }),
1075 }})
1076}
Jingwen Chenbea58092022-09-29 16:56:02 +00001077
1078func TestBp2BuildOverrideApex_CertificateNil(t *testing.T) {
1079 runOverrideApexTestCase(t, Bp2buildTestCase{
1080 Description: "override_apex - don't set default certificate",
1081 ModuleTypeUnderTest: "override_apex",
1082 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
1083 Filesystem: map[string]string{},
1084 Blueprint: `
1085android_app_certificate {
1086 name: "com.android.apogee.certificate",
1087 certificate: "com.android.apogee",
1088 bazel_module: { bp2build_available: false },
1089}
1090
1091filegroup {
1092 name: "com.android.apogee-file_contexts",
1093 srcs: [
1094 "com.android.apogee-file_contexts",
1095 ],
1096 bazel_module: { bp2build_available: false },
1097}
1098
1099apex {
1100 name: "com.android.apogee",
1101 manifest: "apogee_manifest.json",
1102 file_contexts: ":com.android.apogee-file_contexts",
1103 certificate: ":com.android.apogee.certificate",
1104 bazel_module: { bp2build_available: false },
1105}
1106
1107override_apex {
1108 name: "com.google.android.apogee",
1109 base: ":com.android.apogee",
1110 // certificate is deliberately omitted, and not converted to bazel,
1111 // because the overridden apex shouldn't be using the base apex's cert.
1112}
1113`,
1114 ExpectedBazelTargets: []string{
1115 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chenc4c34e12022-11-29 12:07:45 +00001116 "base_apex_name": `"com.android.apogee"`,
1117 "file_contexts": `":com.android.apogee-file_contexts"`,
1118 "manifest": `"apogee_manifest.json"`,
Jingwen Chenbea58092022-09-29 16:56:02 +00001119 }),
1120 }})
1121}
1122
1123func TestApexCertificateIsModule(t *testing.T) {
1124 runApexTestCase(t, Bp2buildTestCase{
1125 Description: "apex - certificate is module",
1126 ModuleTypeUnderTest: "apex",
1127 ModuleTypeUnderTestFactory: apex.BundleFactory,
1128 Filesystem: map[string]string{},
1129 Blueprint: `
1130android_app_certificate {
1131 name: "com.android.apogee.certificate",
1132 certificate: "com.android.apogee",
1133 bazel_module: { bp2build_available: false },
1134}
1135
1136apex {
1137 name: "com.android.apogee",
1138 manifest: "apogee_manifest.json",
1139 file_contexts: ":com.android.apogee-file_contexts",
1140 certificate: ":com.android.apogee.certificate",
1141}
1142` + simpleModuleDoNotConvertBp2build("filegroup", "com.android.apogee-file_contexts"),
1143 ExpectedBazelTargets: []string{
1144 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
1145 "certificate": `":com.android.apogee.certificate"`,
1146 "file_contexts": `":com.android.apogee-file_contexts"`,
1147 "manifest": `"apogee_manifest.json"`,
1148 }),
1149 }})
1150}
1151
Vinh Tran55225e32022-12-20 10:38:48 -05001152func TestApexWithStubLib(t *testing.T) {
1153 runApexTestCase(t, Bp2buildTestCase{
1154 Description: "apex - static variant of stub lib should not have apex_available tag",
1155 ModuleTypeUnderTest: "apex",
1156 ModuleTypeUnderTestFactory: apex.BundleFactory,
1157 Filesystem: map[string]string{},
1158 Blueprint: `
1159cc_library{
1160 name: "foo",
1161 stubs: { symbol_file: "foo.map.txt", versions: ["28", "29", "current"] },
1162 apex_available: ["myapex"],
1163}
1164
1165cc_binary{
1166 name: "bar",
1167 static_libs: ["foo"],
1168 apex_available: ["myapex"],
1169}
1170
1171apex {
1172 name: "myapex",
1173 manifest: "myapex_manifest.json",
1174 file_contexts: ":myapex-file_contexts",
1175 binaries: ["bar"],
1176 native_shared_libs: ["foo"],
1177}
1178` + simpleModuleDoNotConvertBp2build("filegroup", "myapex-file_contexts"),
1179 ExpectedBazelTargets: []string{
1180 MakeBazelTarget("cc_binary", "bar", AttrNameToString{
1181 "local_includes": `["."]`,
1182 "deps": `[":foo_bp2build_cc_library_static"]`,
1183 "tags": `["apex_available=myapex"]`,
1184 }),
1185 MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
1186 "local_includes": `["."]`,
1187 }),
1188 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1189 "local_includes": `["."]`,
1190 "stubs_symbol_file": `"foo.map.txt"`,
1191 "tags": `["apex_available=myapex"]`,
1192 }),
1193 MakeBazelTarget("cc_stub_suite", "foo_stub_libs", AttrNameToString{
1194 "soname": `"foo.so"`,
1195 "source_library": `":foo"`,
1196 "symbol_file": `"foo.map.txt"`,
1197 "versions": `[
1198 "28",
1199 "29",
1200 "current",
1201 ]`,
1202 }),
1203 MakeBazelTarget("apex", "myapex", AttrNameToString{
1204 "file_contexts": `":myapex-file_contexts"`,
1205 "manifest": `"myapex_manifest.json"`,
1206 "binaries": `[":bar"]`,
1207 "native_shared_libs_32": `select({
1208 "//build/bazel/platforms/arch:arm": [":foo"],
1209 "//build/bazel/platforms/arch:x86": [":foo"],
1210 "//conditions:default": [],
1211 })`,
1212 "native_shared_libs_64": `select({
1213 "//build/bazel/platforms/arch:arm64": [":foo"],
1214 "//build/bazel/platforms/arch:x86_64": [":foo"],
1215 "//conditions:default": [],
1216 })`,
1217 }),
1218 },
1219 })
1220}
1221
Jingwen Chenbea58092022-09-29 16:56:02 +00001222func TestApexCertificateIsSrc(t *testing.T) {
1223 runApexTestCase(t, Bp2buildTestCase{
1224 Description: "apex - certificate is src",
1225 ModuleTypeUnderTest: "apex",
1226 ModuleTypeUnderTestFactory: apex.BundleFactory,
1227 Filesystem: map[string]string{},
1228 Blueprint: `
1229apex {
1230 name: "com.android.apogee",
1231 manifest: "apogee_manifest.json",
1232 file_contexts: ":com.android.apogee-file_contexts",
1233 certificate: "com.android.apogee.certificate",
1234}
1235` + simpleModuleDoNotConvertBp2build("filegroup", "com.android.apogee-file_contexts"),
1236 ExpectedBazelTargets: []string{
1237 MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
1238 "certificate_name": `"com.android.apogee.certificate"`,
1239 "file_contexts": `":com.android.apogee-file_contexts"`,
1240 "manifest": `"apogee_manifest.json"`,
1241 }),
1242 }})
1243}
1244
1245func TestBp2BuildOverrideApex_CertificateIsModule(t *testing.T) {
1246 runOverrideApexTestCase(t, Bp2buildTestCase{
1247 Description: "override_apex - certificate is module",
1248 ModuleTypeUnderTest: "override_apex",
1249 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
1250 Filesystem: map[string]string{},
1251 Blueprint: `
1252android_app_certificate {
1253 name: "com.android.apogee.certificate",
1254 certificate: "com.android.apogee",
1255 bazel_module: { bp2build_available: false },
1256}
1257
1258filegroup {
1259 name: "com.android.apogee-file_contexts",
1260 srcs: [
1261 "com.android.apogee-file_contexts",
1262 ],
1263 bazel_module: { bp2build_available: false },
1264}
1265
1266apex {
1267 name: "com.android.apogee",
1268 manifest: "apogee_manifest.json",
1269 file_contexts: ":com.android.apogee-file_contexts",
1270 certificate: ":com.android.apogee.certificate",
1271 bazel_module: { bp2build_available: false },
1272}
1273
1274android_app_certificate {
1275 name: "com.google.android.apogee.certificate",
1276 certificate: "com.google.android.apogee",
1277 bazel_module: { bp2build_available: false },
1278}
1279
1280override_apex {
1281 name: "com.google.android.apogee",
1282 base: ":com.android.apogee",
1283 certificate: ":com.google.android.apogee.certificate",
1284}
1285`,
1286 ExpectedBazelTargets: []string{
1287 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chenc4c34e12022-11-29 12:07:45 +00001288 "base_apex_name": `"com.android.apogee"`,
1289 "file_contexts": `":com.android.apogee-file_contexts"`,
1290 "certificate": `":com.google.android.apogee.certificate"`,
1291 "manifest": `"apogee_manifest.json"`,
Jingwen Chenbea58092022-09-29 16:56:02 +00001292 }),
1293 }})
1294}
1295
1296func TestBp2BuildOverrideApex_CertificateIsSrc(t *testing.T) {
1297 runOverrideApexTestCase(t, Bp2buildTestCase{
1298 Description: "override_apex - certificate is src",
1299 ModuleTypeUnderTest: "override_apex",
1300 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
1301 Filesystem: map[string]string{},
1302 Blueprint: `
1303android_app_certificate {
1304 name: "com.android.apogee.certificate",
1305 certificate: "com.android.apogee",
1306 bazel_module: { bp2build_available: false },
1307}
1308
1309filegroup {
1310 name: "com.android.apogee-file_contexts",
1311 srcs: [
1312 "com.android.apogee-file_contexts",
1313 ],
1314 bazel_module: { bp2build_available: false },
1315}
1316
1317apex {
1318 name: "com.android.apogee",
1319 manifest: "apogee_manifest.json",
1320 file_contexts: ":com.android.apogee-file_contexts",
1321 certificate: ":com.android.apogee.certificate",
1322 bazel_module: { bp2build_available: false },
1323}
1324
1325override_apex {
1326 name: "com.google.android.apogee",
1327 base: ":com.android.apogee",
1328 certificate: "com.google.android.apogee.certificate",
1329}
1330`,
1331 ExpectedBazelTargets: []string{
1332 MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
Jingwen Chenc4c34e12022-11-29 12:07:45 +00001333 "base_apex_name": `"com.android.apogee"`,
Jingwen Chenbea58092022-09-29 16:56:02 +00001334 "file_contexts": `":com.android.apogee-file_contexts"`,
1335 "certificate_name": `"com.google.android.apogee.certificate"`,
1336 "manifest": `"apogee_manifest.json"`,
1337 }),
1338 }})
1339}
Yu Liu4c212ce2022-10-14 12:20:20 -07001340
1341func TestApexTestBundleSimple(t *testing.T) {
1342 runApexTestCase(t, Bp2buildTestCase{
1343 Description: "apex_test - simple",
1344 ModuleTypeUnderTest: "apex_test",
1345 ModuleTypeUnderTestFactory: apex.TestApexBundleFactory,
1346 Filesystem: map[string]string{},
1347 Blueprint: `
1348cc_test { name: "cc_test_1", bazel_module: { bp2build_available: false } }
1349
1350apex_test {
1351 name: "test_com.android.apogee",
1352 file_contexts: "file_contexts_file",
1353 tests: ["cc_test_1"],
1354}
1355`,
1356 ExpectedBazelTargets: []string{
1357 MakeBazelTarget("apex", "test_com.android.apogee", AttrNameToString{
1358 "file_contexts": `"file_contexts_file"`,
1359 "manifest": `"apex_manifest.json"`,
1360 "testonly": `True`,
1361 "tests": `[":cc_test_1"]`,
1362 }),
1363 }})
1364}
Cole Faust912bc882023-03-08 12:29:50 -08001365
1366func TestApexBundle_overridePlusProductVars(t *testing.T) {
1367 // Reproduction of b/271424349
1368 // Tests that overriding an apex that uses product variables correctly copies the product var
1369 // selects over to the override.
1370 runOverrideApexTestCase(t, Bp2buildTestCase{
1371 Description: "apex - overriding a module that uses product vars",
1372 ModuleTypeUnderTest: "override_apex",
1373 ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
1374 Blueprint: `
1375soong_config_string_variable {
1376 name: "library_linking_strategy",
1377 values: [
1378 "prefer_static",
1379 ],
1380}
1381
1382soong_config_module_type {
1383 name: "library_linking_strategy_apex_defaults",
1384 module_type: "apex_defaults",
1385 config_namespace: "ANDROID",
1386 variables: ["library_linking_strategy"],
1387 properties: [
1388 "manifest",
1389 "min_sdk_version",
1390 ],
1391}
1392
1393library_linking_strategy_apex_defaults {
1394 name: "higher_min_sdk_when_prefer_static",
1395 soong_config_variables: {
1396 library_linking_strategy: {
1397 // Use the R min_sdk_version
1398 prefer_static: {},
1399 // Override the R min_sdk_version to min_sdk_version that supports dcla
1400 conditions_default: {
1401 min_sdk_version: "31",
1402 },
1403 },
1404 },
1405}
1406
1407filegroup {
1408 name: "foo-file_contexts",
1409 srcs: [
1410 "com.android.apogee-file_contexts",
1411 ],
1412 bazel_module: { bp2build_available: false },
1413}
1414
1415apex {
1416 name: "foo",
1417 defaults: ["higher_min_sdk_when_prefer_static"],
1418 min_sdk_version: "30",
1419 package_name: "pkg_name",
1420 file_contexts: ":foo-file_contexts",
1421}
1422override_apex {
1423 name: "override_foo",
1424 base: ":foo",
1425 package_name: "override_pkg_name",
1426}
1427`,
1428 ExpectedBazelTargets: []string{
1429 MakeBazelTarget("apex", "foo", AttrNameToString{
1430 "file_contexts": `":foo-file_contexts"`,
1431 "manifest": `"apex_manifest.json"`,
1432 "min_sdk_version": `select({
1433 "//build/bazel/product_variables:android__library_linking_strategy__prefer_static": "30",
1434 "//conditions:default": "31",
1435 })`,
1436 "package_name": `"pkg_name"`,
1437 }), MakeBazelTarget("apex", "override_foo", AttrNameToString{
1438 "base_apex_name": `"foo"`,
1439 "file_contexts": `":foo-file_contexts"`,
1440 "manifest": `"apex_manifest.json"`,
1441 "min_sdk_version": `select({
1442 "//build/bazel/product_variables:android__library_linking_strategy__prefer_static": "30",
1443 "//conditions:default": "31",
1444 })`,
1445 "package_name": `"override_pkg_name"`,
1446 }),
1447 }})
1448}