blob: 2aefe251b1462dc4de17436f287e564efd27700e [file] [log] [blame]
mbonadei9aa3f0a2017-01-24 06:58:22 -08001# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
2#
3# Use of this source code is governed by a BSD-style license
4# that can be found in the LICENSE file in the root of the source
5# tree. An additional intellectual property rights grant can be found
6# in the file PATENTS. All contributing project authors may
7# be found in the AUTHORS file in the root of the source tree.
mbonadei9aa3f0a2017-01-24 06:58:22 -08008import("//build/config/arm.gni")
9import("//build/config/features.gni")
10import("//build/config/mips.gni")
11import("//build/config/sanitizers/sanitizers.gni")
Tomas Popela318da512018-11-13 06:32:23 +010012import("//build/config/sysroot.gni")
ehmaldonado0d729b32017-02-10 01:38:23 -080013import("//build/config/ui.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -080014import("//build_overrides/build.gni")
mbonadei96606272017-03-03 19:41:59 -080015
16if (!build_with_chromium && is_component_build) {
17 print("The Gn argument `is_component_build` is currently " +
18 "ignored for WebRTC builds.")
19 print("Component builds are supported by Chromium and the argument " +
20 "`is_component_build` makes it possible to create shared libraries " +
21 "instead of static libraries.")
22 print("If an app depends on WebRTC it makes sense to just depend on the " +
23 "WebRTC static library, so there is no difference between " +
24 "`is_component_build=true` and `is_component_build=false`.")
25 print(
26 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.md")
27 assert(!is_component_build, "Component builds are not supported in WebRTC.")
28}
29
kthelgason4065a572017-02-14 04:58:56 -080030if (is_ios) {
31 import("//build/config/ios/rules.gni")
32}
mbonadei9aa3f0a2017-01-24 06:58:22 -080033
Anders Carlsson37bbf792018-09-05 16:29:27 +020034if (is_mac) {
35 import("//build/config/mac/rules.gni")
36}
37
mbonadei9aa3f0a2017-01-24 06:58:22 -080038declare_args() {
Mirko Bonadei028248c2018-10-10 12:19:02 +020039 # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h)
40 # expand to code that will manage symbols visibility.
41 rtc_enable_symbol_export = false
42
Mirko Bonadei31b0b452018-08-22 10:37:11 +020043 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 15:44:28 +020044 # will tell the pre-processor to remove the default definition of symbols
45 # needed to use field_trial. In that case a new implementation needs to be
46 # provided.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020047 if (build_with_chromium) {
48 # When WebRTC is built as part of Chromium it should exclude the default
49 # implementation of field_trial unless it is building for NACL or
50 # Chromecast.
51 rtc_exclude_field_trial_default = !is_nacl && !is_chromecast
52 } else {
53 rtc_exclude_field_trial_default = false
54 }
Mirko Bonadei70400902018-08-21 15:44:28 +020055
Mirko Bonadei906add42018-09-05 16:03:16 +020056 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
57 # will tell the pre-processor to remove the default definition of symbols
58 # needed to use metrics. In that case a new implementation needs to be
59 # provided.
60 rtc_exclude_metrics_default = build_with_chromium
61
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070062 # Setting this to false will require the API user to pass in their own
63 # SSLCertificateVerifier to verify the certificates presented from a
64 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
65 rtc_builtin_ssl_root_certificates = true
66
Karl Wibergeb254b42017-11-01 15:08:12 +010067 # Include the iLBC audio codec?
68 rtc_include_ilbc = true
69
mbonadei9aa3f0a2017-01-24 06:58:22 -080070 # Disable this to avoid building the Opus audio codec.
71 rtc_include_opus = true
72
minyue2e03c662017-02-01 17:31:11 -080073 # Enable this if the Opus version upon which WebRTC is built supports direct
74 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020075 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080076
mbonadei9aa3f0a2017-01-24 06:58:22 -080077 # Enable this to let the Opus audio codec change complexity on the fly.
78 rtc_opus_variable_complexity = false
79
mbonadei9aa3f0a2017-01-24 06:58:22 -080080 # Used to specify an external Jsoncpp include path when not compiling the
81 # library that comes with WebRTC (i.e. rtc_build_json == 0).
82 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
83
84 # Used to specify an external OpenSSL include path when not compiling the
85 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
86 rtc_ssl_root = ""
87
88 # Selects fixed-point code where possible.
89 rtc_prefer_fixed_point = false
90
mbonadei9aa3f0a2017-01-24 06:58:22 -080091 # Enable when an external authentication mechanism is used for performing
92 # packet authentication for RTP packets instead of libsrtp.
93 rtc_enable_external_auth = build_with_chromium
94
95 # Selects whether debug dumps for the audio processing module
96 # should be generated.
97 apm_debug_dump = false
98
99 # Set this to true to enable BWE test logging.
100 rtc_enable_bwe_test_logging = false
101
Joachim Bauch93e91342017-12-07 01:25:53 +0100102 # Set this to false to skip building examples.
103 rtc_build_examples = true
104
105 # Set this to false to skip building tools.
106 rtc_build_tools = true
107
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100108 # Set this to false to skip building code that requires X11.
109 rtc_use_x11 = use_x11
110
Tomas Popela318da512018-11-13 06:32:23 +0100111 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 14:37:51 +0100112 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
113 # only when using the sysroot as PipeWire is not available in older and
114 # supported Ubuntu and Debian distributions.
115 rtc_use_pipewire = is_desktop_linux && use_sysroot
116
117 # Set this to link PipeWire directly instead of using the dlopen.
118 rtc_link_pipewire = false
Tomas Popela318da512018-11-13 06:32:23 +0100119
mbonadei9aa3f0a2017-01-24 06:58:22 -0800120 # Enable to use the Mozilla internal settings.
121 build_with_mozilla = false
122
henrika883d00f2018-03-16 10:09:49 +0100123 # Enable use of Android AAudio which requires Android SDK 26 or above and
124 # NDK r16 or above.
125 rtc_enable_android_aaudio = false
126
mbonadei9aa3f0a2017-01-24 06:58:22 -0800127 # Set to "func", "block", "edge" for coverage generation.
128 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
129 # It is recommend to set include_examples=0.
130 # Use llvm's sancov -html-report for human readable reports.
131 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
132 rtc_sanitize_coverage = ""
133
mbonadei9aa3f0a2017-01-24 06:58:22 -0800134 if (current_cpu == "arm" || current_cpu == "arm64") {
135 rtc_prefer_fixed_point = true
136 }
137
mbonadei9aa3f0a2017-01-24 06:58:22 -0800138 # Determines whether NEON code will be built.
139 rtc_build_with_neon =
140 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
141
142 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
143 # all platforms except Android and iOS. Because FFmpeg can be built
144 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
145 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Sergey Silkinfe288eb2018-06-25 16:22:38 +0200146 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800147 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
148 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 10:47:18 +0100149 #
150 # Enabling H264 when building with MSVC is currently not supported, see
151 # bugs.webrtc.org/9213#c13 for more info.
152 rtc_use_h264 =
153 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800154
mbonadei9aa3f0a2017-01-24 06:58:22 -0800155 # By default, use normal platform audio support or dummy audio, but don't
156 # use file-based audio playout and record.
157 rtc_use_dummy_audio_file_devices = false
158
henrika7be78832017-06-13 17:34:16 +0200159 # When set to true, replace the audio output with a sinus tone at 440Hz.
160 # The ADM will ask for audio data from WebRTC but instead of reading real
161 # audio samples from NetEQ, a sinus tone will be generated and replace the
162 # real audio samples.
163 rtc_audio_device_plays_sinus_tone = false
164
Anders Carlsson358f2e02018-06-04 10:24:37 +0200165 if (is_ios) {
166 # Build broadcast extension in AppRTCMobile for iOS. This results in the
167 # binary only running on iOS 11+, which is why it is disabled by default.
168 rtc_apprtcmobile_broadcast_extension = false
169 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200170
171 # Determines whether Metal is available on iOS/macOS.
172 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
Jiawei Ou08745302019-02-12 11:36:13 -0800173
174 # When set to false, builtin audio encoder/decoder factories and all the
175 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
176 # (they will still be included in libjingle_peerconnection_so.so and
177 # WebRTC.framework)
178 rtc_include_builtin_audio_codecs = true
179
180 # When set to false, builtin video encoder/decoder factories and all the
181 # video codecs they depends on will not be included in libwebrtc.{a|lib}
182 # (they will still be included in libjingle_peerconnection_so.so and
183 # WebRTC.framework)
184 rtc_include_builtin_video_codecs = true
Mirko Bonadei20574f42019-03-28 07:50:07 +0100185
186 # When set to true and in a standalone build, it will undefine UNICODE and
187 # _UNICODE (which are always defined globally by the Chromium Windows
188 # toolchain).
189 # This is only needed for testing purposes, WebRTC wants to be sure it
190 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
191 # wide character functions.
192 rtc_win_undef_unicode = false
Dan Minor9c686132018-01-15 10:20:00 -0500193}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800194
Dan Minor9c686132018-01-15 10:20:00 -0500195if (!build_with_mozilla) {
196 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800197}
198
199# A second declare_args block, so that declarations within it can
200# depend on the possibly overridden variables in the first
201# declare_args block.
202declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500203 # Enables the use of protocol buffers for debug recordings.
204 rtc_enable_protobuf = !build_with_mozilla
205
206 # Set this to disable building with support for SCTP data channels.
207 rtc_enable_sctp = !build_with_mozilla
208
209 # Disable these to not build components which can be externally provided.
210 rtc_build_json = !build_with_mozilla
211 rtc_build_libsrtp = !build_with_mozilla
212 rtc_build_libvpx = !build_with_mozilla
213 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500214 rtc_build_opus = !build_with_mozilla
215 rtc_build_ssl = !build_with_mozilla
216 rtc_build_usrsctp = !build_with_mozilla
217
218 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 19:05:00 +0200219 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
220 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 10:20:00 -0500221 rtc_enable_libevent = false
222 rtc_build_libevent = false
223 } else {
224 rtc_enable_libevent = true
225 rtc_build_libevent = !build_with_mozilla
226 }
227
Dan Minor9c686132018-01-15 10:20:00 -0500228 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
229 # build environments, even if available for Chromium builds.
230 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
231
mbonadei9aa3f0a2017-01-24 06:58:22 -0800232 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
233 rtc_include_pulse_audio = !build_with_chromium
234
235 # Chromium uses its own IO handling, so the internal ADM is only built for
236 # standalone WebRTC.
237 rtc_include_internal_audio_device = !build_with_chromium
238
239 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500240 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 13:27:07 +0200241
242 # Set this to false to skip building code that also requires X11 extensions
243 # such as Xdamage, Xfixes.
244 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 16:24:46 +0100245
246 # Set this to true to fully remove logging from WebRTC.
247 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 14:24:31 +0100248
249 # Set this to true to disable trace events.
250 rtc_disable_trace_events = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800251}
252
253# Make it possible to provide custom locations for some libraries (move these
254# up into declare_args should we need to actually use them for the GN build).
255rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800256rtc_opus_dir = "//third_party/opus"
257
258# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200259rtc_desktop_capture_supported =
260 (is_win && current_os != "winuwp") || is_mac ||
261 (is_linux && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800262
263###############################################################################
264# Templates
265#
266
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200267# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800268# chromium.
269# We need absolute paths for all configs in templates as they are shared in
270# different subdirectories.
271webrtc_root = get_path_info(".", "abspath")
272
273# Global configuration that should be applied to all WebRTC targets.
274# You normally shouldn't need to include this in your target as it's
275# automatically included when using the rtc_* templates.
276# It sets defines, include paths and compilation warnings accordingly,
277# both for WebRTC stand-alone builds and for the scenario when WebRTC
278# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700279rtc_common_configs = [
280 webrtc_root + ":common_config",
281 "//build/config/compiler:no_size_t_to_int_warning",
282]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800283
kthelgasonc0977102017-04-24 00:57:16 -0700284if (is_mac || is_ios) {
285 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
286}
287
mbonadei9aa3f0a2017-01-24 06:58:22 -0800288# Global public configuration that should be applied to all WebRTC targets. You
289# normally shouldn't need to include this in your target as it's automatically
290# included when using the rtc_* templates. It set the defines, include paths and
291# compilation warnings that should be propagated to dependents of the targets
292# depending on the target having this config.
293rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
294
295# Common configs to remove or add in all rtc targets.
296rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100297if (!build_with_chromium && is_clang) {
298 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
299}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800300rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200301rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200302rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800303
304set_defaults("rtc_test") {
305 configs = rtc_add_configs
306 suppressed_configs = []
307}
308
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200309set_defaults("rtc_library") {
310 configs = rtc_add_configs
311 suppressed_configs = []
312}
313
mbonadei9aa3f0a2017-01-24 06:58:22 -0800314set_defaults("rtc_source_set") {
315 configs = rtc_add_configs
316 suppressed_configs = []
317}
318
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200319set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800320 configs = rtc_add_configs
321 suppressed_configs = []
322}
323
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200324set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800325 configs = rtc_add_configs
326 suppressed_configs = []
327}
328
329set_defaults("rtc_shared_library") {
330 configs = rtc_add_configs
331 suppressed_configs = []
332}
333
Per Kjellandera7f2d842018-01-10 15:54:53 +0000334webrtc_default_visibility = [ webrtc_root + "/*" ]
335if (build_with_chromium) {
336 # Allow Chromium's WebRTC overrides targets to bypass the regular
337 # visibility restrictions.
338 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
339}
340
Karl Wibergbb23c832018-04-22 19:55:00 +0200341# ---- Poisons ----
342#
343# The general idea is that some targets declare that they contain some
344# kind of poison, which makes it impossible for other targets to
345# depend on them (even transitively) unless they declare themselves
346# immune to that particular type of poison.
347#
348# Targets that *contain* poison of type foo should contain the line
349#
350# poisonous = [ "foo" ]
351#
352# and targets that *are immune but arent't themselves poisonous*
353# should contain
354#
355# allow_poison = [ "foo" ]
356#
357# This useful in cases where we have some large target or set of
358# targets and want to ensure that most other targets do not
359# transitively depend on them. For example, almost no high-level
360# target should depend on the audio codecs, since we want WebRTC users
361# to be able to inject any subset of them and actually end up with a
362# binary that doesn't include the codecs they didn't inject.
363#
364# Test-only targets (`testonly` set to true) and non-public targets
365# (`visibility` not containing "*") are automatically immune to all
366# types of poison.
367#
368# Here's the complete list of all types of poison. It must be kept in
369# 1:1 correspondence with the set of //:poison_* targets.
370#
371all_poison_types = [
372 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
373 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200374
Danil Chapovalov41300af2019-07-10 12:44:43 +0200375 # Default task queue implementation.
376 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 10:45:58 +0200377
378 # JSON parsing should not be needed in the "slim and modular" WebRTC.
379 "rtc_json",
380
381 # Software video codecs (VP8 and VP9 through libvpx).
382 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200383]
384
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000385absl_include_config = "//third_party/abseil-cpp:absl_include_config"
386absl_define_config = "//third_party/abseil-cpp:absl_define_config"
387
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200388# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
389# that are testonly.
390absl_flags_config = webrtc_root + ":absl_flags_configs"
391
mbonadei9aa3f0a2017-01-24 06:58:22 -0800392template("rtc_test") {
393 test(target_name) {
394 forward_variables_from(invoker,
395 "*",
396 [
397 "configs",
398 "public_configs",
399 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200400 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800401 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100402
403 # Always override to public because when target_os is Android the `test`
404 # template can override it to [ "*" ] and we want to avoid conditional
405 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100406 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800407 configs += invoker.configs
408 configs -= rtc_remove_configs
409 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000410 public_configs = [
411 rtc_common_inherited_config,
412 absl_include_config,
413 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200414 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000415 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800416 if (defined(invoker.public_configs)) {
417 public_configs += invoker.public_configs
418 }
sakald7fdb802017-05-26 01:51:53 -0700419 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800420 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Oleh Prypina79abd42019-06-25 23:19:17 +0200421 min_sdk_version = 16
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800422 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700423 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800424 }
425}
426
427template("rtc_source_set") {
428 source_set(target_name) {
429 forward_variables_from(invoker,
430 "*",
431 [
432 "configs",
433 "public_configs",
434 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200435 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800436 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200437 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000438 if (!defined(visibility)) {
439 visibility = webrtc_default_visibility
440 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200441
442 # What's your poison?
443 if (defined(testonly) && testonly) {
444 assert(!defined(poisonous))
445 assert(!defined(allow_poison))
446 } else {
447 if (!defined(poisonous)) {
448 poisonous = []
449 }
450 if (!defined(allow_poison)) {
451 allow_poison = []
452 }
453 if (!defined(assert_no_deps)) {
454 assert_no_deps = []
455 }
456 if (!defined(deps)) {
457 deps = []
458 }
459 foreach(p, poisonous) {
460 deps += [ webrtc_root + ":poison_" + p ]
461 }
462 foreach(poison_type, all_poison_types) {
463 allow_dep = true
464 foreach(v, visibility) {
465 if (v == "*") {
466 allow_dep = false
467 }
468 }
469 foreach(p, allow_poison + poisonous) {
470 if (p == poison_type) {
471 allow_dep = true
472 }
473 }
474 if (!allow_dep) {
475 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
476 }
477 }
478 }
479
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100480 # Chromium should only depend on the WebRTC component in order to
481 # avoid to statically link WebRTC in a component build.
482 if (build_with_chromium) {
483 publicly_visible = false
484 foreach(v, visibility) {
485 if (v == "*") {
486 publicly_visible = true
487 }
488 }
489 if (publicly_visible) {
490 visibility = []
491 visibility = webrtc_default_visibility
492 }
493 }
494
Mirko Bonadei96ede162018-09-06 13:45:44 +0200495 if (!defined(testonly) || !testonly) {
496 configs += rtc_prod_configs
497 }
498
mbonadei9aa3f0a2017-01-24 06:58:22 -0800499 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200500 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800501 configs -= rtc_remove_configs
502 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000503 public_configs = [
504 rtc_common_inherited_config,
505 absl_include_config,
506 absl_define_config,
507 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200508 if (defined(testonly) && testonly) {
509 public_configs += [ absl_flags_config ]
510 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800511 if (defined(invoker.public_configs)) {
512 public_configs += invoker.public_configs
513 }
514 }
515}
516
mbonadei9aa3f0a2017-01-24 06:58:22 -0800517template("rtc_static_library") {
518 static_library(target_name) {
519 forward_variables_from(invoker,
520 "*",
521 [
522 "configs",
523 "public_configs",
524 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200525 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800526 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200527 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000528 if (!defined(visibility)) {
529 visibility = webrtc_default_visibility
530 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200531
532 # What's your poison?
533 if (defined(testonly) && testonly) {
534 assert(!defined(poisonous))
535 assert(!defined(allow_poison))
536 } else {
537 if (!defined(poisonous)) {
538 poisonous = []
539 }
540 if (!defined(allow_poison)) {
541 allow_poison = []
542 }
543 if (!defined(assert_no_deps)) {
544 assert_no_deps = []
545 }
546 if (!defined(deps)) {
547 deps = []
548 }
549 foreach(p, poisonous) {
550 deps += [ webrtc_root + ":poison_" + p ]
551 }
552 foreach(poison_type, all_poison_types) {
553 allow_dep = true
554 foreach(v, visibility) {
555 if (v == "*") {
556 allow_dep = false
557 }
558 }
559 foreach(p, allow_poison + poisonous) {
560 if (p == poison_type) {
561 allow_dep = true
562 }
563 }
564 if (!allow_dep) {
565 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
566 }
567 }
568 }
569
Mirko Bonadei96ede162018-09-06 13:45:44 +0200570 if (!defined(testonly) || !testonly) {
571 configs += rtc_prod_configs
572 }
573
mbonadei9aa3f0a2017-01-24 06:58:22 -0800574 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200575 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800576 configs -= rtc_remove_configs
577 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000578 public_configs = [
579 rtc_common_inherited_config,
580 absl_include_config,
581 absl_define_config,
582 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200583 if (defined(testonly) && testonly) {
584 public_configs += [ absl_flags_config ]
585 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800586 if (defined(invoker.public_configs)) {
587 public_configs += invoker.public_configs
588 }
589 }
590}
591
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200592# This template automatically switches the target type between source_set
593# and static_library.
594#
595# This should be the default target type for all the WebRTC targets with
596# one exception. Do not use this template for header only targets, in that case
597# rtc_source_set must be used in order to avoid build errors (e.g. libtool
598# complains if the output .a file is empty).
599#
600# How does it work:
601# Since all files in a source_set are linked into a final binary, while files
602# in a static library are only linked in if at least one symbol in them is
603# referenced, in component builds source_sets are easy to deal with because
604# all their object files are passed to the linker to create a shared library.
605# In release builds instead, static_libraries are preferred since they allow
606# the linker to discard dead code.
607# For the same reason, testonly targets will always be expanded to
608# source_set in order to be sure that tests are present in the test binary.
609template("rtc_library") {
610 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
611 target_type = "source_set"
612 } else {
613 target_type = "static_library"
614 }
615 target(target_type, target_name) {
616 forward_variables_from(invoker,
617 "*",
618 [
619 "configs",
620 "public_configs",
621 "suppressed_configs",
622 "visibility",
623 ])
624 forward_variables_from(invoker, [ "visibility" ])
625 if (!defined(visibility)) {
626 visibility = webrtc_default_visibility
627 }
628
629 # What's your poison?
630 if (defined(testonly) && testonly) {
631 assert(!defined(poisonous))
632 assert(!defined(allow_poison))
633 } else {
634 if (!defined(poisonous)) {
635 poisonous = []
636 }
637 if (!defined(allow_poison)) {
638 allow_poison = []
639 }
640 if (!defined(assert_no_deps)) {
641 assert_no_deps = []
642 }
643 if (!defined(deps)) {
644 deps = []
645 }
646 foreach(p, poisonous) {
647 deps += [ webrtc_root + ":poison_" + p ]
648 }
649 foreach(poison_type, all_poison_types) {
650 allow_dep = true
651 foreach(v, visibility) {
652 if (v == "*") {
653 allow_dep = false
654 }
655 }
656 foreach(p, allow_poison + poisonous) {
657 if (p == poison_type) {
658 allow_dep = true
659 }
660 }
661 if (!allow_dep) {
662 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
663 }
664 }
665 }
666
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100667 # Chromium should only depend on the WebRTC component in order to
668 # avoid to statically link WebRTC in a component build.
669 if (build_with_chromium) {
670 publicly_visible = false
671 foreach(v, visibility) {
672 if (v == "*") {
673 publicly_visible = true
674 }
675 }
676 if (publicly_visible) {
677 visibility = []
678 visibility = webrtc_default_visibility
679 }
680 }
681
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200682 if (!defined(testonly) || !testonly) {
683 configs += rtc_prod_configs
684 }
685
686 configs += invoker.configs
687 configs += rtc_library_impl_config
688 configs -= rtc_remove_configs
689 configs -= invoker.suppressed_configs
690 public_configs = [
691 rtc_common_inherited_config,
692 absl_include_config,
693 absl_define_config,
694 ]
695 if (defined(testonly) && testonly) {
696 public_configs += [ absl_flags_config ]
697 }
698 if (defined(invoker.public_configs)) {
699 public_configs += invoker.public_configs
700 }
701 }
702}
703
704template("rtc_executable") {
705 executable(target_name) {
706 forward_variables_from(invoker,
707 "*",
708 [
709 "deps",
710 "configs",
711 "public_configs",
712 "suppressed_configs",
713 "visibility",
714 ])
715 forward_variables_from(invoker, [ "visibility" ])
716 if (!defined(visibility)) {
717 visibility = webrtc_default_visibility
718 }
719 configs += invoker.configs
720 configs -= rtc_remove_configs
721 configs -= invoker.suppressed_configs
722 deps = invoker.deps
723
724 public_configs = [
725 rtc_common_inherited_config,
726 absl_include_config,
727 absl_define_config,
728 ]
729 if (defined(testonly) && testonly) {
730 public_configs += [ absl_flags_config ]
731 }
732 if (defined(invoker.public_configs)) {
733 public_configs += invoker.public_configs
734 }
735 if (is_win) {
736 deps += [
737 # Give executables the default manifest on Windows (a no-op elsewhere).
738 "//build/win:default_exe_manifest",
739 ]
740 }
741 }
742}
743
mbonadei9aa3f0a2017-01-24 06:58:22 -0800744template("rtc_shared_library") {
745 shared_library(target_name) {
746 forward_variables_from(invoker,
747 "*",
748 [
749 "configs",
750 "public_configs",
751 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200752 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800753 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200754 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000755 if (!defined(visibility)) {
756 visibility = webrtc_default_visibility
757 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200758
759 # What's your poison?
760 if (defined(testonly) && testonly) {
761 assert(!defined(poisonous))
762 assert(!defined(allow_poison))
763 } else {
764 if (!defined(poisonous)) {
765 poisonous = []
766 }
767 if (!defined(allow_poison)) {
768 allow_poison = []
769 }
770 if (!defined(assert_no_deps)) {
771 assert_no_deps = []
772 }
773 if (!defined(deps)) {
774 deps = []
775 }
776 foreach(p, poisonous) {
777 deps += [ webrtc_root + ":poison_" + p ]
778 }
779 foreach(poison_type, all_poison_types) {
780 allow_dep = true
781 foreach(v, visibility) {
782 if (v == "*") {
783 allow_dep = false
784 }
785 }
786 foreach(p, allow_poison + poisonous) {
787 if (p == poison_type) {
788 allow_dep = true
789 }
790 }
791 if (!allow_dep) {
792 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
793 }
794 }
795 }
796
mbonadei9aa3f0a2017-01-24 06:58:22 -0800797 configs += invoker.configs
798 configs -= rtc_remove_configs
799 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000800 public_configs = [
801 rtc_common_inherited_config,
802 absl_include_config,
803 absl_define_config,
804 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200805 if (defined(testonly) && testonly) {
806 public_configs += [ absl_flags_config ]
807 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800808 if (defined(invoker.public_configs)) {
809 public_configs += invoker.public_configs
810 }
811 }
812}
kthelgason4065a572017-02-14 04:58:56 -0800813
814if (is_ios) {
815 set_defaults("rtc_ios_xctest_test") {
816 configs = rtc_add_configs
817 suppressed_configs = []
818 }
819
820 template("rtc_ios_xctest_test") {
821 ios_xctest_test(target_name) {
822 forward_variables_from(invoker,
823 "*",
824 [
825 "configs",
826 "public_configs",
827 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200828 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800829 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200830 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000831 if (!defined(visibility)) {
832 visibility = webrtc_default_visibility
833 }
kthelgason4065a572017-02-14 04:58:56 -0800834 configs += invoker.configs
835 configs -= rtc_remove_configs
836 configs -= invoker.suppressed_configs
837 public_configs = [ rtc_common_inherited_config ]
838 if (defined(invoker.public_configs)) {
839 public_configs += invoker.public_configs
840 }
841 }
842 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100843
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400844 # TODO: Generate module.modulemap file to enable use in Swift
845 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100846 template("ios_framework_bundle_with_umbrella_header") {
847 forward_variables_from(invoker, [ "output_name" ])
848 umbrella_header_path =
849 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
850
851 ios_framework_bundle(target_name) {
852 forward_variables_from(invoker, "*", [])
853
854 deps += [ ":copy_umbrella_header_$target_name" ]
855 }
856
857 action("umbrella_header_$target_name") {
858 forward_variables_from(invoker, [ "public_headers" ])
859
860 script = "//tools_webrtc/ios/generate_umbrella_header.py"
861
862 outputs = [
863 umbrella_header_path,
864 ]
865 args = [
866 "--out",
867 rebase_path(umbrella_header_path, root_build_dir),
868 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200869 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100870 }
871
872 copy("copy_umbrella_header_$target_name") {
873 sources = [
874 umbrella_header_path,
875 ]
876 outputs = [
877 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
878 ]
879
880 deps = [
881 ":umbrella_header_$target_name",
882 ]
883 }
884 }
885
886 set_defaults("ios_framework_bundle_with_umbrella_header") {
887 configs = default_shared_library_configs
888 }
kthelgason4065a572017-02-14 04:58:56 -0800889}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000890
Anders Carlsson37bbf792018-09-05 16:29:27 +0200891if (is_mac) {
892 template("mac_framework_bundle_with_umbrella_header") {
893 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200894 this_target_name = target_name
895 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400896 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200897
898 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -0800899 forward_variables_from(invoker, "*", [ "configs" ])
900 if (defined(invoker.configs)) {
901 configs += invoker.configs
902 }
Anders Carlsson37bbf792018-09-05 16:29:27 +0200903
904 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400905 framework_contents = [
906 "Headers",
907 "Modules",
908 "Resources",
909 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +0200910
911 ldflags = [
912 "-all_load",
913 "-install_name",
914 "@rpath/$output_name.framework/$output_name",
915 ]
916
917 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200918 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400919 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200920 ":copy_umbrella_header_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400921 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200922 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200923 ]
924 }
925
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200926 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200927 forward_variables_from(invoker, [ "sources" ])
928
929 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200930 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200931 ]
932 }
933
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400934 action("modulemap_$this_target_name") {
935 script = "//tools_webrtc/ios/generate_modulemap.py"
936 args = [
937 "--out",
938 rebase_path(modulemap_path, root_build_dir),
939 "--name",
940 output_name,
941 ]
942 outputs = [
943 modulemap_path,
944 ]
945 }
946
947 bundle_data("copy_modulemap_$this_target_name") {
948 sources = [
949 modulemap_path,
950 ]
951 outputs = [
952 "{{bundle_contents_dir}}/Modules/module.modulemap",
953 ]
954 deps = [
955 ":modulemap_$this_target_name",
956 ]
957 }
958
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200959 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200960 forward_variables_from(invoker, [ "sources" ])
961
962 script = "//tools_webrtc/ios/generate_umbrella_header.py"
963
964 outputs = [
965 umbrella_header_path,
966 ]
967 args = [
968 "--out",
969 rebase_path(umbrella_header_path, root_build_dir),
970 "--sources",
971 ] + sources
972 }
973
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200974 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200975 sources = [
976 umbrella_header_path,
977 ]
978 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200979 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200980 ]
981
982 deps = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200983 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200984 ]
985 }
986 }
987}
988
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000989if (is_android) {
990 template("rtc_android_library") {
991 android_library(target_name) {
992 forward_variables_from(invoker,
993 "*",
994 [
995 "configs",
996 "public_configs",
997 "suppressed_configs",
998 "visibility",
999 ])
1000
Oleh Prypin05aee742018-11-23 17:29:44 +01001001 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001002
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001003 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001004 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001005
Sami Kalliomäki68d58602019-01-24 12:56:12 +01001006 # WebRTC supports API level 16 while Chromium only supports 19.
1007 # (the manifest defines minimum supported SDK version)
Oleh Prypin4cbb4ef2019-06-18 17:09:51 +02001008 if (defined(invoker.min_sdk_version)) {
1009 min_sdk_version = invoker.min_sdk_version
Sami Kalliomäki68d58602019-01-24 12:56:12 +01001010 } else {
Oleh Prypin4cbb4ef2019-06-18 17:09:51 +02001011 min_sdk_version = 16
Sami Kalliomäki68d58602019-01-24 12:56:12 +01001012 }
1013
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001014 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001015 if (defined(invoker.errorprone_args)) {
1016 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001017 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001018
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001019 if (!defined(deps)) {
1020 deps = []
1021 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001022
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001023 no_build_hooks = true
1024 }
1025 }
1026
1027 template("rtc_android_apk") {
1028 android_apk(target_name) {
1029 forward_variables_from(invoker,
1030 "*",
1031 [
1032 "configs",
1033 "public_configs",
1034 "suppressed_configs",
1035 "visibility",
1036 ])
1037
1038 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001039 errorprone_args = []
1040 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001041
1042 if (!defined(deps)) {
1043 deps = []
1044 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001045
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001046 no_build_hooks = true
1047 }
1048 }
1049
1050 template("rtc_instrumentation_test_apk") {
1051 instrumentation_test_apk(target_name) {
1052 forward_variables_from(invoker,
1053 "*",
1054 [
1055 "configs",
1056 "public_configs",
1057 "suppressed_configs",
1058 "visibility",
1059 ])
1060
1061 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001062 errorprone_args = []
1063 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001064
1065 if (!defined(deps)) {
1066 deps = []
1067 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001068
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001069 no_build_hooks = true
1070 }
1071 }
1072}