blob: 133f86ce05e5123b30b1db57dfa73133f1aa6e94 [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 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200163
164 # Determines whether Metal is available on iOS/macOS.
165 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
Dan Minor9c686132018-01-15 10:20:00 -0500166}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800167
Dan Minor9c686132018-01-15 10:20:00 -0500168if (!build_with_mozilla) {
169 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800170}
171
172# A second declare_args block, so that declarations within it can
173# depend on the possibly overridden variables in the first
174# declare_args block.
175declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500176 # Enables the use of protocol buffers for debug recordings.
177 rtc_enable_protobuf = !build_with_mozilla
178
179 # Set this to disable building with support for SCTP data channels.
180 rtc_enable_sctp = !build_with_mozilla
181
182 # Disable these to not build components which can be externally provided.
183 rtc_build_json = !build_with_mozilla
184 rtc_build_libsrtp = !build_with_mozilla
185 rtc_build_libvpx = !build_with_mozilla
186 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500187 rtc_build_opus = !build_with_mozilla
188 rtc_build_ssl = !build_with_mozilla
189 rtc_build_usrsctp = !build_with_mozilla
190
191 # Enable libevent task queues on platforms that support it.
192 # rtc_link_task_queue_impl must be set to true for this to
193 # have an effect.
Wez00cecb92018-02-09 10:41:00 -0800194 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) {
Dan Minor9c686132018-01-15 10:20:00 -0500195 rtc_enable_libevent = false
196 rtc_build_libevent = false
197 } else {
198 rtc_enable_libevent = true
199 rtc_build_libevent = !build_with_mozilla
200 }
201
Dan Minor9c686132018-01-15 10:20:00 -0500202 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
203 # build environments, even if available for Chromium builds.
204 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
205
mbonadei9aa3f0a2017-01-24 06:58:22 -0800206 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
207 rtc_include_pulse_audio = !build_with_chromium
208
209 # Chromium uses its own IO handling, so the internal ADM is only built for
210 # standalone WebRTC.
211 rtc_include_internal_audio_device = !build_with_chromium
212
213 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500214 rtc_include_tests = !build_with_chromium && !build_with_mozilla
mbonadei9aa3f0a2017-01-24 06:58:22 -0800215}
216
217# Make it possible to provide custom locations for some libraries (move these
218# up into declare_args should we need to actually use them for the GN build).
219rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800220rtc_opus_dir = "//third_party/opus"
221
222# Desktop capturer is supported only on Windows, OSX and Linux.
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100223rtc_desktop_capture_supported = is_win || is_mac || (is_linux && rtc_use_x11)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800224
225###############################################################################
226# Templates
227#
228
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200229# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800230# chromium.
231# We need absolute paths for all configs in templates as they are shared in
232# different subdirectories.
233webrtc_root = get_path_info(".", "abspath")
234
235# Global configuration that should be applied to all WebRTC targets.
236# You normally shouldn't need to include this in your target as it's
237# automatically included when using the rtc_* templates.
238# It sets defines, include paths and compilation warnings accordingly,
239# both for WebRTC stand-alone builds and for the scenario when WebRTC
240# native code is built as part of Chromium.
241rtc_common_configs = [ webrtc_root + ":common_config" ]
242
kthelgasonc0977102017-04-24 00:57:16 -0700243if (is_mac || is_ios) {
244 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
245}
246
mbonadei9aa3f0a2017-01-24 06:58:22 -0800247# Global public configuration that should be applied to all WebRTC targets. You
248# normally shouldn't need to include this in your target as it's automatically
249# included when using the rtc_* templates. It set the defines, include paths and
250# compilation warnings that should be propagated to dependents of the targets
251# depending on the target having this config.
252rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
253
254# Common configs to remove or add in all rtc targets.
255rtc_remove_configs = []
256rtc_add_configs = rtc_common_configs
257
258set_defaults("rtc_test") {
259 configs = rtc_add_configs
260 suppressed_configs = []
261}
262
263set_defaults("rtc_source_set") {
264 configs = rtc_add_configs
265 suppressed_configs = []
266}
267
268set_defaults("rtc_executable") {
269 configs = rtc_add_configs
270 suppressed_configs = []
271}
272
273set_defaults("rtc_static_library") {
274 configs = rtc_add_configs
275 suppressed_configs = []
276}
277
278set_defaults("rtc_shared_library") {
279 configs = rtc_add_configs
280 suppressed_configs = []
281}
282
Per Kjellandera7f2d842018-01-10 15:54:53 +0000283webrtc_default_visibility = [ webrtc_root + "/*" ]
284if (build_with_chromium) {
285 # Allow Chromium's WebRTC overrides targets to bypass the regular
286 # visibility restrictions.
287 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
288}
289
Karl Wibergbb23c832018-04-22 19:55:00 +0200290# ---- Poisons ----
291#
292# The general idea is that some targets declare that they contain some
293# kind of poison, which makes it impossible for other targets to
294# depend on them (even transitively) unless they declare themselves
295# immune to that particular type of poison.
296#
297# Targets that *contain* poison of type foo should contain the line
298#
299# poisonous = [ "foo" ]
300#
301# and targets that *are immune but arent't themselves poisonous*
302# should contain
303#
304# allow_poison = [ "foo" ]
305#
306# This useful in cases where we have some large target or set of
307# targets and want to ensure that most other targets do not
308# transitively depend on them. For example, almost no high-level
309# target should depend on the audio codecs, since we want WebRTC users
310# to be able to inject any subset of them and actually end up with a
311# binary that doesn't include the codecs they didn't inject.
312#
313# Test-only targets (`testonly` set to true) and non-public targets
314# (`visibility` not containing "*") are automatically immune to all
315# types of poison.
316#
317# Here's the complete list of all types of poison. It must be kept in
318# 1:1 correspondence with the set of //:poison_* targets.
319#
320all_poison_types = [
321 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
322 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200323
324 # Software video codecs (VP8 and VP9 through libvpx).
325 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200326]
327
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000328absl_include_config = "//third_party/abseil-cpp:absl_include_config"
329absl_define_config = "//third_party/abseil-cpp:absl_define_config"
330
mbonadei9aa3f0a2017-01-24 06:58:22 -0800331template("rtc_test") {
332 test(target_name) {
333 forward_variables_from(invoker,
334 "*",
335 [
336 "configs",
337 "public_configs",
338 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200339 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800340 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100341
342 # Always override to public because when target_os is Android the `test`
343 # template can override it to [ "*" ] and we want to avoid conditional
344 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100345 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800346 configs += invoker.configs
347 configs -= rtc_remove_configs
348 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000349 public_configs = [
350 rtc_common_inherited_config,
351 absl_include_config,
352 absl_define_config,
353 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800354 if (defined(invoker.public_configs)) {
355 public_configs += invoker.public_configs
356 }
sakald7fdb802017-05-26 01:51:53 -0700357 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800358 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
359 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700360 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800361 }
362}
363
364template("rtc_source_set") {
365 source_set(target_name) {
366 forward_variables_from(invoker,
367 "*",
368 [
369 "configs",
370 "public_configs",
371 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200372 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800373 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200374 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000375 if (!defined(visibility)) {
376 visibility = webrtc_default_visibility
377 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200378
379 # What's your poison?
380 if (defined(testonly) && testonly) {
381 assert(!defined(poisonous))
382 assert(!defined(allow_poison))
383 } else {
384 if (!defined(poisonous)) {
385 poisonous = []
386 }
387 if (!defined(allow_poison)) {
388 allow_poison = []
389 }
390 if (!defined(assert_no_deps)) {
391 assert_no_deps = []
392 }
393 if (!defined(deps)) {
394 deps = []
395 }
396 foreach(p, poisonous) {
397 deps += [ webrtc_root + ":poison_" + p ]
398 }
399 foreach(poison_type, all_poison_types) {
400 allow_dep = true
401 foreach(v, visibility) {
402 if (v == "*") {
403 allow_dep = false
404 }
405 }
406 foreach(p, allow_poison + poisonous) {
407 if (p == poison_type) {
408 allow_dep = true
409 }
410 }
411 if (!allow_dep) {
412 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
413 }
414 }
415 }
416
mbonadei9aa3f0a2017-01-24 06:58:22 -0800417 configs += invoker.configs
418 configs -= rtc_remove_configs
419 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000420 public_configs = [
421 rtc_common_inherited_config,
422 absl_include_config,
423 absl_define_config,
424 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800425 if (defined(invoker.public_configs)) {
426 public_configs += invoker.public_configs
427 }
428 }
429}
430
431template("rtc_executable") {
432 executable(target_name) {
433 forward_variables_from(invoker,
434 "*",
435 [
436 "deps",
437 "configs",
438 "public_configs",
439 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200440 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800441 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200442 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000443 if (!defined(visibility)) {
444 visibility = webrtc_default_visibility
445 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800446 configs += invoker.configs
447 configs -= rtc_remove_configs
448 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700449 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700450
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000451 public_configs = [
452 rtc_common_inherited_config,
453 absl_include_config,
454 absl_define_config,
455 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800456 if (defined(invoker.public_configs)) {
457 public_configs += invoker.public_configs
458 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200459 if (is_win) {
460 deps += [
461 # Give executables the default manifest on Windows (a no-op elsewhere).
462 "//build/win:default_exe_manifest",
463 ]
464 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800465 }
466}
467
468template("rtc_static_library") {
469 static_library(target_name) {
470 forward_variables_from(invoker,
471 "*",
472 [
473 "configs",
474 "public_configs",
475 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200476 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800477 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200478 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000479 if (!defined(visibility)) {
480 visibility = webrtc_default_visibility
481 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200482
483 # What's your poison?
484 if (defined(testonly) && testonly) {
485 assert(!defined(poisonous))
486 assert(!defined(allow_poison))
487 } else {
488 if (!defined(poisonous)) {
489 poisonous = []
490 }
491 if (!defined(allow_poison)) {
492 allow_poison = []
493 }
494 if (!defined(assert_no_deps)) {
495 assert_no_deps = []
496 }
497 if (!defined(deps)) {
498 deps = []
499 }
500 foreach(p, poisonous) {
501 deps += [ webrtc_root + ":poison_" + p ]
502 }
503 foreach(poison_type, all_poison_types) {
504 allow_dep = true
505 foreach(v, visibility) {
506 if (v == "*") {
507 allow_dep = false
508 }
509 }
510 foreach(p, allow_poison + poisonous) {
511 if (p == poison_type) {
512 allow_dep = true
513 }
514 }
515 if (!allow_dep) {
516 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
517 }
518 }
519 }
520
mbonadei9aa3f0a2017-01-24 06:58:22 -0800521 configs += invoker.configs
522 configs -= rtc_remove_configs
523 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000524 public_configs = [
525 rtc_common_inherited_config,
526 absl_include_config,
527 absl_define_config,
528 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800529 if (defined(invoker.public_configs)) {
530 public_configs += invoker.public_configs
531 }
532 }
533}
534
535template("rtc_shared_library") {
536 shared_library(target_name) {
537 forward_variables_from(invoker,
538 "*",
539 [
540 "configs",
541 "public_configs",
542 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200543 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800544 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200545 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000546 if (!defined(visibility)) {
547 visibility = webrtc_default_visibility
548 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200549
550 # What's your poison?
551 if (defined(testonly) && testonly) {
552 assert(!defined(poisonous))
553 assert(!defined(allow_poison))
554 } else {
555 if (!defined(poisonous)) {
556 poisonous = []
557 }
558 if (!defined(allow_poison)) {
559 allow_poison = []
560 }
561 if (!defined(assert_no_deps)) {
562 assert_no_deps = []
563 }
564 if (!defined(deps)) {
565 deps = []
566 }
567 foreach(p, poisonous) {
568 deps += [ webrtc_root + ":poison_" + p ]
569 }
570 foreach(poison_type, all_poison_types) {
571 allow_dep = true
572 foreach(v, visibility) {
573 if (v == "*") {
574 allow_dep = false
575 }
576 }
577 foreach(p, allow_poison + poisonous) {
578 if (p == poison_type) {
579 allow_dep = true
580 }
581 }
582 if (!allow_dep) {
583 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
584 }
585 }
586 }
587
mbonadei9aa3f0a2017-01-24 06:58:22 -0800588 configs += invoker.configs
589 configs -= rtc_remove_configs
590 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000591 public_configs = [
592 rtc_common_inherited_config,
593 absl_include_config,
594 absl_define_config,
595 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800596 if (defined(invoker.public_configs)) {
597 public_configs += invoker.public_configs
598 }
599 }
600}
kthelgason4065a572017-02-14 04:58:56 -0800601
602if (is_ios) {
603 set_defaults("rtc_ios_xctest_test") {
604 configs = rtc_add_configs
605 suppressed_configs = []
606 }
607
608 template("rtc_ios_xctest_test") {
609 ios_xctest_test(target_name) {
610 forward_variables_from(invoker,
611 "*",
612 [
613 "configs",
614 "public_configs",
615 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200616 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800617 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200618 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000619 if (!defined(visibility)) {
620 visibility = webrtc_default_visibility
621 }
kthelgason4065a572017-02-14 04:58:56 -0800622 configs += invoker.configs
623 configs -= rtc_remove_configs
624 configs -= invoker.suppressed_configs
625 public_configs = [ rtc_common_inherited_config ]
626 if (defined(invoker.public_configs)) {
627 public_configs += invoker.public_configs
628 }
629 }
630 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100631
632 template("ios_framework_bundle_with_umbrella_header") {
633 forward_variables_from(invoker, [ "output_name" ])
634 umbrella_header_path =
635 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
636
637 ios_framework_bundle(target_name) {
638 forward_variables_from(invoker, "*", [])
639
640 deps += [ ":copy_umbrella_header_$target_name" ]
641 }
642
643 action("umbrella_header_$target_name") {
644 forward_variables_from(invoker, [ "public_headers" ])
645
646 script = "//tools_webrtc/ios/generate_umbrella_header.py"
647
648 outputs = [
649 umbrella_header_path,
650 ]
651 args = [
652 "--out",
653 rebase_path(umbrella_header_path, root_build_dir),
654 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200655 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100656 }
657
658 copy("copy_umbrella_header_$target_name") {
659 sources = [
660 umbrella_header_path,
661 ]
662 outputs = [
663 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
664 ]
665
666 deps = [
667 ":umbrella_header_$target_name",
668 ]
669 }
670 }
671
672 set_defaults("ios_framework_bundle_with_umbrella_header") {
673 configs = default_shared_library_configs
674 }
kthelgason4065a572017-02-14 04:58:56 -0800675}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000676
677if (is_android) {
678 template("rtc_android_library") {
679 android_library(target_name) {
680 forward_variables_from(invoker,
681 "*",
682 [
683 "configs",
684 "public_configs",
685 "suppressed_configs",
686 "visibility",
687 ])
688
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100689 javac_args = []
690
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000691 # Treat warnings as errors.
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100692 javac_args += [ "-Werror" ]
693
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200694 # TODO(crbug.com/824679): Find out why this fails in Chromium
695 if (!build_with_chromium) {
696 javac_args += [
697 "-Xep:ParameterNotNullable:ERROR",
698 "-Xep:FieldMissingNullable:ERROR",
699 "-Xep:ReturnMissingNullable:ERROR",
700 ]
701 }
702
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100703 # Add any arguments defined by the invoker.
704 if (defined(invoker.javac_args)) {
705 javac_args += invoker.javac_args
706 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000707
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200708 if (!defined(deps)) {
709 deps = []
710 }
711 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
712
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000713 no_build_hooks = true
714 }
715 }
716
717 template("rtc_android_apk") {
718 android_apk(target_name) {
719 forward_variables_from(invoker,
720 "*",
721 [
722 "configs",
723 "public_configs",
724 "suppressed_configs",
725 "visibility",
726 ])
727
728 # Treat warnings as errors.
729 javac_args = [ "-Werror" ]
730
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200731 # TODO(crbug.com/824679): Find out why this fails in Chromium
732 if (!build_with_chromium) {
733 javac_args += [
734 "-Xep:ParameterNotNullable:ERROR",
735 "-Xep:FieldMissingNullable:ERROR",
736 "-Xep:ReturnMissingNullable:ERROR",
737 ]
738 }
739
740 if (!defined(deps)) {
741 deps = []
742 }
743 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
744
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000745 no_build_hooks = true
746 }
747 }
748
749 template("rtc_instrumentation_test_apk") {
750 instrumentation_test_apk(target_name) {
751 forward_variables_from(invoker,
752 "*",
753 [
754 "configs",
755 "public_configs",
756 "suppressed_configs",
757 "visibility",
758 ])
759
760 # Treat warnings as errors.
761 javac_args = [ "-Werror" ]
762
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200763 # TODO(crbug.com/824679): Find out why this fails in Chromium
764 if (!build_with_chromium) {
765 javac_args += [
766 "-Xep:ParameterNotNullable:ERROR",
767 "-Xep:FieldMissingNullable:ERROR",
768 "-Xep:ReturnMissingNullable:ERROR",
769 ]
770 }
771
772 if (!defined(deps)) {
773 deps = []
774 }
775 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
776
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000777 no_build_hooks = true
778 }
779 }
780}