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