BUILD.bazel (12577B)
1 # 2 # Copyright 2022 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 17 load( 18 "//absl:copts/configure_copts.bzl", 19 "ABSL_DEFAULT_COPTS", 20 "ABSL_DEFAULT_LINKOPTS", 21 "ABSL_TEST_COPTS", 22 ) 23 24 package( 25 default_visibility = [ 26 ":internal_users", 27 ], 28 features = [ 29 "header_modules", 30 "layering_check", 31 "parse_headers", 32 ], 33 ) 34 35 licenses(["notice"]) 36 37 package_group( 38 name = "internal_users", 39 packages = [ 40 "//absl/log", 41 ], 42 ) 43 44 package_group( 45 name = "structured_proto_users", 46 packages = [ 47 "//absl/log/...", 48 ], 49 ) 50 51 cc_library( 52 name = "check_impl", 53 hdrs = ["check_impl.h"], 54 copts = ABSL_DEFAULT_COPTS, 55 linkopts = ABSL_DEFAULT_LINKOPTS, 56 deps = [ 57 ":check_op", 58 ":conditions", 59 ":log_message", 60 ":strip", 61 "//absl/base:core_headers", 62 ], 63 ) 64 65 cc_library( 66 name = "check_op", 67 srcs = ["check_op.cc"], 68 hdrs = ["check_op.h"], 69 copts = ABSL_DEFAULT_COPTS, 70 linkopts = ABSL_DEFAULT_LINKOPTS, 71 visibility = [ 72 "//absl/log:__pkg__", 73 ], 74 deps = [ 75 ":nullguard", 76 ":nullstream", 77 ":strip", 78 "//absl/base", 79 "//absl/base:config", 80 "//absl/base:core_headers", 81 "//absl/base:nullability", 82 "//absl/debugging:leak_check", 83 "//absl/strings", 84 ], 85 ) 86 87 cc_library( 88 name = "conditions", 89 srcs = ["conditions.cc"], 90 hdrs = ["conditions.h"], 91 copts = ABSL_DEFAULT_COPTS, 92 linkopts = ABSL_DEFAULT_LINKOPTS, 93 deps = [ 94 ":voidify", 95 "//absl/base", 96 "//absl/base:config", 97 "//absl/base:core_headers", 98 ], 99 ) 100 101 cc_library( 102 name = "config", 103 hdrs = ["config.h"], 104 copts = ABSL_DEFAULT_COPTS, 105 linkopts = ABSL_DEFAULT_LINKOPTS, 106 visibility = [ 107 "//absl/log:__pkg__", 108 ], 109 deps = [ 110 "//absl/base:config", 111 "//absl/base:core_headers", 112 ], 113 ) 114 115 cc_library( 116 name = "flags", 117 hdrs = ["flags.h"], 118 copts = ABSL_DEFAULT_COPTS, 119 linkopts = ABSL_DEFAULT_LINKOPTS, 120 deps = [ 121 "//absl/flags:flag", 122 ], 123 ) 124 125 cc_library( 126 name = "format", 127 srcs = ["log_format.cc"], 128 hdrs = ["log_format.h"], 129 copts = ABSL_DEFAULT_COPTS, 130 linkopts = ABSL_DEFAULT_LINKOPTS, 131 deps = [ 132 ":append_truncated", 133 ":config", 134 ":globals", 135 "//absl/base:config", 136 "//absl/base:core_headers", 137 "//absl/base:log_severity", 138 "//absl/strings", 139 "//absl/strings:str_format", 140 "//absl/time", 141 "//absl/types:span", 142 ], 143 ) 144 145 cc_library( 146 name = "globals", 147 srcs = ["globals.cc"], 148 hdrs = ["globals.h"], 149 copts = ABSL_DEFAULT_COPTS, 150 linkopts = ABSL_DEFAULT_LINKOPTS, 151 visibility = [ 152 "//absl/log:__pkg__", 153 ], 154 deps = [ 155 "//absl/base:config", 156 "//absl/base:core_headers", 157 "//absl/base:log_severity", 158 "//absl/base:raw_logging_internal", 159 "//absl/strings", 160 "//absl/time", 161 ], 162 ) 163 164 cc_library( 165 name = "log_impl", 166 hdrs = ["log_impl.h"], 167 copts = ABSL_DEFAULT_COPTS, 168 linkopts = ABSL_DEFAULT_LINKOPTS, 169 deps = [ 170 ":conditions", 171 ":log_message", 172 ":strip", 173 "//absl/log:absl_vlog_is_on", 174 ], 175 ) 176 177 cc_library( 178 name = "log_message", 179 srcs = ["log_message.cc"], 180 hdrs = ["log_message.h"], 181 copts = ABSL_DEFAULT_COPTS, 182 linkopts = ABSL_DEFAULT_LINKOPTS, 183 visibility = [ 184 "//absl/log:__pkg__", 185 ], 186 deps = [ 187 ":append_truncated", 188 ":format", 189 ":globals", 190 ":log_sink_set", 191 ":nullguard", 192 ":proto", 193 ":structured_proto", 194 "//absl/base", 195 "//absl/base:config", 196 "//absl/base:core_headers", 197 "//absl/base:errno_saver", 198 "//absl/base:log_severity", 199 "//absl/base:nullability", 200 "//absl/base:raw_logging_internal", 201 "//absl/base:strerror", 202 "//absl/container:inlined_vector", 203 "//absl/debugging:examine_stack", 204 "//absl/log:globals", 205 "//absl/log:log_entry", 206 "//absl/log:log_sink", 207 "//absl/log:log_sink_registry", 208 "//absl/memory", 209 "//absl/strings", 210 "//absl/time", 211 "//absl/types:span", 212 ], 213 ) 214 215 cc_library( 216 name = "append_truncated", 217 hdrs = ["append_truncated.h"], 218 copts = ABSL_DEFAULT_COPTS, 219 linkopts = ABSL_DEFAULT_LINKOPTS, 220 deps = [ 221 "//absl/base:config", 222 "//absl/strings", 223 "//absl/types:span", 224 ], 225 ) 226 227 cc_library( 228 name = "log_sink_set", 229 srcs = ["log_sink_set.cc"], 230 hdrs = ["log_sink_set.h"], 231 copts = ABSL_DEFAULT_COPTS, 232 linkopts = ABSL_DEFAULT_LINKOPTS + select({ 233 "//conditions:default": [], 234 "@platforms//os:android": ["-llog"], 235 }), 236 deps = [ 237 ":config", 238 ":globals", 239 "//absl/base", 240 "//absl/base:config", 241 "//absl/base:core_headers", 242 "//absl/base:log_severity", 243 "//absl/base:no_destructor", 244 "//absl/base:raw_logging_internal", 245 "//absl/cleanup", 246 "//absl/log:globals", 247 "//absl/log:log_entry", 248 "//absl/log:log_sink", 249 "//absl/strings", 250 "//absl/synchronization", 251 "//absl/types:span", 252 ], 253 ) 254 255 cc_library( 256 name = "nullguard", 257 srcs = ["nullguard.cc"], 258 hdrs = ["nullguard.h"], 259 copts = ABSL_DEFAULT_COPTS, 260 linkopts = ABSL_DEFAULT_LINKOPTS, 261 deps = [ 262 "//absl/base:config", 263 "//absl/base:core_headers", 264 ], 265 ) 266 267 cc_library( 268 name = "nullstream", 269 hdrs = ["nullstream.h"], 270 copts = ABSL_DEFAULT_COPTS, 271 linkopts = ABSL_DEFAULT_LINKOPTS, 272 deps = [ 273 "//absl/base:config", 274 "//absl/base:core_headers", 275 "//absl/base:log_severity", 276 "//absl/strings", 277 ], 278 ) 279 280 cc_library( 281 name = "strip", 282 hdrs = ["strip.h"], 283 copts = ABSL_DEFAULT_COPTS, 284 linkopts = ABSL_DEFAULT_LINKOPTS, 285 deps = [ 286 ":log_message", 287 ":nullstream", 288 "//absl/base:core_headers", 289 "//absl/base:log_severity", 290 ], 291 ) 292 293 cc_library( 294 name = "structured", 295 hdrs = ["structured.h"], 296 copts = ABSL_DEFAULT_COPTS, 297 linkopts = ABSL_DEFAULT_LINKOPTS, 298 visibility = [ 299 ":internal_users", 300 ":structured_proto_users", 301 ], 302 deps = [ 303 ":log_message", 304 ":structured_proto", 305 "//absl/base:config", 306 "//absl/base:core_headers", 307 "//absl/functional:any_invocable", 308 "//absl/strings", 309 ], 310 ) 311 312 cc_library( 313 name = "structured_proto", 314 srcs = ["structured_proto.cc"], 315 hdrs = ["structured_proto.h"], 316 copts = ABSL_DEFAULT_COPTS, 317 linkopts = ABSL_DEFAULT_LINKOPTS, 318 visibility = [ 319 ":structured_proto_users", 320 ], 321 deps = [ 322 ":proto", 323 "//absl/base:config", 324 "//absl/strings", 325 "//absl/types:span", 326 "//absl/types:variant", 327 ], 328 ) 329 330 cc_test( 331 name = "structured_proto_test", 332 srcs = ["structured_proto_test.cc"], 333 deps = [ 334 ":structured_proto", 335 "//absl/base:config", 336 "//absl/strings:string_view", 337 "//absl/types:span", 338 "//absl/utility", 339 "@googletest//:gtest", 340 "@googletest//:gtest_main", 341 ], 342 ) 343 344 cc_library( 345 name = "test_actions", 346 testonly = True, 347 srcs = ["test_actions.cc"], 348 hdrs = ["test_actions.h"], 349 copts = ABSL_DEFAULT_COPTS, 350 linkopts = ABSL_DEFAULT_LINKOPTS, 351 deps = [ 352 "//absl/base:config", 353 "//absl/base:core_headers", 354 "//absl/base:log_severity", 355 "//absl/log:log_entry", 356 "//absl/strings", 357 "//absl/time", 358 ] + select({ 359 "@rules_cc//cc/compiler:msvc-cl": [], 360 "//conditions:default": [ 361 ], 362 }), 363 ) 364 365 cc_library( 366 name = "test_helpers", 367 testonly = True, 368 srcs = ["test_helpers.cc"], 369 hdrs = ["test_helpers.h"], 370 copts = ABSL_DEFAULT_COPTS, 371 linkopts = ABSL_DEFAULT_LINKOPTS, 372 visibility = [ 373 ":internal_users", 374 ":structured_proto_users", 375 ], 376 deps = [ 377 ":globals", 378 "//absl/base:config", 379 "//absl/base:log_severity", 380 "//absl/log:globals", 381 "//absl/log:initialize", 382 "@googletest//:gtest", 383 ], 384 ) 385 386 cc_library( 387 name = "test_matchers", 388 testonly = True, 389 srcs = ["test_matchers.cc"], 390 hdrs = ["test_matchers.h"], 391 copts = ABSL_DEFAULT_COPTS, 392 linkopts = ABSL_DEFAULT_LINKOPTS, 393 visibility = [ 394 ":internal_users", 395 ":structured_proto_users", 396 ], 397 deps = [ 398 ":test_helpers", 399 "//absl/base:config", 400 "//absl/base:core_headers", 401 "//absl/base:log_severity", 402 "//absl/log:log_entry", 403 "//absl/strings", 404 "//absl/time", 405 "@googletest//:gtest", 406 ] + select({ 407 "@rules_cc//cc/compiler:msvc-cl": [], 408 "//conditions:default": [ 409 ], 410 }), 411 ) 412 413 cc_library( 414 name = "voidify", 415 hdrs = ["voidify.h"], 416 copts = ABSL_DEFAULT_COPTS, 417 linkopts = ABSL_DEFAULT_LINKOPTS, 418 deps = [ 419 "//absl/base:config", 420 "//absl/base:core_headers", 421 ], 422 ) 423 424 cc_library( 425 name = "proto", 426 srcs = ["proto.cc"], 427 hdrs = ["proto.h"], 428 copts = ABSL_DEFAULT_COPTS, 429 linkopts = ABSL_DEFAULT_LINKOPTS, 430 visibility = [ 431 ":internal_users", 432 ":structured_proto_users", 433 ], 434 deps = [ 435 "//absl/base", 436 "//absl/base:config", 437 "//absl/base:core_headers", 438 "//absl/strings", 439 "//absl/types:span", 440 ], 441 ) 442 443 cc_library( 444 name = "fnmatch", 445 srcs = ["fnmatch.cc"], 446 hdrs = ["fnmatch.h"], 447 copts = ABSL_DEFAULT_COPTS, 448 linkopts = ABSL_DEFAULT_LINKOPTS, 449 deps = [ 450 "//absl/base:config", 451 "//absl/strings", 452 ], 453 ) 454 455 cc_library( 456 name = "vlog_config", 457 srcs = ["vlog_config.cc"], 458 hdrs = ["vlog_config.h"], 459 copts = ABSL_DEFAULT_COPTS, 460 linkopts = ABSL_DEFAULT_LINKOPTS, 461 visibility = [ 462 "//absl/log:__subpackages__", 463 ], 464 deps = [ 465 ":fnmatch", 466 "//absl/base", 467 "//absl/base:config", 468 "//absl/base:core_headers", 469 "//absl/base:no_destructor", 470 "//absl/base:nullability", 471 "//absl/memory", 472 "//absl/strings", 473 "//absl/synchronization", 474 "//absl/types:optional", 475 ], 476 ) 477 478 cc_binary( 479 name = "vlog_config_benchmark", 480 testonly = True, 481 srcs = ["vlog_config_benchmark.cc"], 482 copts = ABSL_TEST_COPTS, 483 linkopts = ABSL_DEFAULT_LINKOPTS, 484 tags = [ 485 "benchmark", 486 ], 487 visibility = ["//visibility:private"], 488 deps = [ 489 ":vlog_config", 490 "//absl/base:config", 491 "//absl/base:core_headers", 492 "//absl/container:layout", 493 "//absl/memory", 494 "//absl/random:distributions", 495 "//absl/strings", 496 "@google_benchmark//:benchmark_main", 497 ], 498 ) 499 500 # Test targets 501 cc_test( 502 name = "stderr_log_sink_test", 503 size = "small", 504 timeout = "moderate", 505 srcs = ["stderr_log_sink_test.cc"], 506 copts = ABSL_TEST_COPTS, 507 linkopts = ABSL_DEFAULT_LINKOPTS, 508 tags = [ 509 "no_test:os:android", 510 "no_test:os:ios", 511 "no_test_android", 512 "no_test_darwin_arm64", 513 "no_test_darwin_x86_64", 514 "no_test_fuchsia_x64", 515 "no_test_ios", 516 "no_test_wasm", 517 ], 518 deps = [ 519 ":test_helpers", 520 "//absl/base:core_headers", 521 "//absl/base:log_severity", 522 "//absl/log", 523 "//absl/log:globals", 524 "@googletest//:gtest", 525 "@googletest//:gtest_main", 526 ], 527 ) 528 529 cc_test( 530 name = "fnmatch_test", 531 srcs = ["fnmatch_test.cc"], 532 copts = ABSL_TEST_COPTS, 533 linkopts = ABSL_DEFAULT_LINKOPTS, 534 deps = [ 535 ":fnmatch", 536 "@googletest//:gtest", 537 "@googletest//:gtest_main", 538 ], 539 ) 540 541 cc_test( 542 name = "fnmatch_benchmark", 543 srcs = ["fnmatch_benchmark.cc"], 544 copts = ABSL_TEST_COPTS, 545 linkopts = ABSL_DEFAULT_LINKOPTS, 546 tags = ["benchmark"], 547 deps = [ 548 ":fnmatch", 549 "@google_benchmark//:benchmark_main", 550 ], 551 )