blob: 2e6ccc8703baa1c9f92d8e1375b07db131bd3a8e [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
mbonadei9aa3f0a2017-01-24 06:58:22 -0800245}
246
247# Make it possible to provide custom locations for some libraries (move these
248# up into declare_args should we need to actually use them for the GN build).
249rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800250rtc_opus_dir = "//third_party/opus"
251
252# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200253rtc_desktop_capture_supported =
254 (is_win && current_os != "winuwp") || is_mac ||
255 (is_linux && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800256
257###############################################################################
258# Templates
259#
260
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200261# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800262# chromium.
263# We need absolute paths for all configs in templates as they are shared in
264# different subdirectories.
265webrtc_root = get_path_info(".", "abspath")
266
267# Global configuration that should be applied to all WebRTC targets.
268# You normally shouldn't need to include this in your target as it's
269# automatically included when using the rtc_* templates.
270# It sets defines, include paths and compilation warnings accordingly,
271# both for WebRTC stand-alone builds and for the scenario when WebRTC
272# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700273rtc_common_configs = [
274 webrtc_root + ":common_config",
275 "//build/config/compiler:no_size_t_to_int_warning",
276]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800277
kthelgasonc0977102017-04-24 00:57:16 -0700278if (is_mac || is_ios) {
279 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
280}
281
mbonadei9aa3f0a2017-01-24 06:58:22 -0800282# Global public configuration that should be applied to all WebRTC targets. You
283# normally shouldn't need to include this in your target as it's automatically
284# included when using the rtc_* templates. It set the defines, include paths and
285# compilation warnings that should be propagated to dependents of the targets
286# depending on the target having this config.
287rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
288
289# Common configs to remove or add in all rtc targets.
290rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100291if (!build_with_chromium && is_clang) {
292 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
293}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800294rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200295rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200296rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800297
298set_defaults("rtc_test") {
299 configs = rtc_add_configs
300 suppressed_configs = []
301}
302
303set_defaults("rtc_source_set") {
304 configs = rtc_add_configs
305 suppressed_configs = []
306}
307
308set_defaults("rtc_executable") {
309 configs = rtc_add_configs
310 suppressed_configs = []
311}
312
313set_defaults("rtc_static_library") {
314 configs = rtc_add_configs
315 suppressed_configs = []
316}
317
318set_defaults("rtc_shared_library") {
319 configs = rtc_add_configs
320 suppressed_configs = []
321}
322
Per Kjellandera7f2d842018-01-10 15:54:53 +0000323webrtc_default_visibility = [ webrtc_root + "/*" ]
324if (build_with_chromium) {
325 # Allow Chromium's WebRTC overrides targets to bypass the regular
326 # visibility restrictions.
327 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
328}
329
Karl Wibergbb23c832018-04-22 19:55:00 +0200330# ---- Poisons ----
331#
332# The general idea is that some targets declare that they contain some
333# kind of poison, which makes it impossible for other targets to
334# depend on them (even transitively) unless they declare themselves
335# immune to that particular type of poison.
336#
337# Targets that *contain* poison of type foo should contain the line
338#
339# poisonous = [ "foo" ]
340#
341# and targets that *are immune but arent't themselves poisonous*
342# should contain
343#
344# allow_poison = [ "foo" ]
345#
346# This useful in cases where we have some large target or set of
347# targets and want to ensure that most other targets do not
348# transitively depend on them. For example, almost no high-level
349# target should depend on the audio codecs, since we want WebRTC users
350# to be able to inject any subset of them and actually end up with a
351# binary that doesn't include the codecs they didn't inject.
352#
353# Test-only targets (`testonly` set to true) and non-public targets
354# (`visibility` not containing "*") are automatically immune to all
355# types of poison.
356#
357# Here's the complete list of all types of poison. It must be kept in
358# 1:1 correspondence with the set of //:poison_* targets.
359#
360all_poison_types = [
361 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
362 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200363
364 # Software video codecs (VP8 and VP9 through libvpx).
365 "software_video_codecs",
Danil Chapovalov41300af2019-07-10 12:44:43 +0200366
367 # Default task queue implementation.
368 "default_task_queue",
Karl Wibergbb23c832018-04-22 19:55:00 +0200369]
370
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000371absl_include_config = "//third_party/abseil-cpp:absl_include_config"
372absl_define_config = "//third_party/abseil-cpp:absl_define_config"
373
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200374# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
375# that are testonly.
376absl_flags_config = webrtc_root + ":absl_flags_configs"
377
mbonadei9aa3f0a2017-01-24 06:58:22 -0800378template("rtc_test") {
379 test(target_name) {
380 forward_variables_from(invoker,
381 "*",
382 [
383 "configs",
384 "public_configs",
385 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200386 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800387 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100388
389 # Always override to public because when target_os is Android the `test`
390 # template can override it to [ "*" ] and we want to avoid conditional
391 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100392 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800393 configs += invoker.configs
394 configs -= rtc_remove_configs
395 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000396 public_configs = [
397 rtc_common_inherited_config,
398 absl_include_config,
399 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200400 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000401 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800402 if (defined(invoker.public_configs)) {
403 public_configs += invoker.public_configs
404 }
sakald7fdb802017-05-26 01:51:53 -0700405 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800406 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Oleh Prypina79abd42019-06-25 23:19:17 +0200407 min_sdk_version = 16
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800408 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700409 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800410 }
411}
412
413template("rtc_source_set") {
414 source_set(target_name) {
415 forward_variables_from(invoker,
416 "*",
417 [
418 "configs",
419 "public_configs",
420 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200421 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800422 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200423 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000424 if (!defined(visibility)) {
425 visibility = webrtc_default_visibility
426 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200427
428 # What's your poison?
429 if (defined(testonly) && testonly) {
430 assert(!defined(poisonous))
431 assert(!defined(allow_poison))
432 } else {
433 if (!defined(poisonous)) {
434 poisonous = []
435 }
436 if (!defined(allow_poison)) {
437 allow_poison = []
438 }
439 if (!defined(assert_no_deps)) {
440 assert_no_deps = []
441 }
442 if (!defined(deps)) {
443 deps = []
444 }
445 foreach(p, poisonous) {
446 deps += [ webrtc_root + ":poison_" + p ]
447 }
448 foreach(poison_type, all_poison_types) {
449 allow_dep = true
450 foreach(v, visibility) {
451 if (v == "*") {
452 allow_dep = false
453 }
454 }
455 foreach(p, allow_poison + poisonous) {
456 if (p == poison_type) {
457 allow_dep = true
458 }
459 }
460 if (!allow_dep) {
461 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
462 }
463 }
464 }
465
Mirko Bonadei96ede162018-09-06 13:45:44 +0200466 if (!defined(testonly) || !testonly) {
467 configs += rtc_prod_configs
468 }
469
mbonadei9aa3f0a2017-01-24 06:58:22 -0800470 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200471 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800472 configs -= rtc_remove_configs
473 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000474 public_configs = [
475 rtc_common_inherited_config,
476 absl_include_config,
477 absl_define_config,
478 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200479 if (defined(testonly) && testonly) {
480 public_configs += [ absl_flags_config ]
481 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800482 if (defined(invoker.public_configs)) {
483 public_configs += invoker.public_configs
484 }
485 }
486}
487
488template("rtc_executable") {
489 executable(target_name) {
490 forward_variables_from(invoker,
491 "*",
492 [
493 "deps",
494 "configs",
495 "public_configs",
496 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200497 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800498 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200499 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000500 if (!defined(visibility)) {
501 visibility = webrtc_default_visibility
502 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800503 configs += invoker.configs
504 configs -= rtc_remove_configs
505 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700506 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700507
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000508 public_configs = [
509 rtc_common_inherited_config,
510 absl_include_config,
511 absl_define_config,
512 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200513 if (defined(testonly) && testonly) {
514 public_configs += [ absl_flags_config ]
515 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800516 if (defined(invoker.public_configs)) {
517 public_configs += invoker.public_configs
518 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200519 if (is_win) {
520 deps += [
521 # Give executables the default manifest on Windows (a no-op elsewhere).
522 "//build/win:default_exe_manifest",
523 ]
524 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800525 }
526}
527
528template("rtc_static_library") {
529 static_library(target_name) {
530 forward_variables_from(invoker,
531 "*",
532 [
533 "configs",
534 "public_configs",
535 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200536 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800537 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200538 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000539 if (!defined(visibility)) {
540 visibility = webrtc_default_visibility
541 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200542
543 # What's your poison?
544 if (defined(testonly) && testonly) {
545 assert(!defined(poisonous))
546 assert(!defined(allow_poison))
547 } else {
548 if (!defined(poisonous)) {
549 poisonous = []
550 }
551 if (!defined(allow_poison)) {
552 allow_poison = []
553 }
554 if (!defined(assert_no_deps)) {
555 assert_no_deps = []
556 }
557 if (!defined(deps)) {
558 deps = []
559 }
560 foreach(p, poisonous) {
561 deps += [ webrtc_root + ":poison_" + p ]
562 }
563 foreach(poison_type, all_poison_types) {
564 allow_dep = true
565 foreach(v, visibility) {
566 if (v == "*") {
567 allow_dep = false
568 }
569 }
570 foreach(p, allow_poison + poisonous) {
571 if (p == poison_type) {
572 allow_dep = true
573 }
574 }
575 if (!allow_dep) {
576 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
577 }
578 }
579 }
580
Mirko Bonadei96ede162018-09-06 13:45:44 +0200581 if (!defined(testonly) || !testonly) {
582 configs += rtc_prod_configs
583 }
584
mbonadei9aa3f0a2017-01-24 06:58:22 -0800585 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200586 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800587 configs -= rtc_remove_configs
588 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000589 public_configs = [
590 rtc_common_inherited_config,
591 absl_include_config,
592 absl_define_config,
593 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200594 if (defined(testonly) && testonly) {
595 public_configs += [ absl_flags_config ]
596 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800597 if (defined(invoker.public_configs)) {
598 public_configs += invoker.public_configs
599 }
600 }
601}
602
603template("rtc_shared_library") {
604 shared_library(target_name) {
605 forward_variables_from(invoker,
606 "*",
607 [
608 "configs",
609 "public_configs",
610 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200611 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800612 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200613 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000614 if (!defined(visibility)) {
615 visibility = webrtc_default_visibility
616 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200617
618 # What's your poison?
619 if (defined(testonly) && testonly) {
620 assert(!defined(poisonous))
621 assert(!defined(allow_poison))
622 } else {
623 if (!defined(poisonous)) {
624 poisonous = []
625 }
626 if (!defined(allow_poison)) {
627 allow_poison = []
628 }
629 if (!defined(assert_no_deps)) {
630 assert_no_deps = []
631 }
632 if (!defined(deps)) {
633 deps = []
634 }
635 foreach(p, poisonous) {
636 deps += [ webrtc_root + ":poison_" + p ]
637 }
638 foreach(poison_type, all_poison_types) {
639 allow_dep = true
640 foreach(v, visibility) {
641 if (v == "*") {
642 allow_dep = false
643 }
644 }
645 foreach(p, allow_poison + poisonous) {
646 if (p == poison_type) {
647 allow_dep = true
648 }
649 }
650 if (!allow_dep) {
651 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
652 }
653 }
654 }
655
mbonadei9aa3f0a2017-01-24 06:58:22 -0800656 configs += invoker.configs
657 configs -= rtc_remove_configs
658 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000659 public_configs = [
660 rtc_common_inherited_config,
661 absl_include_config,
662 absl_define_config,
663 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200664 if (defined(testonly) && testonly) {
665 public_configs += [ absl_flags_config ]
666 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800667 if (defined(invoker.public_configs)) {
668 public_configs += invoker.public_configs
669 }
670 }
671}
kthelgason4065a572017-02-14 04:58:56 -0800672
673if (is_ios) {
674 set_defaults("rtc_ios_xctest_test") {
675 configs = rtc_add_configs
676 suppressed_configs = []
677 }
678
679 template("rtc_ios_xctest_test") {
680 ios_xctest_test(target_name) {
681 forward_variables_from(invoker,
682 "*",
683 [
684 "configs",
685 "public_configs",
686 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200687 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800688 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200689 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000690 if (!defined(visibility)) {
691 visibility = webrtc_default_visibility
692 }
kthelgason4065a572017-02-14 04:58:56 -0800693 configs += invoker.configs
694 configs -= rtc_remove_configs
695 configs -= invoker.suppressed_configs
696 public_configs = [ rtc_common_inherited_config ]
697 if (defined(invoker.public_configs)) {
698 public_configs += invoker.public_configs
699 }
700 }
701 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100702
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400703 # TODO: Generate module.modulemap file to enable use in Swift
704 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100705 template("ios_framework_bundle_with_umbrella_header") {
706 forward_variables_from(invoker, [ "output_name" ])
707 umbrella_header_path =
708 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
709
710 ios_framework_bundle(target_name) {
711 forward_variables_from(invoker, "*", [])
712
713 deps += [ ":copy_umbrella_header_$target_name" ]
714 }
715
716 action("umbrella_header_$target_name") {
717 forward_variables_from(invoker, [ "public_headers" ])
718
719 script = "//tools_webrtc/ios/generate_umbrella_header.py"
720
721 outputs = [
722 umbrella_header_path,
723 ]
724 args = [
725 "--out",
726 rebase_path(umbrella_header_path, root_build_dir),
727 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200728 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100729 }
730
731 copy("copy_umbrella_header_$target_name") {
732 sources = [
733 umbrella_header_path,
734 ]
735 outputs = [
736 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
737 ]
738
739 deps = [
740 ":umbrella_header_$target_name",
741 ]
742 }
743 }
744
745 set_defaults("ios_framework_bundle_with_umbrella_header") {
746 configs = default_shared_library_configs
747 }
kthelgason4065a572017-02-14 04:58:56 -0800748}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000749
Anders Carlsson37bbf792018-09-05 16:29:27 +0200750if (is_mac) {
751 template("mac_framework_bundle_with_umbrella_header") {
752 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200753 this_target_name = target_name
754 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400755 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200756
757 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -0800758 forward_variables_from(invoker, "*", [ "configs" ])
759 if (defined(invoker.configs)) {
760 configs += invoker.configs
761 }
Anders Carlsson37bbf792018-09-05 16:29:27 +0200762
763 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400764 framework_contents = [
765 "Headers",
766 "Modules",
767 "Resources",
768 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +0200769
770 ldflags = [
771 "-all_load",
772 "-install_name",
773 "@rpath/$output_name.framework/$output_name",
774 ]
775
776 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200777 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400778 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200779 ":copy_umbrella_header_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400780 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200781 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200782 ]
783 }
784
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200785 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200786 forward_variables_from(invoker, [ "sources" ])
787
788 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200789 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200790 ]
791 }
792
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400793 action("modulemap_$this_target_name") {
794 script = "//tools_webrtc/ios/generate_modulemap.py"
795 args = [
796 "--out",
797 rebase_path(modulemap_path, root_build_dir),
798 "--name",
799 output_name,
800 ]
801 outputs = [
802 modulemap_path,
803 ]
804 }
805
806 bundle_data("copy_modulemap_$this_target_name") {
807 sources = [
808 modulemap_path,
809 ]
810 outputs = [
811 "{{bundle_contents_dir}}/Modules/module.modulemap",
812 ]
813 deps = [
814 ":modulemap_$this_target_name",
815 ]
816 }
817
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200818 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200819 forward_variables_from(invoker, [ "sources" ])
820
821 script = "//tools_webrtc/ios/generate_umbrella_header.py"
822
823 outputs = [
824 umbrella_header_path,
825 ]
826 args = [
827 "--out",
828 rebase_path(umbrella_header_path, root_build_dir),
829 "--sources",
830 ] + sources
831 }
832
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200833 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200834 sources = [
835 umbrella_header_path,
836 ]
837 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200838 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200839 ]
840
841 deps = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200842 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200843 ]
844 }
845 }
846}
847
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000848if (is_android) {
849 template("rtc_android_library") {
850 android_library(target_name) {
851 forward_variables_from(invoker,
852 "*",
853 [
854 "configs",
855 "public_configs",
856 "suppressed_configs",
857 "visibility",
858 ])
859
Oleh Prypin05aee742018-11-23 17:29:44 +0100860 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100861
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000862 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100863 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100864
Sami Kalliomäki68d58602019-01-24 12:56:12 +0100865 # WebRTC supports API level 16 while Chromium only supports 19.
866 # (the manifest defines minimum supported SDK version)
Oleh Prypin4cbb4ef2019-06-18 17:09:51 +0200867 if (defined(invoker.min_sdk_version)) {
868 min_sdk_version = invoker.min_sdk_version
Sami Kalliomäki68d58602019-01-24 12:56:12 +0100869 } else {
Oleh Prypin4cbb4ef2019-06-18 17:09:51 +0200870 min_sdk_version = 16
Sami Kalliomäki68d58602019-01-24 12:56:12 +0100871 }
872
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200873 # TODO(crbug.com/824679): Find out why this fails in Chromium
874 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100875 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200876 "-Xep:ParameterNotNullable:ERROR",
877 "-Xep:FieldMissingNullable:ERROR",
878 "-Xep:ReturnMissingNullable:ERROR",
879 ]
880 }
881
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100882 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +0100883 if (defined(invoker.errorprone_args)) {
884 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100885 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000886
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200887 if (!defined(deps)) {
888 deps = []
889 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200890
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000891 no_build_hooks = true
892 }
893 }
894
895 template("rtc_android_apk") {
896 android_apk(target_name) {
897 forward_variables_from(invoker,
898 "*",
899 [
900 "configs",
901 "public_configs",
902 "suppressed_configs",
903 "visibility",
904 ])
905
906 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100907 errorprone_args = [ "-Werror" ]
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000908
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200909 # TODO(crbug.com/824679): Find out why this fails in Chromium
910 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100911 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200912 "-Xep:ParameterNotNullable:ERROR",
913 "-Xep:FieldMissingNullable:ERROR",
914 "-Xep:ReturnMissingNullable:ERROR",
915 ]
916 }
917
918 if (!defined(deps)) {
919 deps = []
920 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200921
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000922 no_build_hooks = true
923 }
924 }
925
926 template("rtc_instrumentation_test_apk") {
927 instrumentation_test_apk(target_name) {
928 forward_variables_from(invoker,
929 "*",
930 [
931 "configs",
932 "public_configs",
933 "suppressed_configs",
934 "visibility",
935 ])
936
937 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100938 errorprone_args = [ "-Werror" ]
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000939
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200940 # TODO(crbug.com/824679): Find out why this fails in Chromium
941 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100942 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200943 "-Xep:ParameterNotNullable:ERROR",
944 "-Xep:FieldMissingNullable:ERROR",
945 "-Xep:ReturnMissingNullable:ERROR",
946 ]
947 }
948
949 if (!defined(deps)) {
950 deps = []
951 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200952
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000953 no_build_hooks = true
954 }
955 }
956}