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