Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 1 | // 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 | |
| 15 | package bp2build |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
| 19 | "android/soong/apex" |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 20 | "android/soong/cc" |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 21 | "android/soong/etc" |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 22 | "android/soong/java" |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 23 | "android/soong/sh" |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 24 | |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 25 | "fmt" |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 26 | "testing" |
| 27 | ) |
| 28 | |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 29 | func runApexTestCase(t *testing.T, tc Bp2buildTestCase) { |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 30 | t.Helper() |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 31 | RunBp2BuildTestCase(t, registerApexModuleTypes, tc) |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | func registerApexModuleTypes(ctx android.RegistrationContext) { |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 35 | // CC module types needed as they can be APEX dependencies |
| 36 | cc.RegisterCCBuildComponents(ctx) |
| 37 | |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 38 | ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory) |
| 39 | ctx.RegisterModuleType("cc_binary", cc.BinaryFactory) |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 40 | 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 Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 44 | ctx.RegisterModuleType("prebuilt_etc", etc.PrebuiltEtcFactory) |
Yu Liu | 4c212ce | 2022-10-14 12:20:20 -0700 | [diff] [blame] | 45 | ctx.RegisterModuleType("cc_test", cc.TestFactory) |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 46 | } |
| 47 | |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 48 | func runOverrideApexTestCase(t *testing.T, tc Bp2buildTestCase) { |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 49 | t.Helper() |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 50 | RunBp2BuildTestCase(t, registerOverrideApexModuleTypes, tc) |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | func 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 Faust | 912bc88 | 2023-03-08 12:29:50 -0800 | [diff] [blame^] | 64 | ctx.RegisterModuleType("apex_defaults", apex.DefaultsFactory) |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 65 | ctx.RegisterModuleType("prebuilt_etc", etc.PrebuiltEtcFactory) |
Cole Faust | 912bc88 | 2023-03-08 12:29:50 -0800 | [diff] [blame^] | 66 | ctx.RegisterModuleType("soong_config_module_type", android.SoongConfigModuleTypeFactory) |
| 67 | ctx.RegisterModuleType("soong_config_string_variable", android.SoongConfigStringVariableDummyFactory) |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 70 | func TestApexBundleSimple(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 71 | 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 Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 77 | apex_key { |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 78 | name: "com.android.apogee.key", |
| 79 | public_key: "com.android.apogee.avbpubkey", |
| 80 | private_key: "com.android.apogee.pem", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 81 | bazel_module: { bp2build_available: false }, |
| 82 | } |
| 83 | |
| 84 | android_app_certificate { |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 85 | name: "com.android.apogee.certificate", |
| 86 | certificate: "com.android.apogee", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 87 | bazel_module: { bp2build_available: false }, |
| 88 | } |
| 89 | |
| 90 | cc_library { |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 91 | name: "native_shared_lib_1", |
| 92 | bazel_module: { bp2build_available: false }, |
| 93 | } |
| 94 | |
| 95 | cc_library { |
| 96 | name: "native_shared_lib_2", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 97 | bazel_module: { bp2build_available: false }, |
| 98 | } |
| 99 | |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 100 | prebuilt_etc { |
| 101 | name: "prebuilt_1", |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 102 | bazel_module: { bp2build_available: false }, |
Rupert Shuttleworth | 9447e1e | 2021-07-28 05:53:42 -0400 | [diff] [blame] | 103 | } |
| 104 | |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 105 | prebuilt_etc { |
| 106 | name: "prebuilt_2", |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 107 | bazel_module: { bp2build_available: false }, |
Rupert Shuttleworth | 9447e1e | 2021-07-28 05:53:42 -0400 | [diff] [blame] | 108 | } |
| 109 | |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 110 | filegroup { |
| 111 | name: "com.android.apogee-file_contexts", |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 112 | srcs: [ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 113 | "com.android.apogee-file_contexts", |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 114 | ], |
| 115 | bazel_module: { bp2build_available: false }, |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 116 | } |
| 117 | |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 118 | cc_binary { name: "cc_binary_1", bazel_module: { bp2build_available: false } } |
| 119 | sh_binary { name: "sh_binary_2", bazel_module: { bp2build_available: false } } |
| 120 | |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 121 | apex { |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 122 | name: "com.android.apogee", |
| 123 | manifest: "apogee_manifest.json", |
| 124 | androidManifest: "ApogeeAndroidManifest.xml", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 125 | file_contexts: ":com.android.apogee-file_contexts", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 126 | min_sdk_version: "29", |
| 127 | key: "com.android.apogee.key", |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 128 | certificate: ":com.android.apogee.certificate", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 129 | updatable: false, |
| 130 | installable: false, |
Wei Li | f034cb4 | 2022-01-19 15:54:31 -0800 | [diff] [blame] | 131 | compressible: false, |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 132 | native_shared_libs: [ |
| 133 | "native_shared_lib_1", |
| 134 | "native_shared_lib_2", |
| 135 | ], |
| 136 | binaries: [ |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 137 | "cc_binary_1", |
| 138 | "sh_binary_2", |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 139 | ], |
Rupert Shuttleworth | 9447e1e | 2021-07-28 05:53:42 -0400 | [diff] [blame] | 140 | prebuilts: [ |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 141 | "prebuilt_1", |
| 142 | "prebuilt_2", |
Rupert Shuttleworth | 9447e1e | 2021-07-28 05:53:42 -0400 | [diff] [blame] | 143 | ], |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 144 | package_name: "com.android.apogee.test.package", |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 145 | logging_parent: "logging.parent", |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 146 | } |
| 147 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 148 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 149 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 150 | "android_manifest": `"ApogeeAndroidManifest.xml"`, |
| 151 | "binaries": `[ |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 152 | ":cc_binary_1", |
| 153 | ":sh_binary_2", |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 154 | ]`, |
| 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 Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 161 | "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 Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 172 | "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 Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 183 | "prebuilts": `[ |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 184 | ":prebuilt_1", |
| 185 | ":prebuilt_2", |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 186 | ]`, |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 187 | "updatable": "False", |
| 188 | "compressible": "False", |
| 189 | "package_name": `"com.android.apogee.test.package"`, |
| 190 | "logging_parent": `"logging.parent"`, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 191 | }), |
| 192 | }}) |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 193 | } |
| 194 | |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 195 | func TestApexBundleSimple_fileContextsInAnotherAndroidBp(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 196 | 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 Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 201 | "a/b/Android.bp": ` |
| 202 | filegroup { |
| 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 Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 211 | Blueprint: ` |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 212 | apex { |
| 213 | name: "com.android.apogee", |
| 214 | file_contexts: ":com.android.apogee-file_contexts", |
| 215 | } |
| 216 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 217 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 218 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 219 | "file_contexts": `"//a/b:com.android.apogee-file_contexts"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 220 | "manifest": `"apex_manifest.json"`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 221 | }), |
| 222 | }}) |
| 223 | } |
| 224 | |
| 225 | func TestApexBundleSimple_fileContextsIsFile(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 226 | 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 Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 232 | apex { |
| 233 | name: "com.android.apogee", |
| 234 | file_contexts: "file_contexts_file", |
| 235 | } |
| 236 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 237 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 238 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 239 | "file_contexts": `"file_contexts_file"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 240 | "manifest": `"apex_manifest.json"`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 241 | }), |
| 242 | }}) |
| 243 | } |
| 244 | |
| 245 | func TestApexBundleSimple_fileContextsIsNotSpecified(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 246 | runApexTestCase(t, Bp2buildTestCase{ |
| 247 | Description: "apex - file contexts is not specified", |
| 248 | ModuleTypeUnderTest: "apex", |
| 249 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 250 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 251 | "system/sepolicy/apex/Android.bp": ` |
| 252 | filegroup { |
| 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 Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 261 | Blueprint: ` |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 262 | apex { |
| 263 | name: "com.android.apogee", |
| 264 | } |
| 265 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 266 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 267 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 268 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 269 | "manifest": `"apex_manifest.json"`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 270 | }), |
| 271 | }}) |
| 272 | } |
| 273 | |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 274 | func TestApexBundleCompileMultilibBoth(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 275 | runApexTestCase(t, Bp2buildTestCase{ |
| 276 | Description: "apex - example with compile_multilib=both", |
| 277 | ModuleTypeUnderTest: "apex", |
| 278 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 279 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 280 | "system/sepolicy/apex/Android.bp": ` |
| 281 | filegroup { |
| 282 | name: "com.android.apogee-file_contexts", |
| 283 | srcs: [ "apogee-file_contexts", ], |
| 284 | bazel_module: { bp2build_available: false }, |
| 285 | } |
| 286 | `, |
| 287 | }, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 288 | Blueprint: createMultilibBlueprint(`compile_multilib: "both",`), |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 289 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 290 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 291 | "native_shared_libs_32": `[ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 292 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 293 | ":native_shared_lib_for_both", |
| 294 | ":native_shared_lib_for_lib32", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 295 | ] + select({ |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 296 | "//build/bazel/platforms/arch:arm": [":native_shared_lib_for_first"], |
| 297 | "//build/bazel/platforms/arch:x86": [":native_shared_lib_for_first"], |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 298 | "//conditions:default": [], |
| 299 | })`, |
| 300 | "native_shared_libs_64": `select({ |
| 301 | "//build/bazel/platforms/arch:arm64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 302 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 303 | ":native_shared_lib_for_both", |
| 304 | ":native_shared_lib_for_lib64", |
| 305 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 306 | ], |
| 307 | "//build/bazel/platforms/arch:x86_64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 308 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 309 | ":native_shared_lib_for_both", |
| 310 | ":native_shared_lib_for_lib64", |
| 311 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 312 | ], |
| 313 | "//conditions:default": [], |
| 314 | })`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 315 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 316 | "manifest": `"apex_manifest.json"`, |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 317 | }), |
| 318 | }}) |
| 319 | } |
| 320 | |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 321 | func TestApexBundleCompileMultilibFirstAndDefaultValue(t *testing.T) { |
| 322 | expectedBazelTargets := []string{ |
| 323 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
| 324 | "native_shared_libs_32": `select({ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 325 | "//build/bazel/platforms/arch:arm": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 326 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 327 | ":native_shared_lib_for_both", |
| 328 | ":native_shared_lib_for_lib32", |
| 329 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 330 | ], |
| 331 | "//build/bazel/platforms/arch:x86": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 332 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 333 | ":native_shared_lib_for_both", |
| 334 | ":native_shared_lib_for_lib32", |
| 335 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 336 | ], |
| 337 | "//conditions:default": [], |
| 338 | })`, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 339 | "native_shared_libs_64": `select({ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 340 | "//build/bazel/platforms/arch:arm64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 341 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 342 | ":native_shared_lib_for_both", |
| 343 | ":native_shared_lib_for_lib64", |
| 344 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 345 | ], |
| 346 | "//build/bazel/platforms/arch:x86_64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 347 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 348 | ":native_shared_lib_for_both", |
| 349 | ":native_shared_lib_for_lib64", |
| 350 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 351 | ], |
| 352 | "//conditions:default": [], |
| 353 | })`, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 354 | "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 Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | func TestApexBundleCompileMultilib32(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 387 | runApexTestCase(t, Bp2buildTestCase{ |
| 388 | Description: "apex - example with compile_multilib=32", |
| 389 | ModuleTypeUnderTest: "apex", |
| 390 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 391 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 392 | "system/sepolicy/apex/Android.bp": ` |
| 393 | filegroup { |
| 394 | name: "com.android.apogee-file_contexts", |
| 395 | srcs: [ "apogee-file_contexts", ], |
| 396 | bazel_module: { bp2build_available: false }, |
| 397 | } |
| 398 | `, |
| 399 | }, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 400 | Blueprint: createMultilibBlueprint(`compile_multilib: "32",`), |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 401 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 402 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 403 | "native_shared_libs_32": `[ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 404 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 405 | ":native_shared_lib_for_both", |
| 406 | ":native_shared_lib_for_lib32", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 407 | ] + select({ |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 408 | "//build/bazel/platforms/arch:arm": [":native_shared_lib_for_first"], |
| 409 | "//build/bazel/platforms/arch:x86": [":native_shared_lib_for_first"], |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 410 | "//conditions:default": [], |
| 411 | })`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 412 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 413 | "manifest": `"apex_manifest.json"`, |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 414 | }), |
| 415 | }}) |
| 416 | } |
| 417 | |
| 418 | func TestApexBundleCompileMultilib64(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 419 | runApexTestCase(t, Bp2buildTestCase{ |
| 420 | Description: "apex - example with compile_multilib=64", |
| 421 | ModuleTypeUnderTest: "apex", |
| 422 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 423 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 424 | "system/sepolicy/apex/Android.bp": ` |
| 425 | filegroup { |
| 426 | name: "com.android.apogee-file_contexts", |
| 427 | srcs: [ "apogee-file_contexts", ], |
| 428 | bazel_module: { bp2build_available: false }, |
| 429 | } |
| 430 | `, |
| 431 | }, |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 432 | Blueprint: createMultilibBlueprint(`compile_multilib: "64",`), |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 433 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 434 | MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 435 | "native_shared_libs_64": `select({ |
| 436 | "//build/bazel/platforms/arch:arm64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 437 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 438 | ":native_shared_lib_for_both", |
| 439 | ":native_shared_lib_for_lib64", |
| 440 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 441 | ], |
| 442 | "//build/bazel/platforms/arch:x86_64": [ |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 443 | ":unnested_native_shared_lib", |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 444 | ":native_shared_lib_for_both", |
| 445 | ":native_shared_lib_for_lib64", |
| 446 | ":native_shared_lib_for_first", |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 447 | ], |
| 448 | "//conditions:default": [], |
| 449 | })`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 450 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 451 | "manifest": `"apex_manifest.json"`, |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 452 | }), |
| 453 | }}) |
| 454 | } |
| 455 | |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 456 | func createMultilibBlueprint(compile_multilib string) string { |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 457 | return fmt.Sprintf(` |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 458 | cc_library { |
| 459 | name: "native_shared_lib_for_both", |
| 460 | bazel_module: { bp2build_available: false }, |
| 461 | } |
| 462 | |
| 463 | cc_library { |
| 464 | name: "native_shared_lib_for_first", |
| 465 | bazel_module: { bp2build_available: false }, |
| 466 | } |
| 467 | |
| 468 | cc_library { |
| 469 | name: "native_shared_lib_for_lib32", |
| 470 | bazel_module: { bp2build_available: false }, |
| 471 | } |
| 472 | |
| 473 | cc_library { |
| 474 | name: "native_shared_lib_for_lib64", |
| 475 | bazel_module: { bp2build_available: false }, |
| 476 | } |
| 477 | |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 478 | cc_library { |
| 479 | name: "unnested_native_shared_lib", |
| 480 | bazel_module: { bp2build_available: false }, |
| 481 | } |
| 482 | |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 483 | apex { |
| 484 | name: "com.android.apogee", |
Vinh Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 485 | %s |
| 486 | native_shared_libs: ["unnested_native_shared_lib"], |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 487 | 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 Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 509 | }`, compile_multilib) |
Jingwen Chen | 34feb14 | 2022-10-06 13:02:30 +0000 | [diff] [blame] | 510 | } |
| 511 | |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 512 | func TestApexBundleDefaultPropertyValues(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 513 | runApexTestCase(t, Bp2buildTestCase{ |
| 514 | Description: "apex - default property values", |
| 515 | ModuleTypeUnderTest: "apex", |
| 516 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 517 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 518 | "system/sepolicy/apex/Android.bp": ` |
| 519 | filegroup { |
| 520 | name: "com.android.apogee-file_contexts", |
| 521 | srcs: [ "apogee-file_contexts", ], |
| 522 | bazel_module: { bp2build_available: false }, |
| 523 | } |
| 524 | `, |
| 525 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 526 | Blueprint: ` |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 527 | apex { |
| 528 | name: "com.android.apogee", |
| 529 | manifest: "apogee_manifest.json", |
| 530 | } |
| 531 | `, |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 532 | ExpectedBazelTargets: []string{MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 533 | "manifest": `"apogee_manifest.json"`, |
| 534 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 535 | }), |
| 536 | }}) |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 537 | } |
Jingwen Chen | f59a8e1 | 2021-07-16 09:28:53 +0000 | [diff] [blame] | 538 | |
| 539 | func TestApexBundleHasBazelModuleProps(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 540 | runApexTestCase(t, Bp2buildTestCase{ |
| 541 | Description: "apex - has bazel module props", |
| 542 | ModuleTypeUnderTest: "apex", |
| 543 | ModuleTypeUnderTestFactory: apex.BundleFactory, |
| 544 | Filesystem: map[string]string{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 545 | "system/sepolicy/apex/Android.bp": ` |
| 546 | filegroup { |
| 547 | name: "apogee-file_contexts", |
| 548 | srcs: [ "apogee-file_contexts", ], |
| 549 | bazel_module: { bp2build_available: false }, |
| 550 | } |
| 551 | `, |
| 552 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 553 | Blueprint: ` |
Jingwen Chen | f59a8e1 | 2021-07-16 09:28:53 +0000 | [diff] [blame] | 554 | apex { |
| 555 | name: "apogee", |
| 556 | manifest: "manifest.json", |
| 557 | bazel_module: { bp2build_available: true }, |
| 558 | } |
| 559 | `, |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 560 | ExpectedBazelTargets: []string{MakeBazelTarget("apex", "apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 561 | "manifest": `"manifest.json"`, |
| 562 | "file_contexts": `"//system/sepolicy/apex:apogee-file_contexts"`, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 563 | }), |
| 564 | }}) |
Jingwen Chen | f59a8e1 | 2021-07-16 09:28:53 +0000 | [diff] [blame] | 565 | } |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 566 | |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 567 | func TestBp2BuildOverrideApex(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 568 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 569 | Description: "override_apex", |
| 570 | ModuleTypeUnderTest: "override_apex", |
| 571 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 572 | Filesystem: map[string]string{}, |
| 573 | Blueprint: ` |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 574 | apex_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 | |
| 581 | android_app_certificate { |
| 582 | name: "com.android.apogee.certificate", |
| 583 | certificate: "com.android.apogee", |
| 584 | bazel_module: { bp2build_available: false }, |
| 585 | } |
| 586 | |
| 587 | cc_library { |
| 588 | name: "native_shared_lib_1", |
| 589 | bazel_module: { bp2build_available: false }, |
| 590 | } |
| 591 | |
| 592 | cc_library { |
| 593 | name: "native_shared_lib_2", |
| 594 | bazel_module: { bp2build_available: false }, |
| 595 | } |
| 596 | |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 597 | prebuilt_etc { |
| 598 | name: "prebuilt_1", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 599 | bazel_module: { bp2build_available: false }, |
| 600 | } |
| 601 | |
Jingwen Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 602 | prebuilt_etc { |
| 603 | name: "prebuilt_2", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 604 | bazel_module: { bp2build_available: false }, |
| 605 | } |
| 606 | |
| 607 | filegroup { |
| 608 | name: "com.android.apogee-file_contexts", |
| 609 | srcs: [ |
| 610 | "com.android.apogee-file_contexts", |
| 611 | ], |
| 612 | bazel_module: { bp2build_available: false }, |
| 613 | } |
| 614 | |
| 615 | cc_binary { name: "cc_binary_1", bazel_module: { bp2build_available: false } } |
| 616 | sh_binary { name: "sh_binary_2", bazel_module: { bp2build_available: false } } |
| 617 | |
| 618 | apex { |
| 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 Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 625 | certificate: ":com.android.apogee.certificate", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 626 | 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 Chen | 81c67d3 | 2022-06-08 16:08:25 +0000 | [diff] [blame] | 638 | "prebuilt_1", |
| 639 | "prebuilt_2", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 640 | ], |
| 641 | bazel_module: { bp2build_available: false }, |
| 642 | } |
| 643 | |
| 644 | apex_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 | |
| 651 | android_app_certificate { |
| 652 | name: "com.google.android.apogee.certificate", |
| 653 | certificate: "com.google.android.apogee", |
| 654 | bazel_module: { bp2build_available: false }, |
| 655 | } |
| 656 | |
| 657 | override_apex { |
| 658 | name: "com.google.android.apogee", |
| 659 | base: ":com.android.apogee", |
| 660 | key: "com.google.android.apogee.key", |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 661 | certificate: ":com.google.android.apogee.certificate", |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 662 | prebuilts: [], |
| 663 | compressible: true, |
| 664 | } |
| 665 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 666 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 667 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 668 | "android_manifest": `"ApogeeAndroidManifest.xml"`, |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 669 | "base_apex_name": `"com.android.apogee"`, |
Wei Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 670 | "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 Tran | 8f5310f | 2022-10-07 18:16:47 -0400 | [diff] [blame] | 680 | "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 Li | 1c66fc7 | 2022-05-09 23:59:14 -0700 | [diff] [blame] | 691 | "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 Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 708 | |
| 709 | func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInDifferentAndroidBp(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 710 | 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 Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 715 | "system/sepolicy/apex/Android.bp": ` |
| 716 | filegroup { |
| 717 | name: "com.android.apogee-file_contexts", |
| 718 | srcs: [ "apogee-file_contexts", ], |
| 719 | bazel_module: { bp2build_available: false }, |
| 720 | }`, |
| 721 | "a/b/Android.bp": ` |
| 722 | apex { |
| 723 | name: "com.android.apogee", |
| 724 | bazel_module: { bp2build_available: false }, |
| 725 | } |
| 726 | `, |
| 727 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 728 | Blueprint: ` |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 729 | override_apex { |
| 730 | name: "com.google.android.apogee", |
| 731 | base: ":com.android.apogee", |
| 732 | } |
| 733 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 734 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 735 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 736 | "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 Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 739 | }), |
| 740 | }}) |
| 741 | } |
| 742 | |
| 743 | func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInDifferentAndroidBp(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 744 | 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 Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 749 | "system/sepolicy/apex/Android.bp": ` |
| 750 | filegroup { |
| 751 | name: "com.android.apogee-file_contexts", |
| 752 | srcs: [ "apogee-file_contexts", ], |
| 753 | bazel_module: { bp2build_available: false }, |
| 754 | }`, |
| 755 | "a/b/Android.bp": ` |
| 756 | apex { |
| 757 | name: "com.android.apogee", |
| 758 | manifest: "apogee_manifest.json", |
| 759 | bazel_module: { bp2build_available: false }, |
| 760 | } |
| 761 | `, |
| 762 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 763 | Blueprint: ` |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 764 | override_apex { |
| 765 | name: "com.google.android.apogee", |
| 766 | base: ":com.android.apogee", |
| 767 | } |
| 768 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 769 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 770 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 771 | "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 Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 774 | }), |
| 775 | }}) |
| 776 | } |
| 777 | |
| 778 | func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInSameAndroidBp(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 779 | 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 Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 784 | "system/sepolicy/apex/Android.bp": ` |
| 785 | filegroup { |
| 786 | name: "com.android.apogee-file_contexts", |
| 787 | srcs: [ "apogee-file_contexts", ], |
| 788 | bazel_module: { bp2build_available: false }, |
| 789 | }`, |
| 790 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 791 | Blueprint: ` |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 792 | apex { |
| 793 | name: "com.android.apogee", |
| 794 | bazel_module: { bp2build_available: false }, |
| 795 | } |
| 796 | |
| 797 | override_apex { |
| 798 | name: "com.google.android.apogee", |
| 799 | base: ":com.android.apogee", |
| 800 | } |
| 801 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 802 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 803 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 804 | "base_apex_name": `"com.android.apogee"`, |
| 805 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 806 | "manifest": `"apex_manifest.json"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 807 | }), |
| 808 | }}) |
| 809 | } |
| 810 | |
| 811 | func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInSameAndroidBp(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 812 | 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 Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 817 | "system/sepolicy/apex/Android.bp": ` |
| 818 | filegroup { |
| 819 | name: "com.android.apogee-file_contexts", |
| 820 | srcs: [ "apogee-file_contexts", ], |
| 821 | bazel_module: { bp2build_available: false }, |
| 822 | }`, |
| 823 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 824 | Blueprint: ` |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 825 | apex { |
| 826 | name: "com.android.apogee", |
| 827 | manifest: "apogee_manifest.json", |
| 828 | bazel_module: { bp2build_available: false }, |
| 829 | } |
| 830 | |
| 831 | override_apex { |
| 832 | name: "com.google.android.apogee", |
| 833 | base: ":com.android.apogee", |
| 834 | } |
| 835 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 836 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 837 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 838 | "base_apex_name": `"com.android.apogee"`, |
| 839 | "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, |
| 840 | "manifest": `"apogee_manifest.json"`, |
Wei Li | 40f9873 | 2022-05-20 22:08:11 -0700 | [diff] [blame] | 841 | }), |
| 842 | }}) |
| 843 | } |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 844 | |
| 845 | func TestApexBundleSimple_packageNameOverride(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 846 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 847 | Description: "override_apex - override package name", |
| 848 | ModuleTypeUnderTest: "override_apex", |
| 849 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 850 | Filesystem: map[string]string{ |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 851 | "system/sepolicy/apex/Android.bp": ` |
| 852 | filegroup { |
| 853 | name: "com.android.apogee-file_contexts", |
| 854 | srcs: [ "apogee-file_contexts", ], |
| 855 | bazel_module: { bp2build_available: false }, |
| 856 | }`, |
| 857 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 858 | Blueprint: ` |
Jingwen Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 859 | apex { |
| 860 | name: "com.android.apogee", |
| 861 | bazel_module: { bp2build_available: false }, |
| 862 | } |
| 863 | |
| 864 | override_apex { |
| 865 | name: "com.google.android.apogee", |
| 866 | base: ":com.android.apogee", |
| 867 | package_name: "com.google.android.apogee", |
| 868 | } |
| 869 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 870 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 871 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 872 | "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 Chen | 9b7ebca | 2022-06-03 09:11:20 +0000 | [diff] [blame] | 876 | }), |
| 877 | }}) |
| 878 | } |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 879 | |
| 880 | func TestApexBundleSimple_NoPrebuiltsOverride(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 881 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 882 | Description: "override_apex - no override", |
| 883 | ModuleTypeUnderTest: "override_apex", |
| 884 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 885 | Filesystem: map[string]string{ |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 886 | "system/sepolicy/apex/Android.bp": ` |
| 887 | filegroup { |
| 888 | name: "com.android.apogee-file_contexts", |
| 889 | srcs: [ "apogee-file_contexts", ], |
| 890 | bazel_module: { bp2build_available: false }, |
| 891 | }`, |
| 892 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 893 | Blueprint: ` |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 894 | prebuilt_etc { |
| 895 | name: "prebuilt_file", |
| 896 | bazel_module: { bp2build_available: false }, |
| 897 | } |
| 898 | |
| 899 | apex { |
| 900 | name: "com.android.apogee", |
| 901 | bazel_module: { bp2build_available: false }, |
| 902 | prebuilts: ["prebuilt_file"] |
| 903 | } |
| 904 | |
| 905 | override_apex { |
| 906 | name: "com.google.android.apogee", |
| 907 | base: ":com.android.apogee", |
| 908 | } |
| 909 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 910 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 911 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 912 | "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 Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 916 | }), |
| 917 | }}) |
| 918 | } |
| 919 | |
| 920 | func TestApexBundleSimple_PrebuiltsOverride(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 921 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 922 | Description: "override_apex - ooverride", |
| 923 | ModuleTypeUnderTest: "override_apex", |
| 924 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 925 | Filesystem: map[string]string{ |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 926 | "system/sepolicy/apex/Android.bp": ` |
| 927 | filegroup { |
| 928 | name: "com.android.apogee-file_contexts", |
| 929 | srcs: [ "apogee-file_contexts", ], |
| 930 | bazel_module: { bp2build_available: false }, |
| 931 | }`, |
| 932 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 933 | Blueprint: ` |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 934 | prebuilt_etc { |
| 935 | name: "prebuilt_file", |
| 936 | bazel_module: { bp2build_available: false }, |
| 937 | } |
| 938 | |
| 939 | prebuilt_etc { |
| 940 | name: "prebuilt_file2", |
| 941 | bazel_module: { bp2build_available: false }, |
| 942 | } |
| 943 | |
| 944 | apex { |
| 945 | name: "com.android.apogee", |
| 946 | bazel_module: { bp2build_available: false }, |
| 947 | prebuilts: ["prebuilt_file"] |
| 948 | } |
| 949 | |
| 950 | override_apex { |
| 951 | name: "com.google.android.apogee", |
| 952 | base: ":com.android.apogee", |
| 953 | prebuilts: ["prebuilt_file2"] |
| 954 | } |
| 955 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 956 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 957 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 958 | "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 Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 962 | }), |
| 963 | }}) |
| 964 | } |
| 965 | |
| 966 | func TestApexBundleSimple_PrebuiltsOverrideEmptyList(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 967 | 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 Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 972 | "system/sepolicy/apex/Android.bp": ` |
| 973 | filegroup { |
| 974 | name: "com.android.apogee-file_contexts", |
| 975 | srcs: [ "apogee-file_contexts", ], |
| 976 | bazel_module: { bp2build_available: false }, |
| 977 | }`, |
| 978 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 979 | Blueprint: ` |
Jingwen Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 980 | prebuilt_etc { |
| 981 | name: "prebuilt_file", |
| 982 | bazel_module: { bp2build_available: false }, |
| 983 | } |
| 984 | |
| 985 | apex { |
| 986 | name: "com.android.apogee", |
| 987 | bazel_module: { bp2build_available: false }, |
| 988 | prebuilts: ["prebuilt_file"] |
| 989 | } |
| 990 | |
| 991 | override_apex { |
| 992 | name: "com.google.android.apogee", |
| 993 | base: ":com.android.apogee", |
| 994 | prebuilts: [], |
| 995 | } |
| 996 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 997 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 998 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 999 | "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 Chen | df165c9 | 2022-06-08 16:00:39 +0000 | [diff] [blame] | 1003 | }), |
| 1004 | }}) |
| 1005 | } |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1006 | |
| 1007 | func TestApexBundleSimple_NoLoggingParentOverride(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1008 | 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 Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1013 | "system/sepolicy/apex/Android.bp": ` |
| 1014 | filegroup { |
| 1015 | name: "com.android.apogee-file_contexts", |
| 1016 | srcs: [ "apogee-file_contexts", ], |
| 1017 | bazel_module: { bp2build_available: false }, |
| 1018 | }`, |
| 1019 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1020 | Blueprint: ` |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1021 | apex { |
| 1022 | name: "com.android.apogee", |
| 1023 | bazel_module: { bp2build_available: false }, |
| 1024 | logging_parent: "foo.bar.baz", |
| 1025 | } |
| 1026 | |
| 1027 | override_apex { |
| 1028 | name: "com.google.android.apogee", |
| 1029 | base: ":com.android.apogee", |
| 1030 | } |
| 1031 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1032 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 1033 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 1034 | "base_apex_name": `"com.android.apogee"`, |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1035 | "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 | |
| 1042 | func TestApexBundleSimple_LoggingParentOverride(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1043 | runOverrideApexTestCase(t, Bp2buildTestCase{ |
| 1044 | Description: "override_apex - logging_parent - override", |
| 1045 | ModuleTypeUnderTest: "override_apex", |
| 1046 | ModuleTypeUnderTestFactory: apex.OverrideApexFactory, |
| 1047 | Filesystem: map[string]string{ |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1048 | "system/sepolicy/apex/Android.bp": ` |
| 1049 | filegroup { |
| 1050 | name: "com.android.apogee-file_contexts", |
| 1051 | srcs: [ "apogee-file_contexts", ], |
| 1052 | bazel_module: { bp2build_available: false }, |
| 1053 | }`, |
| 1054 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1055 | Blueprint: ` |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1056 | apex { |
| 1057 | name: "com.android.apogee", |
| 1058 | bazel_module: { bp2build_available: false }, |
| 1059 | logging_parent: "foo.bar.baz", |
| 1060 | } |
| 1061 | |
| 1062 | override_apex { |
| 1063 | name: "com.google.android.apogee", |
| 1064 | base: ":com.android.apogee", |
| 1065 | logging_parent: "foo.bar.baz.override", |
| 1066 | } |
| 1067 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 1068 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 1069 | MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ |
Jingwen Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 1070 | "base_apex_name": `"com.android.apogee"`, |
Jingwen Chen | b732d7c | 2022-06-10 08:14:19 +0000 | [diff] [blame] | 1071 | "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 Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1077 | |
| 1078 | func 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: ` |
| 1085 | android_app_certificate { |
| 1086 | name: "com.android.apogee.certificate", |
| 1087 | certificate: "com.android.apogee", |
| 1088 | bazel_module: { bp2build_available: false }, |
| 1089 | } |
| 1090 | |
| 1091 | filegroup { |
| 1092 | name: "com.android.apogee-file_contexts", |
| 1093 | srcs: [ |
| 1094 | "com.android.apogee-file_contexts", |
| 1095 | ], |
| 1096 | bazel_module: { bp2build_available: false }, |
| 1097 | } |
| 1098 | |
| 1099 | apex { |
| 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 | |
| 1107 | override_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 Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 1116 | "base_apex_name": `"com.android.apogee"`, |
| 1117 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 1118 | "manifest": `"apogee_manifest.json"`, |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1119 | }), |
| 1120 | }}) |
| 1121 | } |
| 1122 | |
| 1123 | func 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: ` |
| 1130 | android_app_certificate { |
| 1131 | name: "com.android.apogee.certificate", |
| 1132 | certificate: "com.android.apogee", |
| 1133 | bazel_module: { bp2build_available: false }, |
| 1134 | } |
| 1135 | |
| 1136 | apex { |
| 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 Tran | 55225e3 | 2022-12-20 10:38:48 -0500 | [diff] [blame] | 1152 | func 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: ` |
| 1159 | cc_library{ |
| 1160 | name: "foo", |
| 1161 | stubs: { symbol_file: "foo.map.txt", versions: ["28", "29", "current"] }, |
| 1162 | apex_available: ["myapex"], |
| 1163 | } |
| 1164 | |
| 1165 | cc_binary{ |
| 1166 | name: "bar", |
| 1167 | static_libs: ["foo"], |
| 1168 | apex_available: ["myapex"], |
| 1169 | } |
| 1170 | |
| 1171 | apex { |
| 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 Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1222 | func 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: ` |
| 1229 | apex { |
| 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 | |
| 1245 | func 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: ` |
| 1252 | android_app_certificate { |
| 1253 | name: "com.android.apogee.certificate", |
| 1254 | certificate: "com.android.apogee", |
| 1255 | bazel_module: { bp2build_available: false }, |
| 1256 | } |
| 1257 | |
| 1258 | filegroup { |
| 1259 | name: "com.android.apogee-file_contexts", |
| 1260 | srcs: [ |
| 1261 | "com.android.apogee-file_contexts", |
| 1262 | ], |
| 1263 | bazel_module: { bp2build_available: false }, |
| 1264 | } |
| 1265 | |
| 1266 | apex { |
| 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 | |
| 1274 | android_app_certificate { |
| 1275 | name: "com.google.android.apogee.certificate", |
| 1276 | certificate: "com.google.android.apogee", |
| 1277 | bazel_module: { bp2build_available: false }, |
| 1278 | } |
| 1279 | |
| 1280 | override_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 Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 1288 | "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 Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1292 | }), |
| 1293 | }}) |
| 1294 | } |
| 1295 | |
| 1296 | func 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: ` |
| 1303 | android_app_certificate { |
| 1304 | name: "com.android.apogee.certificate", |
| 1305 | certificate: "com.android.apogee", |
| 1306 | bazel_module: { bp2build_available: false }, |
| 1307 | } |
| 1308 | |
| 1309 | filegroup { |
| 1310 | name: "com.android.apogee-file_contexts", |
| 1311 | srcs: [ |
| 1312 | "com.android.apogee-file_contexts", |
| 1313 | ], |
| 1314 | bazel_module: { bp2build_available: false }, |
| 1315 | } |
| 1316 | |
| 1317 | apex { |
| 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 | |
| 1325 | override_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 Chen | c4c34e1 | 2022-11-29 12:07:45 +0000 | [diff] [blame] | 1333 | "base_apex_name": `"com.android.apogee"`, |
Jingwen Chen | bea5809 | 2022-09-29 16:56:02 +0000 | [diff] [blame] | 1334 | "file_contexts": `":com.android.apogee-file_contexts"`, |
| 1335 | "certificate_name": `"com.google.android.apogee.certificate"`, |
| 1336 | "manifest": `"apogee_manifest.json"`, |
| 1337 | }), |
| 1338 | }}) |
| 1339 | } |
Yu Liu | 4c212ce | 2022-10-14 12:20:20 -0700 | [diff] [blame] | 1340 | |
| 1341 | func 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: ` |
| 1348 | cc_test { name: "cc_test_1", bazel_module: { bp2build_available: false } } |
| 1349 | |
| 1350 | apex_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 Faust | 912bc88 | 2023-03-08 12:29:50 -0800 | [diff] [blame^] | 1365 | |
| 1366 | func 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: ` |
| 1375 | soong_config_string_variable { |
| 1376 | name: "library_linking_strategy", |
| 1377 | values: [ |
| 1378 | "prefer_static", |
| 1379 | ], |
| 1380 | } |
| 1381 | |
| 1382 | soong_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 | |
| 1393 | library_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 | |
| 1407 | filegroup { |
| 1408 | name: "foo-file_contexts", |
| 1409 | srcs: [ |
| 1410 | "com.android.apogee-file_contexts", |
| 1411 | ], |
| 1412 | bazel_module: { bp2build_available: false }, |
| 1413 | } |
| 1414 | |
| 1415 | apex { |
| 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 | } |
| 1422 | override_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 | } |