blob: bdbc2dd7529589f79ebd343d8049e997d4d0e4ce [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")
ehmaldonado0d729b32017-02-10 01:38:23 -080012import("//build/config/ui.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -080013import("//build_overrides/build.gni")
mbonadei96606272017-03-03 19:41:59 -080014
15if (!build_with_chromium && is_component_build) {
16 print("The Gn argument `is_component_build` is currently " +
17 "ignored for WebRTC builds.")
18 print("Component builds are supported by Chromium and the argument " +
19 "`is_component_build` makes it possible to create shared libraries " +
20 "instead of static libraries.")
21 print("If an app depends on WebRTC it makes sense to just depend on the " +
22 "WebRTC static library, so there is no difference between " +
23 "`is_component_build=true` and `is_component_build=false`.")
24 print(
25 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.md")
26 assert(!is_component_build, "Component builds are not supported in WebRTC.")
27}
28
kthelgason4065a572017-02-14 04:58:56 -080029if (is_ios) {
30 import("//build/config/ios/rules.gni")
31}
mbonadei9aa3f0a2017-01-24 06:58:22 -080032
33declare_args() {
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070034 # Setting this to false will require the API user to pass in their own
35 # SSLCertificateVerifier to verify the certificates presented from a
36 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
37 rtc_builtin_ssl_root_certificates = true
38
Karl Wibergeb254b42017-11-01 15:08:12 +010039 # Include the iLBC audio codec?
40 rtc_include_ilbc = true
41
mbonadei9aa3f0a2017-01-24 06:58:22 -080042 # Disable this to avoid building the Opus audio codec.
43 rtc_include_opus = true
44
minyue2e03c662017-02-01 17:31:11 -080045 # Enable this if the Opus version upon which WebRTC is built supports direct
46 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020047 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080048
mbonadei9aa3f0a2017-01-24 06:58:22 -080049 # Enable this to let the Opus audio codec change complexity on the fly.
50 rtc_opus_variable_complexity = false
51
mbonadei9aa3f0a2017-01-24 06:58:22 -080052 # Used to specify an external Jsoncpp include path when not compiling the
53 # library that comes with WebRTC (i.e. rtc_build_json == 0).
54 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
55
56 # Used to specify an external OpenSSL include path when not compiling the
57 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
58 rtc_ssl_root = ""
59
60 # Selects fixed-point code where possible.
61 rtc_prefer_fixed_point = false
62
mbonadei9aa3f0a2017-01-24 06:58:22 -080063 # Disable the code for the intelligibility enhancer by default.
64 rtc_enable_intelligibility_enhancer = false
65
66 # Enable when an external authentication mechanism is used for performing
67 # packet authentication for RTP packets instead of libsrtp.
68 rtc_enable_external_auth = build_with_chromium
69
70 # Selects whether debug dumps for the audio processing module
71 # should be generated.
72 apm_debug_dump = false
73
74 # Set this to true to enable BWE test logging.
75 rtc_enable_bwe_test_logging = false
76
Joachim Bauch93e91342017-12-07 01:25:53 +010077 # Set this to false to skip building examples.
78 rtc_build_examples = true
79
80 # Set this to false to skip building tools.
81 rtc_build_tools = true
82
Joachim Bauch75f18fc2017-12-20 21:25:47 +010083 # Set this to false to skip building code that requires X11.
84 rtc_use_x11 = use_x11
85
mbonadei9aa3f0a2017-01-24 06:58:22 -080086 # Enable to use the Mozilla internal settings.
87 build_with_mozilla = false
88
henrika883d00f2018-03-16 10:09:49 +010089 # Enable use of Android AAudio which requires Android SDK 26 or above and
90 # NDK r16 or above.
91 rtc_enable_android_aaudio = false
92
93 # TODO(henrika): can this flag be removed?
mbonadei9aa3f0a2017-01-24 06:58:22 -080094 rtc_enable_android_opensl = false
95
96 # Link-Time Optimizations.
97 # Executes code generation at link-time instead of compile-time.
98 # https://gcc.gnu.org/wiki/LinkTimeOptimization
99 rtc_use_lto = false
100
101 # Set to "func", "block", "edge" for coverage generation.
102 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
103 # It is recommend to set include_examples=0.
104 # Use llvm's sancov -html-report for human readable reports.
105 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
106 rtc_sanitize_coverage = ""
107
perkj650fdae2017-08-25 05:00:11 -0700108 # Links a default implementation of task queues to targets
109 # that depend on the target rtc_task_queue. Set to false to
110 # use an external implementation.
111 rtc_link_task_queue_impl = true
112
mbonadei9aa3f0a2017-01-24 06:58:22 -0800113 if (current_cpu == "arm" || current_cpu == "arm64") {
114 rtc_prefer_fixed_point = true
115 }
116
mbonadei9aa3f0a2017-01-24 06:58:22 -0800117 # Determines whether NEON code will be built.
118 rtc_build_with_neon =
119 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
120
121 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
122 # all platforms except Android and iOS. Because FFmpeg can be built
123 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
124 # value that includes H.264, for example "Chrome". If FFmpeg is built without
125 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize. See
126 # also: |rtc_initialize_ffmpeg|.
127 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
128 # http://www.openh264.org, https://www.ffmpeg.org/
Patrik Höglund3bb11942018-03-16 12:36:26 +0000129 rtc_use_h264 = proprietary_codecs && !is_android && !is_ios
mbonadei9aa3f0a2017-01-24 06:58:22 -0800130
mbonadei9aa3f0a2017-01-24 06:58:22 -0800131 # By default, use normal platform audio support or dummy audio, but don't
132 # use file-based audio playout and record.
133 rtc_use_dummy_audio_file_devices = false
134
henrika7be78832017-06-13 17:34:16 +0200135 # When set to true, replace the audio output with a sinus tone at 440Hz.
136 # The ADM will ask for audio data from WebRTC but instead of reading real
137 # audio samples from NetEQ, a sinus tone will be generated and replace the
138 # real audio samples.
139 rtc_audio_device_plays_sinus_tone = false
140
mbonadei9aa3f0a2017-01-24 06:58:22 -0800141 # When set to true, test targets will declare the files needed to run memcheck
142 # as data dependencies. This is to enable memcheck execution on swarming bots.
143 rtc_use_memcheck = false
144
145 # FFmpeg must be initialized for |H264DecoderImpl| to work. This can be done
146 # by WebRTC during |H264DecoderImpl::InitDecode| or externally. FFmpeg must
147 # only be initialized once. Projects that initialize FFmpeg externally, such
148 # as Chromium, must turn this flag off so that WebRTC does not also
149 # initialize.
150 rtc_initialize_ffmpeg = !build_with_chromium
Anders Carlssondd8c1652018-01-30 10:32:13 +0100151
152 # Disable this to build without support for built-in software codecs.
153 rtc_use_builtin_sw_codecs = true
Anders Carlsson358f2e02018-06-04 10:24:37 +0200154
155 if (is_ios) {
156 # Build broadcast extension in AppRTCMobile for iOS. This results in the
157 # binary only running on iOS 11+, which is why it is disabled by default.
158 rtc_apprtcmobile_broadcast_extension = false
159 }
Dan Minor9c686132018-01-15 10:20:00 -0500160}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800161
Dan Minor9c686132018-01-15 10:20:00 -0500162if (!build_with_mozilla) {
163 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800164}
165
166# A second declare_args block, so that declarations within it can
167# depend on the possibly overridden variables in the first
168# declare_args block.
169declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500170 # Enables the use of protocol buffers for debug recordings.
171 rtc_enable_protobuf = !build_with_mozilla
172
173 # Set this to disable building with support for SCTP data channels.
174 rtc_enable_sctp = !build_with_mozilla
175
176 # Disable these to not build components which can be externally provided.
177 rtc_build_json = !build_with_mozilla
178 rtc_build_libsrtp = !build_with_mozilla
179 rtc_build_libvpx = !build_with_mozilla
180 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500181 rtc_build_opus = !build_with_mozilla
182 rtc_build_ssl = !build_with_mozilla
183 rtc_build_usrsctp = !build_with_mozilla
184
185 # Enable libevent task queues on platforms that support it.
186 # rtc_link_task_queue_impl must be set to true for this to
187 # have an effect.
Wez00cecb92018-02-09 10:41:00 -0800188 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) {
Dan Minor9c686132018-01-15 10:20:00 -0500189 rtc_enable_libevent = false
190 rtc_build_libevent = false
191 } else {
192 rtc_enable_libevent = true
193 rtc_build_libevent = !build_with_mozilla
194 }
195
Dan Minor9c686132018-01-15 10:20:00 -0500196 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
197 # build environments, even if available for Chromium builds.
198 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
199
mbonadei9aa3f0a2017-01-24 06:58:22 -0800200 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
201 rtc_include_pulse_audio = !build_with_chromium
202
203 # Chromium uses its own IO handling, so the internal ADM is only built for
204 # standalone WebRTC.
205 rtc_include_internal_audio_device = !build_with_chromium
206
207 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500208 rtc_include_tests = !build_with_chromium && !build_with_mozilla
mbonadei9aa3f0a2017-01-24 06:58:22 -0800209}
210
211# Make it possible to provide custom locations for some libraries (move these
212# up into declare_args should we need to actually use them for the GN build).
213rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800214rtc_opus_dir = "//third_party/opus"
215
216# Desktop capturer is supported only on Windows, OSX and Linux.
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100217rtc_desktop_capture_supported = is_win || is_mac || (is_linux && rtc_use_x11)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800218
219###############################################################################
220# Templates
221#
222
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200223# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800224# chromium.
225# We need absolute paths for all configs in templates as they are shared in
226# different subdirectories.
227webrtc_root = get_path_info(".", "abspath")
228
229# Global configuration that should be applied to all WebRTC targets.
230# You normally shouldn't need to include this in your target as it's
231# automatically included when using the rtc_* templates.
232# It sets defines, include paths and compilation warnings accordingly,
233# both for WebRTC stand-alone builds and for the scenario when WebRTC
234# native code is built as part of Chromium.
235rtc_common_configs = [ webrtc_root + ":common_config" ]
236
kthelgasonc0977102017-04-24 00:57:16 -0700237if (is_mac || is_ios) {
238 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
239}
240
mbonadei9aa3f0a2017-01-24 06:58:22 -0800241# Global public configuration that should be applied to all WebRTC targets. You
242# normally shouldn't need to include this in your target as it's automatically
243# included when using the rtc_* templates. It set the defines, include paths and
244# compilation warnings that should be propagated to dependents of the targets
245# depending on the target having this config.
246rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
247
248# Common configs to remove or add in all rtc targets.
249rtc_remove_configs = []
250rtc_add_configs = rtc_common_configs
251
252set_defaults("rtc_test") {
253 configs = rtc_add_configs
254 suppressed_configs = []
255}
256
257set_defaults("rtc_source_set") {
258 configs = rtc_add_configs
259 suppressed_configs = []
260}
261
262set_defaults("rtc_executable") {
263 configs = rtc_add_configs
264 suppressed_configs = []
265}
266
267set_defaults("rtc_static_library") {
268 configs = rtc_add_configs
269 suppressed_configs = []
270}
271
272set_defaults("rtc_shared_library") {
273 configs = rtc_add_configs
274 suppressed_configs = []
275}
276
Per Kjellandera7f2d842018-01-10 15:54:53 +0000277webrtc_default_visibility = [ webrtc_root + "/*" ]
278if (build_with_chromium) {
279 # Allow Chromium's WebRTC overrides targets to bypass the regular
280 # visibility restrictions.
281 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
282}
283
Karl Wibergbb23c832018-04-22 19:55:00 +0200284# ---- Poisons ----
285#
286# The general idea is that some targets declare that they contain some
287# kind of poison, which makes it impossible for other targets to
288# depend on them (even transitively) unless they declare themselves
289# immune to that particular type of poison.
290#
291# Targets that *contain* poison of type foo should contain the line
292#
293# poisonous = [ "foo" ]
294#
295# and targets that *are immune but arent't themselves poisonous*
296# should contain
297#
298# allow_poison = [ "foo" ]
299#
300# This useful in cases where we have some large target or set of
301# targets and want to ensure that most other targets do not
302# transitively depend on them. For example, almost no high-level
303# target should depend on the audio codecs, since we want WebRTC users
304# to be able to inject any subset of them and actually end up with a
305# binary that doesn't include the codecs they didn't inject.
306#
307# Test-only targets (`testonly` set to true) and non-public targets
308# (`visibility` not containing "*") are automatically immune to all
309# types of poison.
310#
311# Here's the complete list of all types of poison. It must be kept in
312# 1:1 correspondence with the set of //:poison_* targets.
313#
314all_poison_types = [
315 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
316 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200317
318 # Software video codecs (VP8 and VP9 through libvpx).
319 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200320]
321
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000322absl_include_config = "//third_party/abseil-cpp:absl_include_config"
323absl_define_config = "//third_party/abseil-cpp:absl_define_config"
324
mbonadei9aa3f0a2017-01-24 06:58:22 -0800325template("rtc_test") {
326 test(target_name) {
327 forward_variables_from(invoker,
328 "*",
329 [
330 "configs",
331 "public_configs",
332 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200333 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800334 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100335
336 # Always override to public because when target_os is Android the `test`
337 # template can override it to [ "*" ] and we want to avoid conditional
338 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100339 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800340 configs += invoker.configs
341 configs -= rtc_remove_configs
342 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000343 public_configs = [
344 rtc_common_inherited_config,
345 absl_include_config,
346 absl_define_config,
347 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800348 if (defined(invoker.public_configs)) {
349 public_configs += invoker.public_configs
350 }
sakald7fdb802017-05-26 01:51:53 -0700351 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800352 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
353 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700354 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800355 }
356}
357
358template("rtc_source_set") {
359 source_set(target_name) {
360 forward_variables_from(invoker,
361 "*",
362 [
363 "configs",
364 "public_configs",
365 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200366 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800367 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200368 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000369 if (!defined(visibility)) {
370 visibility = webrtc_default_visibility
371 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200372
373 # What's your poison?
374 if (defined(testonly) && testonly) {
375 assert(!defined(poisonous))
376 assert(!defined(allow_poison))
377 } else {
378 if (!defined(poisonous)) {
379 poisonous = []
380 }
381 if (!defined(allow_poison)) {
382 allow_poison = []
383 }
384 if (!defined(assert_no_deps)) {
385 assert_no_deps = []
386 }
387 if (!defined(deps)) {
388 deps = []
389 }
390 foreach(p, poisonous) {
391 deps += [ webrtc_root + ":poison_" + p ]
392 }
393 foreach(poison_type, all_poison_types) {
394 allow_dep = true
395 foreach(v, visibility) {
396 if (v == "*") {
397 allow_dep = false
398 }
399 }
400 foreach(p, allow_poison + poisonous) {
401 if (p == poison_type) {
402 allow_dep = true
403 }
404 }
405 if (!allow_dep) {
406 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
407 }
408 }
409 }
410
mbonadei9aa3f0a2017-01-24 06:58:22 -0800411 configs += invoker.configs
412 configs -= rtc_remove_configs
413 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000414 public_configs = [
415 rtc_common_inherited_config,
416 absl_include_config,
417 absl_define_config,
418 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800419 if (defined(invoker.public_configs)) {
420 public_configs += invoker.public_configs
421 }
422 }
423}
424
425template("rtc_executable") {
426 executable(target_name) {
427 forward_variables_from(invoker,
428 "*",
429 [
430 "deps",
431 "configs",
432 "public_configs",
433 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200434 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800435 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200436 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000437 if (!defined(visibility)) {
438 visibility = webrtc_default_visibility
439 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800440 configs += invoker.configs
441 configs -= rtc_remove_configs
442 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700443 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700444
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000445 public_configs = [
446 rtc_common_inherited_config,
447 absl_include_config,
448 absl_define_config,
449 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800450 if (defined(invoker.public_configs)) {
451 public_configs += invoker.public_configs
452 }
453 }
454}
455
456template("rtc_static_library") {
457 static_library(target_name) {
458 forward_variables_from(invoker,
459 "*",
460 [
461 "configs",
462 "public_configs",
463 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200464 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800465 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200466 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000467 if (!defined(visibility)) {
468 visibility = webrtc_default_visibility
469 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200470
471 # What's your poison?
472 if (defined(testonly) && testonly) {
473 assert(!defined(poisonous))
474 assert(!defined(allow_poison))
475 } else {
476 if (!defined(poisonous)) {
477 poisonous = []
478 }
479 if (!defined(allow_poison)) {
480 allow_poison = []
481 }
482 if (!defined(assert_no_deps)) {
483 assert_no_deps = []
484 }
485 if (!defined(deps)) {
486 deps = []
487 }
488 foreach(p, poisonous) {
489 deps += [ webrtc_root + ":poison_" + p ]
490 }
491 foreach(poison_type, all_poison_types) {
492 allow_dep = true
493 foreach(v, visibility) {
494 if (v == "*") {
495 allow_dep = false
496 }
497 }
498 foreach(p, allow_poison + poisonous) {
499 if (p == poison_type) {
500 allow_dep = true
501 }
502 }
503 if (!allow_dep) {
504 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
505 }
506 }
507 }
508
mbonadei9aa3f0a2017-01-24 06:58:22 -0800509 configs += invoker.configs
510 configs -= rtc_remove_configs
511 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000512 public_configs = [
513 rtc_common_inherited_config,
514 absl_include_config,
515 absl_define_config,
516 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800517 if (defined(invoker.public_configs)) {
518 public_configs += invoker.public_configs
519 }
520 }
521}
522
523template("rtc_shared_library") {
524 shared_library(target_name) {
525 forward_variables_from(invoker,
526 "*",
527 [
528 "configs",
529 "public_configs",
530 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200531 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800532 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200533 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000534 if (!defined(visibility)) {
535 visibility = webrtc_default_visibility
536 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200537
538 # What's your poison?
539 if (defined(testonly) && testonly) {
540 assert(!defined(poisonous))
541 assert(!defined(allow_poison))
542 } else {
543 if (!defined(poisonous)) {
544 poisonous = []
545 }
546 if (!defined(allow_poison)) {
547 allow_poison = []
548 }
549 if (!defined(assert_no_deps)) {
550 assert_no_deps = []
551 }
552 if (!defined(deps)) {
553 deps = []
554 }
555 foreach(p, poisonous) {
556 deps += [ webrtc_root + ":poison_" + p ]
557 }
558 foreach(poison_type, all_poison_types) {
559 allow_dep = true
560 foreach(v, visibility) {
561 if (v == "*") {
562 allow_dep = false
563 }
564 }
565 foreach(p, allow_poison + poisonous) {
566 if (p == poison_type) {
567 allow_dep = true
568 }
569 }
570 if (!allow_dep) {
571 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
572 }
573 }
574 }
575
mbonadei9aa3f0a2017-01-24 06:58:22 -0800576 configs += invoker.configs
577 configs -= rtc_remove_configs
578 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000579 public_configs = [
580 rtc_common_inherited_config,
581 absl_include_config,
582 absl_define_config,
583 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800584 if (defined(invoker.public_configs)) {
585 public_configs += invoker.public_configs
586 }
587 }
588}
kthelgason4065a572017-02-14 04:58:56 -0800589
590if (is_ios) {
591 set_defaults("rtc_ios_xctest_test") {
592 configs = rtc_add_configs
593 suppressed_configs = []
594 }
595
596 template("rtc_ios_xctest_test") {
597 ios_xctest_test(target_name) {
598 forward_variables_from(invoker,
599 "*",
600 [
601 "configs",
602 "public_configs",
603 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200604 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800605 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200606 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000607 if (!defined(visibility)) {
608 visibility = webrtc_default_visibility
609 }
kthelgason4065a572017-02-14 04:58:56 -0800610 configs += invoker.configs
611 configs -= rtc_remove_configs
612 configs -= invoker.suppressed_configs
613 public_configs = [ rtc_common_inherited_config ]
614 if (defined(invoker.public_configs)) {
615 public_configs += invoker.public_configs
616 }
617 }
618 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100619
620 template("ios_framework_bundle_with_umbrella_header") {
621 forward_variables_from(invoker, [ "output_name" ])
622 umbrella_header_path =
623 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
624
625 ios_framework_bundle(target_name) {
626 forward_variables_from(invoker, "*", [])
627
628 deps += [ ":copy_umbrella_header_$target_name" ]
629 }
630
631 action("umbrella_header_$target_name") {
632 forward_variables_from(invoker, [ "public_headers" ])
633
634 script = "//tools_webrtc/ios/generate_umbrella_header.py"
635
636 outputs = [
637 umbrella_header_path,
638 ]
639 args = [
640 "--out",
641 rebase_path(umbrella_header_path, root_build_dir),
642 "--sources",
643 ] + rebase_path(public_headers, "objc/Framework/Headers/")
644 }
645
646 copy("copy_umbrella_header_$target_name") {
647 sources = [
648 umbrella_header_path,
649 ]
650 outputs = [
651 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
652 ]
653
654 deps = [
655 ":umbrella_header_$target_name",
656 ]
657 }
658 }
659
660 set_defaults("ios_framework_bundle_with_umbrella_header") {
661 configs = default_shared_library_configs
662 }
kthelgason4065a572017-02-14 04:58:56 -0800663}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000664
665if (is_android) {
666 template("rtc_android_library") {
667 android_library(target_name) {
668 forward_variables_from(invoker,
669 "*",
670 [
671 "configs",
672 "public_configs",
673 "suppressed_configs",
674 "visibility",
675 ])
676
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100677 javac_args = []
678
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000679 # Treat warnings as errors.
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100680 javac_args += [ "-Werror" ]
681
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200682 # TODO(crbug.com/824679): Find out why this fails in Chromium
683 if (!build_with_chromium) {
684 javac_args += [
685 "-Xep:ParameterNotNullable:ERROR",
686 "-Xep:FieldMissingNullable:ERROR",
687 "-Xep:ReturnMissingNullable:ERROR",
688 ]
689 }
690
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100691 # Add any arguments defined by the invoker.
692 if (defined(invoker.javac_args)) {
693 javac_args += invoker.javac_args
694 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000695
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200696 if (!defined(deps)) {
697 deps = []
698 }
699 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
700
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000701 no_build_hooks = true
702 }
703 }
704
705 template("rtc_android_apk") {
706 android_apk(target_name) {
707 forward_variables_from(invoker,
708 "*",
709 [
710 "configs",
711 "public_configs",
712 "suppressed_configs",
713 "visibility",
714 ])
715
716 # Treat warnings as errors.
717 javac_args = [ "-Werror" ]
718
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200719 # TODO(crbug.com/824679): Find out why this fails in Chromium
720 if (!build_with_chromium) {
721 javac_args += [
722 "-Xep:ParameterNotNullable:ERROR",
723 "-Xep:FieldMissingNullable:ERROR",
724 "-Xep:ReturnMissingNullable:ERROR",
725 ]
726 }
727
728 if (!defined(deps)) {
729 deps = []
730 }
731 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
732
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000733 no_build_hooks = true
734 }
735 }
736
737 template("rtc_instrumentation_test_apk") {
738 instrumentation_test_apk(target_name) {
739 forward_variables_from(invoker,
740 "*",
741 [
742 "configs",
743 "public_configs",
744 "suppressed_configs",
745 "visibility",
746 ])
747
748 # Treat warnings as errors.
749 javac_args = [ "-Werror" ]
750
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200751 # TODO(crbug.com/824679): Find out why this fails in Chromium
752 if (!build_with_chromium) {
753 javac_args += [
754 "-Xep:ParameterNotNullable:ERROR",
755 "-Xep:FieldMissingNullable:ERROR",
756 "-Xep:ReturnMissingNullable:ERROR",
757 ]
758 }
759
760 if (!defined(deps)) {
761 deps = []
762 }
763 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
764
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000765 no_build_hooks = true
766 }
767 }
768}