blob: b7754de1610b520f97bdf97ae7d1d817d6c69215 [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,
James Kuszmaul872efd22019-12-03 20:59:09 -0800135 linkopts = ABSL_DEFAULT_LINKOPTS,
Austin Schuhd57edc42019-09-21 17:52:38 -0700136 visibility = [
137 "//absl:__subpackages__",
138 ],
139 deps = [
140 ":base",
141 ":config",
142 ":core_headers",
143 ":dynamic_annotations",
144 ":raw_logging_internal",
145 ":spinlock_wait",
146 ],
147)
148
149cc_library(
150 name = "base_internal",
151 hdrs = [
152 "internal/hide_ptr.h",
153 "internal/identity.h",
154 "internal/inline_variable.h",
155 "internal/invoke.h",
156 "internal/scheduling_mode.h",
157 ],
158 copts = ABSL_DEFAULT_COPTS,
159 linkopts = ABSL_DEFAULT_LINKOPTS,
160 visibility = [
161 "//absl:__subpackages__",
162 ],
163 deps = [
164 "//absl/meta:type_traits",
165 ],
166)
167
168cc_library(
169 name = "base",
170 srcs = [
171 "internal/cycleclock.cc",
172 "internal/spinlock.cc",
173 "internal/sysinfo.cc",
174 "internal/thread_identity.cc",
175 "internal/unscaledcycleclock.cc",
176 ],
177 hdrs = [
178 "call_once.h",
179 "casts.h",
180 "internal/cycleclock.h",
181 "internal/low_level_scheduling.h",
182 "internal/per_thread_tls.h",
183 "internal/spinlock.h",
184 "internal/sysinfo.h",
185 "internal/thread_identity.h",
186 "internal/tsan_mutex_interface.h",
187 "internal/unscaledcycleclock.h",
188 ],
189 copts = ABSL_DEFAULT_COPTS,
190 linkopts = select({
191 "//absl:windows": [],
James Kuszmaul872efd22019-12-03 20:59:09 -0800192 "//conditions:default": [],
Austin Schuhd57edc42019-09-21 17:52:38 -0700193 }) + ABSL_DEFAULT_LINKOPTS,
194 deps = [
195 ":atomic_hook",
196 ":base_internal",
197 ":config",
198 ":core_headers",
199 ":dynamic_annotations",
200 ":log_severity",
201 ":raw_logging_internal",
202 ":spinlock_wait",
203 "//absl/meta:type_traits",
204 ],
205)
206
207cc_test(
208 name = "atomic_hook_test",
209 size = "small",
210 srcs = ["internal/atomic_hook_test.cc"],
211 copts = ABSL_TEST_COPTS,
212 linkopts = ABSL_DEFAULT_LINKOPTS,
213 deps = [
214 ":atomic_hook",
215 ":core_headers",
216 "@com_google_googletest//:gtest_main",
217 ],
218)
219
220cc_test(
221 name = "bit_cast_test",
222 size = "small",
223 srcs = [
224 "bit_cast_test.cc",
225 ],
226 copts = ABSL_TEST_COPTS,
227 linkopts = ABSL_DEFAULT_LINKOPTS,
228 deps = [
229 ":base",
230 ":core_headers",
231 "@com_google_googletest//:gtest_main",
232 ],
233)
234
235cc_library(
236 name = "throw_delegate",
237 srcs = ["internal/throw_delegate.cc"],
238 hdrs = ["internal/throw_delegate.h"],
239 copts = ABSL_DEFAULT_COPTS,
240 linkopts = ABSL_DEFAULT_LINKOPTS,
241 visibility = [
242 "//absl:__subpackages__",
243 ],
244 deps = [
245 ":config",
246 ":raw_logging_internal",
247 ],
248)
249
250cc_test(
251 name = "throw_delegate_test",
252 srcs = ["throw_delegate_test.cc"],
253 copts = ABSL_TEST_COPTS,
254 linkopts = ABSL_DEFAULT_LINKOPTS,
255 deps = [
256 ":config",
257 ":throw_delegate",
258 "@com_google_googletest//:gtest_main",
259 ],
260)
261
262cc_library(
263 name = "exception_testing",
264 testonly = 1,
265 hdrs = ["internal/exception_testing.h"],
266 copts = ABSL_TEST_COPTS,
267 linkopts = ABSL_DEFAULT_LINKOPTS,
268 visibility = [
269 "//absl:__subpackages__",
270 ],
271 deps = [
272 ":config",
273 "@com_google_googletest//:gtest",
274 ],
275)
276
277cc_library(
278 name = "pretty_function",
279 hdrs = ["internal/pretty_function.h"],
280 linkopts = ABSL_DEFAULT_LINKOPTS,
281 visibility = ["//absl:__subpackages__"],
282)
283
284cc_library(
285 name = "exception_safety_testing",
286 testonly = 1,
287 srcs = ["internal/exception_safety_testing.cc"],
288 hdrs = ["internal/exception_safety_testing.h"],
289 copts = ABSL_TEST_COPTS,
290 linkopts = ABSL_DEFAULT_LINKOPTS,
291 deps = [
292 ":config",
293 ":pretty_function",
294 "//absl/memory",
295 "//absl/meta:type_traits",
296 "//absl/strings",
297 "//absl/utility",
298 "@com_google_googletest//:gtest",
299 ],
300)
301
302cc_test(
303 name = "exception_safety_testing_test",
304 srcs = ["exception_safety_testing_test.cc"],
305 copts = ABSL_TEST_COPTS,
306 linkopts = ABSL_DEFAULT_LINKOPTS,
307 deps = [
308 ":exception_safety_testing",
309 "//absl/memory",
310 "@com_google_googletest//:gtest_main",
311 ],
312)
313
314cc_test(
315 name = "inline_variable_test",
316 size = "small",
317 srcs = [
318 "inline_variable_test.cc",
319 "inline_variable_test_a.cc",
320 "inline_variable_test_b.cc",
321 "internal/inline_variable_testing.h",
322 ],
323 copts = ABSL_TEST_COPTS,
324 linkopts = ABSL_DEFAULT_LINKOPTS,
325 deps = [
326 ":base_internal",
327 "@com_google_googletest//:gtest_main",
328 ],
329)
330
331cc_test(
332 name = "invoke_test",
333 size = "small",
334 srcs = ["invoke_test.cc"],
335 copts = ABSL_TEST_COPTS,
336 linkopts = ABSL_DEFAULT_LINKOPTS,
337 deps = [
338 ":base_internal",
339 "//absl/memory",
340 "//absl/strings",
341 "@com_google_googletest//:gtest_main",
342 ],
343)
344
345# Common test library made available for use in non-absl code that overrides
346# AbslInternalSpinLockDelay and AbslInternalSpinLockWake.
347cc_library(
348 name = "spinlock_test_common",
349 testonly = 1,
350 srcs = ["spinlock_test_common.cc"],
351 copts = ABSL_TEST_COPTS,
352 linkopts = ABSL_DEFAULT_LINKOPTS,
353 deps = [
354 ":base",
355 ":core_headers",
356 ":spinlock_wait",
357 "//absl/synchronization",
358 "@com_google_googletest//:gtest",
359 ],
360 alwayslink = 1,
361)
362
363cc_test(
364 name = "spinlock_test",
365 size = "medium",
366 srcs = ["spinlock_test_common.cc"],
367 copts = ABSL_TEST_COPTS,
368 linkopts = ABSL_DEFAULT_LINKOPTS,
369 deps = [
370 ":base",
371 ":core_headers",
372 ":spinlock_wait",
373 "//absl/synchronization",
374 "@com_google_googletest//:gtest_main",
375 ],
376)
377
378cc_library(
379 name = "spinlock_benchmark_common",
380 testonly = 1,
381 srcs = ["internal/spinlock_benchmark.cc"],
382 copts = ABSL_TEST_COPTS,
383 linkopts = ABSL_DEFAULT_LINKOPTS,
384 visibility = [
385 "//absl/base:__pkg__",
386 ],
387 deps = [
388 ":base",
389 ":base_internal",
390 ":raw_logging_internal",
391 "//absl/synchronization",
392 "@com_github_google_benchmark//:benchmark_main",
393 ],
394 alwayslink = 1,
395)
396
397cc_binary(
398 name = "spinlock_benchmark",
399 testonly = 1,
400 copts = ABSL_DEFAULT_COPTS,
401 linkopts = ABSL_DEFAULT_LINKOPTS,
402 visibility = ["//visibility:private"],
403 deps = [
404 ":spinlock_benchmark_common",
405 ],
406)
407
408cc_library(
409 name = "endian",
410 hdrs = [
411 "internal/endian.h",
412 "internal/unaligned_access.h",
413 ],
414 copts = ABSL_DEFAULT_COPTS,
415 linkopts = ABSL_DEFAULT_LINKOPTS,
416 deps = [
417 ":config",
418 ":core_headers",
419 ],
420)
421
422cc_test(
423 name = "endian_test",
424 srcs = ["internal/endian_test.cc"],
425 copts = ABSL_TEST_COPTS,
426 deps = [
427 ":config",
428 ":endian",
429 "@com_google_googletest//:gtest_main",
430 ],
431)
432
433cc_test(
434 name = "config_test",
435 srcs = ["config_test.cc"],
436 copts = ABSL_TEST_COPTS,
437 linkopts = ABSL_DEFAULT_LINKOPTS,
438 deps = [
439 ":config",
440 "//absl/synchronization:thread_pool",
441 "@com_google_googletest//:gtest_main",
442 ],
443)
444
445cc_test(
446 name = "call_once_test",
447 srcs = ["call_once_test.cc"],
448 copts = ABSL_TEST_COPTS,
449 linkopts = ABSL_DEFAULT_LINKOPTS,
450 deps = [
451 ":base",
452 ":core_headers",
453 "//absl/synchronization",
454 "@com_google_googletest//:gtest_main",
455 ],
456)
457
458cc_test(
459 name = "raw_logging_test",
460 srcs = ["raw_logging_test.cc"],
461 copts = ABSL_TEST_COPTS,
462 linkopts = ABSL_DEFAULT_LINKOPTS,
463 deps = [
464 ":raw_logging_internal",
465 "//absl/strings",
466 "@com_google_googletest//:gtest_main",
467 ],
468)
469
470cc_test(
471 name = "sysinfo_test",
472 size = "small",
473 srcs = ["internal/sysinfo_test.cc"],
474 copts = ABSL_TEST_COPTS,
475 linkopts = ABSL_DEFAULT_LINKOPTS,
476 deps = [
477 ":base",
478 "//absl/synchronization",
479 "@com_google_googletest//:gtest_main",
480 ],
481)
482
483cc_test(
484 name = "low_level_alloc_test",
485 size = "medium",
486 srcs = ["internal/low_level_alloc_test.cc"],
487 copts = ABSL_TEST_COPTS,
488 linkopts = ABSL_DEFAULT_LINKOPTS,
489 tags = ["no_test_ios_x86_64"],
490 deps = [":malloc_internal"],
491)
492
493cc_test(
494 name = "thread_identity_test",
495 size = "small",
496 srcs = ["internal/thread_identity_test.cc"],
497 copts = ABSL_TEST_COPTS,
498 linkopts = ABSL_DEFAULT_LINKOPTS,
499 deps = [
500 ":base",
501 ":core_headers",
502 "//absl/synchronization",
503 "@com_google_googletest//:gtest_main",
504 ],
505)
506
507cc_test(
508 name = "thread_identity_benchmark",
509 srcs = ["internal/thread_identity_benchmark.cc"],
510 copts = ABSL_TEST_COPTS,
511 linkopts = ABSL_DEFAULT_LINKOPTS,
512 tags = ["benchmark"],
513 visibility = ["//visibility:private"],
514 deps = [
515 ":base",
516 "//absl/synchronization",
517 "@com_github_google_benchmark//:benchmark_main",
518 ],
519)
520
521cc_library(
522 name = "bits",
523 hdrs = ["internal/bits.h"],
524 linkopts = ABSL_DEFAULT_LINKOPTS,
525 visibility = [
526 "//absl:__subpackages__",
527 ],
528 deps = [":core_headers"],
529)
530
531cc_test(
532 name = "bits_test",
533 size = "small",
534 srcs = ["internal/bits_test.cc"],
535 copts = ABSL_TEST_COPTS,
536 linkopts = ABSL_DEFAULT_LINKOPTS,
537 deps = [
538 ":bits",
539 "@com_google_googletest//:gtest_main",
540 ],
541)
542
543cc_library(
544 name = "scoped_set_env",
545 testonly = 1,
546 srcs = ["internal/scoped_set_env.cc"],
547 hdrs = ["internal/scoped_set_env.h"],
548 linkopts = ABSL_DEFAULT_LINKOPTS,
549 visibility = [
550 "//absl:__subpackages__",
551 ],
552 deps = [":raw_logging_internal"],
553)
554
555cc_test(
556 name = "scoped_set_env_test",
557 size = "small",
558 srcs = ["internal/scoped_set_env_test.cc"],
559 copts = ABSL_TEST_COPTS,
560 linkopts = ABSL_DEFAULT_LINKOPTS,
561 deps = [
562 ":scoped_set_env",
563 "@com_google_googletest//:gtest_main",
564 ],
565)
566
567cc_test(
568 name = "log_severity_test",
569 size = "small",
570 srcs = ["log_severity_test.cc"],
571 copts = ABSL_TEST_COPTS,
572 linkopts = ABSL_DEFAULT_LINKOPTS,
573 deps = [
574 ":log_severity",
575 "//absl/flags:marshalling",
576 "//absl/strings",
577 "@com_google_googletest//:gtest_main",
578 ],
579)