From 1e6d77c29afb562ac8b839b9f19b9b576419bb32 Mon Sep 17 00:00:00 2001 From: Peter Kasting Date: Mon, 13 Mar 2023 16:01:00 -0700 Subject: [PATCH] Always check out google_benchmark, part 3. Add a WebRTC-specific arg that can be used to control use of targets that rely on //third_party/google_benchmarks, so the .gni in that directory can eventually be removed. Bug: chromium:1404759 Change-Id: I2a9422fae119ca13eb50028d962fc0a671b5fb33 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/297460 Reviewed-by: Mirko Bonadei Commit-Queue: Mirko Bonadei Auto-Submit: Peter Kasting Cr-Commit-Position: refs/heads/main@{#39553} --- BUILD.gn | 2 +- build_overrides/build.gni | 3 - rtc_base/BUILD.gn | 2 +- rtc_base/synchronization/BUILD.gn | 59 ++-- test/BUILD.gn | 460 +++++++++++++++--------------- webrtc.gni | 4 + 6 files changed, 266 insertions(+), 264 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 59c3af169b..24fe451725 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -628,7 +628,7 @@ if (rtc_include_tests && !build_with_chromium) { } } - if (enable_google_benchmarks) { + if (enable_google_benchmarks && rtc_enable_google_benchmarks) { rtc_test("benchmarks") { testonly = true deps = [ diff --git a/build_overrides/build.gni b/build_overrides/build.gni index 137b6a40b2..34f58c7e66 100644 --- a/build_overrides/build.gni +++ b/build_overrides/build.gni @@ -13,9 +13,6 @@ enable_java_templates = true # only needed to support both WebRTC standalone and Chromium builds. build_with_chromium = false -# WebRTC checks out google_benchmark by default since it is always used. -checkout_google_benchmark = true - # Use our own suppressions files. asan_suppressions_file = "//build/sanitizers/asan_suppressions.cc" lsan_suppressions_file = "//tools_webrtc/sanitizers/lsan_suppressions_webrtc.cc" diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index a657a4442b..4c860cd933 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -2041,7 +2041,7 @@ if (rtc_include_tests) { "synchronization:mutex", "third_party/sigslot", ] - if (enable_google_benchmarks) { + if (enable_google_benchmarks && rtc_enable_google_benchmarks) { deps += [ "synchronization:synchronization_unittests" ] } if (is_win) { diff --git a/rtc_base/synchronization/BUILD.gn b/rtc_base/synchronization/BUILD.gn index 858135f5cc..5b2ff6e3e6 100644 --- a/rtc_base/synchronization/BUILD.gn +++ b/rtc_base/synchronization/BUILD.gn @@ -73,36 +73,35 @@ rtc_library("yield_policy") { ] } -if (rtc_include_tests) { - if (enable_google_benchmarks) { - rtc_library("synchronization_unittests") { - testonly = true - sources = [ - "mutex_unittest.cc", - "yield_policy_unittest.cc", - ] - deps = [ - ":mutex", - ":yield", - ":yield_policy", - "..:checks", - "..:macromagic", - "..:platform_thread", - "..:rtc_event", - "..:threading", - "../../test:test_support", - "//third_party/google_benchmark", - ] - } +if (rtc_include_tests && enable_google_benchmarks && + rtc_enable_google_benchmarks) { + rtc_library("synchronization_unittests") { + testonly = true + sources = [ + "mutex_unittest.cc", + "yield_policy_unittest.cc", + ] + deps = [ + ":mutex", + ":yield", + ":yield_policy", + "..:checks", + "..:macromagic", + "..:platform_thread", + "..:rtc_event", + "..:threading", + "../../test:test_support", + "//third_party/google_benchmark", + ] + } - rtc_library("mutex_benchmark") { - testonly = true - sources = [ "mutex_benchmark.cc" ] - deps = [ - ":mutex", - "../system:unused", - "//third_party/google_benchmark", - ] - } + rtc_library("mutex_benchmark") { + testonly = true + sources = [ "mutex_benchmark.cc" ] + deps = [ + ":mutex", + "../system:unused", + "//third_party/google_benchmark", + ] } } diff --git a/test/BUILD.gn b/test/BUILD.gn index abc8d4ee9c..79595ebdfd 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -494,246 +494,248 @@ rtc_library("video_test_support") { } } -if (rtc_include_tests && enable_google_benchmarks) { - rtc_library("benchmark_main") { - testonly = true - sources = [ "benchmark_main.cc" ] - - deps = [ "//third_party/google_benchmark" ] - } -} - -if (rtc_include_tests && !build_with_chromium) { - rtc_library("resources_dir_flag") { - testonly = true - visibility = [ "*" ] - sources = [ - "testsupport/resources_dir_flag.cc", - "testsupport/resources_dir_flag.h", - ] - absl_deps = [ "//third_party/abseil-cpp/absl/flags:flag" ] - } - - rtc_library("test_flags") { - visibility = [ "*" ] - testonly = true - sources = [ - "test_flags.cc", - "test_flags.h", - ] - absl_deps = [ "//third_party/abseil-cpp/absl/flags:flag" ] - } - - rtc_library("test_main_lib") { - visibility = [ "*" ] - testonly = true - sources = [ - "test_main_lib.cc", - "test_main_lib.h", - ] - - deps = [ - ":field_trial", - ":perf_test", - ":resources_dir_flag", - ":test_flags", - ":test_support", - "../api/test/metrics:chrome_perf_dashboard_metrics_exporter", - "../api/test/metrics:global_metrics_logger_and_exporter", - "../api/test/metrics:metrics_exporter", - "../api/test/metrics:metrics_set_proto_file_exporter", - "../api/test/metrics:print_result_proxy_metrics_exporter", - "../api/test/metrics:stdout_metrics_exporter", - "../rtc_base:checks", - "../rtc_base:event_tracer", - "../rtc_base:logging", - "../rtc_base:ssl", - "../rtc_base:threading", - "../system_wrappers:field_trial", - "../system_wrappers:metrics", - ] - absl_deps = [ - "//third_party/abseil-cpp/absl/flags:flag", - "//third_party/abseil-cpp/absl/memory", - "//third_party/abseil-cpp/absl/strings:strings", - "//third_party/abseil-cpp/absl/types:optional", - ] - - if (is_win) { - deps += [ "../rtc_base:win32_socket_init" ] - } - } - - rtc_library("test_main") { - visibility = [ "*" ] - testonly = true - sources = [ "test_main.cc" ] - - deps = [ - ":test_main_lib", - ":test_support", - ] - - absl_deps = [ - "//third_party/abseil-cpp/absl/debugging:failure_signal_handler", - "//third_party/abseil-cpp/absl/debugging:symbolize", - "//third_party/abseil-cpp/absl/flags:parse", - ] - } - - rtc_library("test_support_test_artifacts") { - testonly = true - sources = [ - "testsupport/test_artifacts.cc", - "testsupport/test_artifacts.h", - ] - deps = [ - ":fileutils", - "../rtc_base:logging", - "../rtc_base/system:file_wrapper", - ] - absl_deps = [ - "//third_party/abseil-cpp/absl/flags:flag", - "//third_party/abseil-cpp/absl/flags:parse", - ] - } - - test_support_unittests_resources = [ - "../resources/foreman_cif_short.yuv", - "../resources/video_coding/frame-ethernet-ii.pcap", - "../resources/video_coding/frame-loopback.pcap", - "../resources/video_coding/pltype103.rtp", - "../resources/video_coding/pltype103_header_only.rtp", - "../resources/video_coding/ssrcs-2.pcap", - "../resources/video_coding/ssrcs-3.pcap", - ] - - if (is_ios) { - bundle_data("test_support_unittests_bundle_data") { +if (rtc_include_tests) { + if (enable_google_benchmarks && rtc_enable_google_benchmarks) { + rtc_library("benchmark_main") { testonly = true - sources = test_support_unittests_resources - outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ] + sources = [ "benchmark_main.cc" ] + + deps = [ "//third_party/google_benchmark" ] } } - rtc_library("fixed_fps_video_frame_writer_adapter_test") { - testonly = true - sources = [ "testsupport/fixed_fps_video_frame_writer_adapter_test.cc" ] - deps = [ - ":fixed_fps_video_frame_writer_adapter", - ":test_support", - ":video_test_support", - "../api/units:time_delta", - "../api/units:timestamp", - "../api/video:video_frame", - "../rtc_base/synchronization:mutex", - "time_controller", - ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] - } - - rtc_test("test_support_unittests") { - deps = [ - ":call_config_utils", - ":copy_to_file_audio_capturer_unittest", - ":direct_transport", - ":fake_video_codecs", - ":fileutils", - ":fileutils_unittests", - ":fixed_fps_video_frame_writer_adapter_test", - ":frame_generator_impl", - ":perf_test", - ":rtc_expect_death", - ":rtp_test_utils", - ":run_loop", - ":scoped_key_value_config", - ":test_main", - ":test_support", - ":test_support_test_artifacts", - ":video_test_common", - ":video_test_support", - ":y4m_frame_generator", - "../api:array_view", - "../api:create_frame_generator", - "../api:create_simulcast_test_fixture_api", - "../api:frame_generator_api", - "../api:scoped_refptr", - "../api:simulcast_test_fixture_api", - "../api/task_queue:task_queue_test", - "../api/test/video:function_video_factory", - "../api/test/video:video_frame_writer", - "../api/units:time_delta", - "../api/video:encoded_image", - "../api/video:video_frame", - "../api/video_codecs:video_codecs_api", - "../call:video_stream_api", - "../common_video", - "../media:codec", - "../media:media_constants", - "../media:rtc_media_base", - "../modules/rtp_rtcp:rtp_rtcp_format", - "../modules/video_coding:simulcast_test_fixture_impl", - "../modules/video_coding:video_codec_interface", - "../modules/video_coding:video_coding_utility", - "../modules/video_coding:webrtc_h264", - "../modules/video_coding:webrtc_vp8", - "../modules/video_coding:webrtc_vp9", - "../rtc_base:criticalsection", - "../rtc_base:rtc_event", - "../rtc_base:rtc_task_queue", - "../rtc_base/synchronization:mutex", - "../rtc_base/system:file_wrapper", - "pc/e2e:e2e_unittests", - "pc/e2e/analyzer/video:video_analyzer_unittests", - "peer_scenario/tests", - "scenario:scenario_unittests", - "time_controller:time_controller", - "time_controller:time_controller_unittests", - ] - absl_deps = [ - "//third_party/abseil-cpp/absl/flags:flag", - "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", - ] - sources = [ - "call_config_utils_unittest.cc", - "direct_transport_unittest.cc", - "fake_vp8_encoder_unittest.cc", - "frame_generator_capturer_unittest.cc", - "frame_generator_unittest.cc", - "rtp_file_reader_unittest.cc", - "rtp_file_writer_unittest.cc", - "run_loop_unittest.cc", - "testsupport/ivf_video_frame_generator_unittest.cc", - "testsupport/perf_test_unittest.cc", - "testsupport/test_artifacts_unittest.cc", - "testsupport/video_frame_writer_unittest.cc", - "testsupport/y4m_frame_generator_test.cc", - "testsupport/y4m_frame_reader_unittest.cc", - "testsupport/y4m_frame_writer_unittest.cc", - "testsupport/yuv_frame_reader_unittest.cc", - "testsupport/yuv_frame_writer_unittest.cc", - ] - - if (rtc_enable_protobuf) { - sources += [ "testsupport/perf_test_histogram_writer_unittest.cc" ] - deps += [ "//third_party/catapult/tracing/tracing:histogram" ] + if (!build_with_chromium) { + rtc_library("resources_dir_flag") { + testonly = true + visibility = [ "*" ] + sources = [ + "testsupport/resources_dir_flag.cc", + "testsupport/resources_dir_flag.h", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/flags:flag" ] } - data = test_support_unittests_resources - if (is_android) { - deps += [ "//testing/android/native_test:native_test_support" ] - shard_timeout = 900 + rtc_library("test_flags") { + visibility = [ "*" ] + testonly = true + sources = [ + "test_flags.cc", + "test_flags.h", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/flags:flag" ] } + rtc_library("test_main_lib") { + visibility = [ "*" ] + testonly = true + sources = [ + "test_main_lib.cc", + "test_main_lib.h", + ] + + deps = [ + ":field_trial", + ":perf_test", + ":resources_dir_flag", + ":test_flags", + ":test_support", + "../api/test/metrics:chrome_perf_dashboard_metrics_exporter", + "../api/test/metrics:global_metrics_logger_and_exporter", + "../api/test/metrics:metrics_exporter", + "../api/test/metrics:metrics_set_proto_file_exporter", + "../api/test/metrics:print_result_proxy_metrics_exporter", + "../api/test/metrics:stdout_metrics_exporter", + "../rtc_base:checks", + "../rtc_base:event_tracer", + "../rtc_base:logging", + "../rtc_base:ssl", + "../rtc_base:threading", + "../system_wrappers:field_trial", + "../system_wrappers:metrics", + ] + absl_deps = [ + "//third_party/abseil-cpp/absl/flags:flag", + "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings:strings", + "//third_party/abseil-cpp/absl/types:optional", + ] + + if (is_win) { + deps += [ "../rtc_base:win32_socket_init" ] + } + } + + rtc_library("test_main") { + visibility = [ "*" ] + testonly = true + sources = [ "test_main.cc" ] + + deps = [ + ":test_main_lib", + ":test_support", + ] + + absl_deps = [ + "//third_party/abseil-cpp/absl/debugging:failure_signal_handler", + "//third_party/abseil-cpp/absl/debugging:symbolize", + "//third_party/abseil-cpp/absl/flags:parse", + ] + } + + rtc_library("test_support_test_artifacts") { + testonly = true + sources = [ + "testsupport/test_artifacts.cc", + "testsupport/test_artifacts.h", + ] + deps = [ + ":fileutils", + "../rtc_base:logging", + "../rtc_base/system:file_wrapper", + ] + absl_deps = [ + "//third_party/abseil-cpp/absl/flags:flag", + "//third_party/abseil-cpp/absl/flags:parse", + ] + } + + test_support_unittests_resources = [ + "../resources/foreman_cif_short.yuv", + "../resources/video_coding/frame-ethernet-ii.pcap", + "../resources/video_coding/frame-loopback.pcap", + "../resources/video_coding/pltype103.rtp", + "../resources/video_coding/pltype103_header_only.rtp", + "../resources/video_coding/ssrcs-2.pcap", + "../resources/video_coding/ssrcs-3.pcap", + ] + if (is_ios) { - deps += [ ":test_support_unittests_bundle_data" ] + bundle_data("test_support_unittests_bundle_data") { + testonly = true + sources = test_support_unittests_resources + outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ] + } } - if (!is_android) { - # This is needed in order to avoid: - # undefined symbol: webrtc::videocapturemodule::VideoCaptureImpl::Create - deps += [ "../modules/video_capture:video_capture_internal_impl" ] + rtc_library("fixed_fps_video_frame_writer_adapter_test") { + testonly = true + sources = [ "testsupport/fixed_fps_video_frame_writer_adapter_test.cc" ] + deps = [ + ":fixed_fps_video_frame_writer_adapter", + ":test_support", + ":video_test_support", + "../api/units:time_delta", + "../api/units:timestamp", + "../api/video:video_frame", + "../rtc_base/synchronization:mutex", + "time_controller", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + } + + rtc_test("test_support_unittests") { + deps = [ + ":call_config_utils", + ":copy_to_file_audio_capturer_unittest", + ":direct_transport", + ":fake_video_codecs", + ":fileutils", + ":fileutils_unittests", + ":fixed_fps_video_frame_writer_adapter_test", + ":frame_generator_impl", + ":perf_test", + ":rtc_expect_death", + ":rtp_test_utils", + ":run_loop", + ":scoped_key_value_config", + ":test_main", + ":test_support", + ":test_support_test_artifacts", + ":video_test_common", + ":video_test_support", + ":y4m_frame_generator", + "../api:array_view", + "../api:create_frame_generator", + "../api:create_simulcast_test_fixture_api", + "../api:frame_generator_api", + "../api:scoped_refptr", + "../api:simulcast_test_fixture_api", + "../api/task_queue:task_queue_test", + "../api/test/video:function_video_factory", + "../api/test/video:video_frame_writer", + "../api/units:time_delta", + "../api/video:encoded_image", + "../api/video:video_frame", + "../api/video_codecs:video_codecs_api", + "../call:video_stream_api", + "../common_video", + "../media:codec", + "../media:media_constants", + "../media:rtc_media_base", + "../modules/rtp_rtcp:rtp_rtcp_format", + "../modules/video_coding:simulcast_test_fixture_impl", + "../modules/video_coding:video_codec_interface", + "../modules/video_coding:video_coding_utility", + "../modules/video_coding:webrtc_h264", + "../modules/video_coding:webrtc_vp8", + "../modules/video_coding:webrtc_vp9", + "../rtc_base:criticalsection", + "../rtc_base:rtc_event", + "../rtc_base:rtc_task_queue", + "../rtc_base/synchronization:mutex", + "../rtc_base/system:file_wrapper", + "pc/e2e:e2e_unittests", + "pc/e2e/analyzer/video:video_analyzer_unittests", + "peer_scenario/tests", + "scenario:scenario_unittests", + "time_controller:time_controller", + "time_controller:time_controller_unittests", + ] + absl_deps = [ + "//third_party/abseil-cpp/absl/flags:flag", + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] + sources = [ + "call_config_utils_unittest.cc", + "direct_transport_unittest.cc", + "fake_vp8_encoder_unittest.cc", + "frame_generator_capturer_unittest.cc", + "frame_generator_unittest.cc", + "rtp_file_reader_unittest.cc", + "rtp_file_writer_unittest.cc", + "run_loop_unittest.cc", + "testsupport/ivf_video_frame_generator_unittest.cc", + "testsupport/perf_test_unittest.cc", + "testsupport/test_artifacts_unittest.cc", + "testsupport/video_frame_writer_unittest.cc", + "testsupport/y4m_frame_generator_test.cc", + "testsupport/y4m_frame_reader_unittest.cc", + "testsupport/y4m_frame_writer_unittest.cc", + "testsupport/yuv_frame_reader_unittest.cc", + "testsupport/yuv_frame_writer_unittest.cc", + ] + + if (rtc_enable_protobuf) { + sources += [ "testsupport/perf_test_histogram_writer_unittest.cc" ] + deps += [ "//third_party/catapult/tracing/tracing:histogram" ] + } + + data = test_support_unittests_resources + if (is_android) { + deps += [ "//testing/android/native_test:native_test_support" ] + shard_timeout = 900 + } + + if (is_ios) { + deps += [ ":test_support_unittests_bundle_data" ] + } + + if (!is_android) { + # This is needed in order to avoid: + # undefined symbol: webrtc::videocapturemodule::VideoCaptureImpl::Create + deps += [ "../modules/video_capture:video_capture_internal_impl" ] + } } } } diff --git a/webrtc.gni b/webrtc.gni index 9052ba5eea..823dfa7418 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -54,6 +54,10 @@ declare_args() { # This is useful for example to be able to get RTC_DLOGs on a release build. rtc_dlog_always_on = false + # Enables additional build targets that rely on + # //third_party/google_benchmarks. + rtc_enable_google_benchmarks = true + # Setting this to true will make RTC_OBJC_EXPORT expand to code that will # manage symbols visibility. By default, Obj-C/Obj-C++ symbols are exported # if C++ symbols are but setting this arg to true while keeping