Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [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 | "testing" |
| 19 | |
| 20 | "android/soong/android" |
| 21 | "android/soong/cc" |
| 22 | ) |
| 23 | |
| 24 | const ( |
| 25 | // See cc/testing.go for more context |
| 26 | // TODO(alexmarquez): Split out the preamble into common code? |
| 27 | soongCcLibrarySharedPreamble = soongCcLibraryStaticPreamble |
| 28 | ) |
| 29 | |
| 30 | func registerCcLibrarySharedModuleTypes(ctx android.RegistrationContext) { |
| 31 | cc.RegisterCCBuildComponents(ctx) |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 32 | ctx.RegisterModuleType("cc_library_headers", cc.LibraryHeaderFactory) |
| 33 | ctx.RegisterModuleType("cc_library_static", cc.LibraryStaticFactory) |
Liz Kammer | 12615db | 2021-09-28 09:19:17 -0400 | [diff] [blame] | 34 | ctx.RegisterModuleType("cc_library", cc.LibraryFactory) |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 37 | func runCcLibrarySharedTestCase(t *testing.T, tc Bp2buildTestCase) { |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 38 | t.Helper() |
Alex Márquez Pérez Muñíz Díaz Puras Thaureaux | c641cc4 | 2023-03-16 17:03:43 +0000 | [diff] [blame] | 39 | t.Parallel() |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 40 | (&tc).ModuleTypeUnderTest = "cc_library_shared" |
| 41 | (&tc).ModuleTypeUnderTestFactory = cc.LibrarySharedFactory |
| 42 | RunBp2BuildTestCase(t, registerCcLibrarySharedModuleTypes, tc) |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | func TestCcLibrarySharedSimple(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 46 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 47 | Description: "cc_library_shared simple overall test", |
| 48 | Filesystem: map[string]string{ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 49 | // NOTE: include_dir headers *should not* appear in Bazel hdrs later (?) |
| 50 | "include_dir_1/include_dir_1_a.h": "", |
| 51 | "include_dir_1/include_dir_1_b.h": "", |
| 52 | "include_dir_2/include_dir_2_a.h": "", |
| 53 | "include_dir_2/include_dir_2_b.h": "", |
| 54 | // NOTE: local_include_dir headers *should not* appear in Bazel hdrs later (?) |
| 55 | "local_include_dir_1/local_include_dir_1_a.h": "", |
| 56 | "local_include_dir_1/local_include_dir_1_b.h": "", |
| 57 | "local_include_dir_2/local_include_dir_2_a.h": "", |
| 58 | "local_include_dir_2/local_include_dir_2_b.h": "", |
| 59 | // NOTE: export_include_dir headers *should* appear in Bazel hdrs later |
| 60 | "export_include_dir_1/export_include_dir_1_a.h": "", |
| 61 | "export_include_dir_1/export_include_dir_1_b.h": "", |
| 62 | "export_include_dir_2/export_include_dir_2_a.h": "", |
| 63 | "export_include_dir_2/export_include_dir_2_b.h": "", |
| 64 | // NOTE: Soong implicitly includes headers in the current directory |
| 65 | "implicit_include_1.h": "", |
| 66 | "implicit_include_2.h": "", |
| 67 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 68 | Blueprint: soongCcLibrarySharedPreamble + ` |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 69 | cc_library_headers { |
| 70 | name: "header_lib_1", |
| 71 | export_include_dirs: ["header_lib_1"], |
| 72 | bazel_module: { bp2build_available: false }, |
| 73 | } |
| 74 | |
| 75 | cc_library_headers { |
| 76 | name: "header_lib_2", |
| 77 | export_include_dirs: ["header_lib_2"], |
| 78 | bazel_module: { bp2build_available: false }, |
| 79 | } |
| 80 | |
| 81 | cc_library_shared { |
| 82 | name: "shared_lib_1", |
| 83 | srcs: ["shared_lib_1.cc"], |
| 84 | bazel_module: { bp2build_available: false }, |
| 85 | } |
| 86 | |
| 87 | cc_library_shared { |
| 88 | name: "shared_lib_2", |
| 89 | srcs: ["shared_lib_2.cc"], |
| 90 | bazel_module: { bp2build_available: false }, |
| 91 | } |
| 92 | |
| 93 | cc_library_static { |
| 94 | name: "whole_static_lib_1", |
| 95 | srcs: ["whole_static_lib_1.cc"], |
| 96 | bazel_module: { bp2build_available: false }, |
| 97 | } |
| 98 | |
| 99 | cc_library_static { |
| 100 | name: "whole_static_lib_2", |
| 101 | srcs: ["whole_static_lib_2.cc"], |
| 102 | bazel_module: { bp2build_available: false }, |
| 103 | } |
| 104 | |
| 105 | cc_library_shared { |
| 106 | name: "foo_shared", |
| 107 | srcs: [ |
| 108 | "foo_shared1.cc", |
| 109 | "foo_shared2.cc", |
| 110 | ], |
| 111 | cflags: [ |
| 112 | "-Dflag1", |
| 113 | "-Dflag2" |
| 114 | ], |
| 115 | shared_libs: [ |
| 116 | "shared_lib_1", |
| 117 | "shared_lib_2" |
| 118 | ], |
| 119 | whole_static_libs: [ |
| 120 | "whole_static_lib_1", |
| 121 | "whole_static_lib_2" |
| 122 | ], |
| 123 | include_dirs: [ |
| 124 | "include_dir_1", |
| 125 | "include_dir_2", |
| 126 | ], |
| 127 | local_include_dirs: [ |
| 128 | "local_include_dir_1", |
| 129 | "local_include_dir_2", |
| 130 | ], |
| 131 | export_include_dirs: [ |
| 132 | "export_include_dir_1", |
| 133 | "export_include_dir_2" |
| 134 | ], |
| 135 | header_libs: [ |
| 136 | "header_lib_1", |
| 137 | "header_lib_2" |
| 138 | ], |
Yu Liu | fc60316 | 2022-03-01 15:44:08 -0800 | [diff] [blame] | 139 | sdk_version: "current", |
| 140 | min_sdk_version: "29", |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 141 | |
| 142 | // TODO: Also support export_header_lib_headers |
| 143 | }`, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 144 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 145 | MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{ |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 146 | "absolute_includes": `[ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 147 | "include_dir_1", |
| 148 | "include_dir_2", |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 149 | ]`, |
| 150 | "copts": `[ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 151 | "-Dflag1", |
| 152 | "-Dflag2", |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 153 | ]`, |
| 154 | "export_includes": `[ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 155 | "export_include_dir_1", |
| 156 | "export_include_dir_2", |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 157 | ]`, |
| 158 | "implementation_deps": `[ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 159 | ":header_lib_1", |
| 160 | ":header_lib_2", |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 161 | ]`, |
| 162 | "implementation_dynamic_deps": `[ |
Liz Kammer | 7a210ac | 2021-09-22 15:52:58 -0400 | [diff] [blame] | 163 | ":shared_lib_1", |
| 164 | ":shared_lib_2", |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 165 | ]`, |
| 166 | "local_includes": `[ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 167 | "local_include_dir_1", |
| 168 | "local_include_dir_2", |
| 169 | ".", |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 170 | ]`, |
| 171 | "srcs": `[ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 172 | "foo_shared1.cc", |
| 173 | "foo_shared2.cc", |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 174 | ]`, |
| 175 | "whole_archive_deps": `[ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 176 | ":whole_static_lib_1", |
| 177 | ":whole_static_lib_2", |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 178 | ]`, |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | 126bd58 | 2022-04-21 15:19:27 +0000 | [diff] [blame] | 179 | "sdk_version": `"current"`, |
| 180 | "min_sdk_version": `"29"`, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 181 | }), |
| 182 | }, |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 183 | }) |
| 184 | } |
| 185 | |
| 186 | func TestCcLibrarySharedArchSpecificSharedLib(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 187 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 188 | Description: "cc_library_shared arch-specific shared_libs with whole_static_libs", |
| 189 | Filesystem: map[string]string{}, |
| 190 | Blueprint: soongCcLibrarySharedPreamble + ` |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 191 | cc_library_static { |
| 192 | name: "static_dep", |
| 193 | bazel_module: { bp2build_available: false }, |
| 194 | } |
| 195 | cc_library_shared { |
| 196 | name: "shared_dep", |
| 197 | bazel_module: { bp2build_available: false }, |
| 198 | } |
| 199 | cc_library_shared { |
| 200 | name: "foo_shared", |
| 201 | arch: { arm64: { shared_libs: ["shared_dep"], whole_static_libs: ["static_dep"] } }, |
| 202 | include_build_directory: false, |
| 203 | }`, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 204 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 205 | MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{ |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 206 | "implementation_dynamic_deps": `select({ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 207 | "//build/bazel/platforms/arch:arm64": [":shared_dep"], |
| 208 | "//conditions:default": [], |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 209 | })`, |
| 210 | "whole_archive_deps": `select({ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 211 | "//build/bazel/platforms/arch:arm64": [":static_dep"], |
| 212 | "//conditions:default": [], |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 213 | })`, |
| 214 | }), |
| 215 | }, |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 216 | }) |
| 217 | } |
| 218 | |
| 219 | func TestCcLibrarySharedOsSpecificSharedLib(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 220 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
Chris Parsons | 5011e61 | 2023-09-13 23:33:20 +0000 | [diff] [blame] | 221 | StubbedBuildDefinitions: []string{"shared_dep"}, |
| 222 | Description: "cc_library_shared os-specific shared_libs", |
| 223 | Filesystem: map[string]string{}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 224 | Blueprint: soongCcLibrarySharedPreamble + ` |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 225 | cc_library_shared { |
| 226 | name: "shared_dep", |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 227 | } |
| 228 | cc_library_shared { |
| 229 | name: "foo_shared", |
| 230 | target: { android: { shared_libs: ["shared_dep"], } }, |
| 231 | include_build_directory: false, |
| 232 | }`, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 233 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 234 | MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{ |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 235 | "implementation_dynamic_deps": `select({ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 236 | "//build/bazel/platforms/os:android": [":shared_dep"], |
| 237 | "//conditions:default": [], |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 238 | })`, |
| 239 | }), |
| 240 | }, |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 241 | }) |
| 242 | } |
| 243 | |
| 244 | func TestCcLibrarySharedBaseArchOsSpecificSharedLib(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 245 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
Chris Parsons | 5011e61 | 2023-09-13 23:33:20 +0000 | [diff] [blame] | 246 | StubbedBuildDefinitions: []string{"shared_dep", "shared_dep2", "shared_dep3"}, |
| 247 | Description: "cc_library_shared base, arch, and os-specific shared_libs", |
| 248 | Filesystem: map[string]string{}, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 249 | Blueprint: soongCcLibrarySharedPreamble + ` |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 250 | cc_library_shared { |
| 251 | name: "shared_dep", |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 252 | } |
| 253 | cc_library_shared { |
| 254 | name: "shared_dep2", |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 255 | } |
| 256 | cc_library_shared { |
| 257 | name: "shared_dep3", |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 258 | } |
| 259 | cc_library_shared { |
| 260 | name: "foo_shared", |
| 261 | shared_libs: ["shared_dep"], |
| 262 | target: { android: { shared_libs: ["shared_dep2"] } }, |
| 263 | arch: { arm64: { shared_libs: ["shared_dep3"] } }, |
| 264 | include_build_directory: false, |
| 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("cc_library_shared", "foo_shared", AttrNameToString{ |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 268 | "implementation_dynamic_deps": `[":shared_dep"] + select({ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 269 | "//build/bazel/platforms/arch:arm64": [":shared_dep3"], |
| 270 | "//conditions:default": [], |
| 271 | }) + select({ |
| 272 | "//build/bazel/platforms/os:android": [":shared_dep2"], |
| 273 | "//conditions:default": [], |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 274 | })`, |
| 275 | }), |
| 276 | }, |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 277 | }) |
| 278 | } |
| 279 | |
| 280 | func TestCcLibrarySharedSimpleExcludeSrcs(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 281 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 282 | Description: "cc_library_shared simple exclude_srcs", |
| 283 | Filesystem: map[string]string{ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 284 | "common.c": "", |
| 285 | "foo-a.c": "", |
| 286 | "foo-excluded.c": "", |
| 287 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 288 | Blueprint: soongCcLibrarySharedPreamble + ` |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 289 | cc_library_shared { |
| 290 | name: "foo_shared", |
| 291 | srcs: ["common.c", "foo-*.c"], |
| 292 | exclude_srcs: ["foo-excluded.c"], |
| 293 | include_build_directory: false, |
| 294 | }`, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 295 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 296 | MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{ |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 297 | "srcs_c": `[ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 298 | "common.c", |
| 299 | "foo-a.c", |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 300 | ]`, |
| 301 | }), |
| 302 | }, |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 303 | }) |
| 304 | } |
| 305 | |
| 306 | func TestCcLibrarySharedStrip(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 307 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 308 | Description: "cc_library_shared stripping", |
| 309 | Filesystem: map[string]string{}, |
| 310 | Blueprint: soongCcLibrarySharedPreamble + ` |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 311 | cc_library_shared { |
| 312 | name: "foo_shared", |
| 313 | strip: { |
| 314 | keep_symbols: false, |
| 315 | keep_symbols_and_debug_frame: true, |
| 316 | keep_symbols_list: ["sym", "sym2"], |
| 317 | all: true, |
| 318 | none: false, |
| 319 | }, |
| 320 | include_build_directory: false, |
| 321 | }`, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 322 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 323 | MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{ |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 324 | "strip": `{ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 325 | "all": True, |
| 326 | "keep_symbols": False, |
| 327 | "keep_symbols_and_debug_frame": True, |
| 328 | "keep_symbols_list": [ |
| 329 | "sym", |
| 330 | "sym2", |
| 331 | ], |
| 332 | "none": False, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 333 | }`, |
| 334 | }), |
| 335 | }, |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 336 | }) |
| 337 | } |
| 338 | |
Trevor Radcliffe | 37ec2f7 | 2022-09-27 01:46:01 +0000 | [diff] [blame] | 339 | func TestCcLibrarySharedVersionScriptAndDynamicList(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 340 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
Trevor Radcliffe | 37ec2f7 | 2022-09-27 01:46:01 +0000 | [diff] [blame] | 341 | Description: "cc_library_shared version script and dynamic list", |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 342 | Filesystem: map[string]string{ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 343 | "version_script": "", |
Trevor Radcliffe | 37ec2f7 | 2022-09-27 01:46:01 +0000 | [diff] [blame] | 344 | "dynamic.list": "", |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 345 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 346 | Blueprint: soongCcLibrarySharedPreamble + ` |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 347 | cc_library_shared { |
| 348 | name: "foo_shared", |
| 349 | version_script: "version_script", |
Trevor Radcliffe | 37ec2f7 | 2022-09-27 01:46:01 +0000 | [diff] [blame] | 350 | dynamic_list: "dynamic.list", |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 351 | include_build_directory: false, |
| 352 | }`, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 353 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 354 | MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{ |
Trevor Radcliffe | 37ec2f7 | 2022-09-27 01:46:01 +0000 | [diff] [blame] | 355 | "additional_linker_inputs": `[ |
| 356 | "version_script", |
| 357 | "dynamic.list", |
| 358 | ]`, |
| 359 | "linkopts": `[ |
| 360 | "-Wl,--version-script,$(location version_script)", |
| 361 | "-Wl,--dynamic-list,$(location dynamic.list)", |
| 362 | ]`, |
Trevor Radcliffe | f06dd91 | 2023-05-19 14:51:41 +0000 | [diff] [blame] | 363 | "features": `["android_cfi_exports_map"]`, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 364 | }), |
| 365 | }, |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | ac5097f | 2021-09-01 21:22:09 +0000 | [diff] [blame] | 366 | }) |
| 367 | } |
Jingwen Chen | 6ada589 | 2021-09-17 11:38:09 +0000 | [diff] [blame] | 368 | |
Trevor Radcliffe | ea6a45d | 2022-09-20 18:58:01 +0000 | [diff] [blame] | 369 | func TestCcLibraryLdflagsSplitBySpaceSoongAdded(t *testing.T) { |
| 370 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 371 | Description: "ldflags are split by spaces except for the ones added by soong (version script and dynamic list)", |
| 372 | Filesystem: map[string]string{ |
| 373 | "version_script": "", |
| 374 | "dynamic.list": "", |
| 375 | }, |
| 376 | Blueprint: ` |
| 377 | cc_library_shared { |
| 378 | name: "foo", |
| 379 | ldflags: [ |
| 380 | "--nospace_flag", |
| 381 | "-z spaceflag", |
| 382 | ], |
| 383 | version_script: "version_script", |
| 384 | dynamic_list: "dynamic.list", |
| 385 | include_build_directory: false, |
| 386 | }`, |
| 387 | ExpectedBazelTargets: []string{ |
| 388 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 389 | "additional_linker_inputs": `[ |
| 390 | "version_script", |
| 391 | "dynamic.list", |
| 392 | ]`, |
| 393 | "linkopts": `[ |
| 394 | "--nospace_flag", |
| 395 | "-z", |
| 396 | "spaceflag", |
| 397 | "-Wl,--version-script,$(location version_script)", |
| 398 | "-Wl,--dynamic-list,$(location dynamic.list)", |
| 399 | ]`, |
Trevor Radcliffe | f06dd91 | 2023-05-19 14:51:41 +0000 | [diff] [blame] | 400 | "features": `["android_cfi_exports_map"]`, |
Trevor Radcliffe | ea6a45d | 2022-09-20 18:58:01 +0000 | [diff] [blame] | 401 | }), |
| 402 | }, |
| 403 | }) |
| 404 | } |
| 405 | |
Jingwen Chen | 6ada589 | 2021-09-17 11:38:09 +0000 | [diff] [blame] | 406 | func TestCcLibrarySharedNoCrtTrue(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 407 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
Alex Márquez Pérez Muñíz Díaz Puras Thaureaux | 01ec55e | 2023-01-30 22:53:04 +0000 | [diff] [blame] | 408 | Description: "cc_library_shared - nocrt: true disables feature", |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 409 | Filesystem: map[string]string{ |
Jingwen Chen | 6ada589 | 2021-09-17 11:38:09 +0000 | [diff] [blame] | 410 | "impl.cpp": "", |
| 411 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 412 | Blueprint: soongCcLibraryPreamble + ` |
Jingwen Chen | 6ada589 | 2021-09-17 11:38:09 +0000 | [diff] [blame] | 413 | cc_library_shared { |
| 414 | name: "foo_shared", |
| 415 | srcs: ["impl.cpp"], |
| 416 | nocrt: true, |
| 417 | include_build_directory: false, |
| 418 | } |
| 419 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 420 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 421 | MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{ |
Alex Márquez Pérez Muñíz Díaz Puras Thaureaux | 01ec55e | 2023-01-30 22:53:04 +0000 | [diff] [blame] | 422 | "features": `["-link_crt"]`, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 423 | "srcs": `["impl.cpp"]`, |
| 424 | }), |
| 425 | }, |
| 426 | }) |
Jingwen Chen | 6ada589 | 2021-09-17 11:38:09 +0000 | [diff] [blame] | 427 | } |
| 428 | |
| 429 | func TestCcLibrarySharedNoCrtFalse(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 430 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
Alex Márquez Pérez Muñíz Díaz Puras Thaureaux | 01ec55e | 2023-01-30 22:53:04 +0000 | [diff] [blame] | 431 | Description: "cc_library_shared - nocrt: false doesn't disable feature", |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 432 | Filesystem: map[string]string{ |
Jingwen Chen | 6ada589 | 2021-09-17 11:38:09 +0000 | [diff] [blame] | 433 | "impl.cpp": "", |
| 434 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 435 | Blueprint: soongCcLibraryPreamble + ` |
Jingwen Chen | 6ada589 | 2021-09-17 11:38:09 +0000 | [diff] [blame] | 436 | cc_library_shared { |
| 437 | name: "foo_shared", |
| 438 | srcs: ["impl.cpp"], |
| 439 | nocrt: false, |
| 440 | include_build_directory: false, |
| 441 | } |
| 442 | `, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 443 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 444 | MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{ |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 445 | "srcs": `["impl.cpp"]`, |
| 446 | }), |
| 447 | }, |
| 448 | }) |
Jingwen Chen | 6ada589 | 2021-09-17 11:38:09 +0000 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | func TestCcLibrarySharedNoCrtArchVariant(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 452 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 453 | Description: "cc_library_shared - nocrt in select", |
| 454 | Filesystem: map[string]string{ |
Jingwen Chen | 6ada589 | 2021-09-17 11:38:09 +0000 | [diff] [blame] | 455 | "impl.cpp": "", |
| 456 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 457 | Blueprint: soongCcLibraryPreamble + ` |
Jingwen Chen | 6ada589 | 2021-09-17 11:38:09 +0000 | [diff] [blame] | 458 | cc_library_shared { |
| 459 | name: "foo_shared", |
| 460 | srcs: ["impl.cpp"], |
| 461 | arch: { |
| 462 | arm: { |
| 463 | nocrt: true, |
| 464 | }, |
| 465 | x86: { |
| 466 | nocrt: false, |
| 467 | }, |
| 468 | }, |
| 469 | include_build_directory: false, |
| 470 | } |
| 471 | `, |
Alex Márquez Pérez Muñíz Díaz Puras Thaureaux | 01ec55e | 2023-01-30 22:53:04 +0000 | [diff] [blame] | 472 | ExpectedBazelTargets: []string{ |
| 473 | MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{ |
| 474 | "features": `select({ |
| 475 | "//build/bazel/platforms/arch:arm": ["-link_crt"], |
| 476 | "//conditions:default": [], |
| 477 | })`, |
| 478 | "srcs": `["impl.cpp"]`, |
| 479 | }), |
| 480 | }, |
Jingwen Chen | 6ada589 | 2021-09-17 11:38:09 +0000 | [diff] [blame] | 481 | }) |
| 482 | } |
Liz Kammer | 12615db | 2021-09-28 09:19:17 -0400 | [diff] [blame] | 483 | |
| 484 | func TestCcLibrarySharedProto(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 485 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 486 | Blueprint: soongCcProtoPreamble + `cc_library_shared { |
Liz Kammer | 12615db | 2021-09-28 09:19:17 -0400 | [diff] [blame] | 487 | name: "foo", |
| 488 | srcs: ["foo.proto"], |
| 489 | proto: { |
Liz Kammer | 12615db | 2021-09-28 09:19:17 -0400 | [diff] [blame] | 490 | export_proto_headers: true, |
| 491 | }, |
| 492 | include_build_directory: false, |
| 493 | }`, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 494 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 495 | MakeBazelTarget("proto_library", "foo_proto", AttrNameToString{ |
Liz Kammer | 12615db | 2021-09-28 09:19:17 -0400 | [diff] [blame] | 496 | "srcs": `["foo.proto"]`, |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 497 | }), MakeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", AttrNameToString{ |
Liz Kammer | 12615db | 2021-09-28 09:19:17 -0400 | [diff] [blame] | 498 | "deps": `[":foo_proto"]`, |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 499 | }), MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
Liz Kammer | 12615db | 2021-09-28 09:19:17 -0400 | [diff] [blame] | 500 | "dynamic_deps": `[":libprotobuf-cpp-lite"]`, |
| 501 | "whole_archive_deps": `[":foo_cc_proto_lite"]`, |
| 502 | }), |
| 503 | }, |
| 504 | }) |
| 505 | } |
Rupert Shuttleworth | 484aa25 | 2021-12-10 07:22:53 -0500 | [diff] [blame] | 506 | |
| 507 | func TestCcLibrarySharedUseVersionLib(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 508 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
Liz Kammer | baced71 | 2022-09-16 09:01:29 -0400 | [diff] [blame] | 509 | Filesystem: map[string]string{ |
| 510 | soongCcVersionLibBpPath: soongCcVersionLibBp, |
| 511 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 512 | Blueprint: soongCcProtoPreamble + `cc_library_shared { |
Rupert Shuttleworth | 484aa25 | 2021-12-10 07:22:53 -0500 | [diff] [blame] | 513 | name: "foo", |
| 514 | use_version_lib: true, |
| 515 | include_build_directory: false, |
| 516 | }`, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 517 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 518 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
Yu Liu | fe978fd | 2023-04-24 16:37:18 -0700 | [diff] [blame] | 519 | "use_version_lib": "True", |
| 520 | "whole_archive_deps": `["//build/soong/cc/libbuildversion:libbuildversion"]`, |
Rupert Shuttleworth | 484aa25 | 2021-12-10 07:22:53 -0500 | [diff] [blame] | 521 | }), |
| 522 | }, |
| 523 | }) |
| 524 | } |
Jingwen Chen | 0ee88a6 | 2022-01-07 14:55:29 +0000 | [diff] [blame] | 525 | |
| 526 | func TestCcLibrarySharedStubs(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 527 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 528 | Description: "cc_library_shared stubs", |
| 529 | ModuleTypeUnderTest: "cc_library_shared", |
| 530 | ModuleTypeUnderTestFactory: cc.LibrarySharedFactory, |
| 531 | Dir: "foo/bar", |
| 532 | Filesystem: map[string]string{ |
Jingwen Chen | 0ee88a6 | 2022-01-07 14:55:29 +0000 | [diff] [blame] | 533 | "foo/bar/Android.bp": ` |
| 534 | cc_library_shared { |
| 535 | name: "a", |
| 536 | stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] }, |
| 537 | bazel_module: { bp2build_available: true }, |
| 538 | include_build_directory: false, |
| 539 | } |
| 540 | `, |
| 541 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 542 | Blueprint: soongCcLibraryPreamble, |
Trevor Radcliffe | f19d8a7 | 2022-09-20 23:04:39 +0000 | [diff] [blame] | 543 | ExpectedBazelTargets: []string{makeCcStubSuiteTargets("a", AttrNameToString{ |
Spandan Das | 04f9f4c | 2023-09-13 23:59:05 +0000 | [diff] [blame] | 544 | "api_surface": `"module-libapi"`, |
Sam Delmerico | 5f90649 | 2023-03-15 18:06:18 -0400 | [diff] [blame] | 545 | "soname": `"a.so"`, |
| 546 | "source_library_label": `"//foo/bar:a"`, |
| 547 | "stubs_symbol_file": `"a.map.txt"`, |
Trevor Radcliffe | f19d8a7 | 2022-09-20 23:04:39 +0000 | [diff] [blame] | 548 | "stubs_versions": `[ |
Trevor Radcliffe | 087af54 | 2022-09-16 15:36:10 +0000 | [diff] [blame] | 549 | "28", |
| 550 | "29", |
| 551 | "current", |
| 552 | ]`, |
Trevor Radcliffe | f19d8a7 | 2022-09-20 23:04:39 +0000 | [diff] [blame] | 553 | }), |
| 554 | MakeBazelTarget("cc_library_shared", "a", AttrNameToString{ |
Yu Liu | 56ccb1a | 2022-11-12 10:47:07 -0800 | [diff] [blame] | 555 | "stubs_symbol_file": `"a.map.txt"`, |
Trevor Radcliffe | 087af54 | 2022-09-16 15:36:10 +0000 | [diff] [blame] | 556 | }), |
Jingwen Chen | 0ee88a6 | 2022-01-07 14:55:29 +0000 | [diff] [blame] | 557 | }, |
Trevor Radcliffe | f19d8a7 | 2022-09-20 23:04:39 +0000 | [diff] [blame] | 558 | }) |
Jingwen Chen | 0ee88a6 | 2022-01-07 14:55:29 +0000 | [diff] [blame] | 559 | } |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | 126bd58 | 2022-04-21 15:19:27 +0000 | [diff] [blame] | 560 | |
Liz Kammer | 48cdbeb | 2023-03-17 10:17:50 -0400 | [diff] [blame] | 561 | func TestCcLibrarySharedStubs_UseImplementationInSameApex(t *testing.T) { |
| 562 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 563 | Description: "cc_library_shared stubs", |
| 564 | ModuleTypeUnderTest: "cc_library_shared", |
| 565 | ModuleTypeUnderTestFactory: cc.LibrarySharedFactory, |
| 566 | Blueprint: soongCcLibrarySharedPreamble + ` |
| 567 | cc_library_shared { |
| 568 | name: "a", |
| 569 | stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] }, |
| 570 | bazel_module: { bp2build_available: false }, |
| 571 | include_build_directory: false, |
| 572 | apex_available: ["made_up_apex"], |
| 573 | } |
| 574 | cc_library_shared { |
| 575 | name: "b", |
| 576 | shared_libs: [":a"], |
| 577 | include_build_directory: false, |
| 578 | apex_available: ["made_up_apex"], |
| 579 | } |
| 580 | `, |
| 581 | ExpectedBazelTargets: []string{ |
| 582 | MakeBazelTarget("cc_library_shared", "b", AttrNameToString{ |
| 583 | "implementation_dynamic_deps": `[":a"]`, |
| 584 | "tags": `["apex_available=made_up_apex"]`, |
| 585 | }), |
| 586 | }, |
| 587 | }) |
| 588 | } |
| 589 | |
| 590 | func TestCcLibrarySharedStubs_UseStubsInDifferentApex(t *testing.T) { |
| 591 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 592 | Description: "cc_library_shared stubs", |
| 593 | ModuleTypeUnderTest: "cc_library_shared", |
| 594 | ModuleTypeUnderTestFactory: cc.LibrarySharedFactory, |
| 595 | Blueprint: soongCcLibrarySharedPreamble + ` |
| 596 | cc_library_shared { |
| 597 | name: "a", |
| 598 | stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] }, |
| 599 | bazel_module: { bp2build_available: false }, |
| 600 | include_build_directory: false, |
| 601 | apex_available: ["apex_a"], |
| 602 | } |
| 603 | cc_library_shared { |
| 604 | name: "b", |
| 605 | shared_libs: [":a"], |
| 606 | include_build_directory: false, |
| 607 | apex_available: ["apex_b"], |
| 608 | } |
| 609 | `, |
| 610 | ExpectedBazelTargets: []string{ |
| 611 | MakeBazelTarget("cc_library_shared", "b", AttrNameToString{ |
| 612 | "implementation_dynamic_deps": `select({ |
Spandan Das | 6d4d9da | 2023-04-18 06:20:40 +0000 | [diff] [blame] | 613 | "//build/bazel/rules/apex:apex_b": ["@api_surfaces//module-libapi/current:a"], |
| 614 | "//build/bazel/rules/apex:system": ["@api_surfaces//module-libapi/current:a"], |
Liz Kammer | 48cdbeb | 2023-03-17 10:17:50 -0400 | [diff] [blame] | 615 | "//conditions:default": [":a"], |
| 616 | })`, |
| 617 | "tags": `["apex_available=apex_b"]`, |
| 618 | }), |
| 619 | }, |
| 620 | }) |
| 621 | } |
| 622 | |
Spandan Das | 6d4d9da | 2023-04-18 06:20:40 +0000 | [diff] [blame] | 623 | // Tests that library in apexfoo links against stubs of platform_lib and otherapex_lib |
| 624 | func TestCcLibrarySharedStubs_UseStubsFromMultipleApiDomains(t *testing.T) { |
| 625 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 626 | Description: "cc_library_shared stubs", |
| 627 | ModuleTypeUnderTest: "cc_library_shared", |
| 628 | ModuleTypeUnderTestFactory: cc.LibrarySharedFactory, |
| 629 | Blueprint: soongCcLibrarySharedPreamble + ` |
| 630 | cc_library_shared { |
| 631 | name: "libplatform_stable", |
| 632 | stubs: { symbol_file: "libplatform_stable.map.txt", versions: ["28", "29", "current"] }, |
| 633 | apex_available: ["//apex_available:platform"], |
| 634 | bazel_module: { bp2build_available: false }, |
| 635 | include_build_directory: false, |
| 636 | } |
| 637 | cc_library_shared { |
| 638 | name: "libapexfoo_stable", |
| 639 | stubs: { symbol_file: "libapexfoo_stable.map.txt", versions: ["28", "29", "current"] }, |
| 640 | apex_available: ["apexfoo"], |
| 641 | bazel_module: { bp2build_available: false }, |
| 642 | include_build_directory: false, |
| 643 | } |
| 644 | cc_library_shared { |
| 645 | name: "libutils", |
| 646 | shared_libs: ["libplatform_stable", "libapexfoo_stable",], |
| 647 | apex_available: ["//apex_available:platform", "apexfoo", "apexbar"], |
| 648 | include_build_directory: false, |
| 649 | } |
| 650 | `, |
| 651 | ExpectedBazelTargets: []string{ |
| 652 | MakeBazelTarget("cc_library_shared", "libutils", AttrNameToString{ |
| 653 | "implementation_dynamic_deps": `select({ |
| 654 | "//build/bazel/rules/apex:apexbar": [ |
| 655 | "@api_surfaces//module-libapi/current:libplatform_stable", |
| 656 | "@api_surfaces//module-libapi/current:libapexfoo_stable", |
| 657 | ], |
| 658 | "//build/bazel/rules/apex:apexfoo": [ |
| 659 | "@api_surfaces//module-libapi/current:libplatform_stable", |
| 660 | ":libapexfoo_stable", |
| 661 | ], |
| 662 | "//build/bazel/rules/apex:system": [ |
Spandan Das | f7bae9a | 2023-09-06 22:07:15 +0000 | [diff] [blame] | 663 | ":libplatform_stable", |
Spandan Das | 6d4d9da | 2023-04-18 06:20:40 +0000 | [diff] [blame] | 664 | "@api_surfaces//module-libapi/current:libapexfoo_stable", |
| 665 | ], |
| 666 | "//conditions:default": [ |
| 667 | ":libplatform_stable", |
| 668 | ":libapexfoo_stable", |
| 669 | ], |
| 670 | })`, |
| 671 | "tags": `[ |
| 672 | "apex_available=//apex_available:platform", |
| 673 | "apex_available=apexfoo", |
| 674 | "apex_available=apexbar", |
| 675 | ]`, |
| 676 | }), |
| 677 | }, |
| 678 | }) |
| 679 | } |
| 680 | |
Liz Kammer | 48cdbeb | 2023-03-17 10:17:50 -0400 | [diff] [blame] | 681 | func TestCcLibrarySharedStubs_IgnorePlatformAvailable(t *testing.T) { |
| 682 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 683 | Description: "cc_library_shared stubs", |
| 684 | ModuleTypeUnderTest: "cc_library_shared", |
| 685 | ModuleTypeUnderTestFactory: cc.LibrarySharedFactory, |
| 686 | Blueprint: soongCcLibrarySharedPreamble + ` |
| 687 | cc_library_shared { |
| 688 | name: "a", |
| 689 | stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] }, |
| 690 | bazel_module: { bp2build_available: false }, |
| 691 | include_build_directory: false, |
| 692 | apex_available: ["//apex_available:platform", "apex_a"], |
| 693 | } |
| 694 | cc_library_shared { |
| 695 | name: "b", |
| 696 | shared_libs: [":a"], |
| 697 | include_build_directory: false, |
| 698 | apex_available: ["//apex_available:platform", "apex_b"], |
| 699 | } |
| 700 | `, |
| 701 | ExpectedBazelTargets: []string{ |
| 702 | MakeBazelTarget("cc_library_shared", "b", AttrNameToString{ |
| 703 | "implementation_dynamic_deps": `select({ |
Spandan Das | 6d4d9da | 2023-04-18 06:20:40 +0000 | [diff] [blame] | 704 | "//build/bazel/rules/apex:apex_b": ["@api_surfaces//module-libapi/current:a"], |
| 705 | "//build/bazel/rules/apex:system": ["@api_surfaces//module-libapi/current:a"], |
Liz Kammer | 48cdbeb | 2023-03-17 10:17:50 -0400 | [diff] [blame] | 706 | "//conditions:default": [":a"], |
| 707 | })`, |
| 708 | "tags": `[ |
| 709 | "apex_available=//apex_available:platform", |
| 710 | "apex_available=apex_b", |
| 711 | ]`, |
| 712 | }), |
| 713 | }, |
| 714 | }) |
| 715 | } |
| 716 | |
Spandan Das | 6d4d9da | 2023-04-18 06:20:40 +0000 | [diff] [blame] | 717 | func TestCcLibraryDoesNotDropStubDepIfNoVariationAcrossAxis(t *testing.T) { |
| 718 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 719 | Description: "cc_library depeends on impl for all configurations", |
| 720 | ModuleTypeUnderTest: "cc_library_shared", |
| 721 | ModuleTypeUnderTestFactory: cc.LibrarySharedFactory, |
| 722 | Blueprint: soongCcLibrarySharedPreamble + ` |
| 723 | cc_library_shared { |
| 724 | name: "a", |
| 725 | stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] }, |
| 726 | bazel_module: { bp2build_available: false }, |
| 727 | apex_available: ["//apex_available:platform"], |
| 728 | } |
| 729 | cc_library_shared { |
| 730 | name: "b", |
| 731 | shared_libs: [":a"], |
| 732 | include_build_directory: false, |
| 733 | apex_available: ["//apex_available:platform"], |
| 734 | } |
| 735 | `, |
| 736 | ExpectedBazelTargets: []string{ |
| 737 | MakeBazelTarget("cc_library_shared", "b", AttrNameToString{ |
| 738 | "implementation_dynamic_deps": `[":a"]`, |
| 739 | "tags": `["apex_available=//apex_available:platform"]`, |
| 740 | }), |
| 741 | }, |
| 742 | }) |
| 743 | } |
| 744 | |
Liz Kammer | 48cdbeb | 2023-03-17 10:17:50 -0400 | [diff] [blame] | 745 | func TestCcLibrarySharedStubs_MultipleApexAvailable(t *testing.T) { |
| 746 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 747 | ModuleTypeUnderTest: "cc_library_shared", |
| 748 | ModuleTypeUnderTestFactory: cc.LibrarySharedFactory, |
| 749 | Blueprint: soongCcLibrarySharedPreamble + ` |
| 750 | cc_library_shared { |
| 751 | name: "a", |
| 752 | stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] }, |
| 753 | bazel_module: { bp2build_available: false }, |
| 754 | include_build_directory: false, |
| 755 | apex_available: ["//apex_available:platform", "apex_a", "apex_b"], |
| 756 | } |
| 757 | cc_library_shared { |
| 758 | name: "b", |
| 759 | shared_libs: [":a"], |
| 760 | include_build_directory: false, |
| 761 | apex_available: ["//apex_available:platform", "apex_b"], |
| 762 | } |
| 763 | |
| 764 | cc_library_shared { |
| 765 | name: "c", |
| 766 | shared_libs: [":a"], |
| 767 | include_build_directory: false, |
| 768 | apex_available: ["//apex_available:platform", "apex_a", "apex_b"], |
| 769 | } |
| 770 | `, |
| 771 | ExpectedBazelTargets: []string{ |
| 772 | MakeBazelTarget("cc_library_shared", "b", AttrNameToString{ |
| 773 | "implementation_dynamic_deps": `select({ |
Spandan Das | 6d4d9da | 2023-04-18 06:20:40 +0000 | [diff] [blame] | 774 | "//build/bazel/rules/apex:system": ["@api_surfaces//module-libapi/current:a"], |
Liz Kammer | 48cdbeb | 2023-03-17 10:17:50 -0400 | [diff] [blame] | 775 | "//conditions:default": [":a"], |
| 776 | })`, |
| 777 | "tags": `[ |
| 778 | "apex_available=//apex_available:platform", |
| 779 | "apex_available=apex_b", |
| 780 | ]`, |
| 781 | }), |
| 782 | MakeBazelTarget("cc_library_shared", "c", AttrNameToString{ |
| 783 | "implementation_dynamic_deps": `[":a"]`, |
| 784 | "tags": `[ |
| 785 | "apex_available=//apex_available:platform", |
| 786 | "apex_available=apex_a", |
| 787 | "apex_available=apex_b", |
| 788 | ]`, |
| 789 | }), |
| 790 | }, |
| 791 | }) |
| 792 | } |
| 793 | |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | 126bd58 | 2022-04-21 15:19:27 +0000 | [diff] [blame] | 794 | func TestCcLibrarySharedSystemSharedLibsSharedEmpty(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 795 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 796 | Description: "cc_library_shared system_shared_libs empty shared default", |
| 797 | ModuleTypeUnderTest: "cc_library_shared", |
| 798 | ModuleTypeUnderTestFactory: cc.LibrarySharedFactory, |
| 799 | Blueprint: soongCcLibrarySharedPreamble + ` |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | 126bd58 | 2022-04-21 15:19:27 +0000 | [diff] [blame] | 800 | cc_defaults { |
| 801 | name: "empty_defaults", |
| 802 | shared: { |
| 803 | system_shared_libs: [], |
| 804 | }, |
| 805 | include_build_directory: false, |
| 806 | } |
| 807 | cc_library_shared { |
| 808 | name: "empty", |
| 809 | defaults: ["empty_defaults"], |
| 810 | } |
| 811 | `, |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 812 | ExpectedBazelTargets: []string{MakeBazelTarget("cc_library_shared", "empty", AttrNameToString{ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | 126bd58 | 2022-04-21 15:19:27 +0000 | [diff] [blame] | 813 | "system_dynamic_deps": "[]", |
| 814 | })}, |
| 815 | }) |
| 816 | } |
Trevor Radcliffe | ef9c900 | 2022-05-13 20:55:35 +0000 | [diff] [blame] | 817 | |
| 818 | func TestCcLibrarySharedConvertLex(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 819 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 820 | Description: "cc_library_shared with lex files", |
| 821 | ModuleTypeUnderTest: "cc_library_shared", |
| 822 | ModuleTypeUnderTestFactory: cc.LibrarySharedFactory, |
| 823 | Filesystem: map[string]string{ |
Trevor Radcliffe | ef9c900 | 2022-05-13 20:55:35 +0000 | [diff] [blame] | 824 | "foo.c": "", |
| 825 | "bar.cc": "", |
| 826 | "foo1.l": "", |
| 827 | "bar1.ll": "", |
| 828 | "foo2.l": "", |
| 829 | "bar2.ll": "", |
| 830 | }, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 831 | Blueprint: `cc_library_shared { |
Trevor Radcliffe | ef9c900 | 2022-05-13 20:55:35 +0000 | [diff] [blame] | 832 | name: "foo_lib", |
| 833 | srcs: ["foo.c", "bar.cc", "foo1.l", "foo2.l", "bar1.ll", "bar2.ll"], |
| 834 | lex: { flags: ["--foo_flags"] }, |
| 835 | include_build_directory: false, |
| 836 | bazel_module: { bp2build_available: true }, |
| 837 | }`, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 838 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 839 | MakeBazelTarget("genlex", "foo_lib_genlex_l", AttrNameToString{ |
Trevor Radcliffe | ef9c900 | 2022-05-13 20:55:35 +0000 | [diff] [blame] | 840 | "srcs": `[ |
| 841 | "foo1.l", |
| 842 | "foo2.l", |
| 843 | ]`, |
| 844 | "lexopts": `["--foo_flags"]`, |
| 845 | }), |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 846 | MakeBazelTarget("genlex", "foo_lib_genlex_ll", AttrNameToString{ |
Trevor Radcliffe | ef9c900 | 2022-05-13 20:55:35 +0000 | [diff] [blame] | 847 | "srcs": `[ |
| 848 | "bar1.ll", |
| 849 | "bar2.ll", |
| 850 | ]`, |
| 851 | "lexopts": `["--foo_flags"]`, |
| 852 | }), |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 853 | MakeBazelTarget("cc_library_shared", "foo_lib", AttrNameToString{ |
Trevor Radcliffe | ef9c900 | 2022-05-13 20:55:35 +0000 | [diff] [blame] | 854 | "srcs": `[ |
| 855 | "bar.cc", |
| 856 | ":foo_lib_genlex_ll", |
| 857 | ]`, |
| 858 | "srcs_c": `[ |
| 859 | "foo.c", |
| 860 | ":foo_lib_genlex_l", |
| 861 | ]`, |
| 862 | }), |
| 863 | }, |
| 864 | }) |
| 865 | } |
Alix | 1be00d4 | 2022-05-16 22:56:04 +0000 | [diff] [blame] | 866 | |
| 867 | func TestCcLibrarySharedClangUnknownFlags(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 868 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 869 | Blueprint: soongCcProtoPreamble + `cc_library_shared { |
Alix | 1be00d4 | 2022-05-16 22:56:04 +0000 | [diff] [blame] | 870 | name: "foo", |
| 871 | conlyflags: ["-a", "-finline-functions"], |
| 872 | cflags: ["-b","-finline-functions"], |
| 873 | cppflags: ["-c", "-finline-functions"], |
| 874 | ldflags: ["-d","-finline-functions", "-e"], |
| 875 | include_build_directory: false, |
| 876 | }`, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 877 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 878 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
Alix | 1be00d4 | 2022-05-16 22:56:04 +0000 | [diff] [blame] | 879 | "conlyflags": `["-a"]`, |
| 880 | "copts": `["-b"]`, |
| 881 | "cppflags": `["-c"]`, |
| 882 | "linkopts": `[ |
| 883 | "-d", |
| 884 | "-e", |
| 885 | ]`, |
| 886 | }), |
| 887 | }, |
| 888 | }) |
| 889 | } |
| 890 | |
| 891 | func TestCCLibraryFlagSpaceSplitting(t *testing.T) { |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 892 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 893 | Blueprint: soongCcProtoPreamble + `cc_library_shared { |
Alix | 1be00d4 | 2022-05-16 22:56:04 +0000 | [diff] [blame] | 894 | name: "foo", |
| 895 | conlyflags: [ "-include header.h"], |
| 896 | cflags: ["-include header.h"], |
| 897 | cppflags: ["-include header.h"], |
| 898 | version_script: "version_script", |
| 899 | include_build_directory: false, |
| 900 | }`, |
Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 901 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 902 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
Alix | 1be00d4 | 2022-05-16 22:56:04 +0000 | [diff] [blame] | 903 | "additional_linker_inputs": `["version_script"]`, |
| 904 | "conlyflags": `[ |
| 905 | "-include", |
| 906 | "header.h", |
| 907 | ]`, |
| 908 | "copts": `[ |
| 909 | "-include", |
| 910 | "header.h", |
| 911 | ]`, |
| 912 | "cppflags": `[ |
| 913 | "-include", |
| 914 | "header.h", |
| 915 | ]`, |
| 916 | "linkopts": `["-Wl,--version-script,$(location version_script)"]`, |
Trevor Radcliffe | f06dd91 | 2023-05-19 14:51:41 +0000 | [diff] [blame] | 917 | "features": `["android_cfi_exports_map"]`, |
Alix | 1be00d4 | 2022-05-16 22:56:04 +0000 | [diff] [blame] | 918 | }), |
| 919 | }, |
| 920 | }) |
| 921 | } |
Cole Faust | 6b29f59 | 2022-08-09 09:50:56 -0700 | [diff] [blame] | 922 | |
| 923 | func TestCCLibrarySharedRuntimeDeps(t *testing.T) { |
| 924 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 925 | Blueprint: `cc_library_shared { |
| 926 | name: "bar", |
| 927 | } |
| 928 | |
| 929 | cc_library_shared { |
| 930 | name: "foo", |
| 931 | runtime_libs: ["foo"], |
| 932 | }`, |
| 933 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 934 | MakeBazelTarget("cc_library_shared", "bar", AttrNameToString{ |
Cole Faust | 6b29f59 | 2022-08-09 09:50:56 -0700 | [diff] [blame] | 935 | "local_includes": `["."]`, |
| 936 | }), |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 937 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
Cole Faust | 6b29f59 | 2022-08-09 09:50:56 -0700 | [diff] [blame] | 938 | "runtime_deps": `[":foo"]`, |
| 939 | "local_includes": `["."]`, |
| 940 | }), |
| 941 | }, |
| 942 | }) |
| 943 | } |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | a56e970 | 2022-02-23 18:39:59 -0500 | [diff] [blame] | 944 | |
| 945 | func TestCcLibrarySharedEmptySuffix(t *testing.T) { |
| 946 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 947 | Description: "cc_library_shared with empty suffix", |
| 948 | Filesystem: map[string]string{ |
| 949 | "foo.c": "", |
| 950 | }, |
| 951 | Blueprint: soongCcLibrarySharedPreamble + ` |
| 952 | cc_library_shared { |
| 953 | name: "foo_shared", |
| 954 | suffix: "", |
| 955 | srcs: ["foo.c"], |
| 956 | include_build_directory: false, |
| 957 | }`, |
| 958 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 959 | MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | a56e970 | 2022-02-23 18:39:59 -0500 | [diff] [blame] | 960 | "srcs_c": `["foo.c"]`, |
| 961 | "suffix": `""`, |
| 962 | }), |
| 963 | }, |
| 964 | }) |
| 965 | } |
| 966 | |
| 967 | func TestCcLibrarySharedSuffix(t *testing.T) { |
| 968 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 969 | Description: "cc_library_shared with suffix", |
| 970 | Filesystem: map[string]string{ |
| 971 | "foo.c": "", |
| 972 | }, |
| 973 | Blueprint: soongCcLibrarySharedPreamble + ` |
| 974 | cc_library_shared { |
| 975 | name: "foo_shared", |
| 976 | suffix: "-suf", |
| 977 | srcs: ["foo.c"], |
| 978 | include_build_directory: false, |
| 979 | }`, |
| 980 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 981 | MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | a56e970 | 2022-02-23 18:39:59 -0500 | [diff] [blame] | 982 | "srcs_c": `["foo.c"]`, |
| 983 | "suffix": `"-suf"`, |
| 984 | }), |
| 985 | }, |
| 986 | }) |
| 987 | } |
| 988 | |
| 989 | func TestCcLibrarySharedArchVariantSuffix(t *testing.T) { |
| 990 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 991 | Description: "cc_library_shared with arch-variant suffix", |
| 992 | Filesystem: map[string]string{ |
| 993 | "foo.c": "", |
| 994 | }, |
| 995 | Blueprint: soongCcLibrarySharedPreamble + ` |
| 996 | cc_library_shared { |
| 997 | name: "foo_shared", |
| 998 | arch: { |
| 999 | arm64: { suffix: "-64" }, |
| 1000 | arm: { suffix: "-32" }, |
| 1001 | }, |
| 1002 | srcs: ["foo.c"], |
| 1003 | include_build_directory: false, |
| 1004 | }`, |
| 1005 | ExpectedBazelTargets: []string{ |
Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 1006 | MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | a56e970 | 2022-02-23 18:39:59 -0500 | [diff] [blame] | 1007 | "srcs_c": `["foo.c"]`, |
| 1008 | "suffix": `select({ |
| 1009 | "//build/bazel/platforms/arch:arm": "-32", |
| 1010 | "//build/bazel/platforms/arch:arm64": "-64", |
| 1011 | "//conditions:default": None, |
| 1012 | })`, |
| 1013 | }), |
| 1014 | }, |
| 1015 | }) |
| 1016 | } |
Trevor Radcliffe | cee4e05 | 2022-09-06 19:31:25 +0000 | [diff] [blame] | 1017 | |
| 1018 | func TestCcLibrarySharedWithSyspropSrcs(t *testing.T) { |
| 1019 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1020 | Description: "cc_library_shared with sysprop sources", |
| 1021 | Blueprint: ` |
| 1022 | cc_library_shared { |
| 1023 | name: "foo", |
| 1024 | srcs: [ |
| 1025 | "bar.sysprop", |
| 1026 | "baz.sysprop", |
| 1027 | "blah.cpp", |
| 1028 | ], |
| 1029 | min_sdk_version: "5", |
| 1030 | }`, |
| 1031 | ExpectedBazelTargets: []string{ |
| 1032 | MakeBazelTarget("sysprop_library", "foo_sysprop_library", AttrNameToString{ |
| 1033 | "srcs": `[ |
| 1034 | "bar.sysprop", |
| 1035 | "baz.sysprop", |
| 1036 | ]`, |
| 1037 | }), |
| 1038 | MakeBazelTarget("cc_sysprop_library_static", "foo_cc_sysprop_library_static", AttrNameToString{ |
| 1039 | "dep": `":foo_sysprop_library"`, |
| 1040 | "min_sdk_version": `"5"`, |
| 1041 | }), |
| 1042 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1043 | "srcs": `["blah.cpp"]`, |
| 1044 | "local_includes": `["."]`, |
| 1045 | "min_sdk_version": `"5"`, |
| 1046 | "whole_archive_deps": `[":foo_cc_sysprop_library_static"]`, |
| 1047 | }), |
| 1048 | }, |
| 1049 | }) |
| 1050 | } |
| 1051 | |
| 1052 | func TestCcLibrarySharedWithSyspropSrcsSomeConfigs(t *testing.T) { |
| 1053 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1054 | Description: "cc_library_shared with sysprop sources in some configs but not others", |
| 1055 | Blueprint: ` |
| 1056 | cc_library_shared { |
| 1057 | name: "foo", |
| 1058 | srcs: [ |
| 1059 | "blah.cpp", |
| 1060 | ], |
| 1061 | target: { |
| 1062 | android: { |
| 1063 | srcs: ["bar.sysprop"], |
| 1064 | }, |
| 1065 | }, |
| 1066 | min_sdk_version: "5", |
| 1067 | }`, |
| 1068 | ExpectedBazelTargets: []string{ |
| 1069 | MakeBazelTarget("sysprop_library", "foo_sysprop_library", AttrNameToString{ |
| 1070 | "srcs": `select({ |
| 1071 | "//build/bazel/platforms/os:android": ["bar.sysprop"], |
| 1072 | "//conditions:default": [], |
| 1073 | })`, |
| 1074 | }), |
| 1075 | MakeBazelTarget("cc_sysprop_library_static", "foo_cc_sysprop_library_static", AttrNameToString{ |
| 1076 | "dep": `":foo_sysprop_library"`, |
| 1077 | "min_sdk_version": `"5"`, |
| 1078 | }), |
| 1079 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1080 | "srcs": `["blah.cpp"]`, |
| 1081 | "local_includes": `["."]`, |
| 1082 | "min_sdk_version": `"5"`, |
| 1083 | "whole_archive_deps": `select({ |
| 1084 | "//build/bazel/platforms/os:android": [":foo_cc_sysprop_library_static"], |
| 1085 | "//conditions:default": [], |
| 1086 | })`, |
| 1087 | }), |
| 1088 | }, |
| 1089 | }) |
| 1090 | } |
Yu Liu | 56ccb1a | 2022-11-12 10:47:07 -0800 | [diff] [blame] | 1091 | |
| 1092 | func TestCcLibrarySharedHeaderAbiChecker(t *testing.T) { |
| 1093 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1094 | Description: "cc_library_shared with header abi checker", |
| 1095 | Blueprint: `cc_library_shared { |
| 1096 | name: "foo", |
| 1097 | header_abi_checker: { |
| 1098 | enabled: true, |
| 1099 | symbol_file: "a.map.txt", |
| 1100 | exclude_symbol_versions: [ |
| 1101 | "29", |
| 1102 | "30", |
| 1103 | ], |
| 1104 | exclude_symbol_tags: [ |
| 1105 | "tag1", |
| 1106 | "tag2", |
| 1107 | ], |
| 1108 | check_all_apis: true, |
| 1109 | diff_flags: ["-allow-adding-removing-weak-symbols"], |
| 1110 | }, |
| 1111 | include_build_directory: false, |
| 1112 | }`, |
| 1113 | ExpectedBazelTargets: []string{ |
| 1114 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1115 | "abi_checker_enabled": `True`, |
| 1116 | "abi_checker_symbol_file": `"a.map.txt"`, |
| 1117 | "abi_checker_exclude_symbol_versions": `[ |
| 1118 | "29", |
| 1119 | "30", |
| 1120 | ]`, |
| 1121 | "abi_checker_exclude_symbol_tags": `[ |
| 1122 | "tag1", |
| 1123 | "tag2", |
| 1124 | ]`, |
| 1125 | "abi_checker_check_all_apis": `True`, |
| 1126 | "abi_checker_diff_flags": `["-allow-adding-removing-weak-symbols"]`, |
| 1127 | }), |
| 1128 | }, |
| 1129 | }) |
| 1130 | } |
Trevor Radcliffe | db7e026 | 2022-10-28 16:48:18 +0000 | [diff] [blame] | 1131 | |
| 1132 | func TestCcLibrarySharedWithIntegerOverflowProperty(t *testing.T) { |
| 1133 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1134 | Description: "cc_library_shared has correct features when integer_overflow property is provided", |
| 1135 | Blueprint: ` |
| 1136 | cc_library_shared { |
| 1137 | name: "foo", |
| 1138 | sanitize: { |
| 1139 | integer_overflow: true, |
| 1140 | }, |
| 1141 | } |
| 1142 | `, |
| 1143 | ExpectedBazelTargets: []string{ |
| 1144 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1145 | "features": `["ubsan_integer_overflow"]`, |
| 1146 | "local_includes": `["."]`, |
| 1147 | }), |
| 1148 | }, |
| 1149 | }) |
| 1150 | } |
| 1151 | |
| 1152 | func TestCcLibrarySharedWithMiscUndefinedProperty(t *testing.T) { |
| 1153 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1154 | Description: "cc_library_shared has correct features when misc_undefined property is provided", |
| 1155 | Blueprint: ` |
| 1156 | cc_library_shared { |
| 1157 | name: "foo", |
| 1158 | sanitize: { |
| 1159 | misc_undefined: ["undefined", "nullability"], |
| 1160 | }, |
| 1161 | } |
| 1162 | `, |
| 1163 | ExpectedBazelTargets: []string{ |
| 1164 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1165 | "features": `[ |
| 1166 | "ubsan_undefined", |
| 1167 | "ubsan_nullability", |
| 1168 | ]`, |
| 1169 | "local_includes": `["."]`, |
| 1170 | }), |
| 1171 | }, |
| 1172 | }) |
| 1173 | } |
| 1174 | |
| 1175 | func TestCcLibrarySharedWithUBSanPropertiesArchSpecific(t *testing.T) { |
| 1176 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1177 | Description: "cc_library_shared has correct feature select when UBSan props are specified in arch specific blocks", |
| 1178 | Blueprint: ` |
| 1179 | cc_library_shared { |
| 1180 | name: "foo", |
| 1181 | sanitize: { |
| 1182 | misc_undefined: ["undefined", "nullability"], |
| 1183 | }, |
| 1184 | target: { |
| 1185 | android: { |
| 1186 | sanitize: { |
| 1187 | misc_undefined: ["alignment"], |
| 1188 | }, |
| 1189 | }, |
| 1190 | linux_glibc: { |
| 1191 | sanitize: { |
| 1192 | integer_overflow: true, |
| 1193 | }, |
| 1194 | }, |
| 1195 | }, |
| 1196 | } |
| 1197 | `, |
| 1198 | ExpectedBazelTargets: []string{ |
| 1199 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1200 | "features": `[ |
| 1201 | "ubsan_undefined", |
| 1202 | "ubsan_nullability", |
| 1203 | ] + select({ |
| 1204 | "//build/bazel/platforms/os:android": ["ubsan_alignment"], |
| 1205 | "//build/bazel/platforms/os:linux_glibc": ["ubsan_integer_overflow"], |
| 1206 | "//conditions:default": [], |
| 1207 | })`, |
| 1208 | "local_includes": `["."]`, |
| 1209 | }), |
| 1210 | }, |
| 1211 | }) |
| 1212 | } |
Trevor Radcliffe | 56b1a2b | 2023-02-06 21:58:30 +0000 | [diff] [blame] | 1213 | |
Trevor Radcliffe | ded095c | 2023-06-12 19:18:28 +0000 | [diff] [blame] | 1214 | func TestCcLibrarySharedWithSanitizerBlocklist(t *testing.T) { |
| 1215 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1216 | Description: "cc_library_shared has correct features when sanitize.blocklist is provided", |
| 1217 | Blueprint: ` |
| 1218 | cc_library_shared { |
| 1219 | name: "foo", |
| 1220 | sanitize: { |
| 1221 | blocklist: "foo_blocklist.txt", |
| 1222 | }, |
| 1223 | } |
| 1224 | `, |
| 1225 | ExpectedBazelTargets: []string{ |
| 1226 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
Trevor Radcliffe | d9b7f17 | 2023-08-09 22:21:38 +0000 | [diff] [blame] | 1227 | "copts": `select({ |
| 1228 | "//build/bazel/rules/cc:sanitizers_enabled": ["-fsanitize-ignorelist=$(location foo_blocklist.txt)"], |
| 1229 | "//conditions:default": [], |
| 1230 | })`, |
| 1231 | "additional_compiler_inputs": `select({ |
| 1232 | "//build/bazel/rules/cc:sanitizers_enabled": [":foo_blocklist.txt"], |
| 1233 | "//conditions:default": [], |
| 1234 | })`, |
Trevor Radcliffe | ded095c | 2023-06-12 19:18:28 +0000 | [diff] [blame] | 1235 | "local_includes": `["."]`, |
| 1236 | }), |
| 1237 | }, |
| 1238 | }) |
| 1239 | } |
| 1240 | |
Trevor Radcliffe | 56b1a2b | 2023-02-06 21:58:30 +0000 | [diff] [blame] | 1241 | func TestCcLibrarySharedWithThinLto(t *testing.T) { |
| 1242 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1243 | Description: "cc_library_shared has correct features when thin lto is enabled", |
| 1244 | Blueprint: ` |
| 1245 | cc_library_shared { |
| 1246 | name: "foo", |
| 1247 | lto: { |
| 1248 | thin: true, |
| 1249 | }, |
| 1250 | } |
| 1251 | `, |
| 1252 | ExpectedBazelTargets: []string{ |
| 1253 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1254 | "features": `["android_thin_lto"]`, |
| 1255 | "local_includes": `["."]`, |
| 1256 | }), |
| 1257 | }, |
| 1258 | }) |
| 1259 | } |
| 1260 | |
| 1261 | func TestCcLibrarySharedWithLtoNever(t *testing.T) { |
| 1262 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1263 | Description: "cc_library_shared has correct features when thin lto is enabled", |
| 1264 | Blueprint: ` |
| 1265 | cc_library_shared { |
| 1266 | name: "foo", |
| 1267 | lto: { |
| 1268 | never: true, |
| 1269 | }, |
| 1270 | } |
| 1271 | `, |
| 1272 | ExpectedBazelTargets: []string{ |
| 1273 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1274 | "features": `["-android_thin_lto"]`, |
| 1275 | "local_includes": `["."]`, |
| 1276 | }), |
| 1277 | }, |
| 1278 | }) |
| 1279 | } |
| 1280 | |
| 1281 | func TestCcLibrarySharedWithThinLtoArchSpecific(t *testing.T) { |
| 1282 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1283 | Description: "cc_library_shared has correct features when LTO differs across arch and os variants", |
| 1284 | Blueprint: ` |
| 1285 | cc_library_shared { |
| 1286 | name: "foo", |
| 1287 | target: { |
| 1288 | android: { |
| 1289 | lto: { |
| 1290 | thin: true, |
| 1291 | }, |
| 1292 | }, |
| 1293 | }, |
| 1294 | arch: { |
| 1295 | riscv64: { |
| 1296 | lto: { |
| 1297 | thin: false, |
| 1298 | }, |
| 1299 | }, |
| 1300 | }, |
| 1301 | }`, |
| 1302 | ExpectedBazelTargets: []string{ |
| 1303 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1304 | "local_includes": `["."]`, |
| 1305 | "features": `select({ |
| 1306 | "//build/bazel/platforms/os_arch:android_arm": ["android_thin_lto"], |
| 1307 | "//build/bazel/platforms/os_arch:android_arm64": ["android_thin_lto"], |
| 1308 | "//build/bazel/platforms/os_arch:android_riscv64": ["-android_thin_lto"], |
| 1309 | "//build/bazel/platforms/os_arch:android_x86": ["android_thin_lto"], |
| 1310 | "//build/bazel/platforms/os_arch:android_x86_64": ["android_thin_lto"], |
| 1311 | "//conditions:default": [], |
| 1312 | })`}), |
| 1313 | }, |
| 1314 | }) |
| 1315 | } |
| 1316 | |
| 1317 | func TestCcLibrarySharedWithThinLtoDisabledDefaultEnabledVariant(t *testing.T) { |
| 1318 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1319 | Description: "cc_library_shared with thin lto disabled by default but enabled on a particular variant", |
| 1320 | Blueprint: ` |
| 1321 | cc_library_shared { |
| 1322 | name: "foo", |
| 1323 | lto: { |
| 1324 | never: true, |
| 1325 | }, |
| 1326 | target: { |
| 1327 | android: { |
| 1328 | lto: { |
| 1329 | thin: true, |
| 1330 | never: false, |
| 1331 | }, |
| 1332 | }, |
| 1333 | }, |
| 1334 | }`, |
| 1335 | ExpectedBazelTargets: []string{ |
| 1336 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1337 | "local_includes": `["."]`, |
| 1338 | "features": `select({ |
| 1339 | "//build/bazel/platforms/os:android": ["android_thin_lto"], |
| 1340 | "//conditions:default": ["-android_thin_lto"], |
| 1341 | })`, |
| 1342 | }), |
| 1343 | }, |
| 1344 | }) |
| 1345 | } |
| 1346 | |
| 1347 | func TestCcLibrarySharedWithThinLtoAndWholeProgramVtables(t *testing.T) { |
| 1348 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1349 | Description: "cc_library_shared has correct features when thin LTO is enabled with whole_program_vtables", |
| 1350 | Blueprint: ` |
| 1351 | cc_library_shared { |
| 1352 | name: "foo", |
| 1353 | lto: { |
| 1354 | thin: true, |
| 1355 | }, |
| 1356 | whole_program_vtables: true, |
| 1357 | } |
| 1358 | `, |
| 1359 | ExpectedBazelTargets: []string{ |
| 1360 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1361 | "features": `[ |
| 1362 | "android_thin_lto", |
| 1363 | "android_thin_lto_whole_program_vtables", |
| 1364 | ]`, |
| 1365 | "local_includes": `["."]`, |
| 1366 | }), |
| 1367 | }, |
| 1368 | }) |
| 1369 | } |
Trevor Radcliffe | a8b4416 | 2023-04-14 18:25:24 +0000 | [diff] [blame] | 1370 | |
| 1371 | func TestCcLibrarySharedHiddenVisibilityConvertedToFeature(t *testing.T) { |
| 1372 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1373 | Description: "cc_library_shared changes hidden visibility flag to feature", |
| 1374 | Blueprint: ` |
| 1375 | cc_library_shared{ |
| 1376 | name: "foo", |
| 1377 | cflags: ["-fvisibility=hidden"], |
| 1378 | }`, |
| 1379 | ExpectedBazelTargets: []string{ |
| 1380 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1381 | "features": `["visibility_hidden"]`, |
| 1382 | "local_includes": `["."]`, |
| 1383 | }), |
| 1384 | }, |
| 1385 | }) |
| 1386 | } |
| 1387 | |
| 1388 | func TestCcLibrarySharedHiddenVisibilityConvertedToFeatureOsSpecific(t *testing.T) { |
| 1389 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1390 | Description: "cc_library_shared changes hidden visibility flag to feature for specific os", |
| 1391 | Blueprint: ` |
| 1392 | cc_library_shared{ |
| 1393 | name: "foo", |
| 1394 | target: { |
| 1395 | android: { |
| 1396 | cflags: ["-fvisibility=hidden"], |
| 1397 | }, |
| 1398 | }, |
| 1399 | }`, |
| 1400 | ExpectedBazelTargets: []string{ |
| 1401 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1402 | "features": `select({ |
| 1403 | "//build/bazel/platforms/os:android": ["visibility_hidden"], |
| 1404 | "//conditions:default": [], |
| 1405 | })`, |
| 1406 | "local_includes": `["."]`, |
| 1407 | }), |
| 1408 | }, |
| 1409 | }) |
| 1410 | } |
Sam Delmerico | 75dbca2 | 2023-04-20 13:13:25 +0000 | [diff] [blame] | 1411 | |
| 1412 | func TestCcLibrarySharedStubsDessertVersionConversion(t *testing.T) { |
| 1413 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1414 | Description: "cc_library_shared converts dessert codename versions to numerical versions", |
| 1415 | Blueprint: ` |
| 1416 | cc_library_shared { |
| 1417 | name: "a", |
| 1418 | include_build_directory: false, |
| 1419 | stubs: { |
| 1420 | symbol_file: "a.map.txt", |
| 1421 | versions: [ |
| 1422 | "Q", |
| 1423 | "R", |
| 1424 | "31", |
| 1425 | ], |
| 1426 | }, |
| 1427 | } |
| 1428 | cc_library_shared { |
| 1429 | name: "b", |
| 1430 | include_build_directory: false, |
| 1431 | stubs: { |
| 1432 | symbol_file: "b.map.txt", |
| 1433 | versions: [ |
| 1434 | "Q", |
| 1435 | "R", |
| 1436 | "31", |
| 1437 | "current", |
| 1438 | ], |
| 1439 | }, |
| 1440 | } |
| 1441 | `, |
| 1442 | ExpectedBazelTargets: []string{ |
| 1443 | makeCcStubSuiteTargets("a", AttrNameToString{ |
Spandan Das | 04f9f4c | 2023-09-13 23:59:05 +0000 | [diff] [blame] | 1444 | "api_surface": `"module-libapi"`, |
Sam Delmerico | 75dbca2 | 2023-04-20 13:13:25 +0000 | [diff] [blame] | 1445 | "soname": `"a.so"`, |
| 1446 | "source_library_label": `"//:a"`, |
| 1447 | "stubs_symbol_file": `"a.map.txt"`, |
| 1448 | "stubs_versions": `[ |
| 1449 | "29", |
| 1450 | "30", |
| 1451 | "31", |
| 1452 | "current", |
| 1453 | ]`, |
| 1454 | }), |
| 1455 | MakeBazelTarget("cc_library_shared", "a", AttrNameToString{ |
| 1456 | "stubs_symbol_file": `"a.map.txt"`, |
| 1457 | }), |
| 1458 | makeCcStubSuiteTargets("b", AttrNameToString{ |
Spandan Das | 04f9f4c | 2023-09-13 23:59:05 +0000 | [diff] [blame] | 1459 | "api_surface": `"module-libapi"`, |
Sam Delmerico | 75dbca2 | 2023-04-20 13:13:25 +0000 | [diff] [blame] | 1460 | "soname": `"b.so"`, |
| 1461 | "source_library_label": `"//:b"`, |
| 1462 | "stubs_symbol_file": `"b.map.txt"`, |
| 1463 | "stubs_versions": `[ |
| 1464 | "29", |
| 1465 | "30", |
| 1466 | "31", |
| 1467 | "current", |
| 1468 | ]`, |
| 1469 | }), |
| 1470 | MakeBazelTarget("cc_library_shared", "b", AttrNameToString{ |
| 1471 | "stubs_symbol_file": `"b.map.txt"`, |
| 1472 | }), |
| 1473 | }, |
| 1474 | }) |
| 1475 | } |
Trevor Radcliffe | 27669c0 | 2023-03-28 20:47:10 +0000 | [diff] [blame] | 1476 | |
| 1477 | func TestCcLibrarySharedWithCfi(t *testing.T) { |
| 1478 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1479 | Description: "cc_library_shared has correct features when cfi is enabled for specific variants", |
| 1480 | Blueprint: ` |
| 1481 | cc_library_shared { |
| 1482 | name: "foo", |
| 1483 | sanitize: { |
| 1484 | cfi: true, |
| 1485 | }, |
| 1486 | }`, |
| 1487 | ExpectedBazelTargets: []string{ |
| 1488 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1489 | "features": `["android_cfi"]`, |
| 1490 | "local_includes": `["."]`, |
| 1491 | }), |
| 1492 | }, |
| 1493 | }) |
| 1494 | } |
| 1495 | |
| 1496 | func TestCcLibrarySharedWithCfiOsSpecific(t *testing.T) { |
| 1497 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1498 | Description: "cc_library_shared has correct features when cfi is enabled", |
| 1499 | Blueprint: ` |
| 1500 | cc_library_shared { |
| 1501 | name: "foo", |
| 1502 | target: { |
| 1503 | android: { |
| 1504 | sanitize: { |
| 1505 | cfi: true, |
| 1506 | }, |
| 1507 | }, |
| 1508 | }, |
| 1509 | }`, |
| 1510 | ExpectedBazelTargets: []string{ |
| 1511 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1512 | "features": `select({ |
| 1513 | "//build/bazel/platforms/os:android": ["android_cfi"], |
| 1514 | "//conditions:default": [], |
| 1515 | })`, |
| 1516 | "local_includes": `["."]`, |
| 1517 | }), |
| 1518 | }, |
| 1519 | }) |
| 1520 | } |
| 1521 | |
| 1522 | func TestCcLibrarySharedWithCfiAndCfiAssemblySupport(t *testing.T) { |
| 1523 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1524 | Description: "cc_library_shared has correct features when cfi is enabled with cfi assembly support", |
| 1525 | Blueprint: ` |
| 1526 | cc_library_static { |
| 1527 | name: "foo", |
| 1528 | sanitize: { |
| 1529 | cfi: true, |
| 1530 | config: { |
| 1531 | cfi_assembly_support: true, |
| 1532 | }, |
| 1533 | }, |
| 1534 | }`, |
| 1535 | ExpectedBazelTargets: []string{ |
| 1536 | MakeBazelTarget("cc_library_static", "foo", AttrNameToString{ |
| 1537 | "features": `[ |
| 1538 | "android_cfi", |
| 1539 | "android_cfi_assembly_support", |
| 1540 | ]`, |
| 1541 | "local_includes": `["."]`, |
| 1542 | }), |
| 1543 | }, |
| 1544 | }) |
| 1545 | } |
Trevor Radcliffe | 523c5c6 | 2023-06-16 20:15:45 +0000 | [diff] [blame] | 1546 | |
| 1547 | func TestCcLibrarySharedExplicitlyDisablesCfiWhenFalse(t *testing.T) { |
| 1548 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1549 | Description: "cc_library_shared disables cfi when explciitly set to false in the bp", |
| 1550 | Blueprint: ` |
| 1551 | cc_library_shared { |
| 1552 | name: "foo", |
| 1553 | sanitize: { |
| 1554 | cfi: false, |
| 1555 | }, |
| 1556 | } |
| 1557 | `, |
| 1558 | ExpectedBazelTargets: []string{ |
| 1559 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1560 | "features": `["-android_cfi"]`, |
| 1561 | "local_includes": `["."]`, |
| 1562 | }), |
| 1563 | }, |
| 1564 | }) |
| 1565 | } |
Alix | e266787 | 2023-04-24 14:57:32 +0000 | [diff] [blame] | 1566 | |
| 1567 | func TestCCLibrarySharedRscriptSrc(t *testing.T) { |
| 1568 | runCcLibrarySharedTestCase(t, Bp2buildTestCase{ |
| 1569 | Description: ``, |
| 1570 | Blueprint: ` |
| 1571 | cc_library_shared{ |
| 1572 | name : "foo", |
| 1573 | srcs : [ |
| 1574 | "ccSrc.cc", |
| 1575 | "rsSrc.rscript", |
| 1576 | ], |
| 1577 | include_build_directory: false, |
| 1578 | } |
| 1579 | `, |
| 1580 | ExpectedBazelTargets: []string{ |
| 1581 | MakeBazelTarget("rscript_to_cpp", "foo_renderscript", AttrNameToString{ |
| 1582 | "srcs": `["rsSrc.rscript"]`, |
| 1583 | }), |
| 1584 | MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{ |
| 1585 | "absolute_includes": `[ |
| 1586 | "frameworks/rs", |
| 1587 | "frameworks/rs/cpp", |
| 1588 | ]`, |
| 1589 | "local_includes": `["."]`, |
| 1590 | "srcs": `[ |
| 1591 | "ccSrc.cc", |
| 1592 | "foo_renderscript", |
| 1593 | ]`, |
| 1594 | })}}) |
| 1595 | } |