From 028248cbd7273f57c6f0ad69fbadc254f0f1fe94 Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Wed, 10 Oct 2018 12:19:02 +0200 Subject: [PATCH] Add `rtc_enable_symbol_export` to incrementally create a WebRTC component. In order to implement a WebRTC component in Chromium, WebRTC needs to export some symbols. If RTC_EXPORT relies on COMPONENT_BUILD to mark symbols as exported or imported, it will not be possible to incrementally add RTC_EXPORT because the Chromium build will break (two Chromium components that export a symbol or no component that exports it). By using `rtc_enable_symbol_export` (which makes GN define WEBRTC_ENABLE_SYMBOL_EXPORT), WebRTC will be able to incrementally mark symbols with RTC_EXPORT and flip the value of `rtc_enable_symbol_export` in the Chromium build when everything will be ready. Bug: webrtc:9419 Change-Id: I57ab63c53545c500eaaefd75c112b4674aa7cf19 Reviewed-on: https://webrtc-review.googlesource.com/c/104980 Commit-Queue: Mirko Bonadei Reviewed-by: Karl Wiberg Reviewed-by: Niels Moller Cr-Commit-Position: refs/heads/master@{#25087} --- BUILD.gn | 4 ++++ rtc_base/system/rtc_export.h | 4 ++-- webrtc.gni | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 3be28fe6e0..107cde7bc1 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -97,6 +97,10 @@ config("common_inherited_config") { cflags = [] ldflags = [] + if (rtc_enable_symbol_export) { + defines = [ "WEBRTC_ENABLE_SYMBOL_EXPORT" ] + } + if (build_with_mozilla) { defines += [ "WEBRTC_MOZILLA_BUILD" ] } diff --git a/rtc_base/system/rtc_export.h b/rtc_base/system/rtc_export.h index b7a0fe4168..d1eb60ad78 100644 --- a/rtc_base/system/rtc_export.h +++ b/rtc_base/system/rtc_export.h @@ -16,7 +16,7 @@ // When WebRTC is built as a static library the RTC_EXPORT macro expands to // nothing. -#ifdef COMPONENT_BUILD +#ifdef WEBRTC_ENABLE_SYMBOL_EXPORT #ifdef WEBRTC_WIN @@ -34,7 +34,7 @@ #endif // WEBRTC_WIN -#endif // COMPONENT_BUILD +#endif // WEBRTC_ENABLE_SYMBOL_EXPORT #ifndef RTC_EXPORT #define RTC_EXPORT diff --git a/webrtc.gni b/webrtc.gni index 71c830e2bc..bba336912d 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -35,6 +35,10 @@ if (is_mac) { } declare_args() { + # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h) + # expand to code that will manage symbols visibility. + rtc_enable_symbol_export = false + # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which # will tell the pre-processor to remove the default definition of symbols # needed to use field_trial. In that case a new implementation needs to be