blob: 5dabc44c652a468885c6f450eac057d8bacdf98a [file] [log] [blame]
mbonadei9aa3f0a2017-01-24 14:58:221# 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 14:58:228import("//build/config/arm.gni")
9import("//build/config/features.gni")
10import("//build/config/mips.gni")
11import("//build/config/sanitizers/sanitizers.gni")
Tomas Popela318da512018-11-13 05:32:2312import("//build/config/sysroot.gni")
ehmaldonado0d729b32017-02-10 09:38:2313import("//build/config/ui.gni")
mbonadei9aa3f0a2017-01-24 14:58:2214import("//build_overrides/build.gni")
mbonadei96606272017-03-04 03:41:5915
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
kthelgason4065a5762017-02-14 12:58:5630if (is_ios) {
31 import("//build/config/ios/rules.gni")
32}
mbonadei9aa3f0a2017-01-24 14:58:2233
Anders Carlsson37bbf792018-09-05 14:29:2734if (is_mac) {
35 import("//build/config/mac/rules.gni")
36}
37
mbonadei9aa3f0a2017-01-24 14:58:2238declare_args() {
Mirko Bonadei028248c2018-10-10 10:19:0239 # 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 08:37:1143 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 13:44:2844 # 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 08:37:1147 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 13:44:2855
Mirko Bonadei906add42018-09-05 14:03:1656 # 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 20:12:2562 # 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 14:08:1267 # Include the iLBC audio codec?
68 rtc_include_ilbc = true
69
mbonadei9aa3f0a2017-01-24 14:58:2270 # Disable this to avoid building the Opus audio codec.
71 rtc_include_opus = true
72
minyue2e03c662017-02-02 01:31:1173 # Enable this if the Opus version upon which WebRTC is built supports direct
74 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 15:45:4975 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-02 01:31:1176
mbonadei9aa3f0a2017-01-24 14:58:2277 # Enable this to let the Opus audio codec change complexity on the fly.
78 rtc_opus_variable_complexity = false
79
mbonadei9aa3f0a2017-01-24 14:58:2280 # 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 14:58:2291 # 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 00:25:53102 # 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 20:25:47108 # Set this to false to skip building code that requires X11.
109 rtc_use_x11 = use_x11
110
Tomas Popela318da512018-11-13 05:32:23111 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 13:37:51112 # 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 05:32:23119
mbonadei9aa3f0a2017-01-24 14:58:22120 # Enable to use the Mozilla internal settings.
121 build_with_mozilla = false
122
henrika883d00f2018-03-16 09:09:49123 # 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 14:58:22127 # 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 14:58:22134 if (current_cpu == "arm" || current_cpu == "arm64") {
135 rtc_prefer_fixed_point = true
136 }
137
mbonadei9aa3f0a2017-01-24 14:58:22138 # 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 14:22:38146 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 14:58:22147 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
148 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 09:47:18149 #
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 14:58:22154
mbonadei9aa3f0a2017-01-24 14:58:22155 # 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 15:34:16159 # 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 08:24:37165 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 07:30:29170
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 19:36:13173
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 06:50:07185
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 15:20:00193}
mbonadei9aa3f0a2017-01-24 14:58:22194
Dan Minor9c686132018-01-15 15:20:00195if (!build_with_mozilla) {
196 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 14:58:22197}
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 15:20:00203 # 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 15:20:00214 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 17:05:00219 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
220 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 15:20:00221 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 15:20:00228 # 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 14:58:22232 # 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 15:20:00240 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 11:27:07241
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 15:24:46245
246 # Set this to true to fully remove logging from WebRTC.
247 rtc_disable_logging = false
mbonadei9aa3f0a2017-01-24 14:58:22248}
249
250# Make it possible to provide custom locations for some libraries (move these
251# up into declare_args should we need to actually use them for the GN build).
252rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 14:58:22253rtc_opus_dir = "//third_party/opus"
254
255# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 11:27:07256rtc_desktop_capture_supported =
257 (is_win && current_os != "winuwp") || is_mac ||
258 (is_linux && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 14:58:22259
260###############################################################################
261# Templates
262#
263
Mirko Bonadei92ea95e2017-09-15 04:47:31264# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 14:58:22265# chromium.
266# We need absolute paths for all configs in templates as they are shared in
267# different subdirectories.
268webrtc_root = get_path_info(".", "abspath")
269
270# Global configuration that should be applied to all WebRTC targets.
271# You normally shouldn't need to include this in your target as it's
272# automatically included when using the rtc_* templates.
273# It sets defines, include paths and compilation warnings accordingly,
274# both for WebRTC stand-alone builds and for the scenario when WebRTC
275# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 20:56:00276rtc_common_configs = [
277 webrtc_root + ":common_config",
278 "//build/config/compiler:no_size_t_to_int_warning",
279]
mbonadei9aa3f0a2017-01-24 14:58:22280
kthelgasonc0977102017-04-24 07:57:16281if (is_mac || is_ios) {
282 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
283}
284
mbonadei9aa3f0a2017-01-24 14:58:22285# Global public configuration that should be applied to all WebRTC targets. You
286# normally shouldn't need to include this in your target as it's automatically
287# included when using the rtc_* templates. It set the defines, include paths and
288# compilation warnings that should be propagated to dependents of the targets
289# depending on the target having this config.
290rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
291
292# Common configs to remove or add in all rtc targets.
293rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 09:32:56294if (!build_with_chromium && is_clang) {
295 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
296}
mbonadei9aa3f0a2017-01-24 14:58:22297rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede16a2018-09-06 11:45:44298rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 11:15:54299rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 14:58:22300
301set_defaults("rtc_test") {
302 configs = rtc_add_configs
303 suppressed_configs = []
304}
305
Mirko Bonadei86d053c2019-10-17 19:32:04306set_defaults("rtc_library") {
307 configs = rtc_add_configs
308 suppressed_configs = []
309}
310
mbonadei9aa3f0a2017-01-24 14:58:22311set_defaults("rtc_source_set") {
312 configs = rtc_add_configs
313 suppressed_configs = []
314}
315
Mirko Bonadei86d053c2019-10-17 19:32:04316set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 14:58:22317 configs = rtc_add_configs
318 suppressed_configs = []
319}
320
Mirko Bonadei86d053c2019-10-17 19:32:04321set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 14:58:22322 configs = rtc_add_configs
323 suppressed_configs = []
324}
325
326set_defaults("rtc_shared_library") {
327 configs = rtc_add_configs
328 suppressed_configs = []
329}
330
Per Kjellandera7f2d842018-01-10 15:54:53331webrtc_default_visibility = [ webrtc_root + "/*" ]
332if (build_with_chromium) {
333 # Allow Chromium's WebRTC overrides targets to bypass the regular
334 # visibility restrictions.
335 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
336}
337
Karl Wibergbb23c832018-04-22 17:55:00338# ---- Poisons ----
339#
340# The general idea is that some targets declare that they contain some
341# kind of poison, which makes it impossible for other targets to
342# depend on them (even transitively) unless they declare themselves
343# immune to that particular type of poison.
344#
345# Targets that *contain* poison of type foo should contain the line
346#
347# poisonous = [ "foo" ]
348#
349# and targets that *are immune but arent't themselves poisonous*
350# should contain
351#
352# allow_poison = [ "foo" ]
353#
354# This useful in cases where we have some large target or set of
355# targets and want to ensure that most other targets do not
356# transitively depend on them. For example, almost no high-level
357# target should depend on the audio codecs, since we want WebRTC users
358# to be able to inject any subset of them and actually end up with a
359# binary that doesn't include the codecs they didn't inject.
360#
361# Test-only targets (`testonly` set to true) and non-public targets
362# (`visibility` not containing "*") are automatically immune to all
363# types of poison.
364#
365# Here's the complete list of all types of poison. It must be kept in
366# 1:1 correspondence with the set of //:poison_* targets.
367#
368all_poison_types = [
369 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
370 "audio_codecs",
Anders Carlsson1f433e42018-04-24 14:39:05371
Danil Chapovalov41300af2019-07-10 10:44:43372 # Default task queue implementation.
373 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 08:45:58374
375 # JSON parsing should not be needed in the "slim and modular" WebRTC.
376 "rtc_json",
377
378 # Software video codecs (VP8 and VP9 through libvpx).
379 "software_video_codecs",
Karl Wibergbb23c832018-04-22 17:55:00380]
381
Mirko Bonadei9a89a492018-05-29 14:22:32382absl_include_config = "//third_party/abseil-cpp:absl_include_config"
383absl_define_config = "//third_party/abseil-cpp:absl_define_config"
384
Mirko Bonadei2ab97f62019-07-18 11:44:12385# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
386# that are testonly.
387absl_flags_config = webrtc_root + ":absl_flags_configs"
388
mbonadei9aa3f0a2017-01-24 14:58:22389template("rtc_test") {
390 test(target_name) {
391 forward_variables_from(invoker,
392 "*",
393 [
394 "configs",
395 "public_configs",
396 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19397 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22398 ])
Mirko Bonadeidd411942017-11-21 14:35:27399
400 # Always override to public because when target_os is Android the `test`
401 # template can override it to [ "*" ] and we want to avoid conditional
402 # visibility.
Mirko Bonadei21558812017-11-21 11:47:34403 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 14:58:22404 configs += invoker.configs
405 configs -= rtc_remove_configs
406 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32407 public_configs = [
408 rtc_common_inherited_config,
409 absl_include_config,
410 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 11:44:12411 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32412 ]
mbonadei9aa3f0a2017-01-24 14:58:22413 if (defined(invoker.public_configs)) {
414 public_configs += invoker.public_configs
415 }
sakald7fdb802017-05-26 08:51:53416 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 13:48:37417 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Oleh Prypina79abd42019-06-25 21:19:17418 min_sdk_version = 16
Jianjun Zhu037f3e42017-08-15 13:48:37419 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 08:51:53420 }
mbonadei9aa3f0a2017-01-24 14:58:22421 }
422}
423
424template("rtc_source_set") {
425 source_set(target_name) {
426 forward_variables_from(invoker,
427 "*",
428 [
429 "configs",
430 "public_configs",
431 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19432 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22433 ])
Karl Wiberg138d4ac2017-10-16 09:16:19434 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53435 if (!defined(visibility)) {
436 visibility = webrtc_default_visibility
437 }
Karl Wibergbb23c832018-04-22 17:55:00438
439 # What's your poison?
440 if (defined(testonly) && testonly) {
441 assert(!defined(poisonous))
442 assert(!defined(allow_poison))
443 } else {
444 if (!defined(poisonous)) {
445 poisonous = []
446 }
447 if (!defined(allow_poison)) {
448 allow_poison = []
449 }
450 if (!defined(assert_no_deps)) {
451 assert_no_deps = []
452 }
453 if (!defined(deps)) {
454 deps = []
455 }
456 foreach(p, poisonous) {
457 deps += [ webrtc_root + ":poison_" + p ]
458 }
459 foreach(poison_type, all_poison_types) {
460 allow_dep = true
461 foreach(v, visibility) {
462 if (v == "*") {
463 allow_dep = false
464 }
465 }
466 foreach(p, allow_poison + poisonous) {
467 if (p == poison_type) {
468 allow_dep = true
469 }
470 }
471 if (!allow_dep) {
472 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
473 }
474 }
475 }
476
Mirko Bonadei92dd35d2019-11-15 15:08:41477 # Chromium should only depend on the WebRTC component in order to
478 # avoid to statically link WebRTC in a component build.
479 if (build_with_chromium) {
480 publicly_visible = false
481 foreach(v, visibility) {
482 if (v == "*") {
483 publicly_visible = true
484 }
485 }
486 if (publicly_visible) {
487 visibility = []
488 visibility = webrtc_default_visibility
489 }
490 }
491
Mirko Bonadei96ede16a2018-09-06 11:45:44492 if (!defined(testonly) || !testonly) {
493 configs += rtc_prod_configs
494 }
495
mbonadei9aa3f0a2017-01-24 14:58:22496 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 11:15:54497 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 14:58:22498 configs -= rtc_remove_configs
499 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32500 public_configs = [
501 rtc_common_inherited_config,
502 absl_include_config,
503 absl_define_config,
504 ]
Mirko Bonadei2ab97f62019-07-18 11:44:12505 if (defined(testonly) && testonly) {
506 public_configs += [ absl_flags_config ]
507 }
mbonadei9aa3f0a2017-01-24 14:58:22508 if (defined(invoker.public_configs)) {
509 public_configs += invoker.public_configs
510 }
511 }
512}
513
mbonadei9aa3f0a2017-01-24 14:58:22514template("rtc_static_library") {
515 static_library(target_name) {
516 forward_variables_from(invoker,
517 "*",
518 [
519 "configs",
520 "public_configs",
521 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19522 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22523 ])
Karl Wiberg138d4ac2017-10-16 09:16:19524 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53525 if (!defined(visibility)) {
526 visibility = webrtc_default_visibility
527 }
Karl Wibergbb23c832018-04-22 17:55:00528
529 # What's your poison?
530 if (defined(testonly) && testonly) {
531 assert(!defined(poisonous))
532 assert(!defined(allow_poison))
533 } else {
534 if (!defined(poisonous)) {
535 poisonous = []
536 }
537 if (!defined(allow_poison)) {
538 allow_poison = []
539 }
540 if (!defined(assert_no_deps)) {
541 assert_no_deps = []
542 }
543 if (!defined(deps)) {
544 deps = []
545 }
546 foreach(p, poisonous) {
547 deps += [ webrtc_root + ":poison_" + p ]
548 }
549 foreach(poison_type, all_poison_types) {
550 allow_dep = true
551 foreach(v, visibility) {
552 if (v == "*") {
553 allow_dep = false
554 }
555 }
556 foreach(p, allow_poison + poisonous) {
557 if (p == poison_type) {
558 allow_dep = true
559 }
560 }
561 if (!allow_dep) {
562 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
563 }
564 }
565 }
566
Mirko Bonadei96ede16a2018-09-06 11:45:44567 if (!defined(testonly) || !testonly) {
568 configs += rtc_prod_configs
569 }
570
mbonadei9aa3f0a2017-01-24 14:58:22571 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 11:15:54572 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 14:58:22573 configs -= rtc_remove_configs
574 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32575 public_configs = [
576 rtc_common_inherited_config,
577 absl_include_config,
578 absl_define_config,
579 ]
Mirko Bonadei2ab97f62019-07-18 11:44:12580 if (defined(testonly) && testonly) {
581 public_configs += [ absl_flags_config ]
582 }
mbonadei9aa3f0a2017-01-24 14:58:22583 if (defined(invoker.public_configs)) {
584 public_configs += invoker.public_configs
585 }
586 }
587}
588
Mirko Bonadei86d053c2019-10-17 19:32:04589# This template automatically switches the target type between source_set
590# and static_library.
591#
592# This should be the default target type for all the WebRTC targets with
593# one exception. Do not use this template for header only targets, in that case
594# rtc_source_set must be used in order to avoid build errors (e.g. libtool
595# complains if the output .a file is empty).
596#
597# How does it work:
598# Since all files in a source_set are linked into a final binary, while files
599# in a static library are only linked in if at least one symbol in them is
600# referenced, in component builds source_sets are easy to deal with because
601# all their object files are passed to the linker to create a shared library.
602# In release builds instead, static_libraries are preferred since they allow
603# the linker to discard dead code.
604# For the same reason, testonly targets will always be expanded to
605# source_set in order to be sure that tests are present in the test binary.
606template("rtc_library") {
607 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
608 target_type = "source_set"
609 } else {
610 target_type = "static_library"
611 }
612 target(target_type, target_name) {
613 forward_variables_from(invoker,
614 "*",
615 [
616 "configs",
617 "public_configs",
618 "suppressed_configs",
619 "visibility",
620 ])
621 forward_variables_from(invoker, [ "visibility" ])
622 if (!defined(visibility)) {
623 visibility = webrtc_default_visibility
624 }
625
626 # What's your poison?
627 if (defined(testonly) && testonly) {
628 assert(!defined(poisonous))
629 assert(!defined(allow_poison))
630 } else {
631 if (!defined(poisonous)) {
632 poisonous = []
633 }
634 if (!defined(allow_poison)) {
635 allow_poison = []
636 }
637 if (!defined(assert_no_deps)) {
638 assert_no_deps = []
639 }
640 if (!defined(deps)) {
641 deps = []
642 }
643 foreach(p, poisonous) {
644 deps += [ webrtc_root + ":poison_" + p ]
645 }
646 foreach(poison_type, all_poison_types) {
647 allow_dep = true
648 foreach(v, visibility) {
649 if (v == "*") {
650 allow_dep = false
651 }
652 }
653 foreach(p, allow_poison + poisonous) {
654 if (p == poison_type) {
655 allow_dep = true
656 }
657 }
658 if (!allow_dep) {
659 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
660 }
661 }
662 }
663
Mirko Bonadei92dd35d2019-11-15 15:08:41664 # Chromium should only depend on the WebRTC component in order to
665 # avoid to statically link WebRTC in a component build.
666 if (build_with_chromium) {
667 publicly_visible = false
668 foreach(v, visibility) {
669 if (v == "*") {
670 publicly_visible = true
671 }
672 }
673 if (publicly_visible) {
674 visibility = []
675 visibility = webrtc_default_visibility
676 }
677 }
678
Mirko Bonadei86d053c2019-10-17 19:32:04679 if (!defined(testonly) || !testonly) {
680 configs += rtc_prod_configs
681 }
682
683 configs += invoker.configs
684 configs += rtc_library_impl_config
685 configs -= rtc_remove_configs
686 configs -= invoker.suppressed_configs
687 public_configs = [
688 rtc_common_inherited_config,
689 absl_include_config,
690 absl_define_config,
691 ]
692 if (defined(testonly) && testonly) {
693 public_configs += [ absl_flags_config ]
694 }
695 if (defined(invoker.public_configs)) {
696 public_configs += invoker.public_configs
697 }
698 }
699}
700
701template("rtc_executable") {
702 executable(target_name) {
703 forward_variables_from(invoker,
704 "*",
705 [
706 "deps",
707 "configs",
708 "public_configs",
709 "suppressed_configs",
710 "visibility",
711 ])
712 forward_variables_from(invoker, [ "visibility" ])
713 if (!defined(visibility)) {
714 visibility = webrtc_default_visibility
715 }
716 configs += invoker.configs
717 configs -= rtc_remove_configs
718 configs -= invoker.suppressed_configs
719 deps = invoker.deps
720
721 public_configs = [
722 rtc_common_inherited_config,
723 absl_include_config,
724 absl_define_config,
725 ]
726 if (defined(testonly) && testonly) {
727 public_configs += [ absl_flags_config ]
728 }
729 if (defined(invoker.public_configs)) {
730 public_configs += invoker.public_configs
731 }
732 if (is_win) {
733 deps += [
734 # Give executables the default manifest on Windows (a no-op elsewhere).
735 "//build/win:default_exe_manifest",
736 ]
737 }
738 }
739}
740
mbonadei9aa3f0a2017-01-24 14:58:22741template("rtc_shared_library") {
742 shared_library(target_name) {
743 forward_variables_from(invoker,
744 "*",
745 [
746 "configs",
747 "public_configs",
748 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19749 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22750 ])
Karl Wiberg138d4ac2017-10-16 09:16:19751 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53752 if (!defined(visibility)) {
753 visibility = webrtc_default_visibility
754 }
Karl Wibergbb23c832018-04-22 17:55:00755
756 # What's your poison?
757 if (defined(testonly) && testonly) {
758 assert(!defined(poisonous))
759 assert(!defined(allow_poison))
760 } else {
761 if (!defined(poisonous)) {
762 poisonous = []
763 }
764 if (!defined(allow_poison)) {
765 allow_poison = []
766 }
767 if (!defined(assert_no_deps)) {
768 assert_no_deps = []
769 }
770 if (!defined(deps)) {
771 deps = []
772 }
773 foreach(p, poisonous) {
774 deps += [ webrtc_root + ":poison_" + p ]
775 }
776 foreach(poison_type, all_poison_types) {
777 allow_dep = true
778 foreach(v, visibility) {
779 if (v == "*") {
780 allow_dep = false
781 }
782 }
783 foreach(p, allow_poison + poisonous) {
784 if (p == poison_type) {
785 allow_dep = true
786 }
787 }
788 if (!allow_dep) {
789 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
790 }
791 }
792 }
793
mbonadei9aa3f0a2017-01-24 14:58:22794 configs += invoker.configs
795 configs -= rtc_remove_configs
796 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32797 public_configs = [
798 rtc_common_inherited_config,
799 absl_include_config,
800 absl_define_config,
801 ]
Mirko Bonadei2ab97f62019-07-18 11:44:12802 if (defined(testonly) && testonly) {
803 public_configs += [ absl_flags_config ]
804 }
mbonadei9aa3f0a2017-01-24 14:58:22805 if (defined(invoker.public_configs)) {
806 public_configs += invoker.public_configs
807 }
808 }
809}
kthelgason4065a5762017-02-14 12:58:56810
811if (is_ios) {
812 set_defaults("rtc_ios_xctest_test") {
813 configs = rtc_add_configs
814 suppressed_configs = []
815 }
816
817 template("rtc_ios_xctest_test") {
818 ios_xctest_test(target_name) {
819 forward_variables_from(invoker,
820 "*",
821 [
822 "configs",
823 "public_configs",
824 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19825 "visibility",
kthelgason4065a5762017-02-14 12:58:56826 ])
Karl Wiberg138d4ac2017-10-16 09:16:19827 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53828 if (!defined(visibility)) {
829 visibility = webrtc_default_visibility
830 }
kthelgason4065a5762017-02-14 12:58:56831 configs += invoker.configs
832 configs -= rtc_remove_configs
833 configs -= invoker.suppressed_configs
834 public_configs = [ rtc_common_inherited_config ]
835 if (defined(invoker.public_configs)) {
836 public_configs += invoker.public_configs
837 }
838 }
839 }
Anders Carlssondc6b4772018-01-15 12:31:03840
Joel Sutherlandd2fb1bf2018-10-02 20:08:25841 # TODO: Generate module.modulemap file to enable use in Swift
842 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 12:31:03843 template("ios_framework_bundle_with_umbrella_header") {
844 forward_variables_from(invoker, [ "output_name" ])
845 umbrella_header_path =
846 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
847
848 ios_framework_bundle(target_name) {
849 forward_variables_from(invoker, "*", [])
850
851 deps += [ ":copy_umbrella_header_$target_name" ]
852 }
853
854 action("umbrella_header_$target_name") {
855 forward_variables_from(invoker, [ "public_headers" ])
856
857 script = "//tools_webrtc/ios/generate_umbrella_header.py"
858
859 outputs = [
860 umbrella_header_path,
861 ]
862 args = [
863 "--out",
864 rebase_path(umbrella_header_path, root_build_dir),
865 "--sources",
Anders Carlsson7bca8ca2018-08-30 07:30:29866 ] + public_headers
Anders Carlssondc6b4772018-01-15 12:31:03867 }
868
869 copy("copy_umbrella_header_$target_name") {
870 sources = [
871 umbrella_header_path,
872 ]
873 outputs = [
874 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
875 ]
876
877 deps = [
878 ":umbrella_header_$target_name",
879 ]
880 }
881 }
882
883 set_defaults("ios_framework_bundle_with_umbrella_header") {
884 configs = default_shared_library_configs
885 }
kthelgason4065a5762017-02-14 12:58:56886}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33887
Anders Carlsson37bbf792018-09-05 14:29:27888if (is_mac) {
889 template("mac_framework_bundle_with_umbrella_header") {
890 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 13:48:17891 this_target_name = target_name
892 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 20:08:25893 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 14:29:27894
895 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 18:40:29896 forward_variables_from(invoker, "*", [ "configs" ])
897 if (defined(invoker.configs)) {
898 configs += invoker.configs
899 }
Anders Carlsson37bbf792018-09-05 14:29:27900
901 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 20:08:25902 framework_contents = [
903 "Headers",
904 "Modules",
905 "Resources",
906 ]
Anders Carlsson37bbf792018-09-05 14:29:27907
908 ldflags = [
909 "-all_load",
910 "-install_name",
911 "@rpath/$output_name.framework/$output_name",
912 ]
913
914 deps += [
Anders Carlsson95c56ee2018-09-06 13:48:17915 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 20:08:25916 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 13:48:17917 ":copy_umbrella_header_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 20:08:25918 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 13:48:17919 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 14:29:27920 ]
921 }
922
Anders Carlsson95c56ee2018-09-06 13:48:17923 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 14:29:27924 forward_variables_from(invoker, [ "sources" ])
925
926 outputs = [
Anders Carlsson95c56ee2018-09-06 13:48:17927 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 14:29:27928 ]
929 }
930
Joel Sutherlandd2fb1bf2018-10-02 20:08:25931 action("modulemap_$this_target_name") {
932 script = "//tools_webrtc/ios/generate_modulemap.py"
933 args = [
934 "--out",
935 rebase_path(modulemap_path, root_build_dir),
936 "--name",
937 output_name,
938 ]
939 outputs = [
940 modulemap_path,
941 ]
942 }
943
944 bundle_data("copy_modulemap_$this_target_name") {
945 sources = [
946 modulemap_path,
947 ]
948 outputs = [
949 "{{bundle_contents_dir}}/Modules/module.modulemap",
950 ]
951 deps = [
952 ":modulemap_$this_target_name",
953 ]
954 }
955
Anders Carlsson95c56ee2018-09-06 13:48:17956 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 14:29:27957 forward_variables_from(invoker, [ "sources" ])
958
959 script = "//tools_webrtc/ios/generate_umbrella_header.py"
960
961 outputs = [
962 umbrella_header_path,
963 ]
964 args = [
965 "--out",
966 rebase_path(umbrella_header_path, root_build_dir),
967 "--sources",
968 ] + sources
969 }
970
Anders Carlsson95c56ee2018-09-06 13:48:17971 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 14:29:27972 sources = [
973 umbrella_header_path,
974 ]
975 outputs = [
Anders Carlsson95c56ee2018-09-06 13:48:17976 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 14:29:27977 ]
978
979 deps = [
Anders Carlsson95c56ee2018-09-06 13:48:17980 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 14:29:27981 ]
982 }
983 }
984}
985
Mirko Bonadeifbb3b7d2017-11-07 15:36:33986if (is_android) {
987 template("rtc_android_library") {
988 android_library(target_name) {
989 forward_variables_from(invoker,
990 "*",
991 [
992 "configs",
993 "public_configs",
994 "suppressed_configs",
995 "visibility",
996 ])
997
Oleh Prypin05aee742018-11-23 16:29:44998 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 15:32:49999
Mirko Bonadeifbb3b7d2017-11-07 15:36:331000 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 16:29:441001 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 15:32:491002
Sami Kalliomäki68d58602019-01-24 11:56:121003 # WebRTC supports API level 16 while Chromium only supports 19.
1004 # (the manifest defines minimum supported SDK version)
Oleh Prypin4cbb4ef2019-06-18 15:09:511005 if (defined(invoker.min_sdk_version)) {
1006 min_sdk_version = invoker.min_sdk_version
Sami Kalliomäki68d58602019-01-24 11:56:121007 } else {
Oleh Prypin4cbb4ef2019-06-18 15:09:511008 min_sdk_version = 16
Sami Kalliomäki68d58602019-01-24 11:56:121009 }
1010
Sami Kalliomäkie7fac682018-03-20 15:32:491011 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 16:29:441012 if (defined(invoker.errorprone_args)) {
1013 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 15:32:491014 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:331015
Sami Kalliomäkidc526512018-03-27 15:07:271016 if (!defined(deps)) {
1017 deps = []
1018 }
Sami Kalliomäkidc526512018-03-27 15:07:271019
Mirko Bonadeifbb3b7d2017-11-07 15:36:331020 no_build_hooks = true
1021 }
1022 }
1023
1024 template("rtc_android_apk") {
1025 android_apk(target_name) {
1026 forward_variables_from(invoker,
1027 "*",
1028 [
1029 "configs",
1030 "public_configs",
1031 "suppressed_configs",
1032 "visibility",
1033 ])
1034
1035 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 11:10:081036 errorprone_args = []
1037 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 15:07:271038
1039 if (!defined(deps)) {
1040 deps = []
1041 }
Sami Kalliomäkidc526512018-03-27 15:07:271042
Mirko Bonadeifbb3b7d2017-11-07 15:36:331043 no_build_hooks = true
1044 }
1045 }
1046
1047 template("rtc_instrumentation_test_apk") {
1048 instrumentation_test_apk(target_name) {
1049 forward_variables_from(invoker,
1050 "*",
1051 [
1052 "configs",
1053 "public_configs",
1054 "suppressed_configs",
1055 "visibility",
1056 ])
1057
1058 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 11:10:081059 errorprone_args = []
1060 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 15:07:271061
1062 if (!defined(deps)) {
1063 deps = []
1064 }
Sami Kalliomäkidc526512018-03-27 15:07:271065
Mirko Bonadeifbb3b7d2017-11-07 15:36:331066 no_build_hooks = true
1067 }
1068 }
1069}