From 16db7fff49c288fbddbbd004c9de6d2a882c4cac Mon Sep 17 00:00:00 2001 From: Tommi Date: Sat, 26 Sep 2020 11:57:26 +0200 Subject: [PATCH] Move win32 files to a new "win32" target to avoid cyclic dependencies. I ran into this when using repeating_task, which depends on clock (in system_wrappers) which in turn added a dependency on rtc_base on Windows due to win32 files. That's a problem since rtc_base depends on repeating_task: //rtc_base:rtc_base -> //rtc_base/task_utils:repeating_task -> //system_wrappers:system_wrappers -> //rtc_base:rtc_base We could additionally consider moving Clock out of system_wrappers. Bug: webrtc:9987 Change-Id: I54ed715ad5eb9e3f5dd6c322233c18c05d895dff Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/185506 Reviewed-by: Mirko Bonadei Commit-Queue: Tommi Cr-Commit-Position: refs/heads/master@{#32203} --- examples/BUILD.gn | 5 ++- modules/audio_device/BUILD.gn | 1 + modules/desktop_capture/BUILD.gn | 33 ++++++++------ rtc_base/BUILD.gn | 74 ++++++++++++++++---------------- system_wrappers/BUILD.gn | 2 +- test/BUILD.gn | 4 +- 6 files changed, 65 insertions(+), 54 deletions(-) diff --git a/examples/BUILD.gn b/examples/BUILD.gn index ad05571da0..86b06cd65d 100644 --- a/examples/BUILD.gn +++ b/examples/BUILD.gn @@ -689,7 +689,10 @@ if (is_linux || is_chromeos || is_win) { "peerconnection/client/main_wnd.h", ] configs += [ "//build/config/win:windowed" ] - deps += [ "../media:rtc_media_base" ] + deps += [ + "../media:rtc_media_base", + "../rtc_base:win32", + ] } if (is_linux || is_chromeos) { sources += [ diff --git a/modules/audio_device/BUILD.gn b/modules/audio_device/BUILD.gn index 819a8668e3..4f701e4be8 100644 --- a/modules/audio_device/BUILD.gn +++ b/modules/audio_device/BUILD.gn @@ -317,6 +317,7 @@ rtc_library("audio_device_impl") { "msdmo.lib", "oleaut32.lib", ] + deps += [ "../../rtc_base:win32" ] } configs += [ ":audio_device_warnings_config" ] } diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn index eb57a465dd..a45c339de8 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn @@ -76,6 +76,9 @@ if (rtc_include_tests) { "window_finder_unittest.cc", ] public_configs = [ ":x11_config" ] + if (is_win) { + deps += [ "../../rtc_base:win32" ] + } } } @@ -412,6 +415,21 @@ rtc_library("desktop_capture_generic") { ] } + deps = [ + ":primitives", + "../../api:function_view", + "../../api:refcountedbase", + "../../api:scoped_refptr", + "../../rtc_base", # TODO(kjellander): Cleanup in bugs.webrtc.org/3806. + "../../rtc_base:checks", + "../../rtc_base/synchronization:mutex", + "../../rtc_base/synchronization:rw_lock_wrapper", + "../../rtc_base/system:arch", + "../../rtc_base/system:rtc_export", + "../../system_wrappers", + "../../system_wrappers:metrics", + ] + if (is_win) { sources += [ "cropping_window_capturer_win.cc", @@ -472,22 +490,9 @@ rtc_library("desktop_capture_generic") { "d3d11.lib", "dxgi.lib", ] + deps += [ "../../rtc_base:win32" ] } - deps = [ - ":primitives", - "../../api:function_view", - "../../api:refcountedbase", - "../../api:scoped_refptr", - "../../rtc_base", # TODO(kjellander): Cleanup in bugs.webrtc.org/3806. - "../../rtc_base:checks", - "../../rtc_base/synchronization:mutex", - "../../rtc_base/synchronization:rw_lock_wrapper", - "../../rtc_base/system:arch", - "../../rtc_base/system:rtc_export", - "../../system_wrappers", - "../../system_wrappers:metrics", - ] absl_deps = [ "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index 4e33aa5f93..e3b4581385 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -784,12 +784,26 @@ if (is_android) { if (is_win) { rtc_source_set("win32") { - # TODO(bugs.webrtc.org/9987): This build target will soon contain - # the following files: - # sources = [ - # "win32.cc", - # "win32.h", - # ] + sources = [ + "win32.cc", + "win32.h", + "win32_window.cc", + "win32_window.h", + ] + + deps = [ + ":checks", + ":macromagic", + ":rtc_base_approved", + ] + + libs = [ + "crypt32.lib", + "iphlpapi.lib", + "secur32.lib", + ] + + defines = [ "_CRT_NONSTDC_NO_DEPRECATE" ] } } @@ -1004,20 +1018,7 @@ rtc_library("rtc_base") { } if (is_win) { - sources += [ - "win32.cc", - "win32.h", - "win32_window.cc", - "win32_window.h", - ] - - libs += [ - "crypt32.lib", - "iphlpapi.lib", - "secur32.lib", - ] - - defines += [ "_CRT_NONSTDC_NO_DEPRECATE" ] + deps += [ ":win32" ] } if (is_posix || is_fuchsia) { @@ -1406,22 +1407,6 @@ if (rtc_include_tests) { "thread_unittest.cc", "unique_id_generator_unittest.cc", ] - if (is_win) { - sources += [ - "win32_unittest.cc", - "win32_window_unittest.cc", - ] - } - if (is_posix || is_fuchsia) { - sources += [ - "openssl_adapter_unittest.cc", - "openssl_session_cache_unittest.cc", - "openssl_utility_unittest.cc", - "ssl_adapter_unittest.cc", - "ssl_identity_unittest.cc", - "ssl_stream_adapter_unittest.cc", - ] - } deps = [ ":checks", ":gunit_helpers", @@ -1442,6 +1427,23 @@ if (rtc_include_tests) { "task_utils:to_queued_task", "third_party/sigslot", ] + if (is_win) { + sources += [ + "win32_unittest.cc", + "win32_window_unittest.cc", + ] + deps += [ ":win32" ] + } + if (is_posix || is_fuchsia) { + sources += [ + "openssl_adapter_unittest.cc", + "openssl_session_cache_unittest.cc", + "openssl_utility_unittest.cc", + "ssl_adapter_unittest.cc", + "ssl_identity_unittest.cc", + "ssl_stream_adapter_unittest.cc", + ] + } absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn index 769e5307e9..b4466482c1 100644 --- a/system_wrappers/BUILD.gn +++ b/system_wrappers/BUILD.gn @@ -71,7 +71,7 @@ rtc_library("system_wrappers") { # Windows needs ../rtc_base due to include of # webrtc/rtc_base/win32.h in source/clock.cc. - deps += [ "../rtc_base" ] + deps += [ "../rtc_base:win32" ] } deps += [ diff --git a/test/BUILD.gn b/test/BUILD.gn index 9cf54228a0..300a083832 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -638,7 +638,7 @@ rtc_library("fileutils") { deps += [ ":fileutils_mac_objc" ] } if (is_win) { - deps += [ "../rtc_base" ] + deps += [ "../rtc_base:win32" ] } } @@ -667,7 +667,7 @@ rtc_library("fileutils_override_impl") { deps += [ ":fileutils_mac_objc" ] } if (is_win) { - deps += [ "../rtc_base" ] + deps += [ "../rtc_base:win32" ] } }