Use source_sets in component builds and static_library in release builds.
Static libraries don't guarantee that an exported symbol gets linked
into a shared library (and in order to support Chromium's component
build mode, WebRTC needs to be linked as a shared library).
Source sets always pass all the object files to the linker.
On the flip side, source_sets link more object files in release builds
and to avoid this, this CL introduces a the GN template "rtc_library" that
expands to static_library during release builds and to source_set during
component builds.
See: https://gn.googlesource.com/gn/+/master/docs/reference.md#func_source_set
Bug: webrtc:9419
Change-Id: I4667e820c2b3fcec417becbd2034acc13e4f04fe
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/157168
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#29525}
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 2c8a114..08b30d1 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -27,7 +27,7 @@
}
}
-rtc_source_set("media_constraints") {
+rtc_library("media_constraints") {
sources = [
"media_constraints.cc",
"media_constraints.h",
@@ -39,7 +39,7 @@
]
}
-rtc_source_set("sdk_tests") {
+rtc_library("sdk_tests") {
testonly = true
sources = [
"media_constraints_unittest.cc",
@@ -81,7 +81,7 @@
# TODO(bugs.webrtc.org/9627): Remove this when unused. Targets should depend on base_objc
# or helpers_objc directly instead.
- rtc_static_library("common_objc") {
+ rtc_library("common_objc") {
visibility = [ "*" ]
sources = [
@@ -96,7 +96,7 @@
]
}
- rtc_static_library("base_objc") {
+ rtc_library("base_objc") {
visibility = [ "*" ]
sources = [
"objc/base/RTCCodecSpecificInfo.h",
@@ -141,7 +141,7 @@
public_configs = [ ":common_config_objc" ]
}
- rtc_static_library("helpers_objc") {
+ rtc_library("helpers_objc") {
sources = [
"objc/helpers/AVCaptureSession+DevicePosition.h",
"objc/helpers/AVCaptureSession+DevicePosition.mm",
@@ -181,7 +181,7 @@
}
if (!build_with_chromium) {
- rtc_static_library("callback_logger_objc") {
+ rtc_library("callback_logger_objc") {
sources = [
"objc/api/logging/RTCCallbackLogger.h",
"objc/api/logging/RTCCallbackLogger.mm",
@@ -200,7 +200,7 @@
]
}
- rtc_static_library("file_logger_objc") {
+ rtc_library("file_logger_objc") {
sources = [
"objc/api/peerconnection/RTCFileLogger.h",
"objc/api/peerconnection/RTCFileLogger.mm",
@@ -222,7 +222,7 @@
if (!build_with_chromium) {
if (is_ios) {
- rtc_static_library("native_api_audio_device_module") {
+ rtc_library("native_api_audio_device_module") {
visibility = [ "*" ]
sources = [
@@ -252,7 +252,7 @@
]
}
- rtc_static_library("audio_device") {
+ rtc_library("audio_device") {
visibility = [ "*" ]
sources = [
@@ -286,7 +286,7 @@
libs = [ "AudioToolbox.framework" ]
}
- rtc_static_library("audio_objc") {
+ rtc_library("audio_objc") {
sources = [
"objc/components/audio/RTCAudioSession+Configuration.mm",
"objc/components/audio/RTCAudioSession+Private.h",
@@ -317,7 +317,7 @@
}
}
- rtc_static_library("videosource_objc") {
+ rtc_library("videosource_objc") {
sources = [
"objc/api/peerconnection/RTCVideoSource+Private.h",
"objc/api/peerconnection/RTCVideoSource.h",
@@ -347,7 +347,7 @@
]
}
- rtc_static_library("videoframebuffer_objc") {
+ rtc_library("videoframebuffer_objc") {
visibility = [ "*" ]
sources = [
"objc/api/video_frame_buffer/RTCNativeI420Buffer+Private.h",
@@ -379,7 +379,7 @@
]
}
- rtc_static_library("video_objc") {
+ rtc_library("video_objc") {
sources = [
"objc/components/renderer/opengl/RTCDefaultShader.h",
"objc/components/renderer/opengl/RTCDefaultShader.mm",
@@ -431,7 +431,7 @@
]
}
- rtc_static_library("ui_objc") {
+ rtc_library("ui_objc") {
visibility = [ "*" ]
allow_poison = [ "audio_codecs" ] # TODO(bugs.webrtc.org/8396): Remove.
if (is_ios) {
@@ -459,7 +459,7 @@
}
if (rtc_use_metal_rendering) {
- rtc_static_library("metal_objc") {
+ rtc_library("metal_objc") {
visibility = [ "*" ]
allow_poison = [
"audio_codecs", # TODO(bugs.webrtc.org/8396): Remove.
@@ -510,7 +510,7 @@
}
# TODO(bugs.webrtc.org/9627): Remove this target.
- rtc_static_library("videocapturebase_objc") {
+ rtc_library("videocapturebase_objc") {
visibility = [ "*" ]
sources = [
"objc/helpers/noop.mm",
@@ -526,7 +526,7 @@
]
}
- rtc_static_library("videocapture_objc") {
+ rtc_library("videocapture_objc") {
visibility = [ "*" ]
allow_poison = [ "audio_codecs" ] # TODO(bugs.webrtc.org/8396): Remove.
sources = [
@@ -556,7 +556,7 @@
]
}
- rtc_static_library("videocodec_objc") {
+ rtc_library("videocodec_objc") {
visibility = [ "*" ]
configs += [ "..:no_global_constructors" ]
sources = [
@@ -588,7 +588,7 @@
]
}
- rtc_static_library("default_codec_factory_objc") {
+ rtc_library("default_codec_factory_objc") {
sources = [
"objc/components/video_codec/RTCDefaultVideoDecoderFactory.h",
"objc/components/video_codec/RTCDefaultVideoDecoderFactory.m",
@@ -607,7 +607,7 @@
]
}
- rtc_static_library("vpx_codec_constants") {
+ rtc_library("vpx_codec_constants") {
configs += [ "..:no_global_constructors" ]
sources = [
"objc/api/video_codec/RTCVideoCodecConstants.h",
@@ -620,7 +620,7 @@
]
}
- rtc_static_library("vp8") {
+ rtc_library("vp8") {
visibility = [ "*" ]
allow_poison = [ "software_video_codecs" ]
sources = [
@@ -637,7 +637,7 @@
]
}
- rtc_static_library("vp9") {
+ rtc_library("vp9") {
visibility = [ "*" ]
allow_poison = [ "software_video_codecs" ]
sources = [
@@ -662,7 +662,7 @@
# when implementing webrtc::PeerConnectionFactoryInterface and
# webrtc::PeerConnectionInterface.
# The applications which only use WebRTC DataChannel can depend on this.
- rtc_static_library("peerconnectionfactory_no_media_objc") {
+ rtc_library("peerconnectionfactory_no_media_objc") {
visibility = [ "*" ]
allow_poison = [
"audio_codecs", # TODO(bugs.webrtc.org/8396): Remove.
@@ -685,7 +685,7 @@
]
}
- rtc_static_library("mediaconstraints_objc") {
+ rtc_library("mediaconstraints_objc") {
configs += [ "..:no_global_constructors" ]
sources = [
"objc/api/peerconnection/RTCMediaConstraints+Private.h",
@@ -702,7 +702,7 @@
}
# TODO(bugs.webrtc.org/9627): Remove, targets should depend on base_objc.
- rtc_source_set("videorenderer_objc") {
+ rtc_library("videorenderer_objc") {
visibility = [ "*" ]
sources = [
"objc/helpers/noop.mm",
@@ -716,7 +716,7 @@
]
}
- rtc_static_library("videorendereradapter_objc") {
+ rtc_library("videorendereradapter_objc") {
visibility = [ "*" ]
allow_poison = [ "audio_codecs" ] # TODO(bugs.webrtc.org/8396): Remove.
sources = [
@@ -737,7 +737,7 @@
]
}
- rtc_static_library("mediasource_objc") {
+ rtc_library("mediasource_objc") {
sources = [
"objc/api/peerconnection/RTCMediaSource+Private.h",
"objc/api/peerconnection/RTCMediaSource.h",
@@ -757,7 +757,7 @@
]
}
- rtc_static_library("base_native_additions_objc") {
+ rtc_library("base_native_additions_objc") {
sources = [
"objc/api/peerconnection/RTCEncodedImage+Private.h",
"objc/api/peerconnection/RTCEncodedImage+Private.mm",
@@ -784,7 +784,7 @@
]
}
- rtc_static_library("peerconnectionfactory_base_objc") {
+ rtc_library("peerconnectionfactory_base_objc") {
visibility = [ "*" ]
allow_poison = [
"audio_codecs", # TODO(bugs.webrtc.org/8396): Remove.
@@ -1045,7 +1045,7 @@
if (rtc_include_tests) {
if (is_ios) {
- rtc_source_set("sdk_unittests_sources") {
+ rtc_library("sdk_unittests_sources") {
testonly = true
include_dirs = [ "objc/" ]
@@ -1164,7 +1164,7 @@
}
# TODO(denicija): once all tests are migrated to xctest remove this source set.
- rtc_source_set("rtc_unittests_objc") {
+ rtc_library("rtc_unittests_objc") {
testonly = true
sources = [
@@ -1523,7 +1523,7 @@
}
}
- rtc_static_library("wrapped_native_codec_objc") {
+ rtc_library("wrapped_native_codec_objc") {
sources = [
"objc/api/video_codec/RTCWrappedNativeVideoDecoder.h",
"objc/api/video_codec/RTCWrappedNativeVideoDecoder.mm",
@@ -1543,7 +1543,7 @@
}
# The native API is currently experimental and may change without notice.
- rtc_static_library("native_api") {
+ rtc_library("native_api") {
visibility = [ "*" ]
allow_poison = [ "audio_codecs" ] # TODO(bugs.webrtc.org/8396): Remove.
sources = [
@@ -1581,7 +1581,7 @@
]
}
- rtc_static_library("native_video") {
+ rtc_library("native_video") {
sources = [
"objc/native/src/objc_frame_buffer.h",
"objc/native/src/objc_frame_buffer.mm",
@@ -1623,7 +1623,7 @@
]
}
- rtc_static_library("video_toolbox_cc") {
+ rtc_library("video_toolbox_cc") {
visibility = [
":videotoolbox_objc",
":sdk_unittests_sources",
@@ -1643,7 +1643,7 @@
]
}
- rtc_static_library("videotoolbox_objc") {
+ rtc_library("videotoolbox_objc") {
visibility = [ "*" ]
allow_poison = [ "audio_codecs" ] # TODO(bugs.webrtc.org/8396): Remove.
sources = [