blob: c43ebd3e8459ca63096bd1a8fc4cb5ada2e6fb8d [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.
Will Harrisfc173d02018-08-29 13:56:00 -0700241rtc_common_configs = [
242 webrtc_root + ":common_config",
243 "//build/config/compiler:no_size_t_to_int_warning",
244]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800245
kthelgasonc0977102017-04-24 00:57:16 -0700246if (is_mac || is_ios) {
247 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
248}
249
mbonadei9aa3f0a2017-01-24 06:58:22 -0800250# Global public configuration that should be applied to all WebRTC targets. You
251# normally shouldn't need to include this in your target as it's automatically
252# included when using the rtc_* templates. It set the defines, include paths and
253# compilation warnings that should be propagated to dependents of the targets
254# depending on the target having this config.
255rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
256
257# Common configs to remove or add in all rtc targets.
258rtc_remove_configs = []
259rtc_add_configs = rtc_common_configs
260
261set_defaults("rtc_test") {
262 configs = rtc_add_configs
263 suppressed_configs = []
264}
265
266set_defaults("rtc_source_set") {
267 configs = rtc_add_configs
268 suppressed_configs = []
269}
270
271set_defaults("rtc_executable") {
272 configs = rtc_add_configs
273 suppressed_configs = []
274}
275
276set_defaults("rtc_static_library") {
277 configs = rtc_add_configs
278 suppressed_configs = []
279}
280
281set_defaults("rtc_shared_library") {
282 configs = rtc_add_configs
283 suppressed_configs = []
284}
285
Per Kjellandera7f2d842018-01-10 15:54:53 +0000286webrtc_default_visibility = [ webrtc_root + "/*" ]
287if (build_with_chromium) {
288 # Allow Chromium's WebRTC overrides targets to bypass the regular
289 # visibility restrictions.
290 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
291}
292
Karl Wibergbb23c832018-04-22 19:55:00 +0200293# ---- Poisons ----
294#
295# The general idea is that some targets declare that they contain some
296# kind of poison, which makes it impossible for other targets to
297# depend on them (even transitively) unless they declare themselves
298# immune to that particular type of poison.
299#
300# Targets that *contain* poison of type foo should contain the line
301#
302# poisonous = [ "foo" ]
303#
304# and targets that *are immune but arent't themselves poisonous*
305# should contain
306#
307# allow_poison = [ "foo" ]
308#
309# This useful in cases where we have some large target or set of
310# targets and want to ensure that most other targets do not
311# transitively depend on them. For example, almost no high-level
312# target should depend on the audio codecs, since we want WebRTC users
313# to be able to inject any subset of them and actually end up with a
314# binary that doesn't include the codecs they didn't inject.
315#
316# Test-only targets (`testonly` set to true) and non-public targets
317# (`visibility` not containing "*") are automatically immune to all
318# types of poison.
319#
320# Here's the complete list of all types of poison. It must be kept in
321# 1:1 correspondence with the set of //:poison_* targets.
322#
323all_poison_types = [
324 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
325 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200326
327 # Software video codecs (VP8 and VP9 through libvpx).
328 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200329]
330
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000331absl_include_config = "//third_party/abseil-cpp:absl_include_config"
332absl_define_config = "//third_party/abseil-cpp:absl_define_config"
333
mbonadei9aa3f0a2017-01-24 06:58:22 -0800334template("rtc_test") {
335 test(target_name) {
336 forward_variables_from(invoker,
337 "*",
338 [
339 "configs",
340 "public_configs",
341 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200342 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800343 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100344
345 # Always override to public because when target_os is Android the `test`
346 # template can override it to [ "*" ] and we want to avoid conditional
347 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100348 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800349 configs += invoker.configs
350 configs -= rtc_remove_configs
351 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000352 public_configs = [
353 rtc_common_inherited_config,
354 absl_include_config,
355 absl_define_config,
356 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800357 if (defined(invoker.public_configs)) {
358 public_configs += invoker.public_configs
359 }
sakald7fdb802017-05-26 01:51:53 -0700360 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800361 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
362 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700363 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800364 }
365}
366
367template("rtc_source_set") {
368 source_set(target_name) {
369 forward_variables_from(invoker,
370 "*",
371 [
372 "configs",
373 "public_configs",
374 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200375 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800376 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200377 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000378 if (!defined(visibility)) {
379 visibility = webrtc_default_visibility
380 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200381
382 # What's your poison?
383 if (defined(testonly) && testonly) {
384 assert(!defined(poisonous))
385 assert(!defined(allow_poison))
386 } else {
387 if (!defined(poisonous)) {
388 poisonous = []
389 }
390 if (!defined(allow_poison)) {
391 allow_poison = []
392 }
393 if (!defined(assert_no_deps)) {
394 assert_no_deps = []
395 }
396 if (!defined(deps)) {
397 deps = []
398 }
399 foreach(p, poisonous) {
400 deps += [ webrtc_root + ":poison_" + p ]
401 }
402 foreach(poison_type, all_poison_types) {
403 allow_dep = true
404 foreach(v, visibility) {
405 if (v == "*") {
406 allow_dep = false
407 }
408 }
409 foreach(p, allow_poison + poisonous) {
410 if (p == poison_type) {
411 allow_dep = true
412 }
413 }
414 if (!allow_dep) {
415 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
416 }
417 }
418 }
419
mbonadei9aa3f0a2017-01-24 06:58:22 -0800420 configs += invoker.configs
421 configs -= rtc_remove_configs
422 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000423 public_configs = [
424 rtc_common_inherited_config,
425 absl_include_config,
426 absl_define_config,
427 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800428 if (defined(invoker.public_configs)) {
429 public_configs += invoker.public_configs
430 }
431 }
432}
433
434template("rtc_executable") {
435 executable(target_name) {
436 forward_variables_from(invoker,
437 "*",
438 [
439 "deps",
440 "configs",
441 "public_configs",
442 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200443 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800444 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200445 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000446 if (!defined(visibility)) {
447 visibility = webrtc_default_visibility
448 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800449 configs += invoker.configs
450 configs -= rtc_remove_configs
451 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700452 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700453
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000454 public_configs = [
455 rtc_common_inherited_config,
456 absl_include_config,
457 absl_define_config,
458 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800459 if (defined(invoker.public_configs)) {
460 public_configs += invoker.public_configs
461 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200462 if (is_win) {
463 deps += [
464 # Give executables the default manifest on Windows (a no-op elsewhere).
465 "//build/win:default_exe_manifest",
466 ]
467 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800468 }
469}
470
471template("rtc_static_library") {
472 static_library(target_name) {
473 forward_variables_from(invoker,
474 "*",
475 [
476 "configs",
477 "public_configs",
478 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200479 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800480 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200481 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000482 if (!defined(visibility)) {
483 visibility = webrtc_default_visibility
484 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200485
486 # What's your poison?
487 if (defined(testonly) && testonly) {
488 assert(!defined(poisonous))
489 assert(!defined(allow_poison))
490 } else {
491 if (!defined(poisonous)) {
492 poisonous = []
493 }
494 if (!defined(allow_poison)) {
495 allow_poison = []
496 }
497 if (!defined(assert_no_deps)) {
498 assert_no_deps = []
499 }
500 if (!defined(deps)) {
501 deps = []
502 }
503 foreach(p, poisonous) {
504 deps += [ webrtc_root + ":poison_" + p ]
505 }
506 foreach(poison_type, all_poison_types) {
507 allow_dep = true
508 foreach(v, visibility) {
509 if (v == "*") {
510 allow_dep = false
511 }
512 }
513 foreach(p, allow_poison + poisonous) {
514 if (p == poison_type) {
515 allow_dep = true
516 }
517 }
518 if (!allow_dep) {
519 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
520 }
521 }
522 }
523
mbonadei9aa3f0a2017-01-24 06:58:22 -0800524 configs += invoker.configs
525 configs -= rtc_remove_configs
526 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000527 public_configs = [
528 rtc_common_inherited_config,
529 absl_include_config,
530 absl_define_config,
531 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800532 if (defined(invoker.public_configs)) {
533 public_configs += invoker.public_configs
534 }
535 }
536}
537
538template("rtc_shared_library") {
539 shared_library(target_name) {
540 forward_variables_from(invoker,
541 "*",
542 [
543 "configs",
544 "public_configs",
545 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200546 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800547 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200548 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000549 if (!defined(visibility)) {
550 visibility = webrtc_default_visibility
551 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200552
553 # What's your poison?
554 if (defined(testonly) && testonly) {
555 assert(!defined(poisonous))
556 assert(!defined(allow_poison))
557 } else {
558 if (!defined(poisonous)) {
559 poisonous = []
560 }
561 if (!defined(allow_poison)) {
562 allow_poison = []
563 }
564 if (!defined(assert_no_deps)) {
565 assert_no_deps = []
566 }
567 if (!defined(deps)) {
568 deps = []
569 }
570 foreach(p, poisonous) {
571 deps += [ webrtc_root + ":poison_" + p ]
572 }
573 foreach(poison_type, all_poison_types) {
574 allow_dep = true
575 foreach(v, visibility) {
576 if (v == "*") {
577 allow_dep = false
578 }
579 }
580 foreach(p, allow_poison + poisonous) {
581 if (p == poison_type) {
582 allow_dep = true
583 }
584 }
585 if (!allow_dep) {
586 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
587 }
588 }
589 }
590
mbonadei9aa3f0a2017-01-24 06:58:22 -0800591 configs += invoker.configs
592 configs -= rtc_remove_configs
593 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000594 public_configs = [
595 rtc_common_inherited_config,
596 absl_include_config,
597 absl_define_config,
598 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800599 if (defined(invoker.public_configs)) {
600 public_configs += invoker.public_configs
601 }
602 }
603}
kthelgason4065a572017-02-14 04:58:56 -0800604
605if (is_ios) {
606 set_defaults("rtc_ios_xctest_test") {
607 configs = rtc_add_configs
608 suppressed_configs = []
609 }
610
611 template("rtc_ios_xctest_test") {
612 ios_xctest_test(target_name) {
613 forward_variables_from(invoker,
614 "*",
615 [
616 "configs",
617 "public_configs",
618 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200619 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800620 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200621 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000622 if (!defined(visibility)) {
623 visibility = webrtc_default_visibility
624 }
kthelgason4065a572017-02-14 04:58:56 -0800625 configs += invoker.configs
626 configs -= rtc_remove_configs
627 configs -= invoker.suppressed_configs
628 public_configs = [ rtc_common_inherited_config ]
629 if (defined(invoker.public_configs)) {
630 public_configs += invoker.public_configs
631 }
632 }
633 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100634
635 template("ios_framework_bundle_with_umbrella_header") {
636 forward_variables_from(invoker, [ "output_name" ])
637 umbrella_header_path =
638 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
639
640 ios_framework_bundle(target_name) {
641 forward_variables_from(invoker, "*", [])
642
643 deps += [ ":copy_umbrella_header_$target_name" ]
644 }
645
646 action("umbrella_header_$target_name") {
647 forward_variables_from(invoker, [ "public_headers" ])
648
649 script = "//tools_webrtc/ios/generate_umbrella_header.py"
650
651 outputs = [
652 umbrella_header_path,
653 ]
654 args = [
655 "--out",
656 rebase_path(umbrella_header_path, root_build_dir),
657 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200658 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100659 }
660
661 copy("copy_umbrella_header_$target_name") {
662 sources = [
663 umbrella_header_path,
664 ]
665 outputs = [
666 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
667 ]
668
669 deps = [
670 ":umbrella_header_$target_name",
671 ]
672 }
673 }
674
675 set_defaults("ios_framework_bundle_with_umbrella_header") {
676 configs = default_shared_library_configs
677 }
kthelgason4065a572017-02-14 04:58:56 -0800678}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000679
680if (is_android) {
681 template("rtc_android_library") {
682 android_library(target_name) {
683 forward_variables_from(invoker,
684 "*",
685 [
686 "configs",
687 "public_configs",
688 "suppressed_configs",
689 "visibility",
690 ])
691
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100692 javac_args = []
693
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000694 # Treat warnings as errors.
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100695 javac_args += [ "-Werror" ]
696
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200697 # TODO(crbug.com/824679): Find out why this fails in Chromium
698 if (!build_with_chromium) {
699 javac_args += [
700 "-Xep:ParameterNotNullable:ERROR",
701 "-Xep:FieldMissingNullable:ERROR",
702 "-Xep:ReturnMissingNullable:ERROR",
703 ]
704 }
705
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100706 # Add any arguments defined by the invoker.
707 if (defined(invoker.javac_args)) {
708 javac_args += invoker.javac_args
709 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000710
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200711 if (!defined(deps)) {
712 deps = []
713 }
714 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
715
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000716 no_build_hooks = true
717 }
718 }
719
720 template("rtc_android_apk") {
721 android_apk(target_name) {
722 forward_variables_from(invoker,
723 "*",
724 [
725 "configs",
726 "public_configs",
727 "suppressed_configs",
728 "visibility",
729 ])
730
731 # Treat warnings as errors.
732 javac_args = [ "-Werror" ]
733
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200734 # TODO(crbug.com/824679): Find out why this fails in Chromium
735 if (!build_with_chromium) {
736 javac_args += [
737 "-Xep:ParameterNotNullable:ERROR",
738 "-Xep:FieldMissingNullable:ERROR",
739 "-Xep:ReturnMissingNullable:ERROR",
740 ]
741 }
742
743 if (!defined(deps)) {
744 deps = []
745 }
746 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
747
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000748 no_build_hooks = true
749 }
750 }
751
752 template("rtc_instrumentation_test_apk") {
753 instrumentation_test_apk(target_name) {
754 forward_variables_from(invoker,
755 "*",
756 [
757 "configs",
758 "public_configs",
759 "suppressed_configs",
760 "visibility",
761 ])
762
763 # Treat warnings as errors.
764 javac_args = [ "-Werror" ]
765
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200766 # TODO(crbug.com/824679): Find out why this fails in Chromium
767 if (!build_with_chromium) {
768 javac_args += [
769 "-Xep:ParameterNotNullable:ERROR",
770 "-Xep:FieldMissingNullable:ERROR",
771 "-Xep:ReturnMissingNullable:ERROR",
772 ]
773 }
774
775 if (!defined(deps)) {
776 deps = []
777 }
778 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
779
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000780 no_build_hooks = true
781 }
782 }
783}