blob: 77ed45f818b71e636aeea9cebfc47c320542c032 [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.
Wez00cecb92018-02-09 10:41:00 -0800224 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) {
Dan Minor9c686132018-01-15 10:20:00 -0500225 rtc_enable_libevent = false
226 rtc_build_libevent = false
227 } else {
228 rtc_enable_libevent = true
229 rtc_build_libevent = !build_with_mozilla
230 }
231
Dan Minor9c686132018-01-15 10:20:00 -0500232 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
233 # build environments, even if available for Chromium builds.
234 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
235
mbonadei9aa3f0a2017-01-24 06:58:22 -0800236 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
237 rtc_include_pulse_audio = !build_with_chromium
238
239 # Chromium uses its own IO handling, so the internal ADM is only built for
240 # standalone WebRTC.
241 rtc_include_internal_audio_device = !build_with_chromium
242
243 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500244 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 13:27:07 +0200245
246 # Set this to false to skip building code that also requires X11 extensions
247 # such as Xdamage, Xfixes.
248 rtc_use_x11_extensions = rtc_use_x11
mbonadei9aa3f0a2017-01-24 06:58:22 -0800249}
250
251# Make it possible to provide custom locations for some libraries (move these
252# up into declare_args should we need to actually use them for the GN build).
253rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800254rtc_opus_dir = "//third_party/opus"
255
256# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200257rtc_desktop_capture_supported =
258 (is_win && current_os != "winuwp") || is_mac ||
259 (is_linux && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800260
261###############################################################################
262# Templates
263#
264
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200265# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800266# chromium.
267# We need absolute paths for all configs in templates as they are shared in
268# different subdirectories.
269webrtc_root = get_path_info(".", "abspath")
270
271# Global configuration that should be applied to all WebRTC targets.
272# You normally shouldn't need to include this in your target as it's
273# automatically included when using the rtc_* templates.
274# It sets defines, include paths and compilation warnings accordingly,
275# both for WebRTC stand-alone builds and for the scenario when WebRTC
276# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700277rtc_common_configs = [
278 webrtc_root + ":common_config",
279 "//build/config/compiler:no_size_t_to_int_warning",
280]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800281
kthelgasonc0977102017-04-24 00:57:16 -0700282if (is_mac || is_ios) {
283 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
284}
285
mbonadei9aa3f0a2017-01-24 06:58:22 -0800286# Global public configuration that should be applied to all WebRTC targets. You
287# normally shouldn't need to include this in your target as it's automatically
288# included when using the rtc_* templates. It set the defines, include paths and
289# compilation warnings that should be propagated to dependents of the targets
290# depending on the target having this config.
291rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
292
293# Common configs to remove or add in all rtc targets.
294rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100295if (!build_with_chromium && is_clang) {
296 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
297}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800298rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200299rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200300rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800301
302set_defaults("rtc_test") {
303 configs = rtc_add_configs
304 suppressed_configs = []
305}
306
307set_defaults("rtc_source_set") {
308 configs = rtc_add_configs
309 suppressed_configs = []
310}
311
312set_defaults("rtc_executable") {
313 configs = rtc_add_configs
314 suppressed_configs = []
315}
316
317set_defaults("rtc_static_library") {
318 configs = rtc_add_configs
319 suppressed_configs = []
320}
321
322set_defaults("rtc_shared_library") {
323 configs = rtc_add_configs
324 suppressed_configs = []
325}
326
Per Kjellandera7f2d842018-01-10 15:54:53 +0000327webrtc_default_visibility = [ webrtc_root + "/*" ]
328if (build_with_chromium) {
329 # Allow Chromium's WebRTC overrides targets to bypass the regular
330 # visibility restrictions.
331 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
332}
333
Karl Wibergbb23c832018-04-22 19:55:00 +0200334# ---- Poisons ----
335#
336# The general idea is that some targets declare that they contain some
337# kind of poison, which makes it impossible for other targets to
338# depend on them (even transitively) unless they declare themselves
339# immune to that particular type of poison.
340#
341# Targets that *contain* poison of type foo should contain the line
342#
343# poisonous = [ "foo" ]
344#
345# and targets that *are immune but arent't themselves poisonous*
346# should contain
347#
348# allow_poison = [ "foo" ]
349#
350# This useful in cases where we have some large target or set of
351# targets and want to ensure that most other targets do not
352# transitively depend on them. For example, almost no high-level
353# target should depend on the audio codecs, since we want WebRTC users
354# to be able to inject any subset of them and actually end up with a
355# binary that doesn't include the codecs they didn't inject.
356#
357# Test-only targets (`testonly` set to true) and non-public targets
358# (`visibility` not containing "*") are automatically immune to all
359# types of poison.
360#
361# Here's the complete list of all types of poison. It must be kept in
362# 1:1 correspondence with the set of //:poison_* targets.
363#
364all_poison_types = [
365 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
366 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200367
368 # Software video codecs (VP8 and VP9 through libvpx).
369 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200370]
371
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000372absl_include_config = "//third_party/abseil-cpp:absl_include_config"
373absl_define_config = "//third_party/abseil-cpp:absl_define_config"
374
mbonadei9aa3f0a2017-01-24 06:58:22 -0800375template("rtc_test") {
376 test(target_name) {
377 forward_variables_from(invoker,
378 "*",
379 [
380 "configs",
381 "public_configs",
382 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200383 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800384 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100385
386 # Always override to public because when target_os is Android the `test`
387 # template can override it to [ "*" ] and we want to avoid conditional
388 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100389 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800390 configs += invoker.configs
391 configs -= rtc_remove_configs
392 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000393 public_configs = [
394 rtc_common_inherited_config,
395 absl_include_config,
396 absl_define_config,
397 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800398 if (defined(invoker.public_configs)) {
399 public_configs += invoker.public_configs
400 }
sakald7fdb802017-05-26 01:51:53 -0700401 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800402 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
403 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700404 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800405 }
406}
407
408template("rtc_source_set") {
409 source_set(target_name) {
410 forward_variables_from(invoker,
411 "*",
412 [
413 "configs",
414 "public_configs",
415 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200416 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800417 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200418 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000419 if (!defined(visibility)) {
420 visibility = webrtc_default_visibility
421 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200422
423 # What's your poison?
424 if (defined(testonly) && testonly) {
425 assert(!defined(poisonous))
426 assert(!defined(allow_poison))
427 } else {
428 if (!defined(poisonous)) {
429 poisonous = []
430 }
431 if (!defined(allow_poison)) {
432 allow_poison = []
433 }
434 if (!defined(assert_no_deps)) {
435 assert_no_deps = []
436 }
437 if (!defined(deps)) {
438 deps = []
439 }
440 foreach(p, poisonous) {
441 deps += [ webrtc_root + ":poison_" + p ]
442 }
443 foreach(poison_type, all_poison_types) {
444 allow_dep = true
445 foreach(v, visibility) {
446 if (v == "*") {
447 allow_dep = false
448 }
449 }
450 foreach(p, allow_poison + poisonous) {
451 if (p == poison_type) {
452 allow_dep = true
453 }
454 }
455 if (!allow_dep) {
456 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
457 }
458 }
459 }
460
Mirko Bonadei96ede162018-09-06 13:45:44 +0200461 if (!defined(testonly) || !testonly) {
462 configs += rtc_prod_configs
463 }
464
mbonadei9aa3f0a2017-01-24 06:58:22 -0800465 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200466 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800467 configs -= rtc_remove_configs
468 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000469 public_configs = [
470 rtc_common_inherited_config,
471 absl_include_config,
472 absl_define_config,
473 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800474 if (defined(invoker.public_configs)) {
475 public_configs += invoker.public_configs
476 }
477 }
478}
479
480template("rtc_executable") {
481 executable(target_name) {
482 forward_variables_from(invoker,
483 "*",
484 [
485 "deps",
486 "configs",
487 "public_configs",
488 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200489 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800490 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200491 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000492 if (!defined(visibility)) {
493 visibility = webrtc_default_visibility
494 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800495 configs += invoker.configs
496 configs -= rtc_remove_configs
497 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700498 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700499
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000500 public_configs = [
501 rtc_common_inherited_config,
502 absl_include_config,
503 absl_define_config,
504 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800505 if (defined(invoker.public_configs)) {
506 public_configs += invoker.public_configs
507 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200508 if (is_win) {
509 deps += [
510 # Give executables the default manifest on Windows (a no-op elsewhere).
511 "//build/win:default_exe_manifest",
512 ]
513 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800514 }
515}
516
517template("rtc_static_library") {
518 static_library(target_name) {
519 forward_variables_from(invoker,
520 "*",
521 [
522 "configs",
523 "public_configs",
524 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200525 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800526 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200527 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000528 if (!defined(visibility)) {
529 visibility = webrtc_default_visibility
530 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200531
532 # What's your poison?
533 if (defined(testonly) && testonly) {
534 assert(!defined(poisonous))
535 assert(!defined(allow_poison))
536 } else {
537 if (!defined(poisonous)) {
538 poisonous = []
539 }
540 if (!defined(allow_poison)) {
541 allow_poison = []
542 }
543 if (!defined(assert_no_deps)) {
544 assert_no_deps = []
545 }
546 if (!defined(deps)) {
547 deps = []
548 }
549 foreach(p, poisonous) {
550 deps += [ webrtc_root + ":poison_" + p ]
551 }
552 foreach(poison_type, all_poison_types) {
553 allow_dep = true
554 foreach(v, visibility) {
555 if (v == "*") {
556 allow_dep = false
557 }
558 }
559 foreach(p, allow_poison + poisonous) {
560 if (p == poison_type) {
561 allow_dep = true
562 }
563 }
564 if (!allow_dep) {
565 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
566 }
567 }
568 }
569
Mirko Bonadei96ede162018-09-06 13:45:44 +0200570 if (!defined(testonly) || !testonly) {
571 configs += rtc_prod_configs
572 }
573
mbonadei9aa3f0a2017-01-24 06:58:22 -0800574 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200575 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800576 configs -= rtc_remove_configs
577 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000578 public_configs = [
579 rtc_common_inherited_config,
580 absl_include_config,
581 absl_define_config,
582 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800583 if (defined(invoker.public_configs)) {
584 public_configs += invoker.public_configs
585 }
586 }
587}
588
589template("rtc_shared_library") {
590 shared_library(target_name) {
591 forward_variables_from(invoker,
592 "*",
593 [
594 "configs",
595 "public_configs",
596 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200597 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800598 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200599 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000600 if (!defined(visibility)) {
601 visibility = webrtc_default_visibility
602 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200603
604 # What's your poison?
605 if (defined(testonly) && testonly) {
606 assert(!defined(poisonous))
607 assert(!defined(allow_poison))
608 } else {
609 if (!defined(poisonous)) {
610 poisonous = []
611 }
612 if (!defined(allow_poison)) {
613 allow_poison = []
614 }
615 if (!defined(assert_no_deps)) {
616 assert_no_deps = []
617 }
618 if (!defined(deps)) {
619 deps = []
620 }
621 foreach(p, poisonous) {
622 deps += [ webrtc_root + ":poison_" + p ]
623 }
624 foreach(poison_type, all_poison_types) {
625 allow_dep = true
626 foreach(v, visibility) {
627 if (v == "*") {
628 allow_dep = false
629 }
630 }
631 foreach(p, allow_poison + poisonous) {
632 if (p == poison_type) {
633 allow_dep = true
634 }
635 }
636 if (!allow_dep) {
637 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
638 }
639 }
640 }
641
mbonadei9aa3f0a2017-01-24 06:58:22 -0800642 configs += invoker.configs
643 configs -= rtc_remove_configs
644 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000645 public_configs = [
646 rtc_common_inherited_config,
647 absl_include_config,
648 absl_define_config,
649 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800650 if (defined(invoker.public_configs)) {
651 public_configs += invoker.public_configs
652 }
653 }
654}
kthelgason4065a572017-02-14 04:58:56 -0800655
656if (is_ios) {
657 set_defaults("rtc_ios_xctest_test") {
658 configs = rtc_add_configs
659 suppressed_configs = []
660 }
661
662 template("rtc_ios_xctest_test") {
663 ios_xctest_test(target_name) {
664 forward_variables_from(invoker,
665 "*",
666 [
667 "configs",
668 "public_configs",
669 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200670 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800671 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200672 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000673 if (!defined(visibility)) {
674 visibility = webrtc_default_visibility
675 }
kthelgason4065a572017-02-14 04:58:56 -0800676 configs += invoker.configs
677 configs -= rtc_remove_configs
678 configs -= invoker.suppressed_configs
679 public_configs = [ rtc_common_inherited_config ]
680 if (defined(invoker.public_configs)) {
681 public_configs += invoker.public_configs
682 }
683 }
684 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100685
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400686 # TODO: Generate module.modulemap file to enable use in Swift
687 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100688 template("ios_framework_bundle_with_umbrella_header") {
689 forward_variables_from(invoker, [ "output_name" ])
690 umbrella_header_path =
691 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
692
693 ios_framework_bundle(target_name) {
694 forward_variables_from(invoker, "*", [])
695
696 deps += [ ":copy_umbrella_header_$target_name" ]
697 }
698
699 action("umbrella_header_$target_name") {
700 forward_variables_from(invoker, [ "public_headers" ])
701
702 script = "//tools_webrtc/ios/generate_umbrella_header.py"
703
704 outputs = [
705 umbrella_header_path,
706 ]
707 args = [
708 "--out",
709 rebase_path(umbrella_header_path, root_build_dir),
710 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200711 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100712 }
713
714 copy("copy_umbrella_header_$target_name") {
715 sources = [
716 umbrella_header_path,
717 ]
718 outputs = [
719 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
720 ]
721
722 deps = [
723 ":umbrella_header_$target_name",
724 ]
725 }
726 }
727
728 set_defaults("ios_framework_bundle_with_umbrella_header") {
729 configs = default_shared_library_configs
730 }
kthelgason4065a572017-02-14 04:58:56 -0800731}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000732
Anders Carlsson37bbf792018-09-05 16:29:27 +0200733if (is_mac) {
734 template("mac_framework_bundle_with_umbrella_header") {
735 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200736 this_target_name = target_name
737 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400738 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200739
740 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -0800741 forward_variables_from(invoker, "*", [ "configs" ])
742 if (defined(invoker.configs)) {
743 configs += invoker.configs
744 }
Anders Carlsson37bbf792018-09-05 16:29:27 +0200745
746 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400747 framework_contents = [
748 "Headers",
749 "Modules",
750 "Resources",
751 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +0200752
753 ldflags = [
754 "-all_load",
755 "-install_name",
756 "@rpath/$output_name.framework/$output_name",
757 ]
758
759 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200760 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400761 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200762 ":copy_umbrella_header_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400763 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200764 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200765 ]
766 }
767
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200768 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200769 forward_variables_from(invoker, [ "sources" ])
770
771 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200772 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200773 ]
774 }
775
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400776 action("modulemap_$this_target_name") {
777 script = "//tools_webrtc/ios/generate_modulemap.py"
778 args = [
779 "--out",
780 rebase_path(modulemap_path, root_build_dir),
781 "--name",
782 output_name,
783 ]
784 outputs = [
785 modulemap_path,
786 ]
787 }
788
789 bundle_data("copy_modulemap_$this_target_name") {
790 sources = [
791 modulemap_path,
792 ]
793 outputs = [
794 "{{bundle_contents_dir}}/Modules/module.modulemap",
795 ]
796 deps = [
797 ":modulemap_$this_target_name",
798 ]
799 }
800
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200801 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200802 forward_variables_from(invoker, [ "sources" ])
803
804 script = "//tools_webrtc/ios/generate_umbrella_header.py"
805
806 outputs = [
807 umbrella_header_path,
808 ]
809 args = [
810 "--out",
811 rebase_path(umbrella_header_path, root_build_dir),
812 "--sources",
813 ] + sources
814 }
815
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200816 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200817 sources = [
818 umbrella_header_path,
819 ]
820 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200821 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200822 ]
823
824 deps = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200825 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200826 ]
827 }
828 }
829}
830
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000831if (is_android) {
832 template("rtc_android_library") {
833 android_library(target_name) {
834 forward_variables_from(invoker,
835 "*",
836 [
837 "configs",
838 "public_configs",
839 "suppressed_configs",
840 "visibility",
841 ])
842
Oleh Prypin05aee742018-11-23 17:29:44 +0100843 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100844
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000845 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100846 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100847
Sami Kalliomäki68d58602019-01-24 12:56:12 +0100848 # WebRTC supports API level 16 while Chromium only supports 19.
849 # (the manifest defines minimum supported SDK version)
Oleh Prypin4cbb4ef2019-06-18 17:09:51 +0200850 if (defined(invoker.min_sdk_version)) {
851 min_sdk_version = invoker.min_sdk_version
Sami Kalliomäki68d58602019-01-24 12:56:12 +0100852 } else {
Oleh Prypin4cbb4ef2019-06-18 17:09:51 +0200853 min_sdk_version = 16
Sami Kalliomäki68d58602019-01-24 12:56:12 +0100854 }
855
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200856 # TODO(crbug.com/824679): Find out why this fails in Chromium
857 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100858 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200859 "-Xep:ParameterNotNullable:ERROR",
860 "-Xep:FieldMissingNullable:ERROR",
861 "-Xep:ReturnMissingNullable:ERROR",
862 ]
863 }
864
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100865 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +0100866 if (defined(invoker.errorprone_args)) {
867 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100868 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000869
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200870 if (!defined(deps)) {
871 deps = []
872 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200873
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000874 no_build_hooks = true
875 }
876 }
877
878 template("rtc_android_apk") {
879 android_apk(target_name) {
880 forward_variables_from(invoker,
881 "*",
882 [
883 "configs",
884 "public_configs",
885 "suppressed_configs",
886 "visibility",
887 ])
888
889 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100890 errorprone_args = [ "-Werror" ]
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000891
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200892 # TODO(crbug.com/824679): Find out why this fails in Chromium
893 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100894 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200895 "-Xep:ParameterNotNullable:ERROR",
896 "-Xep:FieldMissingNullable:ERROR",
897 "-Xep:ReturnMissingNullable:ERROR",
898 ]
899 }
900
901 if (!defined(deps)) {
902 deps = []
903 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200904
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000905 no_build_hooks = true
906 }
907 }
908
909 template("rtc_instrumentation_test_apk") {
910 instrumentation_test_apk(target_name) {
911 forward_variables_from(invoker,
912 "*",
913 [
914 "configs",
915 "public_configs",
916 "suppressed_configs",
917 "visibility",
918 ])
919
920 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100921 errorprone_args = [ "-Werror" ]
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000922
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200923 # TODO(crbug.com/824679): Find out why this fails in Chromium
924 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100925 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200926 "-Xep:ParameterNotNullable:ERROR",
927 "-Xep:FieldMissingNullable:ERROR",
928 "-Xep:ReturnMissingNullable:ERROR",
929 ]
930 }
931
932 if (!defined(deps)) {
933 deps = []
934 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200935
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000936 no_build_hooks = true
937 }
938 }
939}