blob: 67f2b5d040446e13886c8d12207074b0e31b6019 [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
Mirko Bonadei906add42018-09-05 16:03:16 +020049 # WARNING: This argument doesn't have any effect on the WebRTC build until
50 # https://webrtc-review.googlesource.com/c/src/+/95480 will land.
51 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
52 # will tell the pre-processor to remove the default definition of symbols
53 # needed to use metrics. In that case a new implementation needs to be
54 # provided.
55 rtc_exclude_metrics_default = build_with_chromium
56
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070057 # Setting this to false will require the API user to pass in their own
58 # SSLCertificateVerifier to verify the certificates presented from a
59 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
60 rtc_builtin_ssl_root_certificates = true
61
Karl Wibergeb254b42017-11-01 15:08:12 +010062 # Include the iLBC audio codec?
63 rtc_include_ilbc = true
64
mbonadei9aa3f0a2017-01-24 06:58:22 -080065 # Disable this to avoid building the Opus audio codec.
66 rtc_include_opus = true
67
minyue2e03c662017-02-01 17:31:11 -080068 # Enable this if the Opus version upon which WebRTC is built supports direct
69 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020070 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080071
mbonadei9aa3f0a2017-01-24 06:58:22 -080072 # Enable this to let the Opus audio codec change complexity on the fly.
73 rtc_opus_variable_complexity = false
74
mbonadei9aa3f0a2017-01-24 06:58:22 -080075 # Used to specify an external Jsoncpp include path when not compiling the
76 # library that comes with WebRTC (i.e. rtc_build_json == 0).
77 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
78
79 # Used to specify an external OpenSSL include path when not compiling the
80 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
81 rtc_ssl_root = ""
82
83 # Selects fixed-point code where possible.
84 rtc_prefer_fixed_point = false
85
mbonadei9aa3f0a2017-01-24 06:58:22 -080086 # Enable when an external authentication mechanism is used for performing
87 # packet authentication for RTP packets instead of libsrtp.
88 rtc_enable_external_auth = build_with_chromium
89
90 # Selects whether debug dumps for the audio processing module
91 # should be generated.
92 apm_debug_dump = false
93
94 # Set this to true to enable BWE test logging.
95 rtc_enable_bwe_test_logging = false
96
Joachim Bauch93e91342017-12-07 01:25:53 +010097 # Set this to false to skip building examples.
98 rtc_build_examples = true
99
100 # Set this to false to skip building tools.
101 rtc_build_tools = true
102
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100103 # Set this to false to skip building code that requires X11.
104 rtc_use_x11 = use_x11
105
mbonadei9aa3f0a2017-01-24 06:58:22 -0800106 # Enable to use the Mozilla internal settings.
107 build_with_mozilla = false
108
henrika883d00f2018-03-16 10:09:49 +0100109 # Enable use of Android AAudio which requires Android SDK 26 or above and
110 # NDK r16 or above.
111 rtc_enable_android_aaudio = false
112
113 # TODO(henrika): can this flag be removed?
mbonadei9aa3f0a2017-01-24 06:58:22 -0800114 rtc_enable_android_opensl = false
115
116 # Link-Time Optimizations.
117 # Executes code generation at link-time instead of compile-time.
118 # https://gcc.gnu.org/wiki/LinkTimeOptimization
119 rtc_use_lto = false
120
121 # Set to "func", "block", "edge" for coverage generation.
122 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
123 # It is recommend to set include_examples=0.
124 # Use llvm's sancov -html-report for human readable reports.
125 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
126 rtc_sanitize_coverage = ""
127
perkj650fdae2017-08-25 05:00:11 -0700128 # Links a default implementation of task queues to targets
129 # that depend on the target rtc_task_queue. Set to false to
130 # use an external implementation.
131 rtc_link_task_queue_impl = true
132
mbonadei9aa3f0a2017-01-24 06:58:22 -0800133 if (current_cpu == "arm" || current_cpu == "arm64") {
134 rtc_prefer_fixed_point = true
135 }
136
mbonadei9aa3f0a2017-01-24 06:58:22 -0800137 # Determines whether NEON code will be built.
138 rtc_build_with_neon =
139 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
140
141 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
142 # all platforms except Android and iOS. Because FFmpeg can be built
143 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
144 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Sergey Silkinfe288eb2018-06-25 16:22:38 +0200145 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800146 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
147 # http://www.openh264.org, https://www.ffmpeg.org/
Patrik Höglund3bb11942018-03-16 12:36:26 +0000148 rtc_use_h264 = proprietary_codecs && !is_android && !is_ios
mbonadei9aa3f0a2017-01-24 06:58:22 -0800149
mbonadei9aa3f0a2017-01-24 06:58:22 -0800150 # By default, use normal platform audio support or dummy audio, but don't
151 # use file-based audio playout and record.
152 rtc_use_dummy_audio_file_devices = false
153
henrika7be78832017-06-13 17:34:16 +0200154 # When set to true, replace the audio output with a sinus tone at 440Hz.
155 # The ADM will ask for audio data from WebRTC but instead of reading real
156 # audio samples from NetEQ, a sinus tone will be generated and replace the
157 # real audio samples.
158 rtc_audio_device_plays_sinus_tone = false
159
Anders Carlssondd8c1652018-01-30 10:32:13 +0100160 # Disable this to build without support for built-in software codecs.
161 rtc_use_builtin_sw_codecs = true
Anders Carlsson358f2e02018-06-04 10:24:37 +0200162
163 if (is_ios) {
164 # Build broadcast extension in AppRTCMobile for iOS. This results in the
165 # binary only running on iOS 11+, which is why it is disabled by default.
166 rtc_apprtcmobile_broadcast_extension = false
167 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200168
169 # Determines whether Metal is available on iOS/macOS.
170 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
Dan Minor9c686132018-01-15 10:20:00 -0500171}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800172
Dan Minor9c686132018-01-15 10:20:00 -0500173if (!build_with_mozilla) {
174 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800175}
176
177# A second declare_args block, so that declarations within it can
178# depend on the possibly overridden variables in the first
179# declare_args block.
180declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500181 # Enables the use of protocol buffers for debug recordings.
182 rtc_enable_protobuf = !build_with_mozilla
183
184 # Set this to disable building with support for SCTP data channels.
185 rtc_enable_sctp = !build_with_mozilla
186
187 # Disable these to not build components which can be externally provided.
188 rtc_build_json = !build_with_mozilla
189 rtc_build_libsrtp = !build_with_mozilla
190 rtc_build_libvpx = !build_with_mozilla
191 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500192 rtc_build_opus = !build_with_mozilla
193 rtc_build_ssl = !build_with_mozilla
194 rtc_build_usrsctp = !build_with_mozilla
195
196 # Enable libevent task queues on platforms that support it.
197 # rtc_link_task_queue_impl must be set to true for this to
198 # have an effect.
Wez00cecb92018-02-09 10:41:00 -0800199 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) {
Dan Minor9c686132018-01-15 10:20:00 -0500200 rtc_enable_libevent = false
201 rtc_build_libevent = false
202 } else {
203 rtc_enable_libevent = true
204 rtc_build_libevent = !build_with_mozilla
205 }
206
Dan Minor9c686132018-01-15 10:20:00 -0500207 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
208 # build environments, even if available for Chromium builds.
209 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
210
mbonadei9aa3f0a2017-01-24 06:58:22 -0800211 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
212 rtc_include_pulse_audio = !build_with_chromium
213
214 # Chromium uses its own IO handling, so the internal ADM is only built for
215 # standalone WebRTC.
216 rtc_include_internal_audio_device = !build_with_chromium
217
218 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500219 rtc_include_tests = !build_with_chromium && !build_with_mozilla
mbonadei9aa3f0a2017-01-24 06:58:22 -0800220}
221
222# Make it possible to provide custom locations for some libraries (move these
223# up into declare_args should we need to actually use them for the GN build).
224rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800225rtc_opus_dir = "//third_party/opus"
226
227# Desktop capturer is supported only on Windows, OSX and Linux.
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100228rtc_desktop_capture_supported = is_win || is_mac || (is_linux && rtc_use_x11)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800229
230###############################################################################
231# Templates
232#
233
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200234# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800235# chromium.
236# We need absolute paths for all configs in templates as they are shared in
237# different subdirectories.
238webrtc_root = get_path_info(".", "abspath")
239
240# Global configuration that should be applied to all WebRTC targets.
241# You normally shouldn't need to include this in your target as it's
242# automatically included when using the rtc_* templates.
243# It sets defines, include paths and compilation warnings accordingly,
244# both for WebRTC stand-alone builds and for the scenario when WebRTC
245# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700246rtc_common_configs = [
247 webrtc_root + ":common_config",
248 "//build/config/compiler:no_size_t_to_int_warning",
249]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800250
kthelgasonc0977102017-04-24 00:57:16 -0700251if (is_mac || is_ios) {
252 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
253}
254
mbonadei9aa3f0a2017-01-24 06:58:22 -0800255# Global public configuration that should be applied to all WebRTC targets. You
256# normally shouldn't need to include this in your target as it's automatically
257# included when using the rtc_* templates. It set the defines, include paths and
258# compilation warnings that should be propagated to dependents of the targets
259# depending on the target having this config.
260rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
261
262# Common configs to remove or add in all rtc targets.
263rtc_remove_configs = []
264rtc_add_configs = rtc_common_configs
265
266set_defaults("rtc_test") {
267 configs = rtc_add_configs
268 suppressed_configs = []
269}
270
271set_defaults("rtc_source_set") {
272 configs = rtc_add_configs
273 suppressed_configs = []
274}
275
276set_defaults("rtc_executable") {
277 configs = rtc_add_configs
278 suppressed_configs = []
279}
280
281set_defaults("rtc_static_library") {
282 configs = rtc_add_configs
283 suppressed_configs = []
284}
285
286set_defaults("rtc_shared_library") {
287 configs = rtc_add_configs
288 suppressed_configs = []
289}
290
Per Kjellandera7f2d842018-01-10 15:54:53 +0000291webrtc_default_visibility = [ webrtc_root + "/*" ]
292if (build_with_chromium) {
293 # Allow Chromium's WebRTC overrides targets to bypass the regular
294 # visibility restrictions.
295 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
296}
297
Karl Wibergbb23c832018-04-22 19:55:00 +0200298# ---- Poisons ----
299#
300# The general idea is that some targets declare that they contain some
301# kind of poison, which makes it impossible for other targets to
302# depend on them (even transitively) unless they declare themselves
303# immune to that particular type of poison.
304#
305# Targets that *contain* poison of type foo should contain the line
306#
307# poisonous = [ "foo" ]
308#
309# and targets that *are immune but arent't themselves poisonous*
310# should contain
311#
312# allow_poison = [ "foo" ]
313#
314# This useful in cases where we have some large target or set of
315# targets and want to ensure that most other targets do not
316# transitively depend on them. For example, almost no high-level
317# target should depend on the audio codecs, since we want WebRTC users
318# to be able to inject any subset of them and actually end up with a
319# binary that doesn't include the codecs they didn't inject.
320#
321# Test-only targets (`testonly` set to true) and non-public targets
322# (`visibility` not containing "*") are automatically immune to all
323# types of poison.
324#
325# Here's the complete list of all types of poison. It must be kept in
326# 1:1 correspondence with the set of //:poison_* targets.
327#
328all_poison_types = [
329 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
330 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200331
332 # Software video codecs (VP8 and VP9 through libvpx).
333 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200334]
335
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000336absl_include_config = "//third_party/abseil-cpp:absl_include_config"
337absl_define_config = "//third_party/abseil-cpp:absl_define_config"
338
mbonadei9aa3f0a2017-01-24 06:58:22 -0800339template("rtc_test") {
340 test(target_name) {
341 forward_variables_from(invoker,
342 "*",
343 [
344 "configs",
345 "public_configs",
346 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200347 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800348 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100349
350 # Always override to public because when target_os is Android the `test`
351 # template can override it to [ "*" ] and we want to avoid conditional
352 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100353 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800354 configs += invoker.configs
355 configs -= rtc_remove_configs
356 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000357 public_configs = [
358 rtc_common_inherited_config,
359 absl_include_config,
360 absl_define_config,
361 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800362 if (defined(invoker.public_configs)) {
363 public_configs += invoker.public_configs
364 }
sakald7fdb802017-05-26 01:51:53 -0700365 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800366 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
367 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700368 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800369 }
370}
371
372template("rtc_source_set") {
373 source_set(target_name) {
374 forward_variables_from(invoker,
375 "*",
376 [
377 "configs",
378 "public_configs",
379 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200380 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800381 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200382 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000383 if (!defined(visibility)) {
384 visibility = webrtc_default_visibility
385 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200386
387 # What's your poison?
388 if (defined(testonly) && testonly) {
389 assert(!defined(poisonous))
390 assert(!defined(allow_poison))
391 } else {
392 if (!defined(poisonous)) {
393 poisonous = []
394 }
395 if (!defined(allow_poison)) {
396 allow_poison = []
397 }
398 if (!defined(assert_no_deps)) {
399 assert_no_deps = []
400 }
401 if (!defined(deps)) {
402 deps = []
403 }
404 foreach(p, poisonous) {
405 deps += [ webrtc_root + ":poison_" + p ]
406 }
407 foreach(poison_type, all_poison_types) {
408 allow_dep = true
409 foreach(v, visibility) {
410 if (v == "*") {
411 allow_dep = false
412 }
413 }
414 foreach(p, allow_poison + poisonous) {
415 if (p == poison_type) {
416 allow_dep = true
417 }
418 }
419 if (!allow_dep) {
420 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
421 }
422 }
423 }
424
mbonadei9aa3f0a2017-01-24 06:58:22 -0800425 configs += invoker.configs
426 configs -= rtc_remove_configs
427 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000428 public_configs = [
429 rtc_common_inherited_config,
430 absl_include_config,
431 absl_define_config,
432 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800433 if (defined(invoker.public_configs)) {
434 public_configs += invoker.public_configs
435 }
436 }
437}
438
439template("rtc_executable") {
440 executable(target_name) {
441 forward_variables_from(invoker,
442 "*",
443 [
444 "deps",
445 "configs",
446 "public_configs",
447 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200448 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800449 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200450 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000451 if (!defined(visibility)) {
452 visibility = webrtc_default_visibility
453 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800454 configs += invoker.configs
455 configs -= rtc_remove_configs
456 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700457 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700458
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000459 public_configs = [
460 rtc_common_inherited_config,
461 absl_include_config,
462 absl_define_config,
463 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800464 if (defined(invoker.public_configs)) {
465 public_configs += invoker.public_configs
466 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200467 if (is_win) {
468 deps += [
469 # Give executables the default manifest on Windows (a no-op elsewhere).
470 "//build/win:default_exe_manifest",
471 ]
472 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800473 }
474}
475
476template("rtc_static_library") {
477 static_library(target_name) {
478 forward_variables_from(invoker,
479 "*",
480 [
481 "configs",
482 "public_configs",
483 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200484 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800485 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200486 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000487 if (!defined(visibility)) {
488 visibility = webrtc_default_visibility
489 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200490
491 # What's your poison?
492 if (defined(testonly) && testonly) {
493 assert(!defined(poisonous))
494 assert(!defined(allow_poison))
495 } else {
496 if (!defined(poisonous)) {
497 poisonous = []
498 }
499 if (!defined(allow_poison)) {
500 allow_poison = []
501 }
502 if (!defined(assert_no_deps)) {
503 assert_no_deps = []
504 }
505 if (!defined(deps)) {
506 deps = []
507 }
508 foreach(p, poisonous) {
509 deps += [ webrtc_root + ":poison_" + p ]
510 }
511 foreach(poison_type, all_poison_types) {
512 allow_dep = true
513 foreach(v, visibility) {
514 if (v == "*") {
515 allow_dep = false
516 }
517 }
518 foreach(p, allow_poison + poisonous) {
519 if (p == poison_type) {
520 allow_dep = true
521 }
522 }
523 if (!allow_dep) {
524 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
525 }
526 }
527 }
528
mbonadei9aa3f0a2017-01-24 06:58:22 -0800529 configs += invoker.configs
530 configs -= rtc_remove_configs
531 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000532 public_configs = [
533 rtc_common_inherited_config,
534 absl_include_config,
535 absl_define_config,
536 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800537 if (defined(invoker.public_configs)) {
538 public_configs += invoker.public_configs
539 }
540 }
541}
542
543template("rtc_shared_library") {
544 shared_library(target_name) {
545 forward_variables_from(invoker,
546 "*",
547 [
548 "configs",
549 "public_configs",
550 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200551 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800552 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200553 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000554 if (!defined(visibility)) {
555 visibility = webrtc_default_visibility
556 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200557
558 # What's your poison?
559 if (defined(testonly) && testonly) {
560 assert(!defined(poisonous))
561 assert(!defined(allow_poison))
562 } else {
563 if (!defined(poisonous)) {
564 poisonous = []
565 }
566 if (!defined(allow_poison)) {
567 allow_poison = []
568 }
569 if (!defined(assert_no_deps)) {
570 assert_no_deps = []
571 }
572 if (!defined(deps)) {
573 deps = []
574 }
575 foreach(p, poisonous) {
576 deps += [ webrtc_root + ":poison_" + p ]
577 }
578 foreach(poison_type, all_poison_types) {
579 allow_dep = true
580 foreach(v, visibility) {
581 if (v == "*") {
582 allow_dep = false
583 }
584 }
585 foreach(p, allow_poison + poisonous) {
586 if (p == poison_type) {
587 allow_dep = true
588 }
589 }
590 if (!allow_dep) {
591 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
592 }
593 }
594 }
595
mbonadei9aa3f0a2017-01-24 06:58:22 -0800596 configs += invoker.configs
597 configs -= rtc_remove_configs
598 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000599 public_configs = [
600 rtc_common_inherited_config,
601 absl_include_config,
602 absl_define_config,
603 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800604 if (defined(invoker.public_configs)) {
605 public_configs += invoker.public_configs
606 }
607 }
608}
kthelgason4065a572017-02-14 04:58:56 -0800609
610if (is_ios) {
611 set_defaults("rtc_ios_xctest_test") {
612 configs = rtc_add_configs
613 suppressed_configs = []
614 }
615
616 template("rtc_ios_xctest_test") {
617 ios_xctest_test(target_name) {
618 forward_variables_from(invoker,
619 "*",
620 [
621 "configs",
622 "public_configs",
623 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200624 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800625 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200626 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000627 if (!defined(visibility)) {
628 visibility = webrtc_default_visibility
629 }
kthelgason4065a572017-02-14 04:58:56 -0800630 configs += invoker.configs
631 configs -= rtc_remove_configs
632 configs -= invoker.suppressed_configs
633 public_configs = [ rtc_common_inherited_config ]
634 if (defined(invoker.public_configs)) {
635 public_configs += invoker.public_configs
636 }
637 }
638 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100639
640 template("ios_framework_bundle_with_umbrella_header") {
641 forward_variables_from(invoker, [ "output_name" ])
642 umbrella_header_path =
643 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
644
645 ios_framework_bundle(target_name) {
646 forward_variables_from(invoker, "*", [])
647
648 deps += [ ":copy_umbrella_header_$target_name" ]
649 }
650
651 action("umbrella_header_$target_name") {
652 forward_variables_from(invoker, [ "public_headers" ])
653
654 script = "//tools_webrtc/ios/generate_umbrella_header.py"
655
656 outputs = [
657 umbrella_header_path,
658 ]
659 args = [
660 "--out",
661 rebase_path(umbrella_header_path, root_build_dir),
662 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200663 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100664 }
665
666 copy("copy_umbrella_header_$target_name") {
667 sources = [
668 umbrella_header_path,
669 ]
670 outputs = [
671 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
672 ]
673
674 deps = [
675 ":umbrella_header_$target_name",
676 ]
677 }
678 }
679
680 set_defaults("ios_framework_bundle_with_umbrella_header") {
681 configs = default_shared_library_configs
682 }
kthelgason4065a572017-02-14 04:58:56 -0800683}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000684
685if (is_android) {
686 template("rtc_android_library") {
687 android_library(target_name) {
688 forward_variables_from(invoker,
689 "*",
690 [
691 "configs",
692 "public_configs",
693 "suppressed_configs",
694 "visibility",
695 ])
696
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100697 javac_args = []
698
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000699 # Treat warnings as errors.
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100700 javac_args += [ "-Werror" ]
701
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200702 # TODO(crbug.com/824679): Find out why this fails in Chromium
703 if (!build_with_chromium) {
704 javac_args += [
705 "-Xep:ParameterNotNullable:ERROR",
706 "-Xep:FieldMissingNullable:ERROR",
707 "-Xep:ReturnMissingNullable:ERROR",
708 ]
709 }
710
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100711 # Add any arguments defined by the invoker.
712 if (defined(invoker.javac_args)) {
713 javac_args += invoker.javac_args
714 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000715
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200716 if (!defined(deps)) {
717 deps = []
718 }
719 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
720
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000721 no_build_hooks = true
722 }
723 }
724
725 template("rtc_android_apk") {
726 android_apk(target_name) {
727 forward_variables_from(invoker,
728 "*",
729 [
730 "configs",
731 "public_configs",
732 "suppressed_configs",
733 "visibility",
734 ])
735
736 # Treat warnings as errors.
737 javac_args = [ "-Werror" ]
738
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200739 # TODO(crbug.com/824679): Find out why this fails in Chromium
740 if (!build_with_chromium) {
741 javac_args += [
742 "-Xep:ParameterNotNullable:ERROR",
743 "-Xep:FieldMissingNullable:ERROR",
744 "-Xep:ReturnMissingNullable:ERROR",
745 ]
746 }
747
748 if (!defined(deps)) {
749 deps = []
750 }
751 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
752
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000753 no_build_hooks = true
754 }
755 }
756
757 template("rtc_instrumentation_test_apk") {
758 instrumentation_test_apk(target_name) {
759 forward_variables_from(invoker,
760 "*",
761 [
762 "configs",
763 "public_configs",
764 "suppressed_configs",
765 "visibility",
766 ])
767
768 # Treat warnings as errors.
769 javac_args = [ "-Werror" ]
770
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200771 # TODO(crbug.com/824679): Find out why this fails in Chromium
772 if (!build_with_chromium) {
773 javac_args += [
774 "-Xep:ParameterNotNullable:ERROR",
775 "-Xep:FieldMissingNullable:ERROR",
776 "-Xep:ReturnMissingNullable:ERROR",
777 ]
778 }
779
780 if (!defined(deps)) {
781 deps = []
782 }
783 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
784
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000785 no_build_hooks = true
786 }
787 }
788}