• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
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
17load("@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    deps = [
38        ":config",
39        ":core_headers",
40    ],
41)
42
43cc_library(
44    name = "errno_saver",
45    hdrs = ["internal/errno_saver.h"],
46    copts = ABSL_DEFAULT_COPTS,
47    linkopts = ABSL_DEFAULT_LINKOPTS,
48    visibility = [
49        "//absl:__subpackages__",
50    ],
51    deps = [":config"],
52)
53
54cc_library(
55    name = "log_severity",
56    srcs = ["log_severity.cc"],
57    hdrs = ["log_severity.h"],
58    copts = ABSL_DEFAULT_COPTS,
59    linkopts = ABSL_DEFAULT_LINKOPTS,
60    deps = [
61        ":config",
62        ":core_headers",
63    ],
64)
65
66cc_library(
67    name = "raw_logging_internal",
68    srcs = ["internal/raw_logging.cc"],
69    hdrs = ["internal/raw_logging.h"],
70    copts = ABSL_DEFAULT_COPTS,
71    linkopts = ABSL_DEFAULT_LINKOPTS,
72    visibility = [
73        "//absl:__subpackages__",
74    ],
75    deps = [
76        ":atomic_hook",
77        ":config",
78        ":core_headers",
79        ":log_severity",
80    ],
81)
82
83cc_library(
84    name = "spinlock_wait",
85    srcs = [
86        "internal/spinlock_akaros.inc",
87        "internal/spinlock_linux.inc",
88        "internal/spinlock_posix.inc",
89        "internal/spinlock_wait.cc",
90        "internal/spinlock_win32.inc",
91    ],
92    hdrs = ["internal/spinlock_wait.h"],
93    copts = ABSL_DEFAULT_COPTS,
94    linkopts = ABSL_DEFAULT_LINKOPTS,
95    visibility = [
96        "//absl/base:__pkg__",
97    ],
98    deps = [
99        ":base_internal",
100        ":core_headers",
101        ":errno_saver",
102    ],
103)
104
105cc_library(
106    name = "config",
107    hdrs = [
108        "config.h",
109        "options.h",
110        "policy_checks.h",
111    ],
112    copts = ABSL_DEFAULT_COPTS,
113    linkopts = ABSL_DEFAULT_LINKOPTS,
114)
115
116cc_library(
117    name = "dynamic_annotations",
118    srcs = ["dynamic_annotations.cc"],
119    hdrs = ["dynamic_annotations.h"],
120    copts = ABSL_DEFAULT_COPTS,
121    defines = ["__CLANG_SUPPORT_DYN_ANNOTATION__"],
122    linkopts = ABSL_DEFAULT_LINKOPTS,
123)
124
125cc_library(
126    name = "core_headers",
127    srcs = [
128        "internal/thread_annotations.h",
129    ],
130    hdrs = [
131        "attributes.h",
132        "const_init.h",
133        "macros.h",
134        "optimization.h",
135        "port.h",
136        "thread_annotations.h",
137    ],
138    copts = ABSL_DEFAULT_COPTS,
139    linkopts = ABSL_DEFAULT_LINKOPTS,
140    deps = [
141        ":config",
142    ],
143)
144
145cc_library(
146    name = "malloc_internal",
147    srcs = [
148        "internal/low_level_alloc.cc",
149    ],
150    hdrs = [
151        "internal/direct_mmap.h",
152        "internal/low_level_alloc.h",
153    ],
154    copts = ABSL_DEFAULT_COPTS,
155    linkopts = select({
156        "//absl:windows": [],
157        "//conditions:default": ["-pthread"],
158    }) + ABSL_DEFAULT_LINKOPTS,
159    visibility = [
160        "//visibility:public",
161    ],
162    deps = [
163        ":base",
164        ":base_internal",
165        ":config",
166        ":core_headers",
167        ":dynamic_annotations",
168        ":raw_logging_internal",
169    ],
170)
171
172cc_library(
173    name = "base_internal",
174    hdrs = [
175        "internal/hide_ptr.h",
176        "internal/identity.h",
177        "internal/inline_variable.h",
178        "internal/invoke.h",
179        "internal/scheduling_mode.h",
180    ],
181    copts = ABSL_DEFAULT_COPTS,
182    linkopts = ABSL_DEFAULT_LINKOPTS,
183    visibility = [
184        "//absl:__subpackages__",
185    ],
186    deps = [
187        ":config",
188        "//absl/meta:type_traits",
189    ],
190)
191
192cc_library(
193    name = "base",
194    srcs = [
195        "internal/cycleclock.cc",
196        "internal/spinlock.cc",
197        "internal/sysinfo.cc",
198        "internal/thread_identity.cc",
199        "internal/unscaledcycleclock.cc",
200    ],
201    hdrs = [
202        "call_once.h",
203        "casts.h",
204        "internal/cycleclock.h",
205        "internal/low_level_scheduling.h",
206        "internal/per_thread_tls.h",
207        "internal/spinlock.h",
208        "internal/sysinfo.h",
209        "internal/thread_identity.h",
210        "internal/tsan_mutex_interface.h",
211        "internal/unscaledcycleclock.h",
212    ],
213    copts = ABSL_DEFAULT_COPTS,
214    linkopts = select({
215        "//absl:windows": [
216            "-DEFAULTLIB:advapi32.lib",
217        ],
218        "//conditions:default": ["-pthread"],
219    }) + ABSL_DEFAULT_LINKOPTS,
220    deps = [
221        ":atomic_hook",
222        ":base_internal",
223        ":config",
224        ":core_headers",
225        ":dynamic_annotations",
226        ":log_severity",
227        ":raw_logging_internal",
228        ":spinlock_wait",
229        "//absl/meta:type_traits",
230    ],
231)
232
233cc_library(
234    name = "atomic_hook_test_helper",
235    testonly = 1,
236    srcs = ["internal/atomic_hook_test_helper.cc"],
237    hdrs = ["internal/atomic_hook_test_helper.h"],
238    copts = ABSL_DEFAULT_COPTS,
239    linkopts = ABSL_DEFAULT_LINKOPTS,
240    deps = [
241        ":atomic_hook",
242        ":core_headers",
243    ],
244)
245
246cc_test(
247    name = "atomic_hook_test",
248    size = "small",
249    srcs = ["internal/atomic_hook_test.cc"],
250    copts = ABSL_TEST_COPTS,
251    linkopts = ABSL_DEFAULT_LINKOPTS,
252    deps = [
253        ":atomic_hook",
254        ":atomic_hook_test_helper",
255        ":core_headers",
256        "@com_google_googletest//:gtest_main",
257    ],
258)
259
260cc_test(
261    name = "bit_cast_test",
262    size = "small",
263    srcs = [
264        "bit_cast_test.cc",
265    ],
266    copts = ABSL_TEST_COPTS,
267    linkopts = ABSL_DEFAULT_LINKOPTS,
268    deps = [
269        ":base",
270        ":core_headers",
271        "@com_google_googletest//:gtest_main",
272    ],
273)
274
275cc_library(
276    name = "throw_delegate",
277    srcs = ["internal/throw_delegate.cc"],
278    hdrs = ["internal/throw_delegate.h"],
279    copts = ABSL_DEFAULT_COPTS,
280    linkopts = ABSL_DEFAULT_LINKOPTS,
281    visibility = [
282        "//absl:__subpackages__",
283    ],
284    deps = [
285        ":config",
286        ":raw_logging_internal",
287    ],
288)
289
290cc_test(
291    name = "throw_delegate_test",
292    srcs = ["throw_delegate_test.cc"],
293    copts = ABSL_TEST_COPTS,
294    linkopts = ABSL_DEFAULT_LINKOPTS,
295    deps = [
296        ":config",
297        ":throw_delegate",
298        "@com_google_googletest//:gtest_main",
299    ],
300)
301
302cc_test(
303    name = "errno_saver_test",
304    size = "small",
305    srcs = ["internal/errno_saver_test.cc"],
306    copts = ABSL_TEST_COPTS,
307    linkopts = ABSL_DEFAULT_LINKOPTS,
308    deps = [
309        ":errno_saver",
310        "@com_google_googletest//:gtest_main",
311    ],
312)
313
314cc_library(
315    name = "exception_testing",
316    testonly = 1,
317    hdrs = ["internal/exception_testing.h"],
318    copts = ABSL_TEST_COPTS,
319    linkopts = ABSL_DEFAULT_LINKOPTS,
320    visibility = [
321        "//absl:__subpackages__",
322    ],
323    deps = [
324        ":config",
325        "@com_google_googletest//:gtest",
326    ],
327)
328
329cc_library(
330    name = "pretty_function",
331    hdrs = ["internal/pretty_function.h"],
332    linkopts = ABSL_DEFAULT_LINKOPTS,
333    visibility = ["//absl:__subpackages__"],
334)
335
336cc_library(
337    name = "exception_safety_testing",
338    testonly = 1,
339    srcs = ["internal/exception_safety_testing.cc"],
340    hdrs = ["internal/exception_safety_testing.h"],
341    copts = ABSL_TEST_COPTS,
342    linkopts = ABSL_DEFAULT_LINKOPTS,
343    deps = [
344        ":config",
345        ":pretty_function",
346        "//absl/memory",
347        "//absl/meta:type_traits",
348        "//absl/strings",
349        "//absl/utility",
350        "@com_google_googletest//:gtest",
351    ],
352)
353
354cc_test(
355    name = "exception_safety_testing_test",
356    srcs = ["exception_safety_testing_test.cc"],
357    copts = ABSL_TEST_COPTS,
358    linkopts = ABSL_DEFAULT_LINKOPTS,
359    deps = [
360        ":exception_safety_testing",
361        "//absl/memory",
362        "@com_google_googletest//:gtest_main",
363    ],
364)
365
366cc_test(
367    name = "inline_variable_test",
368    size = "small",
369    srcs = [
370        "inline_variable_test.cc",
371        "inline_variable_test_a.cc",
372        "inline_variable_test_b.cc",
373        "internal/inline_variable_testing.h",
374    ],
375    copts = ABSL_TEST_COPTS,
376    linkopts = ABSL_DEFAULT_LINKOPTS,
377    deps = [
378        ":base_internal",
379        "@com_google_googletest//:gtest_main",
380    ],
381)
382
383cc_test(
384    name = "invoke_test",
385    size = "small",
386    srcs = ["invoke_test.cc"],
387    copts = ABSL_TEST_COPTS,
388    linkopts = ABSL_DEFAULT_LINKOPTS,
389    deps = [
390        ":base_internal",
391        "//absl/memory",
392        "//absl/strings",
393        "@com_google_googletest//:gtest_main",
394    ],
395)
396
397# Common test library made available for use in non-absl code that overrides
398# AbslInternalSpinLockDelay and AbslInternalSpinLockWake.
399cc_library(
400    name = "spinlock_test_common",
401    testonly = 1,
402    srcs = ["spinlock_test_common.cc"],
403    copts = ABSL_TEST_COPTS,
404    linkopts = ABSL_DEFAULT_LINKOPTS,
405    deps = [
406        ":base",
407        ":base_internal",
408        ":core_headers",
409        "//absl/synchronization",
410        "@com_google_googletest//:gtest",
411    ],
412    alwayslink = 1,
413)
414
415cc_test(
416    name = "spinlock_test",
417    size = "medium",
418    srcs = ["spinlock_test_common.cc"],
419    copts = ABSL_TEST_COPTS,
420    linkopts = ABSL_DEFAULT_LINKOPTS,
421    deps = [
422        ":base",
423        ":base_internal",
424        ":core_headers",
425        "//absl/synchronization",
426        "@com_google_googletest//:gtest_main",
427    ],
428)
429
430cc_library(
431    name = "spinlock_benchmark_common",
432    testonly = 1,
433    srcs = ["internal/spinlock_benchmark.cc"],
434    copts = ABSL_TEST_COPTS,
435    linkopts = ABSL_DEFAULT_LINKOPTS,
436    visibility = [
437        "//absl/base:__pkg__",
438    ],
439    deps = [
440        ":base",
441        ":base_internal",
442        ":raw_logging_internal",
443        "//absl/synchronization",
444        "@com_github_google_benchmark//:benchmark_main",
445    ],
446    alwayslink = 1,
447)
448
449cc_binary(
450    name = "spinlock_benchmark",
451    testonly = 1,
452    copts = ABSL_DEFAULT_COPTS,
453    linkopts = ABSL_DEFAULT_LINKOPTS,
454    visibility = ["//visibility:private"],
455    deps = [
456        ":spinlock_benchmark_common",
457    ],
458)
459
460cc_library(
461    name = "endian",
462    hdrs = [
463        "internal/endian.h",
464        "internal/unaligned_access.h",
465    ],
466    copts = ABSL_DEFAULT_COPTS,
467    linkopts = ABSL_DEFAULT_LINKOPTS,
468    deps = [
469        ":config",
470        ":core_headers",
471    ],
472)
473
474cc_test(
475    name = "endian_test",
476    srcs = ["internal/endian_test.cc"],
477    copts = ABSL_TEST_COPTS,
478    deps = [
479        ":config",
480        ":endian",
481        "@com_google_googletest//:gtest_main",
482    ],
483)
484
485cc_test(
486    name = "config_test",
487    srcs = ["config_test.cc"],
488    copts = ABSL_TEST_COPTS,
489    linkopts = ABSL_DEFAULT_LINKOPTS,
490    deps = [
491        ":config",
492        "//absl/synchronization:thread_pool",
493        "@com_google_googletest//:gtest_main",
494    ],
495)
496
497cc_test(
498    name = "call_once_test",
499    srcs = ["call_once_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 = "raw_logging_test",
512    srcs = ["raw_logging_test.cc"],
513    copts = ABSL_TEST_COPTS,
514    linkopts = ABSL_DEFAULT_LINKOPTS,
515    deps = [
516        ":raw_logging_internal",
517        "//absl/strings",
518        "@com_google_googletest//:gtest_main",
519    ],
520)
521
522cc_test(
523    name = "sysinfo_test",
524    size = "small",
525    srcs = ["internal/sysinfo_test.cc"],
526    copts = ABSL_TEST_COPTS,
527    linkopts = ABSL_DEFAULT_LINKOPTS,
528    deps = [
529        ":base",
530        "//absl/synchronization",
531        "@com_google_googletest//:gtest_main",
532    ],
533)
534
535cc_test(
536    name = "low_level_alloc_test",
537    size = "medium",
538    srcs = ["internal/low_level_alloc_test.cc"],
539    copts = ABSL_TEST_COPTS,
540    linkopts = ABSL_DEFAULT_LINKOPTS,
541    tags = ["no_test_ios_x86_64"],
542    deps = [":malloc_internal"],
543)
544
545cc_test(
546    name = "thread_identity_test",
547    size = "small",
548    srcs = ["internal/thread_identity_test.cc"],
549    copts = ABSL_TEST_COPTS,
550    linkopts = ABSL_DEFAULT_LINKOPTS,
551    deps = [
552        ":base",
553        ":core_headers",
554        "//absl/synchronization",
555        "@com_google_googletest//:gtest_main",
556    ],
557)
558
559cc_test(
560    name = "thread_identity_benchmark",
561    srcs = ["internal/thread_identity_benchmark.cc"],
562    copts = ABSL_TEST_COPTS,
563    linkopts = ABSL_DEFAULT_LINKOPTS,
564    tags = ["benchmark"],
565    visibility = ["//visibility:private"],
566    deps = [
567        ":base",
568        "//absl/synchronization",
569        "@com_github_google_benchmark//:benchmark_main",
570    ],
571)
572
573cc_library(
574    name = "bits",
575    hdrs = ["internal/bits.h"],
576    linkopts = ABSL_DEFAULT_LINKOPTS,
577    visibility = [
578        "//absl:__subpackages__",
579    ],
580    deps = [
581        ":config",
582        ":core_headers",
583    ],
584)
585
586cc_test(
587    name = "bits_test",
588    size = "small",
589    srcs = ["internal/bits_test.cc"],
590    copts = ABSL_TEST_COPTS,
591    linkopts = ABSL_DEFAULT_LINKOPTS,
592    deps = [
593        ":bits",
594        "@com_google_googletest//:gtest_main",
595    ],
596)
597
598cc_library(
599    name = "exponential_biased",
600    srcs = ["internal/exponential_biased.cc"],
601    hdrs = ["internal/exponential_biased.h"],
602    linkopts = ABSL_DEFAULT_LINKOPTS,
603    visibility = [
604        "//absl:__subpackages__",
605    ],
606    deps = [
607        ":config",
608        ":core_headers",
609    ],
610)
611
612cc_test(
613    name = "exponential_biased_test",
614    size = "small",
615    srcs = ["internal/exponential_biased_test.cc"],
616    copts = ABSL_TEST_COPTS,
617    linkopts = ABSL_DEFAULT_LINKOPTS,
618    visibility = ["//visibility:private"],
619    deps = [
620        ":exponential_biased",
621        "//absl/strings",
622        "@com_google_googletest//:gtest_main",
623    ],
624)
625
626cc_library(
627    name = "periodic_sampler",
628    srcs = ["internal/periodic_sampler.cc"],
629    hdrs = ["internal/periodic_sampler.h"],
630    copts = ABSL_DEFAULT_COPTS,
631    linkopts = ABSL_DEFAULT_LINKOPTS,
632    deps = [
633        ":core_headers",
634        ":exponential_biased",
635    ],
636)
637
638cc_test(
639    name = "periodic_sampler_test",
640    size = "small",
641    srcs = ["internal/periodic_sampler_test.cc"],
642    copts = ABSL_TEST_COPTS,
643    linkopts = ABSL_DEFAULT_LINKOPTS,
644    visibility = ["//visibility:private"],
645    deps = [
646        ":core_headers",
647        ":periodic_sampler",
648        "@com_google_googletest//:gtest_main",
649    ],
650)
651
652cc_binary(
653    name = "periodic_sampler_benchmark",
654    testonly = 1,
655    srcs = ["internal/periodic_sampler_benchmark.cc"],
656    copts = ABSL_TEST_COPTS,
657    linkopts = ABSL_DEFAULT_LINKOPTS,
658    tags = ["benchmark"],
659    visibility = ["//visibility:private"],
660    deps = [
661        ":core_headers",
662        ":periodic_sampler",
663        "@com_github_google_benchmark//:benchmark_main",
664    ],
665)
666
667cc_library(
668    name = "scoped_set_env",
669    testonly = 1,
670    srcs = ["internal/scoped_set_env.cc"],
671    hdrs = ["internal/scoped_set_env.h"],
672    linkopts = ABSL_DEFAULT_LINKOPTS,
673    visibility = [
674        "//absl:__subpackages__",
675    ],
676    deps = [
677        ":config",
678        ":raw_logging_internal",
679    ],
680)
681
682cc_test(
683    name = "scoped_set_env_test",
684    size = "small",
685    srcs = ["internal/scoped_set_env_test.cc"],
686    copts = ABSL_TEST_COPTS,
687    linkopts = ABSL_DEFAULT_LINKOPTS,
688    deps = [
689        ":scoped_set_env",
690        "@com_google_googletest//:gtest_main",
691    ],
692)
693
694cc_test(
695    name = "log_severity_test",
696    size = "small",
697    srcs = ["log_severity_test.cc"],
698    copts = ABSL_TEST_COPTS,
699    linkopts = ABSL_DEFAULT_LINKOPTS,
700    deps = [
701        ":log_severity",
702        "//absl/flags:flag_internal",
703        "//absl/flags:marshalling",
704        "//absl/strings",
705        "@com_google_googletest//:gtest_main",
706    ],
707)
708