blob: 8cd1c1df3432486a1b98de172e1c3d563c7f395b [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() {
Mirko Bonadei70400902018-08-21 15:44:28 +020034 # WARNING: This argument doesn't have any effect on the WebRTC build until
35 # https://webrtc-review.googlesource.com/c/src/+/94766 will land.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020036 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 15:44:28 +020037 # will tell the pre-processor to remove the default definition of symbols
38 # needed to use field_trial. In that case a new implementation needs to be
39 # provided.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020040 if (build_with_chromium) {
41 # When WebRTC is built as part of Chromium it should exclude the default
42 # implementation of field_trial unless it is building for NACL or
43 # Chromecast.
44 rtc_exclude_field_trial_default = !is_nacl && !is_chromecast
45 } else {
46 rtc_exclude_field_trial_default = false
47 }
Mirko Bonadei70400902018-08-21 15:44:28 +020048
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070049 # Setting this to false will require the API user to pass in their own
50 # SSLCertificateVerifier to verify the certificates presented from a
51 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
52 rtc_builtin_ssl_root_certificates = true
53
Karl Wibergeb254b42017-11-01 15:08:12 +010054 # Include the iLBC audio codec?
55 rtc_include_ilbc = true
56
mbonadei9aa3f0a2017-01-24 06:58:22 -080057 # Disable this to avoid building the Opus audio codec.
58 rtc_include_opus = true
59
minyue2e03c662017-02-01 17:31:11 -080060 # Enable this if the Opus version upon which WebRTC is built supports direct
61 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020062 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080063
mbonadei9aa3f0a2017-01-24 06:58:22 -080064 # Enable this to let the Opus audio codec change complexity on the fly.
65 rtc_opus_variable_complexity = false
66
mbonadei9aa3f0a2017-01-24 06:58:22 -080067 # Used to specify an external Jsoncpp include path when not compiling the
68 # library that comes with WebRTC (i.e. rtc_build_json == 0).
69 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
70
71 # Used to specify an external OpenSSL include path when not compiling the
72 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
73 rtc_ssl_root = ""
74
75 # Selects fixed-point code where possible.
76 rtc_prefer_fixed_point = false
77
mbonadei9aa3f0a2017-01-24 06:58:22 -080078 # Disable the code for the intelligibility enhancer by default.
79 rtc_enable_intelligibility_enhancer = false
80
81 # Enable when an external authentication mechanism is used for performing
82 # packet authentication for RTP packets instead of libsrtp.
83 rtc_enable_external_auth = build_with_chromium
84
85 # Selects whether debug dumps for the audio processing module
86 # should be generated.
87 apm_debug_dump = false
88
89 # Set this to true to enable BWE test logging.
90 rtc_enable_bwe_test_logging = false
91
Joachim Bauch93e91342017-12-07 01:25:53 +010092 # Set this to false to skip building examples.
93 rtc_build_examples = true
94
95 # Set this to false to skip building tools.
96 rtc_build_tools = true
97
Joachim Bauch75f18fc2017-12-20 21:25:47 +010098 # Set this to false to skip building code that requires X11.
99 rtc_use_x11 = use_x11
100
mbonadei9aa3f0a2017-01-24 06:58:22 -0800101 # Enable to use the Mozilla internal settings.
102 build_with_mozilla = false
103
henrika883d00f2018-03-16 10:09:49 +0100104 # Enable use of Android AAudio which requires Android SDK 26 or above and
105 # NDK r16 or above.
106 rtc_enable_android_aaudio = false
107
108 # TODO(henrika): can this flag be removed?
mbonadei9aa3f0a2017-01-24 06:58:22 -0800109 rtc_enable_android_opensl = false
110
111 # Link-Time Optimizations.
112 # Executes code generation at link-time instead of compile-time.
113 # https://gcc.gnu.org/wiki/LinkTimeOptimization
114 rtc_use_lto = false
115
116 # Set to "func", "block", "edge" for coverage generation.
117 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
118 # It is recommend to set include_examples=0.
119 # Use llvm's sancov -html-report for human readable reports.
120 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
121 rtc_sanitize_coverage = ""
122
perkj650fdae2017-08-25 05:00:11 -0700123 # Links a default implementation of task queues to targets
124 # that depend on the target rtc_task_queue. Set to false to
125 # use an external implementation.
126 rtc_link_task_queue_impl = true
127
mbonadei9aa3f0a2017-01-24 06:58:22 -0800128 if (current_cpu == "arm" || current_cpu == "arm64") {
129 rtc_prefer_fixed_point = true
130 }
131
mbonadei9aa3f0a2017-01-24 06:58:22 -0800132 # Determines whether NEON code will be built.
133 rtc_build_with_neon =
134 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
135
136 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
137 # all platforms except Android and iOS. Because FFmpeg can be built
138 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
139 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Sergey Silkinfe288eb2018-06-25 16:22:38 +0200140 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800141 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
142 # http://www.openh264.org, https://www.ffmpeg.org/
Patrik Höglund3bb11942018-03-16 12:36:26 +0000143 rtc_use_h264 = proprietary_codecs && !is_android && !is_ios
mbonadei9aa3f0a2017-01-24 06:58:22 -0800144
mbonadei9aa3f0a2017-01-24 06:58:22 -0800145 # By default, use normal platform audio support or dummy audio, but don't
146 # use file-based audio playout and record.
147 rtc_use_dummy_audio_file_devices = false
148
henrika7be78832017-06-13 17:34:16 +0200149 # When set to true, replace the audio output with a sinus tone at 440Hz.
150 # The ADM will ask for audio data from WebRTC but instead of reading real
151 # audio samples from NetEQ, a sinus tone will be generated and replace the
152 # real audio samples.
153 rtc_audio_device_plays_sinus_tone = false
154
Anders Carlssondd8c1652018-01-30 10:32:13 +0100155 # Disable this to build without support for built-in software codecs.
156 rtc_use_builtin_sw_codecs = true
Anders Carlsson358f2e02018-06-04 10:24:37 +0200157
158 if (is_ios) {
159 # Build broadcast extension in AppRTCMobile for iOS. This results in the
160 # binary only running on iOS 11+, which is why it is disabled by default.
161 rtc_apprtcmobile_broadcast_extension = false
162 }
Dan Minor9c686132018-01-15 10:20:00 -0500163}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800164
Dan Minor9c686132018-01-15 10:20:00 -0500165if (!build_with_mozilla) {
166 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800167}
168
169# A second declare_args block, so that declarations within it can
170# depend on the possibly overridden variables in the first
171# declare_args block.
172declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500173 # Enables the use of protocol buffers for debug recordings.
174 rtc_enable_protobuf = !build_with_mozilla
175
176 # Set this to disable building with support for SCTP data channels.
177 rtc_enable_sctp = !build_with_mozilla
178
179 # Disable these to not build components which can be externally provided.
180 rtc_build_json = !build_with_mozilla
181 rtc_build_libsrtp = !build_with_mozilla
182 rtc_build_libvpx = !build_with_mozilla
183 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500184 rtc_build_opus = !build_with_mozilla
185 rtc_build_ssl = !build_with_mozilla
186 rtc_build_usrsctp = !build_with_mozilla
187
188 # Enable libevent task queues on platforms that support it.
189 # rtc_link_task_queue_impl must be set to true for this to
190 # have an effect.
Wez00cecb92018-02-09 10:41:00 -0800191 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) {
Dan Minor9c686132018-01-15 10:20:00 -0500192 rtc_enable_libevent = false
193 rtc_build_libevent = false
194 } else {
195 rtc_enable_libevent = true
196 rtc_build_libevent = !build_with_mozilla
197 }
198
Dan Minor9c686132018-01-15 10:20:00 -0500199 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
200 # build environments, even if available for Chromium builds.
201 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
202
mbonadei9aa3f0a2017-01-24 06:58:22 -0800203 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
204 rtc_include_pulse_audio = !build_with_chromium
205
206 # Chromium uses its own IO handling, so the internal ADM is only built for
207 # standalone WebRTC.
208 rtc_include_internal_audio_device = !build_with_chromium
209
210 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500211 rtc_include_tests = !build_with_chromium && !build_with_mozilla
mbonadei9aa3f0a2017-01-24 06:58:22 -0800212}
213
214# Make it possible to provide custom locations for some libraries (move these
215# up into declare_args should we need to actually use them for the GN build).
216rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800217rtc_opus_dir = "//third_party/opus"
218
219# Desktop capturer is supported only on Windows, OSX and Linux.
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100220rtc_desktop_capture_supported = is_win || is_mac || (is_linux && rtc_use_x11)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800221
222###############################################################################
223# Templates
224#
225
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200226# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800227# chromium.
228# We need absolute paths for all configs in templates as they are shared in
229# different subdirectories.
230webrtc_root = get_path_info(".", "abspath")
231
232# Global configuration that should be applied to all WebRTC targets.
233# You normally shouldn't need to include this in your target as it's
234# automatically included when using the rtc_* templates.
235# It sets defines, include paths and compilation warnings accordingly,
236# both for WebRTC stand-alone builds and for the scenario when WebRTC
237# native code is built as part of Chromium.
238rtc_common_configs = [ webrtc_root + ":common_config" ]
239
kthelgasonc0977102017-04-24 00:57:16 -0700240if (is_mac || is_ios) {
241 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
242}
243
mbonadei9aa3f0a2017-01-24 06:58:22 -0800244# Global public configuration that should be applied to all WebRTC targets. You
245# normally shouldn't need to include this in your target as it's automatically
246# included when using the rtc_* templates. It set the defines, include paths and
247# compilation warnings that should be propagated to dependents of the targets
248# depending on the target having this config.
249rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
250
251# Common configs to remove or add in all rtc targets.
252rtc_remove_configs = []
253rtc_add_configs = rtc_common_configs
254
255set_defaults("rtc_test") {
256 configs = rtc_add_configs
257 suppressed_configs = []
258}
259
260set_defaults("rtc_source_set") {
261 configs = rtc_add_configs
262 suppressed_configs = []
263}
264
265set_defaults("rtc_executable") {
266 configs = rtc_add_configs
267 suppressed_configs = []
268}
269
270set_defaults("rtc_static_library") {
271 configs = rtc_add_configs
272 suppressed_configs = []
273}
274
275set_defaults("rtc_shared_library") {
276 configs = rtc_add_configs
277 suppressed_configs = []
278}
279
Per Kjellandera7f2d842018-01-10 15:54:53 +0000280webrtc_default_visibility = [ webrtc_root + "/*" ]
281if (build_with_chromium) {
282 # Allow Chromium's WebRTC overrides targets to bypass the regular
283 # visibility restrictions.
284 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
285}
286
Karl Wibergbb23c832018-04-22 19:55:00 +0200287# ---- Poisons ----
288#
289# The general idea is that some targets declare that they contain some
290# kind of poison, which makes it impossible for other targets to
291# depend on them (even transitively) unless they declare themselves
292# immune to that particular type of poison.
293#
294# Targets that *contain* poison of type foo should contain the line
295#
296# poisonous = [ "foo" ]
297#
298# and targets that *are immune but arent't themselves poisonous*
299# should contain
300#
301# allow_poison = [ "foo" ]
302#
303# This useful in cases where we have some large target or set of
304# targets and want to ensure that most other targets do not
305# transitively depend on them. For example, almost no high-level
306# target should depend on the audio codecs, since we want WebRTC users
307# to be able to inject any subset of them and actually end up with a
308# binary that doesn't include the codecs they didn't inject.
309#
310# Test-only targets (`testonly` set to true) and non-public targets
311# (`visibility` not containing "*") are automatically immune to all
312# types of poison.
313#
314# Here's the complete list of all types of poison. It must be kept in
315# 1:1 correspondence with the set of //:poison_* targets.
316#
317all_poison_types = [
318 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
319 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200320
321 # Software video codecs (VP8 and VP9 through libvpx).
322 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200323]
324
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000325absl_include_config = "//third_party/abseil-cpp:absl_include_config"
326absl_define_config = "//third_party/abseil-cpp:absl_define_config"
327
mbonadei9aa3f0a2017-01-24 06:58:22 -0800328template("rtc_test") {
329 test(target_name) {
330 forward_variables_from(invoker,
331 "*",
332 [
333 "configs",
334 "public_configs",
335 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200336 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800337 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100338
339 # Always override to public because when target_os is Android the `test`
340 # template can override it to [ "*" ] and we want to avoid conditional
341 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100342 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800343 configs += invoker.configs
344 configs -= rtc_remove_configs
345 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000346 public_configs = [
347 rtc_common_inherited_config,
348 absl_include_config,
349 absl_define_config,
350 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800351 if (defined(invoker.public_configs)) {
352 public_configs += invoker.public_configs
353 }
sakald7fdb802017-05-26 01:51:53 -0700354 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800355 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
356 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700357 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800358 }
359}
360
361template("rtc_source_set") {
362 source_set(target_name) {
363 forward_variables_from(invoker,
364 "*",
365 [
366 "configs",
367 "public_configs",
368 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200369 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800370 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200371 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000372 if (!defined(visibility)) {
373 visibility = webrtc_default_visibility
374 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200375
376 # What's your poison?
377 if (defined(testonly) && testonly) {
378 assert(!defined(poisonous))
379 assert(!defined(allow_poison))
380 } else {
381 if (!defined(poisonous)) {
382 poisonous = []
383 }
384 if (!defined(allow_poison)) {
385 allow_poison = []
386 }
387 if (!defined(assert_no_deps)) {
388 assert_no_deps = []
389 }
390 if (!defined(deps)) {
391 deps = []
392 }
393 foreach(p, poisonous) {
394 deps += [ webrtc_root + ":poison_" + p ]
395 }
396 foreach(poison_type, all_poison_types) {
397 allow_dep = true
398 foreach(v, visibility) {
399 if (v == "*") {
400 allow_dep = false
401 }
402 }
403 foreach(p, allow_poison + poisonous) {
404 if (p == poison_type) {
405 allow_dep = true
406 }
407 }
408 if (!allow_dep) {
409 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
410 }
411 }
412 }
413
mbonadei9aa3f0a2017-01-24 06:58:22 -0800414 configs += invoker.configs
415 configs -= rtc_remove_configs
416 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000417 public_configs = [
418 rtc_common_inherited_config,
419 absl_include_config,
420 absl_define_config,
421 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800422 if (defined(invoker.public_configs)) {
423 public_configs += invoker.public_configs
424 }
425 }
426}
427
428template("rtc_executable") {
429 executable(target_name) {
430 forward_variables_from(invoker,
431 "*",
432 [
433 "deps",
434 "configs",
435 "public_configs",
436 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200437 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800438 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200439 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000440 if (!defined(visibility)) {
441 visibility = webrtc_default_visibility
442 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800443 configs += invoker.configs
444 configs -= rtc_remove_configs
445 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700446 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 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200456 if (is_win) {
457 deps += [
458 # Give executables the default manifest on Windows (a no-op elsewhere).
459 "//build/win:default_exe_manifest",
460 ]
461 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800462 }
463}
464
465template("rtc_static_library") {
466 static_library(target_name) {
467 forward_variables_from(invoker,
468 "*",
469 [
470 "configs",
471 "public_configs",
472 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200473 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800474 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200475 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000476 if (!defined(visibility)) {
477 visibility = webrtc_default_visibility
478 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200479
480 # What's your poison?
481 if (defined(testonly) && testonly) {
482 assert(!defined(poisonous))
483 assert(!defined(allow_poison))
484 } else {
485 if (!defined(poisonous)) {
486 poisonous = []
487 }
488 if (!defined(allow_poison)) {
489 allow_poison = []
490 }
491 if (!defined(assert_no_deps)) {
492 assert_no_deps = []
493 }
494 if (!defined(deps)) {
495 deps = []
496 }
497 foreach(p, poisonous) {
498 deps += [ webrtc_root + ":poison_" + p ]
499 }
500 foreach(poison_type, all_poison_types) {
501 allow_dep = true
502 foreach(v, visibility) {
503 if (v == "*") {
504 allow_dep = false
505 }
506 }
507 foreach(p, allow_poison + poisonous) {
508 if (p == poison_type) {
509 allow_dep = true
510 }
511 }
512 if (!allow_dep) {
513 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
514 }
515 }
516 }
517
mbonadei9aa3f0a2017-01-24 06:58:22 -0800518 configs += invoker.configs
519 configs -= rtc_remove_configs
520 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000521 public_configs = [
522 rtc_common_inherited_config,
523 absl_include_config,
524 absl_define_config,
525 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800526 if (defined(invoker.public_configs)) {
527 public_configs += invoker.public_configs
528 }
529 }
530}
531
532template("rtc_shared_library") {
533 shared_library(target_name) {
534 forward_variables_from(invoker,
535 "*",
536 [
537 "configs",
538 "public_configs",
539 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200540 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800541 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200542 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000543 if (!defined(visibility)) {
544 visibility = webrtc_default_visibility
545 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200546
547 # What's your poison?
548 if (defined(testonly) && testonly) {
549 assert(!defined(poisonous))
550 assert(!defined(allow_poison))
551 } else {
552 if (!defined(poisonous)) {
553 poisonous = []
554 }
555 if (!defined(allow_poison)) {
556 allow_poison = []
557 }
558 if (!defined(assert_no_deps)) {
559 assert_no_deps = []
560 }
561 if (!defined(deps)) {
562 deps = []
563 }
564 foreach(p, poisonous) {
565 deps += [ webrtc_root + ":poison_" + p ]
566 }
567 foreach(poison_type, all_poison_types) {
568 allow_dep = true
569 foreach(v, visibility) {
570 if (v == "*") {
571 allow_dep = false
572 }
573 }
574 foreach(p, allow_poison + poisonous) {
575 if (p == poison_type) {
576 allow_dep = true
577 }
578 }
579 if (!allow_dep) {
580 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
581 }
582 }
583 }
584
mbonadei9aa3f0a2017-01-24 06:58:22 -0800585 configs += invoker.configs
586 configs -= rtc_remove_configs
587 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000588 public_configs = [
589 rtc_common_inherited_config,
590 absl_include_config,
591 absl_define_config,
592 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800593 if (defined(invoker.public_configs)) {
594 public_configs += invoker.public_configs
595 }
596 }
597}
kthelgason4065a572017-02-14 04:58:56 -0800598
599if (is_ios) {
600 set_defaults("rtc_ios_xctest_test") {
601 configs = rtc_add_configs
602 suppressed_configs = []
603 }
604
605 template("rtc_ios_xctest_test") {
606 ios_xctest_test(target_name) {
607 forward_variables_from(invoker,
608 "*",
609 [
610 "configs",
611 "public_configs",
612 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200613 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800614 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200615 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000616 if (!defined(visibility)) {
617 visibility = webrtc_default_visibility
618 }
kthelgason4065a572017-02-14 04:58:56 -0800619 configs += invoker.configs
620 configs -= rtc_remove_configs
621 configs -= invoker.suppressed_configs
622 public_configs = [ rtc_common_inherited_config ]
623 if (defined(invoker.public_configs)) {
624 public_configs += invoker.public_configs
625 }
626 }
627 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100628
629 template("ios_framework_bundle_with_umbrella_header") {
630 forward_variables_from(invoker, [ "output_name" ])
631 umbrella_header_path =
632 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
633
634 ios_framework_bundle(target_name) {
635 forward_variables_from(invoker, "*", [])
636
637 deps += [ ":copy_umbrella_header_$target_name" ]
638 }
639
640 action("umbrella_header_$target_name") {
641 forward_variables_from(invoker, [ "public_headers" ])
642
643 script = "//tools_webrtc/ios/generate_umbrella_header.py"
644
645 outputs = [
646 umbrella_header_path,
647 ]
648 args = [
649 "--out",
650 rebase_path(umbrella_header_path, root_build_dir),
651 "--sources",
652 ] + rebase_path(public_headers, "objc/Framework/Headers/")
653 }
654
655 copy("copy_umbrella_header_$target_name") {
656 sources = [
657 umbrella_header_path,
658 ]
659 outputs = [
660 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
661 ]
662
663 deps = [
664 ":umbrella_header_$target_name",
665 ]
666 }
667 }
668
669 set_defaults("ios_framework_bundle_with_umbrella_header") {
670 configs = default_shared_library_configs
671 }
kthelgason4065a572017-02-14 04:58:56 -0800672}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000673
674if (is_android) {
675 template("rtc_android_library") {
676 android_library(target_name) {
677 forward_variables_from(invoker,
678 "*",
679 [
680 "configs",
681 "public_configs",
682 "suppressed_configs",
683 "visibility",
684 ])
685
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100686 javac_args = []
687
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000688 # Treat warnings as errors.
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100689 javac_args += [ "-Werror" ]
690
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200691 # TODO(crbug.com/824679): Find out why this fails in Chromium
692 if (!build_with_chromium) {
693 javac_args += [
694 "-Xep:ParameterNotNullable:ERROR",
695 "-Xep:FieldMissingNullable:ERROR",
696 "-Xep:ReturnMissingNullable:ERROR",
697 ]
698 }
699
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100700 # Add any arguments defined by the invoker.
701 if (defined(invoker.javac_args)) {
702 javac_args += invoker.javac_args
703 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000704
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200705 if (!defined(deps)) {
706 deps = []
707 }
708 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
709
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000710 no_build_hooks = true
711 }
712 }
713
714 template("rtc_android_apk") {
715 android_apk(target_name) {
716 forward_variables_from(invoker,
717 "*",
718 [
719 "configs",
720 "public_configs",
721 "suppressed_configs",
722 "visibility",
723 ])
724
725 # Treat warnings as errors.
726 javac_args = [ "-Werror" ]
727
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200728 # TODO(crbug.com/824679): Find out why this fails in Chromium
729 if (!build_with_chromium) {
730 javac_args += [
731 "-Xep:ParameterNotNullable:ERROR",
732 "-Xep:FieldMissingNullable:ERROR",
733 "-Xep:ReturnMissingNullable:ERROR",
734 ]
735 }
736
737 if (!defined(deps)) {
738 deps = []
739 }
740 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
741
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000742 no_build_hooks = true
743 }
744 }
745
746 template("rtc_instrumentation_test_apk") {
747 instrumentation_test_apk(target_name) {
748 forward_variables_from(invoker,
749 "*",
750 [
751 "configs",
752 "public_configs",
753 "suppressed_configs",
754 "visibility",
755 ])
756
757 # Treat warnings as errors.
758 javac_args = [ "-Werror" ]
759
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200760 # TODO(crbug.com/824679): Find out why this fails in Chromium
761 if (!build_with_chromium) {
762 javac_args += [
763 "-Xep:ParameterNotNullable:ERROR",
764 "-Xep:FieldMissingNullable:ERROR",
765 "-Xep:ReturnMissingNullable:ERROR",
766 ]
767 }
768
769 if (!defined(deps)) {
770 deps = []
771 }
772 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
773
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000774 no_build_hooks = true
775 }
776 }
777}