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