blob: a71d8e7d4cd7cb1f5eed3dd48698255822e061f0 [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
443 deps = [
thomasanderson7f52f082017-05-18 23:51:46 -0700444 "//build/config:exe_and_shlib_deps",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800445 ]
446 deps += invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700447
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000448 public_configs = [
449 rtc_common_inherited_config,
450 absl_include_config,
451 absl_define_config,
452 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800453 if (defined(invoker.public_configs)) {
454 public_configs += invoker.public_configs
455 }
456 }
457}
458
459template("rtc_static_library") {
460 static_library(target_name) {
461 forward_variables_from(invoker,
462 "*",
463 [
464 "configs",
465 "public_configs",
466 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200467 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800468 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200469 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000470 if (!defined(visibility)) {
471 visibility = webrtc_default_visibility
472 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200473
474 # What's your poison?
475 if (defined(testonly) && testonly) {
476 assert(!defined(poisonous))
477 assert(!defined(allow_poison))
478 } else {
479 if (!defined(poisonous)) {
480 poisonous = []
481 }
482 if (!defined(allow_poison)) {
483 allow_poison = []
484 }
485 if (!defined(assert_no_deps)) {
486 assert_no_deps = []
487 }
488 if (!defined(deps)) {
489 deps = []
490 }
491 foreach(p, poisonous) {
492 deps += [ webrtc_root + ":poison_" + p ]
493 }
494 foreach(poison_type, all_poison_types) {
495 allow_dep = true
496 foreach(v, visibility) {
497 if (v == "*") {
498 allow_dep = false
499 }
500 }
501 foreach(p, allow_poison + poisonous) {
502 if (p == poison_type) {
503 allow_dep = true
504 }
505 }
506 if (!allow_dep) {
507 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
508 }
509 }
510 }
511
mbonadei9aa3f0a2017-01-24 06:58:22 -0800512 configs += invoker.configs
513 configs -= rtc_remove_configs
514 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000515 public_configs = [
516 rtc_common_inherited_config,
517 absl_include_config,
518 absl_define_config,
519 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800520 if (defined(invoker.public_configs)) {
521 public_configs += invoker.public_configs
522 }
523 }
524}
525
526template("rtc_shared_library") {
527 shared_library(target_name) {
528 forward_variables_from(invoker,
529 "*",
530 [
531 "configs",
532 "public_configs",
533 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200534 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800535 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200536 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000537 if (!defined(visibility)) {
538 visibility = webrtc_default_visibility
539 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200540
541 # What's your poison?
542 if (defined(testonly) && testonly) {
543 assert(!defined(poisonous))
544 assert(!defined(allow_poison))
545 } else {
546 if (!defined(poisonous)) {
547 poisonous = []
548 }
549 if (!defined(allow_poison)) {
550 allow_poison = []
551 }
552 if (!defined(assert_no_deps)) {
553 assert_no_deps = []
554 }
555 if (!defined(deps)) {
556 deps = []
557 }
558 foreach(p, poisonous) {
559 deps += [ webrtc_root + ":poison_" + p ]
560 }
561 foreach(poison_type, all_poison_types) {
562 allow_dep = true
563 foreach(v, visibility) {
564 if (v == "*") {
565 allow_dep = false
566 }
567 }
568 foreach(p, allow_poison + poisonous) {
569 if (p == poison_type) {
570 allow_dep = true
571 }
572 }
573 if (!allow_dep) {
574 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
575 }
576 }
577 }
578
mbonadei9aa3f0a2017-01-24 06:58:22 -0800579 configs += invoker.configs
580 configs -= rtc_remove_configs
581 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000582 public_configs = [
583 rtc_common_inherited_config,
584 absl_include_config,
585 absl_define_config,
586 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800587 if (defined(invoker.public_configs)) {
588 public_configs += invoker.public_configs
589 }
590 }
591}
kthelgason4065a572017-02-14 04:58:56 -0800592
593if (is_ios) {
594 set_defaults("rtc_ios_xctest_test") {
595 configs = rtc_add_configs
596 suppressed_configs = []
597 }
598
599 template("rtc_ios_xctest_test") {
600 ios_xctest_test(target_name) {
601 forward_variables_from(invoker,
602 "*",
603 [
604 "configs",
605 "public_configs",
606 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200607 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800608 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200609 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000610 if (!defined(visibility)) {
611 visibility = webrtc_default_visibility
612 }
kthelgason4065a572017-02-14 04:58:56 -0800613 configs += invoker.configs
614 configs -= rtc_remove_configs
615 configs -= invoker.suppressed_configs
616 public_configs = [ rtc_common_inherited_config ]
617 if (defined(invoker.public_configs)) {
618 public_configs += invoker.public_configs
619 }
620 }
621 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100622
623 template("ios_framework_bundle_with_umbrella_header") {
624 forward_variables_from(invoker, [ "output_name" ])
625 umbrella_header_path =
626 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
627
628 ios_framework_bundle(target_name) {
629 forward_variables_from(invoker, "*", [])
630
631 deps += [ ":copy_umbrella_header_$target_name" ]
632 }
633
634 action("umbrella_header_$target_name") {
635 forward_variables_from(invoker, [ "public_headers" ])
636
637 script = "//tools_webrtc/ios/generate_umbrella_header.py"
638
639 outputs = [
640 umbrella_header_path,
641 ]
642 args = [
643 "--out",
644 rebase_path(umbrella_header_path, root_build_dir),
645 "--sources",
646 ] + rebase_path(public_headers, "objc/Framework/Headers/")
647 }
648
649 copy("copy_umbrella_header_$target_name") {
650 sources = [
651 umbrella_header_path,
652 ]
653 outputs = [
654 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
655 ]
656
657 deps = [
658 ":umbrella_header_$target_name",
659 ]
660 }
661 }
662
663 set_defaults("ios_framework_bundle_with_umbrella_header") {
664 configs = default_shared_library_configs
665 }
kthelgason4065a572017-02-14 04:58:56 -0800666}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000667
668if (is_android) {
669 template("rtc_android_library") {
670 android_library(target_name) {
671 forward_variables_from(invoker,
672 "*",
673 [
674 "configs",
675 "public_configs",
676 "suppressed_configs",
677 "visibility",
678 ])
679
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100680 javac_args = []
681
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000682 # Treat warnings as errors.
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100683 javac_args += [ "-Werror" ]
684
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200685 # TODO(crbug.com/824679): Find out why this fails in Chromium
686 if (!build_with_chromium) {
687 javac_args += [
688 "-Xep:ParameterNotNullable:ERROR",
689 "-Xep:FieldMissingNullable:ERROR",
690 "-Xep:ReturnMissingNullable:ERROR",
691 ]
692 }
693
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100694 # Add any arguments defined by the invoker.
695 if (defined(invoker.javac_args)) {
696 javac_args += invoker.javac_args
697 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000698
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200699 if (!defined(deps)) {
700 deps = []
701 }
702 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
703
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000704 no_build_hooks = true
705 }
706 }
707
708 template("rtc_android_apk") {
709 android_apk(target_name) {
710 forward_variables_from(invoker,
711 "*",
712 [
713 "configs",
714 "public_configs",
715 "suppressed_configs",
716 "visibility",
717 ])
718
719 # Treat warnings as errors.
720 javac_args = [ "-Werror" ]
721
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200722 # TODO(crbug.com/824679): Find out why this fails in Chromium
723 if (!build_with_chromium) {
724 javac_args += [
725 "-Xep:ParameterNotNullable:ERROR",
726 "-Xep:FieldMissingNullable:ERROR",
727 "-Xep:ReturnMissingNullable:ERROR",
728 ]
729 }
730
731 if (!defined(deps)) {
732 deps = []
733 }
734 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
735
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000736 no_build_hooks = true
737 }
738 }
739
740 template("rtc_instrumentation_test_apk") {
741 instrumentation_test_apk(target_name) {
742 forward_variables_from(invoker,
743 "*",
744 [
745 "configs",
746 "public_configs",
747 "suppressed_configs",
748 "visibility",
749 ])
750
751 # Treat warnings as errors.
752 javac_args = [ "-Werror" ]
753
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200754 # TODO(crbug.com/824679): Find out why this fails in Chromium
755 if (!build_with_chromium) {
756 javac_args += [
757 "-Xep:ParameterNotNullable:ERROR",
758 "-Xep:FieldMissingNullable:ERROR",
759 "-Xep:ReturnMissingNullable:ERROR",
760 ]
761 }
762
763 if (!defined(deps)) {
764 deps = []
765 }
766 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
767
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000768 no_build_hooks = true
769 }
770 }
771}