blob: 9e13283ec083af2ebcac591e473a74a7bdc74a52 [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 # Link-Time Optimizations.
128 # Executes code generation at link-time instead of compile-time.
129 # https://gcc.gnu.org/wiki/LinkTimeOptimization
130 rtc_use_lto = false
131
132 # Set to "func", "block", "edge" for coverage generation.
133 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
134 # It is recommend to set include_examples=0.
135 # Use llvm's sancov -html-report for human readable reports.
136 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
137 rtc_sanitize_coverage = ""
138
mbonadei9aa3f0a2017-01-24 06:58:22 -0800139 if (current_cpu == "arm" || current_cpu == "arm64") {
140 rtc_prefer_fixed_point = true
141 }
142
mbonadei9aa3f0a2017-01-24 06:58:22 -0800143 # Determines whether NEON code will be built.
144 rtc_build_with_neon =
145 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
146
147 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
148 # all platforms except Android and iOS. Because FFmpeg can be built
149 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
150 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Sergey Silkinfe288eb2018-06-25 16:22:38 +0200151 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800152 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
153 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 10:47:18 +0100154 #
155 # Enabling H264 when building with MSVC is currently not supported, see
156 # bugs.webrtc.org/9213#c13 for more info.
157 rtc_use_h264 =
158 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800159
mbonadei9aa3f0a2017-01-24 06:58:22 -0800160 # By default, use normal platform audio support or dummy audio, but don't
161 # use file-based audio playout and record.
162 rtc_use_dummy_audio_file_devices = false
163
henrika7be78832017-06-13 17:34:16 +0200164 # When set to true, replace the audio output with a sinus tone at 440Hz.
165 # The ADM will ask for audio data from WebRTC but instead of reading real
166 # audio samples from NetEQ, a sinus tone will be generated and replace the
167 # real audio samples.
168 rtc_audio_device_plays_sinus_tone = false
169
Anders Carlsson358f2e02018-06-04 10:24:37 +0200170 if (is_ios) {
171 # Build broadcast extension in AppRTCMobile for iOS. This results in the
172 # binary only running on iOS 11+, which is why it is disabled by default.
173 rtc_apprtcmobile_broadcast_extension = false
174 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200175
176 # Determines whether Metal is available on iOS/macOS.
177 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
Jiawei Ou08745302019-02-12 11:36:13 -0800178
179 # When set to false, builtin audio encoder/decoder factories and all the
180 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
181 # (they will still be included in libjingle_peerconnection_so.so and
182 # WebRTC.framework)
183 rtc_include_builtin_audio_codecs = true
184
185 # When set to false, builtin video encoder/decoder factories and all the
186 # video codecs they depends on will not be included in libwebrtc.{a|lib}
187 # (they will still be included in libjingle_peerconnection_so.so and
188 # WebRTC.framework)
189 rtc_include_builtin_video_codecs = true
Mirko Bonadei20574f42019-03-28 07:50:07 +0100190
191 # When set to true and in a standalone build, it will undefine UNICODE and
192 # _UNICODE (which are always defined globally by the Chromium Windows
193 # toolchain).
194 # This is only needed for testing purposes, WebRTC wants to be sure it
195 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
196 # wide character functions.
197 rtc_win_undef_unicode = false
Dan Minor9c686132018-01-15 10:20:00 -0500198}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800199
Dan Minor9c686132018-01-15 10:20:00 -0500200if (!build_with_mozilla) {
201 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800202}
203
204# A second declare_args block, so that declarations within it can
205# depend on the possibly overridden variables in the first
206# declare_args block.
207declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500208 # Enables the use of protocol buffers for debug recordings.
209 rtc_enable_protobuf = !build_with_mozilla
210
211 # Set this to disable building with support for SCTP data channels.
212 rtc_enable_sctp = !build_with_mozilla
213
214 # Disable these to not build components which can be externally provided.
215 rtc_build_json = !build_with_mozilla
216 rtc_build_libsrtp = !build_with_mozilla
217 rtc_build_libvpx = !build_with_mozilla
218 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500219 rtc_build_opus = !build_with_mozilla
220 rtc_build_ssl = !build_with_mozilla
221 rtc_build_usrsctp = !build_with_mozilla
222
223 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 19:05:00 +0200224 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
225 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 10:20:00 -0500226 rtc_enable_libevent = false
227 rtc_build_libevent = false
228 } else {
229 rtc_enable_libevent = true
230 rtc_build_libevent = !build_with_mozilla
231 }
232
Dan Minor9c686132018-01-15 10:20:00 -0500233 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
234 # build environments, even if available for Chromium builds.
235 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
236
mbonadei9aa3f0a2017-01-24 06:58:22 -0800237 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
238 rtc_include_pulse_audio = !build_with_chromium
239
240 # Chromium uses its own IO handling, so the internal ADM is only built for
241 # standalone WebRTC.
242 rtc_include_internal_audio_device = !build_with_chromium
243
244 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500245 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 13:27:07 +0200246
247 # Set this to false to skip building code that also requires X11 extensions
248 # such as Xdamage, Xfixes.
249 rtc_use_x11_extensions = rtc_use_x11
mbonadei9aa3f0a2017-01-24 06:58:22 -0800250}
251
252# Make it possible to provide custom locations for some libraries (move these
253# up into declare_args should we need to actually use them for the GN build).
254rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800255rtc_opus_dir = "//third_party/opus"
256
257# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200258rtc_desktop_capture_supported =
259 (is_win && current_os != "winuwp") || is_mac ||
260 (is_linux && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800261
262###############################################################################
263# Templates
264#
265
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200266# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800267# chromium.
268# We need absolute paths for all configs in templates as they are shared in
269# different subdirectories.
270webrtc_root = get_path_info(".", "abspath")
271
272# Global configuration that should be applied to all WebRTC targets.
273# You normally shouldn't need to include this in your target as it's
274# automatically included when using the rtc_* templates.
275# It sets defines, include paths and compilation warnings accordingly,
276# both for WebRTC stand-alone builds and for the scenario when WebRTC
277# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700278rtc_common_configs = [
279 webrtc_root + ":common_config",
280 "//build/config/compiler:no_size_t_to_int_warning",
281]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800282
kthelgasonc0977102017-04-24 00:57:16 -0700283if (is_mac || is_ios) {
284 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
285}
286
mbonadei9aa3f0a2017-01-24 06:58:22 -0800287# Global public configuration that should be applied to all WebRTC targets. You
288# normally shouldn't need to include this in your target as it's automatically
289# included when using the rtc_* templates. It set the defines, include paths and
290# compilation warnings that should be propagated to dependents of the targets
291# depending on the target having this config.
292rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
293
294# Common configs to remove or add in all rtc targets.
295rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100296if (!build_with_chromium && is_clang) {
297 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
298}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800299rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200300rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200301rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800302
303set_defaults("rtc_test") {
304 configs = rtc_add_configs
305 suppressed_configs = []
306}
307
308set_defaults("rtc_source_set") {
309 configs = rtc_add_configs
310 suppressed_configs = []
311}
312
313set_defaults("rtc_executable") {
314 configs = rtc_add_configs
315 suppressed_configs = []
316}
317
318set_defaults("rtc_static_library") {
319 configs = rtc_add_configs
320 suppressed_configs = []
321}
322
323set_defaults("rtc_shared_library") {
324 configs = rtc_add_configs
325 suppressed_configs = []
326}
327
Per Kjellandera7f2d842018-01-10 15:54:53 +0000328webrtc_default_visibility = [ webrtc_root + "/*" ]
329if (build_with_chromium) {
330 # Allow Chromium's WebRTC overrides targets to bypass the regular
331 # visibility restrictions.
332 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
333}
334
Karl Wibergbb23c832018-04-22 19:55:00 +0200335# ---- Poisons ----
336#
337# The general idea is that some targets declare that they contain some
338# kind of poison, which makes it impossible for other targets to
339# depend on them (even transitively) unless they declare themselves
340# immune to that particular type of poison.
341#
342# Targets that *contain* poison of type foo should contain the line
343#
344# poisonous = [ "foo" ]
345#
346# and targets that *are immune but arent't themselves poisonous*
347# should contain
348#
349# allow_poison = [ "foo" ]
350#
351# This useful in cases where we have some large target or set of
352# targets and want to ensure that most other targets do not
353# transitively depend on them. For example, almost no high-level
354# target should depend on the audio codecs, since we want WebRTC users
355# to be able to inject any subset of them and actually end up with a
356# binary that doesn't include the codecs they didn't inject.
357#
358# Test-only targets (`testonly` set to true) and non-public targets
359# (`visibility` not containing "*") are automatically immune to all
360# types of poison.
361#
362# Here's the complete list of all types of poison. It must be kept in
363# 1:1 correspondence with the set of //:poison_* targets.
364#
365all_poison_types = [
366 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
367 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200368
369 # Software video codecs (VP8 and VP9 through libvpx).
370 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200371]
372
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000373absl_include_config = "//third_party/abseil-cpp:absl_include_config"
374absl_define_config = "//third_party/abseil-cpp:absl_define_config"
375
mbonadei9aa3f0a2017-01-24 06:58:22 -0800376template("rtc_test") {
377 test(target_name) {
378 forward_variables_from(invoker,
379 "*",
380 [
381 "configs",
382 "public_configs",
383 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200384 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800385 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100386
387 # Always override to public because when target_os is Android the `test`
388 # template can override it to [ "*" ] and we want to avoid conditional
389 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100390 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800391 configs += invoker.configs
392 configs -= rtc_remove_configs
393 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000394 public_configs = [
395 rtc_common_inherited_config,
396 absl_include_config,
397 absl_define_config,
398 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800399 if (defined(invoker.public_configs)) {
400 public_configs += invoker.public_configs
401 }
sakald7fdb802017-05-26 01:51:53 -0700402 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800403 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Oleh Prypina79abd42019-06-25 23:19:17 +0200404 min_sdk_version = 16
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800405 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700406 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800407 }
408}
409
410template("rtc_source_set") {
411 source_set(target_name) {
412 forward_variables_from(invoker,
413 "*",
414 [
415 "configs",
416 "public_configs",
417 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200418 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800419 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200420 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000421 if (!defined(visibility)) {
422 visibility = webrtc_default_visibility
423 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200424
425 # What's your poison?
426 if (defined(testonly) && testonly) {
427 assert(!defined(poisonous))
428 assert(!defined(allow_poison))
429 } else {
430 if (!defined(poisonous)) {
431 poisonous = []
432 }
433 if (!defined(allow_poison)) {
434 allow_poison = []
435 }
436 if (!defined(assert_no_deps)) {
437 assert_no_deps = []
438 }
439 if (!defined(deps)) {
440 deps = []
441 }
442 foreach(p, poisonous) {
443 deps += [ webrtc_root + ":poison_" + p ]
444 }
445 foreach(poison_type, all_poison_types) {
446 allow_dep = true
447 foreach(v, visibility) {
448 if (v == "*") {
449 allow_dep = false
450 }
451 }
452 foreach(p, allow_poison + poisonous) {
453 if (p == poison_type) {
454 allow_dep = true
455 }
456 }
457 if (!allow_dep) {
458 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
459 }
460 }
461 }
462
Mirko Bonadei96ede162018-09-06 13:45:44 +0200463 if (!defined(testonly) || !testonly) {
464 configs += rtc_prod_configs
465 }
466
mbonadei9aa3f0a2017-01-24 06:58:22 -0800467 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200468 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800469 configs -= rtc_remove_configs
470 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000471 public_configs = [
472 rtc_common_inherited_config,
473 absl_include_config,
474 absl_define_config,
475 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800476 if (defined(invoker.public_configs)) {
477 public_configs += invoker.public_configs
478 }
479 }
480}
481
482template("rtc_executable") {
483 executable(target_name) {
484 forward_variables_from(invoker,
485 "*",
486 [
487 "deps",
488 "configs",
489 "public_configs",
490 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200491 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800492 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200493 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000494 if (!defined(visibility)) {
495 visibility = webrtc_default_visibility
496 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800497 configs += invoker.configs
498 configs -= rtc_remove_configs
499 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700500 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700501
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000502 public_configs = [
503 rtc_common_inherited_config,
504 absl_include_config,
505 absl_define_config,
506 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800507 if (defined(invoker.public_configs)) {
508 public_configs += invoker.public_configs
509 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200510 if (is_win) {
511 deps += [
512 # Give executables the default manifest on Windows (a no-op elsewhere).
513 "//build/win:default_exe_manifest",
514 ]
515 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800516 }
517}
518
519template("rtc_static_library") {
520 static_library(target_name) {
521 forward_variables_from(invoker,
522 "*",
523 [
524 "configs",
525 "public_configs",
526 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200527 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800528 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200529 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000530 if (!defined(visibility)) {
531 visibility = webrtc_default_visibility
532 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200533
534 # What's your poison?
535 if (defined(testonly) && testonly) {
536 assert(!defined(poisonous))
537 assert(!defined(allow_poison))
538 } else {
539 if (!defined(poisonous)) {
540 poisonous = []
541 }
542 if (!defined(allow_poison)) {
543 allow_poison = []
544 }
545 if (!defined(assert_no_deps)) {
546 assert_no_deps = []
547 }
548 if (!defined(deps)) {
549 deps = []
550 }
551 foreach(p, poisonous) {
552 deps += [ webrtc_root + ":poison_" + p ]
553 }
554 foreach(poison_type, all_poison_types) {
555 allow_dep = true
556 foreach(v, visibility) {
557 if (v == "*") {
558 allow_dep = false
559 }
560 }
561 foreach(p, allow_poison + poisonous) {
562 if (p == poison_type) {
563 allow_dep = true
564 }
565 }
566 if (!allow_dep) {
567 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
568 }
569 }
570 }
571
Mirko Bonadei96ede162018-09-06 13:45:44 +0200572 if (!defined(testonly) || !testonly) {
573 configs += rtc_prod_configs
574 }
575
mbonadei9aa3f0a2017-01-24 06:58:22 -0800576 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200577 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800578 configs -= rtc_remove_configs
579 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000580 public_configs = [
581 rtc_common_inherited_config,
582 absl_include_config,
583 absl_define_config,
584 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800585 if (defined(invoker.public_configs)) {
586 public_configs += invoker.public_configs
587 }
588 }
589}
590
591template("rtc_shared_library") {
592 shared_library(target_name) {
593 forward_variables_from(invoker,
594 "*",
595 [
596 "configs",
597 "public_configs",
598 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200599 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800600 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200601 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000602 if (!defined(visibility)) {
603 visibility = webrtc_default_visibility
604 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200605
606 # What's your poison?
607 if (defined(testonly) && testonly) {
608 assert(!defined(poisonous))
609 assert(!defined(allow_poison))
610 } else {
611 if (!defined(poisonous)) {
612 poisonous = []
613 }
614 if (!defined(allow_poison)) {
615 allow_poison = []
616 }
617 if (!defined(assert_no_deps)) {
618 assert_no_deps = []
619 }
620 if (!defined(deps)) {
621 deps = []
622 }
623 foreach(p, poisonous) {
624 deps += [ webrtc_root + ":poison_" + p ]
625 }
626 foreach(poison_type, all_poison_types) {
627 allow_dep = true
628 foreach(v, visibility) {
629 if (v == "*") {
630 allow_dep = false
631 }
632 }
633 foreach(p, allow_poison + poisonous) {
634 if (p == poison_type) {
635 allow_dep = true
636 }
637 }
638 if (!allow_dep) {
639 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
640 }
641 }
642 }
643
mbonadei9aa3f0a2017-01-24 06:58:22 -0800644 configs += invoker.configs
645 configs -= rtc_remove_configs
646 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000647 public_configs = [
648 rtc_common_inherited_config,
649 absl_include_config,
650 absl_define_config,
651 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800652 if (defined(invoker.public_configs)) {
653 public_configs += invoker.public_configs
654 }
655 }
656}
kthelgason4065a572017-02-14 04:58:56 -0800657
658if (is_ios) {
659 set_defaults("rtc_ios_xctest_test") {
660 configs = rtc_add_configs
661 suppressed_configs = []
662 }
663
664 template("rtc_ios_xctest_test") {
665 ios_xctest_test(target_name) {
666 forward_variables_from(invoker,
667 "*",
668 [
669 "configs",
670 "public_configs",
671 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200672 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800673 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200674 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000675 if (!defined(visibility)) {
676 visibility = webrtc_default_visibility
677 }
kthelgason4065a572017-02-14 04:58:56 -0800678 configs += invoker.configs
679 configs -= rtc_remove_configs
680 configs -= invoker.suppressed_configs
681 public_configs = [ rtc_common_inherited_config ]
682 if (defined(invoker.public_configs)) {
683 public_configs += invoker.public_configs
684 }
685 }
686 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100687
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400688 # TODO: Generate module.modulemap file to enable use in Swift
689 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100690 template("ios_framework_bundle_with_umbrella_header") {
691 forward_variables_from(invoker, [ "output_name" ])
692 umbrella_header_path =
693 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
694
695 ios_framework_bundle(target_name) {
696 forward_variables_from(invoker, "*", [])
697
698 deps += [ ":copy_umbrella_header_$target_name" ]
699 }
700
701 action("umbrella_header_$target_name") {
702 forward_variables_from(invoker, [ "public_headers" ])
703
704 script = "//tools_webrtc/ios/generate_umbrella_header.py"
705
706 outputs = [
707 umbrella_header_path,
708 ]
709 args = [
710 "--out",
711 rebase_path(umbrella_header_path, root_build_dir),
712 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200713 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100714 }
715
716 copy("copy_umbrella_header_$target_name") {
717 sources = [
718 umbrella_header_path,
719 ]
720 outputs = [
721 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
722 ]
723
724 deps = [
725 ":umbrella_header_$target_name",
726 ]
727 }
728 }
729
730 set_defaults("ios_framework_bundle_with_umbrella_header") {
731 configs = default_shared_library_configs
732 }
kthelgason4065a572017-02-14 04:58:56 -0800733}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000734
Anders Carlsson37bbf792018-09-05 16:29:27 +0200735if (is_mac) {
736 template("mac_framework_bundle_with_umbrella_header") {
737 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200738 this_target_name = target_name
739 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400740 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200741
742 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -0800743 forward_variables_from(invoker, "*", [ "configs" ])
744 if (defined(invoker.configs)) {
745 configs += invoker.configs
746 }
Anders Carlsson37bbf792018-09-05 16:29:27 +0200747
748 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400749 framework_contents = [
750 "Headers",
751 "Modules",
752 "Resources",
753 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +0200754
755 ldflags = [
756 "-all_load",
757 "-install_name",
758 "@rpath/$output_name.framework/$output_name",
759 ]
760
761 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200762 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400763 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200764 ":copy_umbrella_header_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400765 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200766 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200767 ]
768 }
769
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200770 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200771 forward_variables_from(invoker, [ "sources" ])
772
773 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200774 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200775 ]
776 }
777
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400778 action("modulemap_$this_target_name") {
779 script = "//tools_webrtc/ios/generate_modulemap.py"
780 args = [
781 "--out",
782 rebase_path(modulemap_path, root_build_dir),
783 "--name",
784 output_name,
785 ]
786 outputs = [
787 modulemap_path,
788 ]
789 }
790
791 bundle_data("copy_modulemap_$this_target_name") {
792 sources = [
793 modulemap_path,
794 ]
795 outputs = [
796 "{{bundle_contents_dir}}/Modules/module.modulemap",
797 ]
798 deps = [
799 ":modulemap_$this_target_name",
800 ]
801 }
802
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200803 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200804 forward_variables_from(invoker, [ "sources" ])
805
806 script = "//tools_webrtc/ios/generate_umbrella_header.py"
807
808 outputs = [
809 umbrella_header_path,
810 ]
811 args = [
812 "--out",
813 rebase_path(umbrella_header_path, root_build_dir),
814 "--sources",
815 ] + sources
816 }
817
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200818 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200819 sources = [
820 umbrella_header_path,
821 ]
822 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200823 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200824 ]
825
826 deps = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200827 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200828 ]
829 }
830 }
831}
832
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000833if (is_android) {
834 template("rtc_android_library") {
835 android_library(target_name) {
836 forward_variables_from(invoker,
837 "*",
838 [
839 "configs",
840 "public_configs",
841 "suppressed_configs",
842 "visibility",
843 ])
844
Oleh Prypin05aee742018-11-23 17:29:44 +0100845 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100846
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000847 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100848 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100849
Sami Kalliomäki68d58602019-01-24 12:56:12 +0100850 # WebRTC supports API level 16 while Chromium only supports 19.
851 # (the manifest defines minimum supported SDK version)
Oleh Prypin4cbb4ef2019-06-18 17:09:51 +0200852 if (defined(invoker.min_sdk_version)) {
853 min_sdk_version = invoker.min_sdk_version
Sami Kalliomäki68d58602019-01-24 12:56:12 +0100854 } else {
Oleh Prypin4cbb4ef2019-06-18 17:09:51 +0200855 min_sdk_version = 16
Sami Kalliomäki68d58602019-01-24 12:56:12 +0100856 }
857
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200858 # TODO(crbug.com/824679): Find out why this fails in Chromium
859 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100860 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200861 "-Xep:ParameterNotNullable:ERROR",
862 "-Xep:FieldMissingNullable:ERROR",
863 "-Xep:ReturnMissingNullable:ERROR",
864 ]
865 }
866
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100867 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +0100868 if (defined(invoker.errorprone_args)) {
869 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100870 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000871
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200872 if (!defined(deps)) {
873 deps = []
874 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200875
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000876 no_build_hooks = true
877 }
878 }
879
880 template("rtc_android_apk") {
881 android_apk(target_name) {
882 forward_variables_from(invoker,
883 "*",
884 [
885 "configs",
886 "public_configs",
887 "suppressed_configs",
888 "visibility",
889 ])
890
891 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100892 errorprone_args = [ "-Werror" ]
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000893
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200894 # TODO(crbug.com/824679): Find out why this fails in Chromium
895 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100896 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200897 "-Xep:ParameterNotNullable:ERROR",
898 "-Xep:FieldMissingNullable:ERROR",
899 "-Xep:ReturnMissingNullable:ERROR",
900 ]
901 }
902
903 if (!defined(deps)) {
904 deps = []
905 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200906
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000907 no_build_hooks = true
908 }
909 }
910
911 template("rtc_instrumentation_test_apk") {
912 instrumentation_test_apk(target_name) {
913 forward_variables_from(invoker,
914 "*",
915 [
916 "configs",
917 "public_configs",
918 "suppressed_configs",
919 "visibility",
920 ])
921
922 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100923 errorprone_args = [ "-Werror" ]
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000924
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200925 # TODO(crbug.com/824679): Find out why this fails in Chromium
926 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100927 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200928 "-Xep:ParameterNotNullable:ERROR",
929 "-Xep:FieldMissingNullable:ERROR",
930 "-Xep:ReturnMissingNullable:ERROR",
931 ]
932 }
933
934 if (!defined(deps)) {
935 deps = []
936 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200937
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000938 no_build_hooks = true
939 }
940 }
941}