• 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"])
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 = [
119        "internal/dynamic_annotations.h",
120    ],
121    hdrs = [
122        "dynamic_annotations.h",
123    ],
124    copts = ABSL_DEFAULT_COPTS,
125    linkopts = ABSL_DEFAULT_LINKOPTS,
126    deps = [
127        ":config",
128        ":core_headers",
129    ],
130)
131
132cc_library(
133    name = "core_headers",
134    srcs = [
135        "internal/thread_annotations.h",
136    ],
137    hdrs = [
138        "attributes.h",
139        "const_init.h",
140        "macros.h",
141        "optimization.h",
142        "port.h",
143        "thread_annotations.h",
144    ],
145    copts = ABSL_DEFAULT_COPTS,
146    linkopts = ABSL_DEFAULT_LINKOPTS,
147    deps = [
148        ":config",
149    ],
150)
151
152cc_library(
153    name = "malloc_internal",
154    srcs = [
155        "internal/low_level_alloc.cc",
156    ],
157    hdrs = [
158        "internal/direct_mmap.h",
159        "internal/low_level_alloc.h",
160    ],
161    copts = ABSL_DEFAULT_COPTS,
162    linkopts = select({
163        "//absl:msvc_compiler": [],
164        "//absl:clang-cl_compiler": [],
165        "//absl:wasm": [],
166        "//conditions:default": ["-pthread"],
167    }) + ABSL_DEFAULT_LINKOPTS,
168    visibility = [
169        "//visibility:public",
170    ],
171    deps = [
172        ":base",
173        ":base_internal",
174        ":config",
175        ":core_headers",
176        ":dynamic_annotations",
177        ":raw_logging_internal",
178    ],
179)
180
181cc_library(
182    name = "base_internal",
183    hdrs = [
184        "internal/hide_ptr.h",
185        "internal/identity.h",
186        "internal/inline_variable.h",
187        "internal/invoke.h",
188        "internal/scheduling_mode.h",
189    ],
190    copts = ABSL_DEFAULT_COPTS,
191    linkopts = ABSL_DEFAULT_LINKOPTS,
192    visibility = [
193        "//absl:__subpackages__",
194    ],
195    deps = [
196        ":config",
197        "//absl/meta:type_traits",
198    ],
199)
200
201cc_library(
202    name = "base",
203    srcs = [
204        "internal/cycleclock.cc",
205        "internal/spinlock.cc",
206        "internal/sysinfo.cc",
207        "internal/thread_identity.cc",
208        "internal/unscaledcycleclock.cc",
209    ],
210    hdrs = [
211        "call_once.h",
212        "casts.h",
213        "internal/cycleclock.h",
214        "internal/low_level_scheduling.h",
215        "internal/per_thread_tls.h",
216        "internal/spinlock.h",
217        "internal/sysinfo.h",
218        "internal/thread_identity.h",
219        "internal/tsan_mutex_interface.h",
220        "internal/unscaledcycleclock.h",
221    ],
222    copts = ABSL_DEFAULT_COPTS,
223    linkopts = select({
224        "//absl:msvc_compiler": [
225            "-DEFAULTLIB:advapi32.lib",
226        ],
227        "//absl:clang-cl_compiler": [
228            "-DEFAULTLIB:advapi32.lib",
229        ],
230        "//absl:wasm": [],
231        "//conditions:default": ["-pthread"],
232    }) + ABSL_DEFAULT_LINKOPTS,
233    deps = [
234        ":atomic_hook",
235        ":base_internal",
236        ":config",
237        ":core_headers",
238        ":dynamic_annotations",
239        ":log_severity",
240        ":raw_logging_internal",
241        ":spinlock_wait",
242        "//absl/meta:type_traits",
243    ],
244)
245
246cc_library(
247    name = "atomic_hook_test_helper",
248    testonly = 1,
249    srcs = ["internal/atomic_hook_test_helper.cc"],
250    hdrs = ["internal/atomic_hook_test_helper.h"],
251    copts = ABSL_DEFAULT_COPTS,
252    linkopts = ABSL_DEFAULT_LINKOPTS,
253    deps = [
254        ":atomic_hook",
255        ":core_headers",
256    ],
257)
258
259cc_test(
260    name = "atomic_hook_test",
261    size = "small",
262    srcs = ["internal/atomic_hook_test.cc"],
263    copts = ABSL_TEST_COPTS,
264    linkopts = ABSL_DEFAULT_LINKOPTS,
265    deps = [
266        ":atomic_hook",
267        ":atomic_hook_test_helper",
268        ":core_headers",
269        "@com_google_googletest//:gtest_main",
270    ],
271)
272
273cc_test(
274    name = "bit_cast_test",
275    size = "small",
276    srcs = [
277        "bit_cast_test.cc",
278    ],
279    copts = ABSL_TEST_COPTS,
280    linkopts = ABSL_DEFAULT_LINKOPTS,
281    deps = [
282        ":base",
283        ":core_headers",
284        "@com_google_googletest//:gtest_main",
285    ],
286)
287
288cc_library(
289    name = "throw_delegate",
290    srcs = ["internal/throw_delegate.cc"],
291    hdrs = ["internal/throw_delegate.h"],
292    copts = ABSL_DEFAULT_COPTS,
293    linkopts = ABSL_DEFAULT_LINKOPTS,
294    visibility = [
295        "//absl:__subpackages__",
296    ],
297    deps = [
298        ":config",
299        ":raw_logging_internal",
300    ],
301)
302
303cc_test(
304    name = "throw_delegate_test",
305    srcs = ["throw_delegate_test.cc"],
306    copts = ABSL_TEST_COPTS,
307    linkopts = ABSL_DEFAULT_LINKOPTS,
308    deps = [
309        ":config",
310        ":throw_delegate",
311        "@com_google_googletest//:gtest_main",
312    ],
313)
314
315cc_test(
316    name = "errno_saver_test",
317    size = "small",
318    srcs = ["internal/errno_saver_test.cc"],
319    copts = ABSL_TEST_COPTS,
320    linkopts = ABSL_DEFAULT_LINKOPTS,
321    deps = [
322        ":errno_saver",
323        ":strerror",
324        "@com_google_googletest//:gtest_main",
325    ],
326)
327
328cc_library(
329    name = "exception_testing",
330    testonly = 1,
331    hdrs = ["internal/exception_testing.h"],
332    copts = ABSL_TEST_COPTS,
333    linkopts = ABSL_DEFAULT_LINKOPTS,
334    visibility = [
335        "//absl:__subpackages__",
336    ],
337    deps = [
338        ":config",
339        "@com_google_googletest//:gtest",
340    ],
341)
342
343cc_library(
344    name = "pretty_function",
345    hdrs = ["internal/pretty_function.h"],
346    linkopts = ABSL_DEFAULT_LINKOPTS,
347    visibility = ["//absl:__subpackages__"],
348)
349
350cc_library(
351    name = "exception_safety_testing",
352    testonly = 1,
353    srcs = ["internal/exception_safety_testing.cc"],
354    hdrs = ["internal/exception_safety_testing.h"],
355    copts = ABSL_TEST_COPTS,
356    linkopts = ABSL_DEFAULT_LINKOPTS,
357    deps = [
358        ":config",
359        ":pretty_function",
360        "//absl/memory",
361        "//absl/meta:type_traits",
362        "//absl/strings",
363        "//absl/utility",
364        "@com_google_googletest//:gtest",
365    ],
366)
367
368cc_test(
369    name = "exception_safety_testing_test",
370    srcs = ["exception_safety_testing_test.cc"],
371    copts = ABSL_TEST_COPTS,
372    linkopts = ABSL_DEFAULT_LINKOPTS,
373    deps = [
374        ":exception_safety_testing",
375        "//absl/memory",
376        "@com_google_googletest//:gtest_main",
377    ],
378)
379
380cc_test(
381    name = "inline_variable_test",
382    size = "small",
383    srcs = [
384        "inline_variable_test.cc",
385        "inline_variable_test_a.cc",
386        "inline_variable_test_b.cc",
387        "internal/inline_variable_testing.h",
388    ],
389    copts = ABSL_TEST_COPTS,
390    linkopts = ABSL_DEFAULT_LINKOPTS,
391    deps = [
392        ":base_internal",
393        "@com_google_googletest//:gtest_main",
394    ],
395)
396
397cc_test(
398    name = "invoke_test",
399    size = "small",
400    srcs = ["invoke_test.cc"],
401    copts = ABSL_TEST_COPTS,
402    linkopts = ABSL_DEFAULT_LINKOPTS,
403    deps = [
404        ":base_internal",
405        "//absl/memory",
406        "//absl/strings",
407        "@com_google_googletest//:gtest_main",
408    ],
409)
410
411# Common test library made available for use in non-absl code that overrides
412# AbslInternalSpinLockDelay and AbslInternalSpinLockWake.
413cc_library(
414    name = "spinlock_test_common",
415    testonly = 1,
416    srcs = ["spinlock_test_common.cc"],
417    copts = ABSL_TEST_COPTS,
418    linkopts = ABSL_DEFAULT_LINKOPTS,
419    deps = [
420        ":base",
421        ":base_internal",
422        ":config",
423        ":core_headers",
424        "//absl/synchronization",
425        "@com_google_googletest//:gtest",
426    ],
427    alwayslink = 1,
428)
429
430cc_test(
431    name = "spinlock_test",
432    size = "medium",
433    srcs = ["spinlock_test_common.cc"],
434    copts = ABSL_TEST_COPTS,
435    linkopts = ABSL_DEFAULT_LINKOPTS,
436    deps = [
437        ":base",
438        ":base_internal",
439        ":config",
440        ":core_headers",
441        "//absl/synchronization",
442        "@com_google_googletest//:gtest_main",
443    ],
444)
445
446cc_library(
447    name = "spinlock_benchmark_common",
448    testonly = 1,
449    srcs = ["internal/spinlock_benchmark.cc"],
450    copts = ABSL_TEST_COPTS,
451    linkopts = ABSL_DEFAULT_LINKOPTS,
452    visibility = [
453        "//absl/base:__pkg__",
454    ],
455    deps = [
456        ":base",
457        ":base_internal",
458        ":raw_logging_internal",
459        "//absl/synchronization",
460        "@com_github_google_benchmark//:benchmark_main",
461    ],
462    alwayslink = 1,
463)
464
465cc_binary(
466    name = "spinlock_benchmark",
467    testonly = 1,
468    copts = ABSL_DEFAULT_COPTS,
469    linkopts = ABSL_DEFAULT_LINKOPTS,
470    tags = ["benchmark"],
471    visibility = ["//visibility:private"],
472    deps = [
473        ":spinlock_benchmark_common",
474    ],
475)
476
477cc_library(
478    name = "endian",
479    hdrs = [
480        "internal/endian.h",
481        "internal/unaligned_access.h",
482    ],
483    copts = ABSL_DEFAULT_COPTS,
484    linkopts = ABSL_DEFAULT_LINKOPTS,
485    deps = [
486        ":base",
487        ":config",
488        ":core_headers",
489    ],
490)
491
492cc_test(
493    name = "endian_test",
494    srcs = ["internal/endian_test.cc"],
495    copts = ABSL_TEST_COPTS,
496    deps = [
497        ":config",
498        ":endian",
499        "@com_google_googletest//:gtest_main",
500    ],
501)
502
503cc_test(
504    name = "config_test",
505    srcs = ["config_test.cc"],
506    copts = ABSL_TEST_COPTS,
507    linkopts = ABSL_DEFAULT_LINKOPTS,
508    deps = [
509        ":config",
510        "//absl/synchronization:thread_pool",
511        "@com_google_googletest//:gtest_main",
512    ],
513)
514
515cc_test(
516    name = "call_once_test",
517    srcs = ["call_once_test.cc"],
518    copts = ABSL_TEST_COPTS,
519    linkopts = ABSL_DEFAULT_LINKOPTS,
520    deps = [
521        ":base",
522        ":core_headers",
523        "//absl/synchronization",
524        "@com_google_googletest//:gtest_main",
525    ],
526)
527
528cc_test(
529    name = "raw_logging_test",
530    srcs = ["raw_logging_test.cc"],
531    copts = ABSL_TEST_COPTS,
532    linkopts = ABSL_DEFAULT_LINKOPTS,
533    deps = [
534        ":raw_logging_internal",
535        "//absl/strings",
536        "@com_google_googletest//:gtest_main",
537    ],
538)
539
540cc_test(
541    name = "sysinfo_test",
542    size = "small",
543    srcs = ["internal/sysinfo_test.cc"],
544    copts = ABSL_TEST_COPTS,
545    linkopts = ABSL_DEFAULT_LINKOPTS,
546    deps = [
547        ":base",
548        "//absl/synchronization",
549        "@com_google_googletest//:gtest_main",
550    ],
551)
552
553cc_test(
554    name = "low_level_alloc_test",
555    size = "medium",
556    srcs = ["internal/low_level_alloc_test.cc"],
557    copts = ABSL_TEST_COPTS,
558    linkopts = ABSL_DEFAULT_LINKOPTS,
559    tags = [
560        "no_test_ios_x86_64",
561    ],
562    deps = [
563        ":malloc_internal",
564        "//absl/container:node_hash_map",
565    ],
566)
567
568cc_test(
569    name = "thread_identity_test",
570    size = "small",
571    srcs = ["internal/thread_identity_test.cc"],
572    copts = ABSL_TEST_COPTS,
573    linkopts = ABSL_DEFAULT_LINKOPTS,
574    deps = [
575        ":base",
576        ":core_headers",
577        "//absl/synchronization",
578        "@com_google_googletest//:gtest_main",
579    ],
580)
581
582cc_test(
583    name = "thread_identity_benchmark",
584    srcs = ["internal/thread_identity_benchmark.cc"],
585    copts = ABSL_TEST_COPTS,
586    linkopts = ABSL_DEFAULT_LINKOPTS,
587    tags = ["benchmark"],
588    visibility = ["//visibility:private"],
589    deps = [
590        ":base",
591        "//absl/synchronization",
592        "@com_github_google_benchmark//:benchmark_main",
593    ],
594)
595
596cc_library(
597    name = "exponential_biased",
598    srcs = ["internal/exponential_biased.cc"],
599    hdrs = ["internal/exponential_biased.h"],
600    linkopts = ABSL_DEFAULT_LINKOPTS,
601    visibility = [
602        "//absl:__subpackages__",
603    ],
604    deps = [
605        ":config",
606        ":core_headers",
607    ],
608)
609
610cc_test(
611    name = "exponential_biased_test",
612    size = "small",
613    srcs = ["internal/exponential_biased_test.cc"],
614    copts = ABSL_TEST_COPTS,
615    linkopts = ABSL_DEFAULT_LINKOPTS,
616    visibility = ["//visibility:private"],
617    deps = [
618        ":exponential_biased",
619        "//absl/strings",
620        "@com_google_googletest//:gtest_main",
621    ],
622)
623
624cc_library(
625    name = "periodic_sampler",
626    srcs = ["internal/periodic_sampler.cc"],
627    hdrs = ["internal/periodic_sampler.h"],
628    copts = ABSL_DEFAULT_COPTS,
629    linkopts = ABSL_DEFAULT_LINKOPTS,
630    deps = [
631        ":core_headers",
632        ":exponential_biased",
633    ],
634)
635
636cc_test(
637    name = "periodic_sampler_test",
638    size = "small",
639    srcs = ["internal/periodic_sampler_test.cc"],
640    copts = ABSL_TEST_COPTS,
641    linkopts = ABSL_DEFAULT_LINKOPTS,
642    visibility = ["//visibility:private"],
643    deps = [
644        ":core_headers",
645        ":periodic_sampler",
646        "@com_google_googletest//:gtest_main",
647    ],
648)
649
650cc_binary(
651    name = "periodic_sampler_benchmark",
652    testonly = 1,
653    srcs = ["internal/periodic_sampler_benchmark.cc"],
654    copts = ABSL_TEST_COPTS,
655    linkopts = ABSL_DEFAULT_LINKOPTS,
656    tags = ["benchmark"],
657    visibility = ["//visibility:private"],
658    deps = [
659        ":core_headers",
660        ":periodic_sampler",
661        "@com_github_google_benchmark//:benchmark_main",
662    ],
663)
664
665cc_library(
666    name = "scoped_set_env",
667    testonly = 1,
668    srcs = ["internal/scoped_set_env.cc"],
669    hdrs = ["internal/scoped_set_env.h"],
670    linkopts = ABSL_DEFAULT_LINKOPTS,
671    visibility = [
672        "//absl:__subpackages__",
673    ],
674    deps = [
675        ":config",
676        ":raw_logging_internal",
677    ],
678)
679
680cc_test(
681    name = "scoped_set_env_test",
682    size = "small",
683    srcs = ["internal/scoped_set_env_test.cc"],
684    copts = ABSL_TEST_COPTS,
685    linkopts = ABSL_DEFAULT_LINKOPTS,
686    deps = [
687        ":scoped_set_env",
688        "@com_google_googletest//:gtest_main",
689    ],
690)
691
692cc_test(
693    name = "log_severity_test",
694    size = "small",
695    srcs = ["log_severity_test.cc"],
696    copts = ABSL_TEST_COPTS,
697    linkopts = ABSL_DEFAULT_LINKOPTS,
698    deps = [
699        ":log_severity",
700        "//absl/flags:flag_internal",
701        "//absl/flags:marshalling",
702        "//absl/strings",
703        "@com_google_googletest//:gtest_main",
704    ],
705)
706
707cc_library(
708    name = "strerror",
709    srcs = ["internal/strerror.cc"],
710    hdrs = ["internal/strerror.h"],
711    copts = ABSL_DEFAULT_COPTS,
712    linkopts = ABSL_DEFAULT_LINKOPTS,
713    visibility = [
714        "//absl:__subpackages__",
715    ],
716    deps = [
717        ":config",
718        ":core_headers",
719        ":errno_saver",
720    ],
721)
722
723cc_test(
724    name = "strerror_test",
725    size = "small",
726    srcs = ["internal/strerror_test.cc"],
727    copts = ABSL_TEST_COPTS,
728    linkopts = ABSL_DEFAULT_LINKOPTS,
729    deps = [
730        ":strerror",
731        "//absl/strings",
732        "@com_google_googletest//:gtest_main",
733    ],
734)
735
736cc_binary(
737    name = "strerror_benchmark",
738    testonly = 1,
739    srcs = ["internal/strerror_benchmark.cc"],
740    copts = ABSL_TEST_COPTS,
741    linkopts = ABSL_DEFAULT_LINKOPTS,
742    tags = ["benchmark"],
743    visibility = ["//visibility:private"],
744    deps = [
745        ":strerror",
746        "@com_github_google_benchmark//:benchmark_main",
747    ],
748)
749
750cc_library(
751    name = "fast_type_id",
752    hdrs = ["internal/fast_type_id.h"],
753    copts = ABSL_DEFAULT_COPTS,
754    linkopts = ABSL_DEFAULT_LINKOPTS,
755    visibility = [
756        "//absl:__subpackages__",
757    ],
758    deps = [
759        ":config",
760    ],
761)
762
763cc_test(
764    name = "fast_type_id_test",
765    size = "small",
766    srcs = ["internal/fast_type_id_test.cc"],
767    copts = ABSL_TEST_COPTS,
768    linkopts = ABSL_DEFAULT_LINKOPTS,
769    deps = [
770        ":fast_type_id",
771        "@com_google_googletest//:gtest_main",
772    ],
773)
774
775cc_test(
776    name = "unique_small_name_test",
777    size = "small",
778    srcs = ["internal/unique_small_name_test.cc"],
779    copts = ABSL_TEST_COPTS,
780    linkopts = ABSL_DEFAULT_LINKOPTS,
781    linkstatic = 1,
782    deps = [
783        ":core_headers",
784        "//absl/strings",
785        "@com_google_googletest//:gtest_main",
786    ],
787)
788
789cc_test(
790    name = "optimization_test",
791    size = "small",
792    srcs = ["optimization_test.cc"],
793    copts = ABSL_TEST_COPTS,
794    linkopts = ABSL_DEFAULT_LINKOPTS,
795    deps = [
796        ":core_headers",
797        "//absl/types:optional",
798        "@com_google_googletest//:gtest_main",
799    ],
800)
801