blob: 762e954c2c1517c38fea01d108771e2dc769dc45 [file] [log] [blame]
Austin Schuhd57edc42019-09-21 17:52:38 -07001#
2# Copyright 2017 The Abseil Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# https://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17#load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
18load(
19 "//absl:copts/configure_copts.bzl",
20 "ABSL_DEFAULT_COPTS",
21 "ABSL_DEFAULT_LINKOPTS",
22 "ABSL_TEST_COPTS",
23)
24
25package(default_visibility = ["//visibility:public"])
26
27licenses(["notice"]) # Apache 2.0
28
29cc_library(
30 name = "atomic_hook",
31 hdrs = ["internal/atomic_hook.h"],
32 copts = ABSL_DEFAULT_COPTS,
33 linkopts = ABSL_DEFAULT_LINKOPTS,
34 visibility = [
35 "//absl:__subpackages__",
36 ],
37)
38
39cc_library(
40 name = "log_severity",
41 srcs = ["log_severity.cc"],
42 hdrs = ["log_severity.h"],
43 copts = ABSL_DEFAULT_COPTS,
44 linkopts = ABSL_DEFAULT_LINKOPTS,
45 deps = [":core_headers"],
46)
47
48cc_library(
49 name = "raw_logging_internal",
50 srcs = ["internal/raw_logging.cc"],
51 hdrs = ["internal/raw_logging.h"],
52 copts = ABSL_DEFAULT_COPTS,
53 linkopts = ABSL_DEFAULT_LINKOPTS,
54 visibility = [
55 "//absl:__subpackages__",
56 ],
57 deps = [
58 ":atomic_hook",
59 ":config",
60 ":core_headers",
61 ":log_severity",
62 ],
63)
64
65cc_library(
66 name = "spinlock_wait",
67 srcs = [
68 "internal/spinlock_akaros.inc",
69 "internal/spinlock_linux.inc",
70 "internal/spinlock_posix.inc",
71 "internal/spinlock_wait.cc",
72 "internal/spinlock_win32.inc",
73 ],
74 hdrs = [
75 "internal/scheduling_mode.h",
76 "internal/spinlock_wait.h",
77 ],
78 copts = ABSL_DEFAULT_COPTS,
79 linkopts = ABSL_DEFAULT_LINKOPTS,
80 visibility = [
81 "//absl/base:__pkg__",
82 ],
83 deps = [":core_headers"],
84)
85
86cc_library(
87 name = "config",
88 hdrs = [
89 "config.h",
90 "policy_checks.h",
91 ],
92 copts = ABSL_DEFAULT_COPTS,
93 linkopts = ABSL_DEFAULT_LINKOPTS,
94)
95
96cc_library(
97 name = "dynamic_annotations",
98 srcs = ["dynamic_annotations.cc"],
99 hdrs = ["dynamic_annotations.h"],
100 copts = ABSL_DEFAULT_COPTS,
101 defines = ["__CLANG_SUPPORT_DYN_ANNOTATION__"],
102 linkopts = ABSL_DEFAULT_LINKOPTS,
103)
104
105cc_library(
106 name = "core_headers",
107 srcs = [
108 "internal/thread_annotations.h",
109 ],
110 hdrs = [
111 "attributes.h",
112 "const_init.h",
113 "macros.h",
114 "optimization.h",
115 "port.h",
116 "thread_annotations.h",
117 ],
118 copts = ABSL_DEFAULT_COPTS,
119 linkopts = ABSL_DEFAULT_LINKOPTS,
120 deps = [
121 ":config",
122 ],
123)
124
125cc_library(
126 name = "malloc_internal",
127 srcs = [
128 "internal/low_level_alloc.cc",
129 ],
130 hdrs = [
131 "internal/direct_mmap.h",
132 "internal/low_level_alloc.h",
133 ],
134 copts = ABSL_DEFAULT_COPTS,
135 linkopts = select({
136 "//absl:windows": [],
137 "//conditions:default": ["-pthread"],
138 }) + ABSL_DEFAULT_LINKOPTS,
139 visibility = [
140 "//absl:__subpackages__",
141 ],
142 deps = [
143 ":base",
144 ":config",
145 ":core_headers",
146 ":dynamic_annotations",
147 ":raw_logging_internal",
148 ":spinlock_wait",
149 ],
150)
151
152cc_library(
153 name = "base_internal",
154 hdrs = [
155 "internal/hide_ptr.h",
156 "internal/identity.h",
157 "internal/inline_variable.h",
158 "internal/invoke.h",
159 "internal/scheduling_mode.h",
160 ],
161 copts = ABSL_DEFAULT_COPTS,
162 linkopts = ABSL_DEFAULT_LINKOPTS,
163 visibility = [
164 "//absl:__subpackages__",
165 ],
166 deps = [
167 "//absl/meta:type_traits",
168 ],
169)
170
171cc_library(
172 name = "base",
173 srcs = [
174 "internal/cycleclock.cc",
175 "internal/spinlock.cc",
176 "internal/sysinfo.cc",
177 "internal/thread_identity.cc",
178 "internal/unscaledcycleclock.cc",
179 ],
180 hdrs = [
181 "call_once.h",
182 "casts.h",
183 "internal/cycleclock.h",
184 "internal/low_level_scheduling.h",
185 "internal/per_thread_tls.h",
186 "internal/spinlock.h",
187 "internal/sysinfo.h",
188 "internal/thread_identity.h",
189 "internal/tsan_mutex_interface.h",
190 "internal/unscaledcycleclock.h",
191 ],
192 copts = ABSL_DEFAULT_COPTS,
193 linkopts = select({
194 "//absl:windows": [],
195 "//conditions:default": ["-pthread"],
196 }) + ABSL_DEFAULT_LINKOPTS,
197 deps = [
198 ":atomic_hook",
199 ":base_internal",
200 ":config",
201 ":core_headers",
202 ":dynamic_annotations",
203 ":log_severity",
204 ":raw_logging_internal",
205 ":spinlock_wait",
206 "//absl/meta:type_traits",
207 ],
208)
209
210cc_test(
211 name = "atomic_hook_test",
212 size = "small",
213 srcs = ["internal/atomic_hook_test.cc"],
214 copts = ABSL_TEST_COPTS,
215 linkopts = ABSL_DEFAULT_LINKOPTS,
216 deps = [
217 ":atomic_hook",
218 ":core_headers",
219 "@com_google_googletest//:gtest_main",
220 ],
221)
222
223cc_test(
224 name = "bit_cast_test",
225 size = "small",
226 srcs = [
227 "bit_cast_test.cc",
228 ],
229 copts = ABSL_TEST_COPTS,
230 linkopts = ABSL_DEFAULT_LINKOPTS,
231 deps = [
232 ":base",
233 ":core_headers",
234 "@com_google_googletest//:gtest_main",
235 ],
236)
237
238cc_library(
239 name = "throw_delegate",
240 srcs = ["internal/throw_delegate.cc"],
241 hdrs = ["internal/throw_delegate.h"],
242 copts = ABSL_DEFAULT_COPTS,
243 linkopts = ABSL_DEFAULT_LINKOPTS,
244 visibility = [
245 "//absl:__subpackages__",
246 ],
247 deps = [
248 ":config",
249 ":raw_logging_internal",
250 ],
251)
252
253cc_test(
254 name = "throw_delegate_test",
255 srcs = ["throw_delegate_test.cc"],
256 copts = ABSL_TEST_COPTS,
257 linkopts = ABSL_DEFAULT_LINKOPTS,
258 deps = [
259 ":config",
260 ":throw_delegate",
261 "@com_google_googletest//:gtest_main",
262 ],
263)
264
265cc_library(
266 name = "exception_testing",
267 testonly = 1,
268 hdrs = ["internal/exception_testing.h"],
269 copts = ABSL_TEST_COPTS,
270 linkopts = ABSL_DEFAULT_LINKOPTS,
271 visibility = [
272 "//absl:__subpackages__",
273 ],
274 deps = [
275 ":config",
276 "@com_google_googletest//:gtest",
277 ],
278)
279
280cc_library(
281 name = "pretty_function",
282 hdrs = ["internal/pretty_function.h"],
283 linkopts = ABSL_DEFAULT_LINKOPTS,
284 visibility = ["//absl:__subpackages__"],
285)
286
287cc_library(
288 name = "exception_safety_testing",
289 testonly = 1,
290 srcs = ["internal/exception_safety_testing.cc"],
291 hdrs = ["internal/exception_safety_testing.h"],
292 copts = ABSL_TEST_COPTS,
293 linkopts = ABSL_DEFAULT_LINKOPTS,
294 deps = [
295 ":config",
296 ":pretty_function",
297 "//absl/memory",
298 "//absl/meta:type_traits",
299 "//absl/strings",
300 "//absl/utility",
301 "@com_google_googletest//:gtest",
302 ],
303)
304
305cc_test(
306 name = "exception_safety_testing_test",
307 srcs = ["exception_safety_testing_test.cc"],
308 copts = ABSL_TEST_COPTS,
309 linkopts = ABSL_DEFAULT_LINKOPTS,
310 deps = [
311 ":exception_safety_testing",
312 "//absl/memory",
313 "@com_google_googletest//:gtest_main",
314 ],
315)
316
317cc_test(
318 name = "inline_variable_test",
319 size = "small",
320 srcs = [
321 "inline_variable_test.cc",
322 "inline_variable_test_a.cc",
323 "inline_variable_test_b.cc",
324 "internal/inline_variable_testing.h",
325 ],
326 copts = ABSL_TEST_COPTS,
327 linkopts = ABSL_DEFAULT_LINKOPTS,
328 deps = [
329 ":base_internal",
330 "@com_google_googletest//:gtest_main",
331 ],
332)
333
334cc_test(
335 name = "invoke_test",
336 size = "small",
337 srcs = ["invoke_test.cc"],
338 copts = ABSL_TEST_COPTS,
339 linkopts = ABSL_DEFAULT_LINKOPTS,
340 deps = [
341 ":base_internal",
342 "//absl/memory",
343 "//absl/strings",
344 "@com_google_googletest//:gtest_main",
345 ],
346)
347
348# Common test library made available for use in non-absl code that overrides
349# AbslInternalSpinLockDelay and AbslInternalSpinLockWake.
350cc_library(
351 name = "spinlock_test_common",
352 testonly = 1,
353 srcs = ["spinlock_test_common.cc"],
354 copts = ABSL_TEST_COPTS,
355 linkopts = ABSL_DEFAULT_LINKOPTS,
356 deps = [
357 ":base",
358 ":core_headers",
359 ":spinlock_wait",
360 "//absl/synchronization",
361 "@com_google_googletest//:gtest",
362 ],
363 alwayslink = 1,
364)
365
366cc_test(
367 name = "spinlock_test",
368 size = "medium",
369 srcs = ["spinlock_test_common.cc"],
370 copts = ABSL_TEST_COPTS,
371 linkopts = ABSL_DEFAULT_LINKOPTS,
372 deps = [
373 ":base",
374 ":core_headers",
375 ":spinlock_wait",
376 "//absl/synchronization",
377 "@com_google_googletest//:gtest_main",
378 ],
379)
380
381cc_library(
382 name = "spinlock_benchmark_common",
383 testonly = 1,
384 srcs = ["internal/spinlock_benchmark.cc"],
385 copts = ABSL_TEST_COPTS,
386 linkopts = ABSL_DEFAULT_LINKOPTS,
387 visibility = [
388 "//absl/base:__pkg__",
389 ],
390 deps = [
391 ":base",
392 ":base_internal",
393 ":raw_logging_internal",
394 "//absl/synchronization",
395 "@com_github_google_benchmark//:benchmark_main",
396 ],
397 alwayslink = 1,
398)
399
400cc_binary(
401 name = "spinlock_benchmark",
402 testonly = 1,
403 copts = ABSL_DEFAULT_COPTS,
404 linkopts = ABSL_DEFAULT_LINKOPTS,
405 visibility = ["//visibility:private"],
406 deps = [
407 ":spinlock_benchmark_common",
408 ],
409)
410
411cc_library(
412 name = "endian",
413 hdrs = [
414 "internal/endian.h",
415 "internal/unaligned_access.h",
416 ],
417 copts = ABSL_DEFAULT_COPTS,
418 linkopts = ABSL_DEFAULT_LINKOPTS,
419 deps = [
420 ":config",
421 ":core_headers",
422 ],
423)
424
425cc_test(
426 name = "endian_test",
427 srcs = ["internal/endian_test.cc"],
428 copts = ABSL_TEST_COPTS,
429 deps = [
430 ":config",
431 ":endian",
432 "@com_google_googletest//:gtest_main",
433 ],
434)
435
436cc_test(
437 name = "config_test",
438 srcs = ["config_test.cc"],
439 copts = ABSL_TEST_COPTS,
440 linkopts = ABSL_DEFAULT_LINKOPTS,
441 deps = [
442 ":config",
443 "//absl/synchronization:thread_pool",
444 "@com_google_googletest//:gtest_main",
445 ],
446)
447
448cc_test(
449 name = "call_once_test",
450 srcs = ["call_once_test.cc"],
451 copts = ABSL_TEST_COPTS,
452 linkopts = ABSL_DEFAULT_LINKOPTS,
453 deps = [
454 ":base",
455 ":core_headers",
456 "//absl/synchronization",
457 "@com_google_googletest//:gtest_main",
458 ],
459)
460
461cc_test(
462 name = "raw_logging_test",
463 srcs = ["raw_logging_test.cc"],
464 copts = ABSL_TEST_COPTS,
465 linkopts = ABSL_DEFAULT_LINKOPTS,
466 deps = [
467 ":raw_logging_internal",
468 "//absl/strings",
469 "@com_google_googletest//:gtest_main",
470 ],
471)
472
473cc_test(
474 name = "sysinfo_test",
475 size = "small",
476 srcs = ["internal/sysinfo_test.cc"],
477 copts = ABSL_TEST_COPTS,
478 linkopts = ABSL_DEFAULT_LINKOPTS,
479 deps = [
480 ":base",
481 "//absl/synchronization",
482 "@com_google_googletest//:gtest_main",
483 ],
484)
485
486cc_test(
487 name = "low_level_alloc_test",
488 size = "medium",
489 srcs = ["internal/low_level_alloc_test.cc"],
490 copts = ABSL_TEST_COPTS,
491 linkopts = ABSL_DEFAULT_LINKOPTS,
492 tags = ["no_test_ios_x86_64"],
493 deps = [":malloc_internal"],
494)
495
496cc_test(
497 name = "thread_identity_test",
498 size = "small",
499 srcs = ["internal/thread_identity_test.cc"],
500 copts = ABSL_TEST_COPTS,
501 linkopts = ABSL_DEFAULT_LINKOPTS,
502 deps = [
503 ":base",
504 ":core_headers",
505 "//absl/synchronization",
506 "@com_google_googletest//:gtest_main",
507 ],
508)
509
510cc_test(
511 name = "thread_identity_benchmark",
512 srcs = ["internal/thread_identity_benchmark.cc"],
513 copts = ABSL_TEST_COPTS,
514 linkopts = ABSL_DEFAULT_LINKOPTS,
515 tags = ["benchmark"],
516 visibility = ["//visibility:private"],
517 deps = [
518 ":base",
519 "//absl/synchronization",
520 "@com_github_google_benchmark//:benchmark_main",
521 ],
522)
523
524cc_library(
525 name = "bits",
526 hdrs = ["internal/bits.h"],
527 linkopts = ABSL_DEFAULT_LINKOPTS,
528 visibility = [
529 "//absl:__subpackages__",
530 ],
531 deps = [":core_headers"],
532)
533
534cc_test(
535 name = "bits_test",
536 size = "small",
537 srcs = ["internal/bits_test.cc"],
538 copts = ABSL_TEST_COPTS,
539 linkopts = ABSL_DEFAULT_LINKOPTS,
540 deps = [
541 ":bits",
542 "@com_google_googletest//:gtest_main",
543 ],
544)
545
546cc_library(
547 name = "scoped_set_env",
548 testonly = 1,
549 srcs = ["internal/scoped_set_env.cc"],
550 hdrs = ["internal/scoped_set_env.h"],
551 linkopts = ABSL_DEFAULT_LINKOPTS,
552 visibility = [
553 "//absl:__subpackages__",
554 ],
555 deps = [":raw_logging_internal"],
556)
557
558cc_test(
559 name = "scoped_set_env_test",
560 size = "small",
561 srcs = ["internal/scoped_set_env_test.cc"],
562 copts = ABSL_TEST_COPTS,
563 linkopts = ABSL_DEFAULT_LINKOPTS,
564 deps = [
565 ":scoped_set_env",
566 "@com_google_googletest//:gtest_main",
567 ],
568)
569
570cc_test(
571 name = "log_severity_test",
572 size = "small",
573 srcs = ["log_severity_test.cc"],
574 copts = ABSL_TEST_COPTS,
575 linkopts = ABSL_DEFAULT_LINKOPTS,
576 deps = [
577 ":log_severity",
578 "//absl/flags:marshalling",
579 "//absl/strings",
580 "@com_google_googletest//:gtest_main",
581 ],
582)