BUILD.bazel 16 KB

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