Abseil Common Libraries (C++) (grcp 依赖)
https://abseil.io/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
479 lines
12 KiB
479 lines
12 KiB
# |
|
# Copyright 2022 The Abseil Authors. |
|
# |
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
|
# you may not use this file except in compliance with the License. |
|
# You may obtain a copy of the License at |
|
# |
|
# https://www.apache.org/licenses/LICENSE-2.0 |
|
# |
|
# Unless required by applicable law or agreed to in writing, software |
|
# distributed under the License is distributed on an "AS IS" BASIS, |
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
# See the License for the specific language governing permissions and |
|
# limitations under the License. |
|
# |
|
|
|
load( |
|
"//absl:copts/configure_copts.bzl", |
|
"ABSL_DEFAULT_COPTS", |
|
"ABSL_DEFAULT_LINKOPTS", |
|
"ABSL_TEST_COPTS", |
|
) |
|
|
|
package(default_visibility = ["//visibility:public"]) |
|
|
|
licenses(["notice"]) |
|
|
|
# Public targets |
|
cc_library( |
|
name = "check", |
|
hdrs = ["check.h"], |
|
copts = ABSL_DEFAULT_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
"//absl/base:core_headers", |
|
"//absl/log/internal:check_op", |
|
"//absl/log/internal:conditions", |
|
"//absl/log/internal:log_message", |
|
"//absl/log/internal:strip", |
|
], |
|
) |
|
|
|
cc_library( |
|
name = "die_if_null", |
|
srcs = ["die_if_null.cc"], |
|
hdrs = ["die_if_null.h"], |
|
copts = ABSL_DEFAULT_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
":log", |
|
"//absl/base:config", |
|
"//absl/base:core_headers", |
|
"//absl/strings", |
|
], |
|
) |
|
|
|
cc_library( |
|
name = "flags", |
|
srcs = ["flags.cc"], |
|
hdrs = ["flags.h"], |
|
copts = ABSL_DEFAULT_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
visibility = ["//visibility:public"], |
|
deps = [ |
|
":globals", |
|
"//absl/base:config", |
|
"//absl/base:core_headers", |
|
"//absl/base:log_severity", |
|
"//absl/flags:flag", |
|
"//absl/flags:marshalling", |
|
"//absl/log/internal:config", |
|
"//absl/log/internal:flags", |
|
"//absl/strings", |
|
], |
|
# Binaries which do not access these flags from C++ still want this library linked in. |
|
alwayslink = True, |
|
) |
|
|
|
cc_library( |
|
name = "globals", |
|
srcs = ["globals.cc"], |
|
hdrs = ["globals.h"], |
|
copts = ABSL_DEFAULT_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
visibility = ["//visibility:public"], |
|
deps = [ |
|
"//absl/base:atomic_hook", |
|
"//absl/base:config", |
|
"//absl/base:core_headers", |
|
"//absl/base:log_severity", |
|
"//absl/hash", |
|
"//absl/strings", |
|
], |
|
) |
|
|
|
cc_library( |
|
name = "initialize", |
|
srcs = ["initialize.cc"], |
|
hdrs = ["initialize.h"], |
|
copts = ABSL_DEFAULT_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
visibility = ["//visibility:public"], |
|
deps = [ |
|
":globals", |
|
"//absl/base:config", |
|
"//absl/log/internal:globals", |
|
"//absl/time", |
|
], |
|
) |
|
|
|
cc_library( |
|
name = "log", |
|
hdrs = ["log.h"], |
|
copts = ABSL_DEFAULT_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
"//absl/log/internal:conditions", |
|
"//absl/log/internal:log_message", |
|
"//absl/log/internal:strip", |
|
], |
|
) |
|
|
|
cc_library( |
|
name = "log_entry", |
|
srcs = ["log_entry.cc"], |
|
hdrs = ["log_entry.h"], |
|
copts = ABSL_DEFAULT_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
"//absl/base:config", |
|
"//absl/base:log_severity", |
|
"//absl/log/internal:config", |
|
"//absl/strings", |
|
"//absl/time", |
|
"//absl/types:span", |
|
], |
|
) |
|
|
|
cc_library( |
|
name = "log_sink", |
|
srcs = ["log_sink.cc"], |
|
hdrs = ["log_sink.h"], |
|
copts = ABSL_DEFAULT_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
":log_entry", |
|
"//absl/base:config", |
|
], |
|
) |
|
|
|
cc_library( |
|
name = "log_sink_registry", |
|
hdrs = ["log_sink_registry.h"], |
|
copts = ABSL_DEFAULT_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
":log_sink", |
|
"//absl/base:config", |
|
"//absl/log/internal:log_sink_set", |
|
], |
|
) |
|
|
|
cc_library( |
|
name = "log_streamer", |
|
hdrs = ["log_streamer.h"], |
|
copts = ABSL_DEFAULT_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
":log", |
|
"//absl/base:config", |
|
"//absl/base:log_severity", |
|
"//absl/memory", |
|
"//absl/strings", |
|
"//absl/strings:internal", |
|
], |
|
) |
|
|
|
cc_library( |
|
name = "scoped_mock_log", |
|
testonly = True, |
|
srcs = ["scoped_mock_log.cc"], |
|
hdrs = ["scoped_mock_log.h"], |
|
copts = ABSL_DEFAULT_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
":log_entry", |
|
":log_sink", |
|
":log_sink_registry", |
|
"//absl/base:config", |
|
"//absl/base:log_severity", |
|
"//absl/base:raw_logging_internal", |
|
"//absl/strings", |
|
"@com_google_googletest//:gtest", |
|
], |
|
) |
|
|
|
# Test targets |
|
cc_test( |
|
name = "basic_log_test", |
|
size = "small", |
|
srcs = ["basic_log_test.cc"], |
|
copts = ABSL_TEST_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
":globals", |
|
":log", |
|
":log_entry", |
|
":scoped_mock_log", |
|
"//absl/base", |
|
"//absl/base:log_severity", |
|
"//absl/log/internal:test_actions", |
|
"//absl/log/internal:test_helpers", |
|
"//absl/log/internal:test_matchers", |
|
"@com_google_googletest//:gtest_main", |
|
], |
|
) |
|
|
|
cc_test( |
|
name = "check_test", |
|
size = "small", |
|
srcs = ["check_test.cc"], |
|
copts = ABSL_TEST_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
tags = [ |
|
"no_test:os:ios", |
|
"no_test_ios", |
|
"no_test_wasm", |
|
], |
|
deps = [ |
|
":check", |
|
"//absl/base:config", |
|
"//absl/base:core_headers", |
|
"//absl/log/internal:test_helpers", |
|
"@com_google_googletest//:gtest_main", |
|
], |
|
) |
|
|
|
cc_test( |
|
name = "die_if_null_test", |
|
size = "small", |
|
srcs = ["die_if_null_test.cc"], |
|
copts = ABSL_TEST_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
":die_if_null", |
|
"//absl/base:core_headers", |
|
"//absl/log/internal:test_helpers", |
|
"@com_google_googletest//:gtest_main", |
|
], |
|
) |
|
|
|
cc_test( |
|
name = "flags_test", |
|
size = "small", |
|
srcs = ["flags_test.cc"], |
|
copts = ABSL_TEST_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
":flags", |
|
":globals", |
|
":log", |
|
":scoped_mock_log", |
|
"//absl/base:core_headers", |
|
"//absl/base:log_severity", |
|
"//absl/flags:flag", |
|
"//absl/flags:reflection", |
|
"//absl/log/internal:flags", |
|
"//absl/log/internal:test_helpers", |
|
"//absl/log/internal:test_matchers", |
|
"//absl/strings", |
|
"@com_google_googletest//:gtest_main", |
|
], |
|
) |
|
|
|
cc_test( |
|
name = "globals_test", |
|
size = "small", |
|
srcs = ["globals_test.cc"], |
|
copts = ABSL_TEST_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
":globals", |
|
":log", |
|
":scoped_mock_log", |
|
"//absl/base:core_headers", |
|
"//absl/base:log_severity", |
|
"//absl/log/internal:globals", |
|
"//absl/log/internal:test_helpers", |
|
"@com_google_googletest//:gtest_main", |
|
], |
|
) |
|
|
|
cc_test( |
|
name = "log_entry_test", |
|
size = "small", |
|
srcs = ["log_entry_test.cc"], |
|
copts = ABSL_TEST_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
":log_entry", |
|
"//absl/base:config", |
|
"//absl/base:core_headers", |
|
"//absl/base:log_severity", |
|
"//absl/log/internal:format", |
|
"//absl/log/internal:test_helpers", |
|
"//absl/strings", |
|
"//absl/time", |
|
"//absl/types:span", |
|
"@com_google_googletest//:gtest_main", |
|
], |
|
) |
|
|
|
cc_test( |
|
name = "log_format_test", |
|
size = "small", |
|
srcs = ["log_format_test.cc"], |
|
copts = ABSL_TEST_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
":log", |
|
":scoped_mock_log", |
|
"//absl/log/internal:config", |
|
"//absl/log/internal:test_matchers", |
|
"//absl/strings", |
|
"@com_google_googletest//:gtest_main", |
|
], |
|
) |
|
|
|
cc_test( |
|
name = "log_macro_hygiene_test", |
|
size = "small", |
|
srcs = ["log_macro_hygiene_test.cc"], |
|
copts = ABSL_TEST_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
":log", |
|
":scoped_mock_log", |
|
"//absl/base:core_headers", |
|
"//absl/base:log_severity", |
|
"@com_google_googletest//:gtest_main", |
|
], |
|
) |
|
|
|
cc_test( |
|
name = "log_sink_test", |
|
size = "medium", |
|
srcs = ["log_sink_test.cc"], |
|
copts = ABSL_TEST_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
tags = [ |
|
"no_test:os:ios", |
|
"no_test_ios", |
|
"no_test_wasm", |
|
], |
|
deps = [ |
|
":log", |
|
":log_sink", |
|
":log_sink_registry", |
|
":scoped_mock_log", |
|
"//absl/base:core_headers", |
|
"//absl/base:raw_logging_internal", |
|
"//absl/log/internal:test_actions", |
|
"//absl/log/internal:test_helpers", |
|
"//absl/log/internal:test_matchers", |
|
"//absl/strings", |
|
"@com_google_googletest//:gtest_main", |
|
], |
|
) |
|
|
|
cc_test( |
|
name = "log_streamer_test", |
|
size = "medium", |
|
srcs = ["log_streamer_test.cc"], |
|
copts = ABSL_TEST_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
":log", |
|
":log_streamer", |
|
":scoped_mock_log", |
|
"//absl/base", |
|
"//absl/base:core_headers", |
|
"//absl/base:log_severity", |
|
"//absl/log/internal:test_actions", |
|
"//absl/log/internal:test_helpers", |
|
"//absl/log/internal:test_matchers", |
|
"//absl/strings", |
|
"@com_google_googletest//:gtest_main", |
|
], |
|
) |
|
|
|
cc_test( |
|
name = "log_modifier_methods_test", |
|
size = "small", |
|
srcs = ["log_modifier_methods_test.cc"], |
|
copts = ABSL_TEST_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
deps = [ |
|
":log", |
|
":log_sink", |
|
":scoped_mock_log", |
|
"//absl/log/internal:test_actions", |
|
"//absl/log/internal:test_helpers", |
|
"//absl/log/internal:test_matchers", |
|
"//absl/strings", |
|
"//absl/time", |
|
"@com_google_googletest//:gtest_main", |
|
], |
|
) |
|
|
|
cc_test( |
|
name = "scoped_mock_log_test", |
|
size = "small", |
|
srcs = ["scoped_mock_log_test.cc"], |
|
copts = ABSL_TEST_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
linkstatic = 1, |
|
tags = [ |
|
"no_test:os:ios", |
|
"no_test_ios", |
|
"no_test_wasm", |
|
], |
|
deps = [ |
|
":globals", |
|
":log", |
|
":scoped_mock_log", |
|
"//absl/base:core_headers", |
|
"//absl/base:log_severity", |
|
"//absl/log/internal:test_helpers", |
|
"//absl/log/internal:test_matchers", |
|
"//absl/memory", |
|
"//absl/strings", |
|
"//absl/synchronization", |
|
"@com_google_googletest//:gtest_main", |
|
], |
|
) |
|
|
|
cc_test( |
|
name = "stripping_test", |
|
size = "small", |
|
srcs = ["stripping_test.cc"], |
|
copts = ABSL_TEST_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
# This test requires all code live in the binary (instead of shared libraries) |
|
# because we test for the existence of specific literals in the binary. |
|
linkstatic = 1, |
|
deps = [ |
|
":check", |
|
":log", |
|
"//absl/base:strerror", |
|
"//absl/flags:program_name", |
|
"//absl/log/internal:test_helpers", |
|
"//absl/strings", |
|
"//absl/strings:str_format", |
|
"@com_google_googletest//:gtest_main", |
|
], |
|
) |
|
|
|
cc_binary( |
|
name = "log_benchmark", |
|
testonly = 1, |
|
srcs = ["log_benchmark.cc"], |
|
copts = ABSL_TEST_COPTS, |
|
linkopts = ABSL_DEFAULT_LINKOPTS, |
|
tags = ["benchmark"], |
|
deps = [ |
|
":check", |
|
":flags", |
|
":globals", |
|
":log", |
|
":log_entry", |
|
":log_sink", |
|
":log_sink_registry", |
|
"//absl/base:core_headers", |
|
"//absl/base:log_severity", |
|
"//absl/flags:flag", |
|
"//absl/log/internal:flags", |
|
"@com_github_google_benchmark//:benchmark_main", |
|
], |
|
)
|
|
|