Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +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 | "android/soong/android" |
| 19 | "android/soong/cc" |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 20 | "android/soong/genrule" |
| 21 | |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 22 | "testing" |
| 23 | ) |
| 24 | |
| 25 | const ( |
| 26 | // See cc/testing.go for more context |
| 27 | soongCcLibraryStaticPreamble = ` |
| 28 | cc_defaults { |
| 29 | name: "linux_bionic_supported", |
| 30 | } |
| 31 | |
| 32 | toolchain_library { |
| 33 | name: "libclang_rt.builtins-x86_64-android", |
| 34 | defaults: ["linux_bionic_supported"], |
| 35 | vendor_available: true, |
| 36 | vendor_ramdisk_available: true, |
| 37 | product_available: true, |
| 38 | recovery_available: true, |
| 39 | native_bridge_supported: true, |
| 40 | src: "", |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 41 | }` |
| 42 | ) |
| 43 | |
| 44 | func TestCcLibraryStaticLoadStatement(t *testing.T) { |
| 45 | testCases := []struct { |
| 46 | bazelTargets BazelTargets |
| 47 | expectedLoadStatements string |
| 48 | }{ |
| 49 | { |
| 50 | bazelTargets: BazelTargets{ |
| 51 | BazelTarget{ |
| 52 | name: "cc_library_static_target", |
| 53 | ruleClass: "cc_library_static", |
| 54 | // NOTE: No bzlLoadLocation for native rules |
| 55 | }, |
| 56 | }, |
| 57 | expectedLoadStatements: ``, |
| 58 | }, |
| 59 | } |
| 60 | |
| 61 | for _, testCase := range testCases { |
| 62 | actual := testCase.bazelTargets.LoadStatements() |
| 63 | expected := testCase.expectedLoadStatements |
| 64 | if actual != expected { |
| 65 | t.Fatalf("Expected load statements to be %s, got %s", expected, actual) |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | } |
| 70 | |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 71 | func registerCcLibraryStaticModuleTypes(ctx android.RegistrationContext) { |
| 72 | cc.RegisterCCBuildComponents(ctx) |
| 73 | ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory) |
| 74 | ctx.RegisterModuleType("cc_library_headers", cc.LibraryHeaderFactory) |
| 75 | ctx.RegisterModuleType("genrule", genrule.GenRuleFactory) |
| 76 | } |
| 77 | |
| 78 | func runCcLibraryStaticTestCase(t *testing.T, tc bp2buildTestCase) { |
Liz Kammer | e4982e8 | 2021-05-25 10:39:35 -0400 | [diff] [blame] | 79 | t.Helper() |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 80 | runBp2BuildTestCase(t, registerCcLibraryStaticModuleTypes, tc) |
| 81 | } |
| 82 | |
| 83 | func TestCcLibraryStaticSimple(t *testing.T) { |
| 84 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 85 | description: "cc_library_static test", |
| 86 | moduleTypeUnderTest: "cc_library_static", |
| 87 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 88 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 89 | filesystem: map[string]string{ |
| 90 | // NOTE: include_dir headers *should not* appear in Bazel hdrs later (?) |
| 91 | "include_dir_1/include_dir_1_a.h": "", |
| 92 | "include_dir_1/include_dir_1_b.h": "", |
| 93 | "include_dir_2/include_dir_2_a.h": "", |
| 94 | "include_dir_2/include_dir_2_b.h": "", |
| 95 | // NOTE: local_include_dir headers *should not* appear in Bazel hdrs later (?) |
| 96 | "local_include_dir_1/local_include_dir_1_a.h": "", |
| 97 | "local_include_dir_1/local_include_dir_1_b.h": "", |
| 98 | "local_include_dir_2/local_include_dir_2_a.h": "", |
| 99 | "local_include_dir_2/local_include_dir_2_b.h": "", |
| 100 | // NOTE: export_include_dir headers *should* appear in Bazel hdrs later |
| 101 | "export_include_dir_1/export_include_dir_1_a.h": "", |
| 102 | "export_include_dir_1/export_include_dir_1_b.h": "", |
| 103 | "export_include_dir_2/export_include_dir_2_a.h": "", |
| 104 | "export_include_dir_2/export_include_dir_2_b.h": "", |
| 105 | // NOTE: Soong implicitly includes headers in the current directory |
| 106 | "implicit_include_1.h": "", |
| 107 | "implicit_include_2.h": "", |
| 108 | }, |
| 109 | blueprint: soongCcLibraryStaticPreamble + ` |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 110 | cc_library_headers { |
| 111 | name: "header_lib_1", |
| 112 | export_include_dirs: ["header_lib_1"], |
| 113 | } |
| 114 | |
| 115 | cc_library_headers { |
| 116 | name: "header_lib_2", |
| 117 | export_include_dirs: ["header_lib_2"], |
| 118 | } |
| 119 | |
| 120 | cc_library_static { |
| 121 | name: "static_lib_1", |
| 122 | srcs: ["static_lib_1.cc"], |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | cc_library_static { |
| 126 | name: "static_lib_2", |
| 127 | srcs: ["static_lib_2.cc"], |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | cc_library_static { |
| 131 | name: "whole_static_lib_1", |
| 132 | srcs: ["whole_static_lib_1.cc"], |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | cc_library_static { |
| 136 | name: "whole_static_lib_2", |
| 137 | srcs: ["whole_static_lib_2.cc"], |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | cc_library_static { |
| 141 | name: "foo_static", |
| 142 | srcs: [ |
| 143 | "foo_static1.cc", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 144 | "foo_static2.cc", |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 145 | ], |
| 146 | cflags: [ |
| 147 | "-Dflag1", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 148 | "-Dflag2" |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 149 | ], |
| 150 | static_libs: [ |
| 151 | "static_lib_1", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 152 | "static_lib_2" |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 153 | ], |
| 154 | whole_static_libs: [ |
| 155 | "whole_static_lib_1", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 156 | "whole_static_lib_2" |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 157 | ], |
| 158 | include_dirs: [ |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 159 | "include_dir_1", |
| 160 | "include_dir_2", |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 161 | ], |
| 162 | local_include_dirs: [ |
| 163 | "local_include_dir_1", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 164 | "local_include_dir_2", |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 165 | ], |
| 166 | export_include_dirs: [ |
Chris Parsons | d635877 | 2021-05-18 18:35:24 -0400 | [diff] [blame] | 167 | "export_include_dir_1", |
| 168 | "export_include_dir_2" |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 169 | ], |
| 170 | header_libs: [ |
| 171 | "header_lib_1", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 172 | "header_lib_2" |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 173 | ], |
| 174 | |
| 175 | // TODO: Also support export_header_lib_headers |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 176 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 177 | expectedBazelTargets: []string{`cc_library_static( |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 178 | name = "foo_static", |
| 179 | copts = [ |
| 180 | "-Dflag1", |
| 181 | "-Dflag2", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 182 | "-Iinclude_dir_1", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 183 | "-I$(BINDIR)/include_dir_1", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 184 | "-Iinclude_dir_2", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 185 | "-I$(BINDIR)/include_dir_2", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 186 | "-Ilocal_include_dir_1", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 187 | "-I$(BINDIR)/local_include_dir_1", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 188 | "-Ilocal_include_dir_2", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 189 | "-I$(BINDIR)/local_include_dir_2", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 190 | "-I.", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 191 | "-I$(BINDIR)/.", |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 192 | ], |
Chris Parsons | d635877 | 2021-05-18 18:35:24 -0400 | [diff] [blame] | 193 | implementation_deps = [ |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 194 | ":header_lib_1", |
| 195 | ":header_lib_2", |
| 196 | ":static_lib_1", |
| 197 | ":static_lib_2", |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 198 | ], |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 199 | includes = [ |
| 200 | "export_include_dir_1", |
| 201 | "export_include_dir_2", |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 202 | ], |
| 203 | linkstatic = True, |
| 204 | srcs = [ |
| 205 | "foo_static1.cc", |
| 206 | "foo_static2.cc", |
| 207 | ], |
Chris Parsons | 0864831 | 2021-05-06 16:23:19 -0400 | [diff] [blame] | 208 | whole_archive_deps = [ |
| 209 | ":whole_static_lib_1", |
| 210 | ":whole_static_lib_2", |
| 211 | ], |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 212 | )`, `cc_library_static( |
| 213 | name = "static_lib_1", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 214 | copts = [ |
| 215 | "-I.", |
| 216 | "-I$(BINDIR)/.", |
| 217 | ], |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 218 | linkstatic = True, |
Jingwen Chen | 882bcc1 | 2021-04-27 05:54:20 +0000 | [diff] [blame] | 219 | srcs = ["static_lib_1.cc"], |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 220 | )`, `cc_library_static( |
| 221 | name = "static_lib_2", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 222 | copts = [ |
| 223 | "-I.", |
| 224 | "-I$(BINDIR)/.", |
| 225 | ], |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 226 | linkstatic = True, |
Jingwen Chen | 882bcc1 | 2021-04-27 05:54:20 +0000 | [diff] [blame] | 227 | srcs = ["static_lib_2.cc"], |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 228 | )`, `cc_library_static( |
| 229 | name = "whole_static_lib_1", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 230 | copts = [ |
| 231 | "-I.", |
| 232 | "-I$(BINDIR)/.", |
| 233 | ], |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 234 | linkstatic = True, |
Jingwen Chen | 882bcc1 | 2021-04-27 05:54:20 +0000 | [diff] [blame] | 235 | srcs = ["whole_static_lib_1.cc"], |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 236 | )`, `cc_library_static( |
| 237 | name = "whole_static_lib_2", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 238 | copts = [ |
| 239 | "-I.", |
| 240 | "-I$(BINDIR)/.", |
| 241 | ], |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 242 | linkstatic = True, |
Jingwen Chen | 882bcc1 | 2021-04-27 05:54:20 +0000 | [diff] [blame] | 243 | srcs = ["whole_static_lib_2.cc"], |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 244 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 245 | }) |
| 246 | } |
| 247 | |
| 248 | func TestCcLibraryStaticSubpackage(t *testing.T) { |
| 249 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 250 | description: "cc_library_static subpackage test", |
| 251 | moduleTypeUnderTest: "cc_library_static", |
| 252 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 253 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 254 | filesystem: map[string]string{ |
| 255 | // subpackage with subdirectory |
| 256 | "subpackage/Android.bp": "", |
| 257 | "subpackage/subpackage_header.h": "", |
| 258 | "subpackage/subdirectory/subdirectory_header.h": "", |
| 259 | // subsubpackage with subdirectory |
| 260 | "subpackage/subsubpackage/Android.bp": "", |
| 261 | "subpackage/subsubpackage/subsubpackage_header.h": "", |
| 262 | "subpackage/subsubpackage/subdirectory/subdirectory_header.h": "", |
| 263 | // subsubsubpackage with subdirectory |
| 264 | "subpackage/subsubpackage/subsubsubpackage/Android.bp": "", |
| 265 | "subpackage/subsubpackage/subsubsubpackage/subsubsubpackage_header.h": "", |
| 266 | "subpackage/subsubpackage/subsubsubpackage/subdirectory/subdirectory_header.h": "", |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 267 | }, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 268 | blueprint: soongCcLibraryStaticPreamble + ` |
Rupert Shuttleworth | c143cc5 | 2021-04-13 13:08:04 -0400 | [diff] [blame] | 269 | cc_library_static { |
| 270 | name: "foo_static", |
| 271 | srcs: [ |
| 272 | ], |
| 273 | include_dirs: [ |
| 274 | "subpackage", |
| 275 | ], |
Rupert Shuttleworth | c143cc5 | 2021-04-13 13:08:04 -0400 | [diff] [blame] | 276 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 277 | expectedBazelTargets: []string{`cc_library_static( |
Rupert Shuttleworth | c143cc5 | 2021-04-13 13:08:04 -0400 | [diff] [blame] | 278 | name = "foo_static", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 279 | copts = [ |
| 280 | "-Isubpackage", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 281 | "-I$(BINDIR)/subpackage", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 282 | "-I.", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 283 | "-I$(BINDIR)/.", |
Rupert Shuttleworth | c143cc5 | 2021-04-13 13:08:04 -0400 | [diff] [blame] | 284 | ], |
| 285 | linkstatic = True, |
Rupert Shuttleworth | c143cc5 | 2021-04-13 13:08:04 -0400 | [diff] [blame] | 286 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 287 | }) |
| 288 | } |
| 289 | |
| 290 | func TestCcLibraryStaticExportIncludeDir(t *testing.T) { |
| 291 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 292 | description: "cc_library_static export include dir", |
| 293 | moduleTypeUnderTest: "cc_library_static", |
| 294 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 295 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 296 | filesystem: map[string]string{ |
| 297 | // subpackage with subdirectory |
| 298 | "subpackage/Android.bp": "", |
| 299 | "subpackage/subpackage_header.h": "", |
| 300 | "subpackage/subdirectory/subdirectory_header.h": "", |
Rupert Shuttleworth | c143cc5 | 2021-04-13 13:08:04 -0400 | [diff] [blame] | 301 | }, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 302 | blueprint: soongCcLibraryStaticPreamble + ` |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 303 | cc_library_static { |
| 304 | name: "foo_static", |
| 305 | export_include_dirs: ["subpackage"], |
| 306 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 307 | expectedBazelTargets: []string{`cc_library_static( |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 308 | name = "foo_static", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 309 | copts = [ |
| 310 | "-I.", |
| 311 | "-I$(BINDIR)/.", |
| 312 | ], |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 313 | includes = ["subpackage"], |
| 314 | linkstatic = True, |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 315 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 316 | }) |
| 317 | } |
| 318 | |
| 319 | func TestCcLibraryStaticExportSystemIncludeDir(t *testing.T) { |
| 320 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 321 | description: "cc_library_static export system include dir", |
| 322 | moduleTypeUnderTest: "cc_library_static", |
| 323 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 324 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 325 | filesystem: map[string]string{ |
| 326 | // subpackage with subdirectory |
| 327 | "subpackage/Android.bp": "", |
| 328 | "subpackage/subpackage_header.h": "", |
| 329 | "subpackage/subdirectory/subdirectory_header.h": "", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 330 | }, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 331 | blueprint: soongCcLibraryStaticPreamble + ` |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 332 | cc_library_static { |
| 333 | name: "foo_static", |
| 334 | export_system_include_dirs: ["subpackage"], |
| 335 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 336 | expectedBazelTargets: []string{`cc_library_static( |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 337 | name = "foo_static", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 338 | copts = [ |
| 339 | "-I.", |
| 340 | "-I$(BINDIR)/.", |
| 341 | ], |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 342 | includes = ["subpackage"], |
| 343 | linkstatic = True, |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 344 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 345 | }) |
| 346 | } |
| 347 | |
| 348 | func TestCcLibraryStaticManyIncludeDirs(t *testing.T) { |
| 349 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 350 | description: "cc_library_static include_dirs, local_include_dirs, export_include_dirs (b/183742505)", |
| 351 | moduleTypeUnderTest: "cc_library_static", |
| 352 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 353 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 354 | dir: "subpackage", |
| 355 | filesystem: map[string]string{ |
| 356 | // subpackage with subdirectory |
| 357 | "subpackage/Android.bp": ` |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 358 | cc_library_static { |
| 359 | name: "foo_static", |
| 360 | // include_dirs are workspace/root relative |
| 361 | include_dirs: [ |
| 362 | "subpackage/subsubpackage", |
| 363 | "subpackage2", |
| 364 | "subpackage3/subsubpackage" |
| 365 | ], |
| 366 | local_include_dirs: ["subsubpackage2"], // module dir relative |
| 367 | export_include_dirs: ["./exported_subsubpackage"], // module dir relative |
| 368 | include_build_directory: true, |
| 369 | bazel_module: { bp2build_available: true }, |
| 370 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 371 | "subpackage/subsubpackage/header.h": "", |
| 372 | "subpackage/subsubpackage2/header.h": "", |
| 373 | "subpackage/exported_subsubpackage/header.h": "", |
| 374 | "subpackage2/header.h": "", |
| 375 | "subpackage3/subsubpackage/header.h": "", |
| 376 | }, |
| 377 | blueprint: soongCcLibraryStaticPreamble, |
| 378 | expectedBazelTargets: []string{`cc_library_static( |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 379 | name = "foo_static", |
| 380 | copts = [ |
| 381 | "-Isubpackage/subsubpackage", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 382 | "-I$(BINDIR)/subpackage/subsubpackage", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 383 | "-Isubpackage2", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 384 | "-I$(BINDIR)/subpackage2", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 385 | "-Isubpackage3/subsubpackage", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 386 | "-I$(BINDIR)/subpackage3/subsubpackage", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 387 | "-Isubpackage/subsubpackage2", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 388 | "-I$(BINDIR)/subpackage/subsubpackage2", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 389 | "-Isubpackage", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 390 | "-I$(BINDIR)/subpackage", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 391 | ], |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 392 | includes = ["./exported_subsubpackage"], |
| 393 | linkstatic = True, |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 394 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 395 | }) |
| 396 | } |
| 397 | |
| 398 | func TestCcLibraryStaticIncludeBuildDirectoryDisabled(t *testing.T) { |
| 399 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 400 | description: "cc_library_static include_build_directory disabled", |
| 401 | moduleTypeUnderTest: "cc_library_static", |
| 402 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 403 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 404 | filesystem: map[string]string{ |
| 405 | // subpackage with subdirectory |
| 406 | "subpackage/Android.bp": "", |
| 407 | "subpackage/subpackage_header.h": "", |
| 408 | "subpackage/subdirectory/subdirectory_header.h": "", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 409 | }, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 410 | blueprint: soongCcLibraryStaticPreamble + ` |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 411 | cc_library_static { |
| 412 | name: "foo_static", |
| 413 | include_dirs: ["subpackage"], // still used, but local_include_dirs is recommended |
| 414 | local_include_dirs: ["subpackage2"], |
| 415 | include_build_directory: false, |
| 416 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 417 | expectedBazelTargets: []string{`cc_library_static( |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 418 | name = "foo_static", |
| 419 | copts = [ |
| 420 | "-Isubpackage", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 421 | "-I$(BINDIR)/subpackage", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 422 | "-Isubpackage2", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 423 | "-I$(BINDIR)/subpackage2", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 424 | ], |
| 425 | linkstatic = True, |
| 426 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 427 | }) |
| 428 | } |
| 429 | |
| 430 | func TestCcLibraryStaticIncludeBuildDirectoryEnabled(t *testing.T) { |
| 431 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 432 | description: "cc_library_static include_build_directory enabled", |
| 433 | moduleTypeUnderTest: "cc_library_static", |
| 434 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 435 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 436 | filesystem: map[string]string{ |
| 437 | // subpackage with subdirectory |
| 438 | "subpackage/Android.bp": "", |
| 439 | "subpackage/subpackage_header.h": "", |
| 440 | "subpackage2/Android.bp": "", |
| 441 | "subpackage2/subpackage2_header.h": "", |
| 442 | "subpackage/subdirectory/subdirectory_header.h": "", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 443 | }, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 444 | blueprint: soongCcLibraryStaticPreamble + ` |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 445 | cc_library_static { |
| 446 | name: "foo_static", |
| 447 | include_dirs: ["subpackage"], // still used, but local_include_dirs is recommended |
| 448 | local_include_dirs: ["subpackage2"], |
| 449 | include_build_directory: true, |
| 450 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 451 | expectedBazelTargets: []string{`cc_library_static( |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 452 | name = "foo_static", |
| 453 | copts = [ |
| 454 | "-Isubpackage", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 455 | "-I$(BINDIR)/subpackage", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 456 | "-Isubpackage2", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 457 | "-I$(BINDIR)/subpackage2", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 458 | "-I.", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 459 | "-I$(BINDIR)/.", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 460 | ], |
| 461 | linkstatic = True, |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 462 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 463 | }) |
| 464 | } |
| 465 | |
| 466 | func TestCcLibraryStaticArchSpecificStaticLib(t *testing.T) { |
| 467 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 468 | description: "cc_library_static arch-specific static_libs", |
| 469 | moduleTypeUnderTest: "cc_library_static", |
| 470 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 471 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 472 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 473 | filesystem: map[string]string{}, |
| 474 | blueprint: soongCcLibraryStaticPreamble + ` |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 475 | cc_library_static { name: "static_dep" } |
| 476 | cc_library_static { name: "static_dep2" } |
| 477 | cc_library_static { |
| 478 | name: "foo_static", |
| 479 | arch: { arm64: { static_libs: ["static_dep"], whole_static_libs: ["static_dep2"] } }, |
| 480 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 481 | expectedBazelTargets: []string{`cc_library_static( |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 482 | name = "foo_static", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 483 | copts = [ |
| 484 | "-I.", |
| 485 | "-I$(BINDIR)/.", |
| 486 | ], |
Chris Parsons | d635877 | 2021-05-18 18:35:24 -0400 | [diff] [blame] | 487 | implementation_deps = select({ |
Chris Parsons | 0864831 | 2021-05-06 16:23:19 -0400 | [diff] [blame] | 488 | "//build/bazel/platforms/arch:arm64": [":static_dep"], |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 489 | "//conditions:default": [], |
| 490 | }), |
| 491 | linkstatic = True, |
Chris Parsons | 0864831 | 2021-05-06 16:23:19 -0400 | [diff] [blame] | 492 | whole_archive_deps = select({ |
| 493 | "//build/bazel/platforms/arch:arm64": [":static_dep2"], |
| 494 | "//conditions:default": [], |
| 495 | }), |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 496 | )`, `cc_library_static( |
| 497 | name = "static_dep", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 498 | copts = [ |
| 499 | "-I.", |
| 500 | "-I$(BINDIR)/.", |
| 501 | ], |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 502 | linkstatic = True, |
| 503 | )`, `cc_library_static( |
| 504 | name = "static_dep2", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 505 | copts = [ |
| 506 | "-I.", |
| 507 | "-I$(BINDIR)/.", |
| 508 | ], |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 509 | linkstatic = True, |
| 510 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 511 | }) |
| 512 | } |
| 513 | |
| 514 | func TestCcLibraryStaticOsSpecificStaticLib(t *testing.T) { |
| 515 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 516 | description: "cc_library_static os-specific static_libs", |
| 517 | moduleTypeUnderTest: "cc_library_static", |
| 518 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 519 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 520 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 521 | filesystem: map[string]string{}, |
| 522 | blueprint: soongCcLibraryStaticPreamble + ` |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 523 | cc_library_static { name: "static_dep" } |
| 524 | cc_library_static { name: "static_dep2" } |
| 525 | cc_library_static { |
| 526 | name: "foo_static", |
| 527 | target: { android: { static_libs: ["static_dep"], whole_static_libs: ["static_dep2"] } }, |
| 528 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 529 | expectedBazelTargets: []string{`cc_library_static( |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 530 | name = "foo_static", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 531 | copts = [ |
| 532 | "-I.", |
| 533 | "-I$(BINDIR)/.", |
| 534 | ], |
Chris Parsons | d635877 | 2021-05-18 18:35:24 -0400 | [diff] [blame] | 535 | implementation_deps = select({ |
Chris Parsons | 0864831 | 2021-05-06 16:23:19 -0400 | [diff] [blame] | 536 | "//build/bazel/platforms/os:android": [":static_dep"], |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 537 | "//conditions:default": [], |
| 538 | }), |
| 539 | linkstatic = True, |
Chris Parsons | 0864831 | 2021-05-06 16:23:19 -0400 | [diff] [blame] | 540 | whole_archive_deps = select({ |
| 541 | "//build/bazel/platforms/os:android": [":static_dep2"], |
| 542 | "//conditions:default": [], |
| 543 | }), |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 544 | )`, `cc_library_static( |
| 545 | name = "static_dep", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 546 | copts = [ |
| 547 | "-I.", |
| 548 | "-I$(BINDIR)/.", |
| 549 | ], |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 550 | linkstatic = True, |
| 551 | )`, `cc_library_static( |
| 552 | name = "static_dep2", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 553 | copts = [ |
| 554 | "-I.", |
| 555 | "-I$(BINDIR)/.", |
| 556 | ], |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 557 | linkstatic = True, |
| 558 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 559 | }) |
| 560 | } |
| 561 | |
| 562 | func TestCcLibraryStaticBaseArchOsSpecificStaticLib(t *testing.T) { |
| 563 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 564 | description: "cc_library_static base, arch and os-specific static_libs", |
| 565 | moduleTypeUnderTest: "cc_library_static", |
| 566 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 567 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 568 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 569 | filesystem: map[string]string{}, |
| 570 | blueprint: soongCcLibraryStaticPreamble + ` |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 571 | cc_library_static { name: "static_dep" } |
| 572 | cc_library_static { name: "static_dep2" } |
| 573 | cc_library_static { name: "static_dep3" } |
| 574 | cc_library_static { name: "static_dep4" } |
| 575 | cc_library_static { |
| 576 | name: "foo_static", |
| 577 | static_libs: ["static_dep"], |
| 578 | whole_static_libs: ["static_dep2"], |
| 579 | target: { android: { static_libs: ["static_dep3"] } }, |
| 580 | arch: { arm64: { static_libs: ["static_dep4"] } }, |
| 581 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 582 | expectedBazelTargets: []string{`cc_library_static( |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 583 | name = "foo_static", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 584 | copts = [ |
| 585 | "-I.", |
| 586 | "-I$(BINDIR)/.", |
| 587 | ], |
Chris Parsons | d635877 | 2021-05-18 18:35:24 -0400 | [diff] [blame] | 588 | implementation_deps = [":static_dep"] + select({ |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 589 | "//build/bazel/platforms/arch:arm64": [":static_dep4"], |
| 590 | "//conditions:default": [], |
| 591 | }) + select({ |
| 592 | "//build/bazel/platforms/os:android": [":static_dep3"], |
| 593 | "//conditions:default": [], |
| 594 | }), |
| 595 | linkstatic = True, |
Chris Parsons | 0864831 | 2021-05-06 16:23:19 -0400 | [diff] [blame] | 596 | whole_archive_deps = [":static_dep2"], |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 597 | )`, `cc_library_static( |
| 598 | name = "static_dep", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 599 | copts = [ |
| 600 | "-I.", |
| 601 | "-I$(BINDIR)/.", |
| 602 | ], |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 603 | linkstatic = True, |
| 604 | )`, `cc_library_static( |
| 605 | name = "static_dep2", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 606 | copts = [ |
| 607 | "-I.", |
| 608 | "-I$(BINDIR)/.", |
| 609 | ], |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 610 | linkstatic = True, |
| 611 | )`, `cc_library_static( |
| 612 | name = "static_dep3", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 613 | copts = [ |
| 614 | "-I.", |
| 615 | "-I$(BINDIR)/.", |
| 616 | ], |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 617 | linkstatic = True, |
| 618 | )`, `cc_library_static( |
| 619 | name = "static_dep4", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 620 | copts = [ |
| 621 | "-I.", |
| 622 | "-I$(BINDIR)/.", |
| 623 | ], |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 624 | linkstatic = True, |
| 625 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 626 | }) |
| 627 | } |
| 628 | |
| 629 | func TestCcLibraryStaticSimpleExcludeSrcs(t *testing.T) { |
| 630 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 631 | description: "cc_library_static simple exclude_srcs", |
| 632 | moduleTypeUnderTest: "cc_library_static", |
| 633 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 634 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 635 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 636 | filesystem: map[string]string{ |
| 637 | "common.c": "", |
| 638 | "foo-a.c": "", |
| 639 | "foo-excluded.c": "", |
Jingwen Chen | ed9c17d | 2021-04-13 07:14:55 +0000 | [diff] [blame] | 640 | }, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 641 | blueprint: soongCcLibraryStaticPreamble + ` |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 642 | cc_library_static { |
| 643 | name: "foo_static", |
| 644 | srcs: ["common.c", "foo-*.c"], |
| 645 | exclude_srcs: ["foo-excluded.c"], |
| 646 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 647 | expectedBazelTargets: []string{`cc_library_static( |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 648 | name = "foo_static", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 649 | copts = [ |
| 650 | "-I.", |
| 651 | "-I$(BINDIR)/.", |
| 652 | ], |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 653 | linkstatic = True, |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 654 | srcs_c = [ |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 655 | "common.c", |
| 656 | "foo-a.c", |
| 657 | ], |
| 658 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 659 | }) |
| 660 | } |
| 661 | |
| 662 | func TestCcLibraryStaticOneArchSrcs(t *testing.T) { |
| 663 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 664 | description: "cc_library_static one arch specific srcs", |
| 665 | moduleTypeUnderTest: "cc_library_static", |
| 666 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 667 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 668 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 669 | filesystem: map[string]string{ |
| 670 | "common.c": "", |
| 671 | "foo-arm.c": "", |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 672 | }, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 673 | blueprint: soongCcLibraryStaticPreamble + ` |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 674 | cc_library_static { |
| 675 | name: "foo_static", |
| 676 | srcs: ["common.c"], |
| 677 | arch: { arm: { srcs: ["foo-arm.c"] } } |
| 678 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 679 | expectedBazelTargets: []string{`cc_library_static( |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 680 | name = "foo_static", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 681 | copts = [ |
| 682 | "-I.", |
| 683 | "-I$(BINDIR)/.", |
| 684 | ], |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 685 | linkstatic = True, |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 686 | srcs_c = ["common.c"] + select({ |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 687 | "//build/bazel/platforms/arch:arm": ["foo-arm.c"], |
| 688 | "//conditions:default": [], |
| 689 | }), |
| 690 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 691 | }) |
| 692 | } |
| 693 | |
| 694 | func TestCcLibraryStaticOneArchSrcsExcludeSrcs(t *testing.T) { |
| 695 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 696 | description: "cc_library_static one arch specific srcs and exclude_srcs", |
| 697 | moduleTypeUnderTest: "cc_library_static", |
| 698 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 699 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 700 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 701 | filesystem: map[string]string{ |
| 702 | "common.c": "", |
| 703 | "for-arm.c": "", |
| 704 | "not-for-arm.c": "", |
| 705 | "not-for-anything.c": "", |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 706 | }, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 707 | blueprint: soongCcLibraryStaticPreamble + ` |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 708 | cc_library_static { |
| 709 | name: "foo_static", |
| 710 | srcs: ["common.c", "not-for-*.c"], |
| 711 | exclude_srcs: ["not-for-anything.c"], |
| 712 | arch: { |
| 713 | arm: { srcs: ["for-arm.c"], exclude_srcs: ["not-for-arm.c"] }, |
| 714 | }, |
| 715 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 716 | expectedBazelTargets: []string{`cc_library_static( |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 717 | name = "foo_static", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 718 | copts = [ |
| 719 | "-I.", |
| 720 | "-I$(BINDIR)/.", |
| 721 | ], |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 722 | linkstatic = True, |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 723 | srcs_c = ["common.c"] + select({ |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 724 | "//build/bazel/platforms/arch:arm": ["for-arm.c"], |
| 725 | "//conditions:default": ["not-for-arm.c"], |
| 726 | }), |
| 727 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 728 | }) |
| 729 | } |
| 730 | |
| 731 | func TestCcLibraryStaticTwoArchExcludeSrcs(t *testing.T) { |
| 732 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 733 | description: "cc_library_static arch specific exclude_srcs for 2 architectures", |
| 734 | moduleTypeUnderTest: "cc_library_static", |
| 735 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 736 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 737 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 738 | filesystem: map[string]string{ |
| 739 | "common.c": "", |
| 740 | "for-arm.c": "", |
| 741 | "for-x86.c": "", |
| 742 | "not-for-arm.c": "", |
| 743 | "not-for-x86.c": "", |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 744 | }, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 745 | blueprint: soongCcLibraryStaticPreamble + ` |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 746 | cc_library_static { |
| 747 | name: "foo_static", |
| 748 | srcs: ["common.c", "not-for-*.c"], |
| 749 | exclude_srcs: ["not-for-everything.c"], |
| 750 | arch: { |
| 751 | arm: { srcs: ["for-arm.c"], exclude_srcs: ["not-for-arm.c"] }, |
| 752 | x86: { srcs: ["for-x86.c"], exclude_srcs: ["not-for-x86.c"] }, |
| 753 | }, |
| 754 | } `, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 755 | expectedBazelTargets: []string{`cc_library_static( |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 756 | name = "foo_static", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 757 | copts = [ |
| 758 | "-I.", |
| 759 | "-I$(BINDIR)/.", |
| 760 | ], |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 761 | linkstatic = True, |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 762 | srcs_c = ["common.c"] + select({ |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 763 | "//build/bazel/platforms/arch:arm": [ |
| 764 | "for-arm.c", |
| 765 | "not-for-x86.c", |
| 766 | ], |
| 767 | "//build/bazel/platforms/arch:x86": [ |
| 768 | "for-x86.c", |
| 769 | "not-for-arm.c", |
| 770 | ], |
| 771 | "//conditions:default": [ |
| 772 | "not-for-arm.c", |
| 773 | "not-for-x86.c", |
| 774 | ], |
| 775 | }), |
| 776 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 777 | }) |
| 778 | } |
| 779 | func TestCcLibraryStaticFourArchExcludeSrcs(t *testing.T) { |
| 780 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 781 | description: "cc_library_static arch specific exclude_srcs for 4 architectures", |
| 782 | moduleTypeUnderTest: "cc_library_static", |
| 783 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 784 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 785 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 786 | filesystem: map[string]string{ |
| 787 | "common.c": "", |
| 788 | "for-arm.c": "", |
| 789 | "for-arm64.c": "", |
| 790 | "for-x86.c": "", |
| 791 | "for-x86_64.c": "", |
| 792 | "not-for-arm.c": "", |
| 793 | "not-for-arm64.c": "", |
| 794 | "not-for-x86.c": "", |
| 795 | "not-for-x86_64.c": "", |
| 796 | "not-for-everything.c": "", |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 797 | }, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 798 | blueprint: soongCcLibraryStaticPreamble + ` |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 799 | cc_library_static { |
| 800 | name: "foo_static", |
| 801 | srcs: ["common.c", "not-for-*.c"], |
| 802 | exclude_srcs: ["not-for-everything.c"], |
| 803 | arch: { |
| 804 | arm: { srcs: ["for-arm.c"], exclude_srcs: ["not-for-arm.c"] }, |
| 805 | arm64: { srcs: ["for-arm64.c"], exclude_srcs: ["not-for-arm64.c"] }, |
| 806 | x86: { srcs: ["for-x86.c"], exclude_srcs: ["not-for-x86.c"] }, |
| 807 | x86_64: { srcs: ["for-x86_64.c"], exclude_srcs: ["not-for-x86_64.c"] }, |
| 808 | }, |
| 809 | } `, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 810 | expectedBazelTargets: []string{`cc_library_static( |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 811 | name = "foo_static", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 812 | copts = [ |
| 813 | "-I.", |
| 814 | "-I$(BINDIR)/.", |
| 815 | ], |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 816 | linkstatic = True, |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 817 | srcs_c = ["common.c"] + select({ |
Jingwen Chen | e32e9e0 | 2021-04-23 09:17:24 +0000 | [diff] [blame] | 818 | "//build/bazel/platforms/arch:arm": [ |
| 819 | "for-arm.c", |
| 820 | "not-for-arm64.c", |
| 821 | "not-for-x86.c", |
| 822 | "not-for-x86_64.c", |
| 823 | ], |
| 824 | "//build/bazel/platforms/arch:arm64": [ |
| 825 | "for-arm64.c", |
| 826 | "not-for-arm.c", |
| 827 | "not-for-x86.c", |
| 828 | "not-for-x86_64.c", |
| 829 | ], |
| 830 | "//build/bazel/platforms/arch:x86": [ |
| 831 | "for-x86.c", |
| 832 | "not-for-arm.c", |
| 833 | "not-for-arm64.c", |
| 834 | "not-for-x86_64.c", |
| 835 | ], |
| 836 | "//build/bazel/platforms/arch:x86_64": [ |
| 837 | "for-x86_64.c", |
| 838 | "not-for-arm.c", |
| 839 | "not-for-arm64.c", |
| 840 | "not-for-x86.c", |
| 841 | ], |
| 842 | "//conditions:default": [ |
| 843 | "not-for-arm.c", |
| 844 | "not-for-arm64.c", |
| 845 | "not-for-x86.c", |
| 846 | "not-for-x86_64.c", |
| 847 | ], |
| 848 | }), |
| 849 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 850 | }) |
| 851 | } |
| 852 | |
Liz Kammer | 2b07ec7 | 2021-05-26 15:08:27 -0400 | [diff] [blame^] | 853 | func TestCcLibraryStaticOneArchEmpty(t *testing.T) { |
| 854 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 855 | description: "cc_library_static one arch empty", |
| 856 | moduleTypeUnderTest: "cc_library_static", |
| 857 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 858 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 859 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 860 | filesystem: map[string]string{ |
| 861 | "common.cc": "", |
| 862 | "foo-no-arm.cc": "", |
| 863 | "foo-excluded.cc": "", |
| 864 | }, |
| 865 | blueprint: soongCcLibraryStaticPreamble + ` |
| 866 | cc_library_static { |
| 867 | name: "foo_static", |
| 868 | srcs: ["common.cc", "foo-*.cc"], |
| 869 | exclude_srcs: ["foo-excluded.cc"], |
| 870 | arch: { |
| 871 | arm: { exclude_srcs: ["foo-no-arm.cc"] }, |
| 872 | }, |
| 873 | }`, |
| 874 | expectedBazelTargets: []string{`cc_library_static( |
| 875 | name = "foo_static", |
| 876 | copts = [ |
| 877 | "-I.", |
| 878 | "-I$(BINDIR)/.", |
| 879 | ], |
| 880 | linkstatic = True, |
| 881 | srcs = ["common.cc"] + select({ |
| 882 | "//build/bazel/platforms/arch:arm": [], |
| 883 | "//conditions:default": ["foo-no-arm.cc"], |
| 884 | }), |
| 885 | )`}, |
| 886 | }) |
| 887 | } |
| 888 | |
| 889 | func TestCcLibraryStaticOneArchEmptyOtherSet(t *testing.T) { |
| 890 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 891 | description: "cc_library_static one arch empty other set", |
| 892 | moduleTypeUnderTest: "cc_library_static", |
| 893 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 894 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 895 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 896 | filesystem: map[string]string{ |
| 897 | "common.cc": "", |
| 898 | "foo-no-arm.cc": "", |
| 899 | "x86-only.cc": "", |
| 900 | "foo-excluded.cc": "", |
| 901 | }, |
| 902 | blueprint: soongCcLibraryStaticPreamble + ` |
| 903 | cc_library_static { |
| 904 | name: "foo_static", |
| 905 | srcs: ["common.cc", "foo-*.cc"], |
| 906 | exclude_srcs: ["foo-excluded.cc"], |
| 907 | arch: { |
| 908 | arm: { exclude_srcs: ["foo-no-arm.cc"] }, |
| 909 | x86: { srcs: ["x86-only.cc"] }, |
| 910 | }, |
| 911 | }`, |
| 912 | expectedBazelTargets: []string{`cc_library_static( |
| 913 | name = "foo_static", |
| 914 | copts = [ |
| 915 | "-I.", |
| 916 | "-I$(BINDIR)/.", |
| 917 | ], |
| 918 | linkstatic = True, |
| 919 | srcs = ["common.cc"] + select({ |
| 920 | "//build/bazel/platforms/arch:arm": [], |
| 921 | "//build/bazel/platforms/arch:x86": [ |
| 922 | "foo-no-arm.cc", |
| 923 | "x86-only.cc", |
| 924 | ], |
| 925 | "//conditions:default": ["foo-no-arm.cc"], |
| 926 | }), |
| 927 | )`}, |
| 928 | }) |
| 929 | } |
| 930 | |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 931 | func TestCcLibraryStaticMultipleDepSameName(t *testing.T) { |
| 932 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 933 | description: "cc_library_static multiple dep same name panic", |
| 934 | moduleTypeUnderTest: "cc_library_static", |
| 935 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 936 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 937 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 938 | filesystem: map[string]string{}, |
| 939 | blueprint: soongCcLibraryStaticPreamble + ` |
Liz Kammer | 2b50ce6 | 2021-04-26 15:47:28 -0400 | [diff] [blame] | 940 | cc_library_static { name: "static_dep" } |
| 941 | cc_library_static { |
| 942 | name: "foo_static", |
Chris Parsons | 0864831 | 2021-05-06 16:23:19 -0400 | [diff] [blame] | 943 | static_libs: ["static_dep", "static_dep"], |
Liz Kammer | 2b50ce6 | 2021-04-26 15:47:28 -0400 | [diff] [blame] | 944 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 945 | expectedBazelTargets: []string{`cc_library_static( |
Liz Kammer | 2b50ce6 | 2021-04-26 15:47:28 -0400 | [diff] [blame] | 946 | name = "foo_static", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 947 | copts = [ |
| 948 | "-I.", |
| 949 | "-I$(BINDIR)/.", |
| 950 | ], |
Chris Parsons | d635877 | 2021-05-18 18:35:24 -0400 | [diff] [blame] | 951 | implementation_deps = [":static_dep"], |
Liz Kammer | 2b50ce6 | 2021-04-26 15:47:28 -0400 | [diff] [blame] | 952 | linkstatic = True, |
| 953 | )`, `cc_library_static( |
| 954 | name = "static_dep", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 955 | copts = [ |
| 956 | "-I.", |
| 957 | "-I$(BINDIR)/.", |
| 958 | ], |
Liz Kammer | 2b50ce6 | 2021-04-26 15:47:28 -0400 | [diff] [blame] | 959 | linkstatic = True, |
| 960 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 961 | }) |
| 962 | } |
| 963 | |
| 964 | func TestCcLibraryStaticOneMultilibSrcsExcludeSrcs(t *testing.T) { |
| 965 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 966 | description: "cc_library_static 1 multilib srcs and exclude_srcs", |
| 967 | moduleTypeUnderTest: "cc_library_static", |
| 968 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 969 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 970 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 971 | filesystem: map[string]string{ |
| 972 | "common.c": "", |
| 973 | "for-lib32.c": "", |
| 974 | "not-for-lib32.c": "", |
Liz Kammer | 2b50ce6 | 2021-04-26 15:47:28 -0400 | [diff] [blame] | 975 | }, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 976 | blueprint: soongCcLibraryStaticPreamble + ` |
Chris Parsons | c424b76 | 2021-04-29 18:06:50 -0400 | [diff] [blame] | 977 | cc_library_static { |
| 978 | name: "foo_static", |
| 979 | srcs: ["common.c", "not-for-*.c"], |
| 980 | multilib: { |
| 981 | lib32: { srcs: ["for-lib32.c"], exclude_srcs: ["not-for-lib32.c"] }, |
| 982 | }, |
| 983 | } `, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 984 | expectedBazelTargets: []string{`cc_library_static( |
Chris Parsons | c424b76 | 2021-04-29 18:06:50 -0400 | [diff] [blame] | 985 | name = "foo_static", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 986 | copts = [ |
| 987 | "-I.", |
| 988 | "-I$(BINDIR)/.", |
| 989 | ], |
Chris Parsons | c424b76 | 2021-04-29 18:06:50 -0400 | [diff] [blame] | 990 | linkstatic = True, |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 991 | srcs_c = ["common.c"] + select({ |
Chris Parsons | c424b76 | 2021-04-29 18:06:50 -0400 | [diff] [blame] | 992 | "//build/bazel/platforms/arch:arm": ["for-lib32.c"], |
| 993 | "//build/bazel/platforms/arch:x86": ["for-lib32.c"], |
| 994 | "//conditions:default": ["not-for-lib32.c"], |
| 995 | }), |
| 996 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 997 | }) |
| 998 | } |
| 999 | |
| 1000 | func TestCcLibraryStaticTwoMultilibSrcsExcludeSrcs(t *testing.T) { |
| 1001 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 1002 | description: "cc_library_static 2 multilib srcs and exclude_srcs", |
| 1003 | moduleTypeUnderTest: "cc_library_static", |
| 1004 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 1005 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 1006 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 1007 | filesystem: map[string]string{ |
| 1008 | "common.c": "", |
| 1009 | "for-lib32.c": "", |
| 1010 | "for-lib64.c": "", |
| 1011 | "not-for-lib32.c": "", |
| 1012 | "not-for-lib64.c": "", |
Chris Parsons | c424b76 | 2021-04-29 18:06:50 -0400 | [diff] [blame] | 1013 | }, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 1014 | blueprint: soongCcLibraryStaticPreamble + ` |
Chris Parsons | c424b76 | 2021-04-29 18:06:50 -0400 | [diff] [blame] | 1015 | cc_library_static { |
| 1016 | name: "foo_static2", |
| 1017 | srcs: ["common.c", "not-for-*.c"], |
| 1018 | multilib: { |
| 1019 | lib32: { srcs: ["for-lib32.c"], exclude_srcs: ["not-for-lib32.c"] }, |
| 1020 | lib64: { srcs: ["for-lib64.c"], exclude_srcs: ["not-for-lib64.c"] }, |
| 1021 | }, |
| 1022 | } `, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 1023 | expectedBazelTargets: []string{`cc_library_static( |
Chris Parsons | c424b76 | 2021-04-29 18:06:50 -0400 | [diff] [blame] | 1024 | name = "foo_static2", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 1025 | copts = [ |
| 1026 | "-I.", |
| 1027 | "-I$(BINDIR)/.", |
| 1028 | ], |
Chris Parsons | c424b76 | 2021-04-29 18:06:50 -0400 | [diff] [blame] | 1029 | linkstatic = True, |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 1030 | srcs_c = ["common.c"] + select({ |
Chris Parsons | c424b76 | 2021-04-29 18:06:50 -0400 | [diff] [blame] | 1031 | "//build/bazel/platforms/arch:arm": [ |
| 1032 | "for-lib32.c", |
| 1033 | "not-for-lib64.c", |
| 1034 | ], |
| 1035 | "//build/bazel/platforms/arch:arm64": [ |
| 1036 | "for-lib64.c", |
| 1037 | "not-for-lib32.c", |
| 1038 | ], |
| 1039 | "//build/bazel/platforms/arch:x86": [ |
| 1040 | "for-lib32.c", |
| 1041 | "not-for-lib64.c", |
| 1042 | ], |
| 1043 | "//build/bazel/platforms/arch:x86_64": [ |
| 1044 | "for-lib64.c", |
| 1045 | "not-for-lib32.c", |
| 1046 | ], |
| 1047 | "//conditions:default": [ |
| 1048 | "not-for-lib32.c", |
| 1049 | "not-for-lib64.c", |
| 1050 | ], |
| 1051 | }), |
| 1052 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 1053 | }) |
| 1054 | } |
| 1055 | |
| 1056 | func TestCcLibrarySTaticArchMultilibSrcsExcludeSrcs(t *testing.T) { |
| 1057 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 1058 | description: "cc_library_static arch and multilib srcs and exclude_srcs", |
| 1059 | moduleTypeUnderTest: "cc_library_static", |
| 1060 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 1061 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 1062 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 1063 | filesystem: map[string]string{ |
| 1064 | "common.c": "", |
| 1065 | "for-arm.c": "", |
| 1066 | "for-arm64.c": "", |
| 1067 | "for-x86.c": "", |
| 1068 | "for-x86_64.c": "", |
| 1069 | "for-lib32.c": "", |
| 1070 | "for-lib64.c": "", |
| 1071 | "not-for-arm.c": "", |
| 1072 | "not-for-arm64.c": "", |
| 1073 | "not-for-x86.c": "", |
| 1074 | "not-for-x86_64.c": "", |
| 1075 | "not-for-lib32.c": "", |
| 1076 | "not-for-lib64.c": "", |
| 1077 | "not-for-everything.c": "", |
Chris Parsons | c424b76 | 2021-04-29 18:06:50 -0400 | [diff] [blame] | 1078 | }, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 1079 | blueprint: soongCcLibraryStaticPreamble + ` |
Chris Parsons | c424b76 | 2021-04-29 18:06:50 -0400 | [diff] [blame] | 1080 | cc_library_static { |
| 1081 | name: "foo_static3", |
| 1082 | srcs: ["common.c", "not-for-*.c"], |
| 1083 | exclude_srcs: ["not-for-everything.c"], |
| 1084 | arch: { |
| 1085 | arm: { srcs: ["for-arm.c"], exclude_srcs: ["not-for-arm.c"] }, |
| 1086 | arm64: { srcs: ["for-arm64.c"], exclude_srcs: ["not-for-arm64.c"] }, |
| 1087 | x86: { srcs: ["for-x86.c"], exclude_srcs: ["not-for-x86.c"] }, |
| 1088 | x86_64: { srcs: ["for-x86_64.c"], exclude_srcs: ["not-for-x86_64.c"] }, |
| 1089 | }, |
| 1090 | multilib: { |
| 1091 | lib32: { srcs: ["for-lib32.c"], exclude_srcs: ["not-for-lib32.c"] }, |
| 1092 | lib64: { srcs: ["for-lib64.c"], exclude_srcs: ["not-for-lib64.c"] }, |
| 1093 | }, |
| 1094 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 1095 | expectedBazelTargets: []string{`cc_library_static( |
Chris Parsons | c424b76 | 2021-04-29 18:06:50 -0400 | [diff] [blame] | 1096 | name = "foo_static3", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 1097 | copts = [ |
| 1098 | "-I.", |
| 1099 | "-I$(BINDIR)/.", |
| 1100 | ], |
Chris Parsons | c424b76 | 2021-04-29 18:06:50 -0400 | [diff] [blame] | 1101 | linkstatic = True, |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 1102 | srcs_c = ["common.c"] + select({ |
Chris Parsons | c424b76 | 2021-04-29 18:06:50 -0400 | [diff] [blame] | 1103 | "//build/bazel/platforms/arch:arm": [ |
| 1104 | "for-arm.c", |
| 1105 | "for-lib32.c", |
| 1106 | "not-for-arm64.c", |
| 1107 | "not-for-lib64.c", |
| 1108 | "not-for-x86.c", |
| 1109 | "not-for-x86_64.c", |
| 1110 | ], |
| 1111 | "//build/bazel/platforms/arch:arm64": [ |
| 1112 | "for-arm64.c", |
| 1113 | "for-lib64.c", |
| 1114 | "not-for-arm.c", |
| 1115 | "not-for-lib32.c", |
| 1116 | "not-for-x86.c", |
| 1117 | "not-for-x86_64.c", |
| 1118 | ], |
| 1119 | "//build/bazel/platforms/arch:x86": [ |
| 1120 | "for-lib32.c", |
| 1121 | "for-x86.c", |
| 1122 | "not-for-arm.c", |
| 1123 | "not-for-arm64.c", |
| 1124 | "not-for-lib64.c", |
| 1125 | "not-for-x86_64.c", |
| 1126 | ], |
| 1127 | "//build/bazel/platforms/arch:x86_64": [ |
| 1128 | "for-lib64.c", |
| 1129 | "for-x86_64.c", |
| 1130 | "not-for-arm.c", |
| 1131 | "not-for-arm64.c", |
| 1132 | "not-for-lib32.c", |
| 1133 | "not-for-x86.c", |
| 1134 | ], |
| 1135 | "//conditions:default": [ |
| 1136 | "not-for-arm.c", |
| 1137 | "not-for-arm64.c", |
| 1138 | "not-for-lib32.c", |
| 1139 | "not-for-lib64.c", |
| 1140 | "not-for-x86.c", |
| 1141 | "not-for-x86_64.c", |
| 1142 | ], |
| 1143 | }), |
| 1144 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 1145 | }) |
| 1146 | } |
| 1147 | |
| 1148 | func TestCcLibraryStaticArchSrcsExcludeSrcsGeneratedFiles(t *testing.T) { |
| 1149 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 1150 | description: "cc_library_static arch srcs/exclude_srcs with generated files", |
| 1151 | moduleTypeUnderTest: "cc_library_static", |
| 1152 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 1153 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 1154 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 1155 | filesystem: map[string]string{ |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 1156 | "common.cpp": "", |
| 1157 | "for-x86.cpp": "", |
| 1158 | "not-for-x86.cpp": "", |
| 1159 | "not-for-everything.cpp": "", |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 1160 | "dep/Android.bp": ` |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 1161 | genrule { |
| 1162 | name: "generated_src_other_pkg", |
| 1163 | out: ["generated_src_other_pkg.cpp"], |
| 1164 | cmd: "nothing to see here", |
| 1165 | } |
| 1166 | |
| 1167 | genrule { |
| 1168 | name: "generated_hdr_other_pkg", |
| 1169 | out: ["generated_hdr_other_pkg.cpp"], |
| 1170 | cmd: "nothing to see here", |
| 1171 | } |
| 1172 | |
| 1173 | genrule { |
| 1174 | name: "generated_hdr_other_pkg_x86", |
| 1175 | out: ["generated_hdr_other_pkg_x86.cpp"], |
| 1176 | cmd: "nothing to see here", |
| 1177 | }`, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 1178 | }, |
| 1179 | blueprint: soongCcLibraryStaticPreamble + ` |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 1180 | genrule { |
| 1181 | name: "generated_src", |
| 1182 | out: ["generated_src.cpp"], |
| 1183 | cmd: "nothing to see here", |
| 1184 | } |
| 1185 | |
| 1186 | genrule { |
| 1187 | name: "generated_src_x86", |
| 1188 | out: ["generated_src_x86.cpp"], |
| 1189 | cmd: "nothing to see here", |
| 1190 | } |
| 1191 | |
| 1192 | genrule { |
| 1193 | name: "generated_hdr", |
| 1194 | out: ["generated_hdr.h"], |
| 1195 | cmd: "nothing to see here", |
| 1196 | } |
| 1197 | |
| 1198 | cc_library_static { |
| 1199 | name: "foo_static3", |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 1200 | srcs: ["common.cpp", "not-for-*.cpp"], |
| 1201 | exclude_srcs: ["not-for-everything.cpp"], |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 1202 | generated_sources: ["generated_src", "generated_src_other_pkg"], |
| 1203 | generated_headers: ["generated_hdr", "generated_hdr_other_pkg"], |
| 1204 | arch: { |
| 1205 | x86: { |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 1206 | srcs: ["for-x86.cpp"], |
| 1207 | exclude_srcs: ["not-for-x86.cpp"], |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 1208 | generated_sources: ["generated_src_x86"], |
| 1209 | generated_headers: ["generated_hdr_other_pkg_x86"], |
| 1210 | }, |
| 1211 | }, |
| 1212 | } |
| 1213 | `, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 1214 | expectedBazelTargets: []string{`cc_library_static( |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 1215 | name = "foo_static3", |
| 1216 | copts = [ |
| 1217 | "-I.", |
| 1218 | "-I$(BINDIR)/.", |
| 1219 | ], |
| 1220 | linkstatic = True, |
| 1221 | srcs = [ |
| 1222 | "//dep:generated_hdr_other_pkg", |
| 1223 | "//dep:generated_src_other_pkg", |
| 1224 | ":generated_hdr", |
| 1225 | ":generated_src", |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 1226 | "common.cpp", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 1227 | ] + select({ |
| 1228 | "//build/bazel/platforms/arch:x86": [ |
| 1229 | "//dep:generated_hdr_other_pkg_x86", |
| 1230 | ":generated_src_x86", |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 1231 | "for-x86.cpp", |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 1232 | ], |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 1233 | "//conditions:default": ["not-for-x86.cpp"], |
Chris Parsons | 484e50a | 2021-05-13 15:13:04 -0400 | [diff] [blame] | 1234 | }), |
| 1235 | )`}, |
Lukacs T. Berki | c1cc3b9 | 2021-05-21 09:37:00 +0200 | [diff] [blame] | 1236 | }) |
Rupert Shuttleworth | 095081c | 2021-03-25 09:06:03 +0000 | [diff] [blame] | 1237 | } |
Liz Kammer | 6fd7b3f | 2021-05-06 13:54:29 -0400 | [diff] [blame] | 1238 | |
Rupert Shuttleworth | c194ffb | 2021-05-19 06:49:02 -0400 | [diff] [blame] | 1239 | func TestCcLibraryStaticGetTargetProperties(t *testing.T) { |
| 1240 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 1241 | |
| 1242 | description: "cc_library_static complex GetTargetProperties", |
| 1243 | moduleTypeUnderTest: "cc_library_static", |
| 1244 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 1245 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 1246 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 1247 | blueprint: soongCcLibraryStaticPreamble + ` |
| 1248 | cc_library_static { |
| 1249 | name: "foo_static", |
| 1250 | target: { |
| 1251 | android: { |
| 1252 | srcs: ["android_src.c"], |
| 1253 | }, |
| 1254 | android_arm: { |
| 1255 | srcs: ["android_arm_src.c"], |
| 1256 | }, |
| 1257 | android_arm64: { |
| 1258 | srcs: ["android_arm64_src.c"], |
| 1259 | }, |
| 1260 | android_x86: { |
| 1261 | srcs: ["android_x86_src.c"], |
| 1262 | }, |
| 1263 | android_x86_64: { |
| 1264 | srcs: ["android_x86_64_src.c"], |
| 1265 | }, |
| 1266 | linux_bionic_arm64: { |
| 1267 | srcs: ["linux_bionic_arm64_src.c"], |
| 1268 | }, |
| 1269 | linux_bionic_x86_64: { |
| 1270 | srcs: ["linux_bionic_x86_64_src.c"], |
| 1271 | }, |
| 1272 | }, |
| 1273 | }`, |
| 1274 | expectedBazelTargets: []string{`cc_library_static( |
| 1275 | name = "foo_static", |
| 1276 | copts = [ |
| 1277 | "-I.", |
| 1278 | "-I$(BINDIR)/.", |
| 1279 | ], |
| 1280 | linkstatic = True, |
| 1281 | srcs_c = select({ |
| 1282 | "//build/bazel/platforms/os:android": ["android_src.c"], |
| 1283 | "//conditions:default": [], |
| 1284 | }) + select({ |
| 1285 | "//build/bazel/platforms:android_arm": ["android_arm_src.c"], |
| 1286 | "//build/bazel/platforms:android_arm64": ["android_arm64_src.c"], |
| 1287 | "//build/bazel/platforms:android_x86": ["android_x86_src.c"], |
| 1288 | "//build/bazel/platforms:android_x86_64": ["android_x86_64_src.c"], |
| 1289 | "//conditions:default": [], |
| 1290 | }) + select({ |
| 1291 | "//build/bazel/platforms:linux_bionic_arm64": ["linux_bionic_arm64_src.c"], |
| 1292 | "//build/bazel/platforms:linux_bionic_x86_64": ["linux_bionic_x86_64_src.c"], |
| 1293 | "//conditions:default": [], |
| 1294 | }), |
| 1295 | )`}, |
| 1296 | }) |
| 1297 | } |
| 1298 | |
Liz Kammer | 6fd7b3f | 2021-05-06 13:54:29 -0400 | [diff] [blame] | 1299 | func TestCcLibraryStaticProductVariableSelects(t *testing.T) { |
| 1300 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 1301 | description: "cc_library_static product variable selects", |
| 1302 | moduleTypeUnderTest: "cc_library_static", |
| 1303 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 1304 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 1305 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 1306 | filesystem: map[string]string{}, |
| 1307 | blueprint: soongCcLibraryStaticPreamble + ` |
| 1308 | cc_library_static { |
| 1309 | name: "foo_static", |
| 1310 | srcs: ["common.c"], |
| 1311 | product_variables: { |
| 1312 | malloc_not_svelte: { |
| 1313 | cflags: ["-Wmalloc_not_svelte"], |
| 1314 | }, |
| 1315 | malloc_zero_contents: { |
| 1316 | cflags: ["-Wmalloc_zero_contents"], |
| 1317 | }, |
| 1318 | binder32bit: { |
| 1319 | cflags: ["-Wbinder32bit"], |
| 1320 | }, |
| 1321 | }, |
| 1322 | } `, |
| 1323 | expectedBazelTargets: []string{`cc_library_static( |
| 1324 | name = "foo_static", |
| 1325 | copts = [ |
| 1326 | "-I.", |
| 1327 | "-I$(BINDIR)/.", |
| 1328 | ] + select({ |
Liz Kammer | e3e4a5f | 2021-05-10 11:39:53 -0400 | [diff] [blame] | 1329 | "//build/bazel/product_variables:binder32bit": ["-Wbinder32bit"], |
| 1330 | "//conditions:default": [], |
| 1331 | }) + select({ |
Liz Kammer | 6fd7b3f | 2021-05-06 13:54:29 -0400 | [diff] [blame] | 1332 | "//build/bazel/product_variables:malloc_not_svelte": ["-Wmalloc_not_svelte"], |
| 1333 | "//conditions:default": [], |
| 1334 | }) + select({ |
| 1335 | "//build/bazel/product_variables:malloc_zero_contents": ["-Wmalloc_zero_contents"], |
| 1336 | "//conditions:default": [], |
Liz Kammer | e3e4a5f | 2021-05-10 11:39:53 -0400 | [diff] [blame] | 1337 | }), |
| 1338 | linkstatic = True, |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 1339 | srcs_c = ["common.c"], |
Liz Kammer | e3e4a5f | 2021-05-10 11:39:53 -0400 | [diff] [blame] | 1340 | )`}, |
| 1341 | }) |
| 1342 | } |
| 1343 | |
| 1344 | func TestCcLibraryStaticProductVariableArchSpecificSelects(t *testing.T) { |
| 1345 | runCcLibraryStaticTestCase(t, bp2buildTestCase{ |
| 1346 | description: "cc_library_static arch-specific product variable selects", |
| 1347 | moduleTypeUnderTest: "cc_library_static", |
| 1348 | moduleTypeUnderTestFactory: cc.LibraryStaticFactory, |
| 1349 | moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, |
| 1350 | depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, |
| 1351 | filesystem: map[string]string{}, |
| 1352 | blueprint: soongCcLibraryStaticPreamble + ` |
| 1353 | cc_library_static { |
| 1354 | name: "foo_static", |
| 1355 | srcs: ["common.c"], |
| 1356 | product_variables: { |
| 1357 | malloc_not_svelte: { |
| 1358 | cflags: ["-Wmalloc_not_svelte"], |
| 1359 | }, |
| 1360 | }, |
| 1361 | arch: { |
| 1362 | arm64: { |
| 1363 | product_variables: { |
| 1364 | malloc_not_svelte: { |
| 1365 | cflags: ["-Warm64_malloc_not_svelte"], |
| 1366 | }, |
| 1367 | }, |
| 1368 | }, |
| 1369 | }, |
| 1370 | multilib: { |
| 1371 | lib32: { |
| 1372 | product_variables: { |
| 1373 | malloc_not_svelte: { |
| 1374 | cflags: ["-Wlib32_malloc_not_svelte"], |
| 1375 | }, |
| 1376 | }, |
| 1377 | }, |
| 1378 | }, |
| 1379 | target: { |
| 1380 | android: { |
| 1381 | product_variables: { |
| 1382 | malloc_not_svelte: { |
| 1383 | cflags: ["-Wandroid_malloc_not_svelte"], |
| 1384 | }, |
| 1385 | }, |
| 1386 | } |
| 1387 | }, |
| 1388 | } `, |
| 1389 | expectedBazelTargets: []string{`cc_library_static( |
| 1390 | name = "foo_static", |
| 1391 | copts = [ |
| 1392 | "-I.", |
| 1393 | "-I$(BINDIR)/.", |
| 1394 | ] + select({ |
| 1395 | "//build/bazel/product_variables:malloc_not_svelte": ["-Wmalloc_not_svelte"], |
| 1396 | "//conditions:default": [], |
Liz Kammer | 6fd7b3f | 2021-05-06 13:54:29 -0400 | [diff] [blame] | 1397 | }) + select({ |
Liz Kammer | e3e4a5f | 2021-05-10 11:39:53 -0400 | [diff] [blame] | 1398 | "//build/bazel/product_variables:malloc_not_svelte-android": ["-Wandroid_malloc_not_svelte"], |
| 1399 | "//conditions:default": [], |
| 1400 | }) + select({ |
| 1401 | "//build/bazel/product_variables:malloc_not_svelte-arm": ["-Wlib32_malloc_not_svelte"], |
| 1402 | "//conditions:default": [], |
| 1403 | }) + select({ |
| 1404 | "//build/bazel/product_variables:malloc_not_svelte-arm64": ["-Warm64_malloc_not_svelte"], |
| 1405 | "//conditions:default": [], |
| 1406 | }) + select({ |
| 1407 | "//build/bazel/product_variables:malloc_not_svelte-x86": ["-Wlib32_malloc_not_svelte"], |
Liz Kammer | 6fd7b3f | 2021-05-06 13:54:29 -0400 | [diff] [blame] | 1408 | "//conditions:default": [], |
| 1409 | }), |
| 1410 | linkstatic = True, |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 1411 | srcs_c = ["common.c"], |
Liz Kammer | 6fd7b3f | 2021-05-06 13:54:29 -0400 | [diff] [blame] | 1412 | )`}, |
| 1413 | }) |
| 1414 | } |