blob: 8970f5575ae48ebb01b793f144d2d4fbb5e001a0 [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
Anders Carlsson37bbf792018-09-05 16:29:27 +020033if (is_mac) {
34 import("//build/config/mac/rules.gni")
35}
36
mbonadei9aa3f0a2017-01-24 06:58:22 -080037declare_args() {
Mirko Bonadei70400902018-08-21 15:44:28 +020038 # WARNING: This argument doesn't have any effect on the WebRTC build until
39 # https://webrtc-review.googlesource.com/c/src/+/94766 will land.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020040 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 15:44:28 +020041 # will tell the pre-processor to remove the default definition of symbols
42 # needed to use field_trial. In that case a new implementation needs to be
43 # provided.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020044 if (build_with_chromium) {
45 # When WebRTC is built as part of Chromium it should exclude the default
46 # implementation of field_trial unless it is building for NACL or
47 # Chromecast.
48 rtc_exclude_field_trial_default = !is_nacl && !is_chromecast
49 } else {
50 rtc_exclude_field_trial_default = false
51 }
Mirko Bonadei70400902018-08-21 15:44:28 +020052
Mirko Bonadei906add42018-09-05 16:03:16 +020053 # WARNING: This argument doesn't have any effect on the WebRTC build until
54 # https://webrtc-review.googlesource.com/c/src/+/95480 will land.
55 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
56 # will tell the pre-processor to remove the default definition of symbols
57 # needed to use metrics. In that case a new implementation needs to be
58 # provided.
59 rtc_exclude_metrics_default = build_with_chromium
60
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070061 # Setting this to false will require the API user to pass in their own
62 # SSLCertificateVerifier to verify the certificates presented from a
63 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
64 rtc_builtin_ssl_root_certificates = true
65
Karl Wibergeb254b42017-11-01 15:08:12 +010066 # Include the iLBC audio codec?
67 rtc_include_ilbc = true
68
mbonadei9aa3f0a2017-01-24 06:58:22 -080069 # Disable this to avoid building the Opus audio codec.
70 rtc_include_opus = true
71
minyue2e03c662017-02-01 17:31:11 -080072 # Enable this if the Opus version upon which WebRTC is built supports direct
73 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020074 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080075
mbonadei9aa3f0a2017-01-24 06:58:22 -080076 # Enable this to let the Opus audio codec change complexity on the fly.
77 rtc_opus_variable_complexity = false
78
mbonadei9aa3f0a2017-01-24 06:58:22 -080079 # Used to specify an external Jsoncpp include path when not compiling the
80 # library that comes with WebRTC (i.e. rtc_build_json == 0).
81 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
82
83 # Used to specify an external OpenSSL include path when not compiling the
84 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
85 rtc_ssl_root = ""
86
87 # Selects fixed-point code where possible.
88 rtc_prefer_fixed_point = false
89
mbonadei9aa3f0a2017-01-24 06:58:22 -080090 # Enable when an external authentication mechanism is used for performing
91 # packet authentication for RTP packets instead of libsrtp.
92 rtc_enable_external_auth = build_with_chromium
93
94 # Selects whether debug dumps for the audio processing module
95 # should be generated.
96 apm_debug_dump = false
97
98 # Set this to true to enable BWE test logging.
99 rtc_enable_bwe_test_logging = false
100
Joachim Bauch93e91342017-12-07 01:25:53 +0100101 # Set this to false to skip building examples.
102 rtc_build_examples = true
103
104 # Set this to false to skip building tools.
105 rtc_build_tools = true
106
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100107 # Set this to false to skip building code that requires X11.
108 rtc_use_x11 = use_x11
109
mbonadei9aa3f0a2017-01-24 06:58:22 -0800110 # Enable to use the Mozilla internal settings.
111 build_with_mozilla = false
112
henrika883d00f2018-03-16 10:09:49 +0100113 # Enable use of Android AAudio which requires Android SDK 26 or above and
114 # NDK r16 or above.
115 rtc_enable_android_aaudio = false
116
117 # TODO(henrika): can this flag be removed?
mbonadei9aa3f0a2017-01-24 06:58:22 -0800118 rtc_enable_android_opensl = false
119
120 # Link-Time Optimizations.
121 # Executes code generation at link-time instead of compile-time.
122 # https://gcc.gnu.org/wiki/LinkTimeOptimization
123 rtc_use_lto = false
124
125 # Set to "func", "block", "edge" for coverage generation.
126 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
127 # It is recommend to set include_examples=0.
128 # Use llvm's sancov -html-report for human readable reports.
129 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
130 rtc_sanitize_coverage = ""
131
perkj650fdae2017-08-25 05:00:11 -0700132 # Links a default implementation of task queues to targets
133 # that depend on the target rtc_task_queue. Set to false to
134 # use an external implementation.
135 rtc_link_task_queue_impl = true
136
mbonadei9aa3f0a2017-01-24 06:58:22 -0800137 if (current_cpu == "arm" || current_cpu == "arm64") {
138 rtc_prefer_fixed_point = true
139 }
140
mbonadei9aa3f0a2017-01-24 06:58:22 -0800141 # Determines whether NEON code will be built.
142 rtc_build_with_neon =
143 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
144
145 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
146 # all platforms except Android and iOS. Because FFmpeg can be built
147 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
148 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Sergey Silkinfe288eb2018-06-25 16:22:38 +0200149 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800150 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
151 # http://www.openh264.org, https://www.ffmpeg.org/
Patrik Höglund3bb11942018-03-16 12:36:26 +0000152 rtc_use_h264 = proprietary_codecs && !is_android && !is_ios
mbonadei9aa3f0a2017-01-24 06:58:22 -0800153
mbonadei9aa3f0a2017-01-24 06:58:22 -0800154 # By default, use normal platform audio support or dummy audio, but don't
155 # use file-based audio playout and record.
156 rtc_use_dummy_audio_file_devices = false
157
henrika7be78832017-06-13 17:34:16 +0200158 # When set to true, replace the audio output with a sinus tone at 440Hz.
159 # The ADM will ask for audio data from WebRTC but instead of reading real
160 # audio samples from NetEQ, a sinus tone will be generated and replace the
161 # real audio samples.
162 rtc_audio_device_plays_sinus_tone = false
163
Anders Carlssondd8c1652018-01-30 10:32:13 +0100164 # Disable this to build without support for built-in software codecs.
165 rtc_use_builtin_sw_codecs = true
Anders Carlsson358f2e02018-06-04 10:24:37 +0200166
167 if (is_ios) {
168 # Build broadcast extension in AppRTCMobile for iOS. This results in the
169 # binary only running on iOS 11+, which is why it is disabled by default.
170 rtc_apprtcmobile_broadcast_extension = false
171 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200172
173 # Determines whether Metal is available on iOS/macOS.
174 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
Dan Minor9c686132018-01-15 10:20:00 -0500175}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800176
Dan Minor9c686132018-01-15 10:20:00 -0500177if (!build_with_mozilla) {
178 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800179}
180
181# A second declare_args block, so that declarations within it can
182# depend on the possibly overridden variables in the first
183# declare_args block.
184declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500185 # Enables the use of protocol buffers for debug recordings.
186 rtc_enable_protobuf = !build_with_mozilla
187
188 # Set this to disable building with support for SCTP data channels.
189 rtc_enable_sctp = !build_with_mozilla
190
191 # Disable these to not build components which can be externally provided.
192 rtc_build_json = !build_with_mozilla
193 rtc_build_libsrtp = !build_with_mozilla
194 rtc_build_libvpx = !build_with_mozilla
195 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500196 rtc_build_opus = !build_with_mozilla
197 rtc_build_ssl = !build_with_mozilla
198 rtc_build_usrsctp = !build_with_mozilla
199
200 # Enable libevent task queues on platforms that support it.
201 # rtc_link_task_queue_impl must be set to true for this to
202 # have an effect.
Wez00cecb92018-02-09 10:41:00 -0800203 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) {
Dan Minor9c686132018-01-15 10:20:00 -0500204 rtc_enable_libevent = false
205 rtc_build_libevent = false
206 } else {
207 rtc_enable_libevent = true
208 rtc_build_libevent = !build_with_mozilla
209 }
210
Dan Minor9c686132018-01-15 10:20:00 -0500211 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
212 # build environments, even if available for Chromium builds.
213 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
214
mbonadei9aa3f0a2017-01-24 06:58:22 -0800215 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
216 rtc_include_pulse_audio = !build_with_chromium
217
218 # Chromium uses its own IO handling, so the internal ADM is only built for
219 # standalone WebRTC.
220 rtc_include_internal_audio_device = !build_with_chromium
221
222 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500223 rtc_include_tests = !build_with_chromium && !build_with_mozilla
mbonadei9aa3f0a2017-01-24 06:58:22 -0800224}
225
226# Make it possible to provide custom locations for some libraries (move these
227# up into declare_args should we need to actually use them for the GN build).
228rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800229rtc_opus_dir = "//third_party/opus"
230
231# Desktop capturer is supported only on Windows, OSX and Linux.
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100232rtc_desktop_capture_supported = is_win || is_mac || (is_linux && rtc_use_x11)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800233
234###############################################################################
235# Templates
236#
237
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200238# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800239# chromium.
240# We need absolute paths for all configs in templates as they are shared in
241# different subdirectories.
242webrtc_root = get_path_info(".", "abspath")
243
244# Global configuration that should be applied to all WebRTC targets.
245# You normally shouldn't need to include this in your target as it's
246# automatically included when using the rtc_* templates.
247# It sets defines, include paths and compilation warnings accordingly,
248# both for WebRTC stand-alone builds and for the scenario when WebRTC
249# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700250rtc_common_configs = [
251 webrtc_root + ":common_config",
252 "//build/config/compiler:no_size_t_to_int_warning",
253]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800254
kthelgasonc0977102017-04-24 00:57:16 -0700255if (is_mac || is_ios) {
256 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
257}
258
mbonadei9aa3f0a2017-01-24 06:58:22 -0800259# Global public configuration that should be applied to all WebRTC targets. You
260# normally shouldn't need to include this in your target as it's automatically
261# included when using the rtc_* templates. It set the defines, include paths and
262# compilation warnings that should be propagated to dependents of the targets
263# depending on the target having this config.
264rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
265
266# Common configs to remove or add in all rtc targets.
267rtc_remove_configs = []
268rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200269rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800270
271set_defaults("rtc_test") {
272 configs = rtc_add_configs
273 suppressed_configs = []
274}
275
276set_defaults("rtc_source_set") {
277 configs = rtc_add_configs
278 suppressed_configs = []
279}
280
281set_defaults("rtc_executable") {
282 configs = rtc_add_configs
283 suppressed_configs = []
284}
285
286set_defaults("rtc_static_library") {
287 configs = rtc_add_configs
288 suppressed_configs = []
289}
290
291set_defaults("rtc_shared_library") {
292 configs = rtc_add_configs
293 suppressed_configs = []
294}
295
Per Kjellandera7f2d842018-01-10 15:54:53 +0000296webrtc_default_visibility = [ webrtc_root + "/*" ]
297if (build_with_chromium) {
298 # Allow Chromium's WebRTC overrides targets to bypass the regular
299 # visibility restrictions.
300 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
301}
302
Karl Wibergbb23c832018-04-22 19:55:00 +0200303# ---- Poisons ----
304#
305# The general idea is that some targets declare that they contain some
306# kind of poison, which makes it impossible for other targets to
307# depend on them (even transitively) unless they declare themselves
308# immune to that particular type of poison.
309#
310# Targets that *contain* poison of type foo should contain the line
311#
312# poisonous = [ "foo" ]
313#
314# and targets that *are immune but arent't themselves poisonous*
315# should contain
316#
317# allow_poison = [ "foo" ]
318#
319# This useful in cases where we have some large target or set of
320# targets and want to ensure that most other targets do not
321# transitively depend on them. For example, almost no high-level
322# target should depend on the audio codecs, since we want WebRTC users
323# to be able to inject any subset of them and actually end up with a
324# binary that doesn't include the codecs they didn't inject.
325#
326# Test-only targets (`testonly` set to true) and non-public targets
327# (`visibility` not containing "*") are automatically immune to all
328# types of poison.
329#
330# Here's the complete list of all types of poison. It must be kept in
331# 1:1 correspondence with the set of //:poison_* targets.
332#
333all_poison_types = [
334 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
335 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200336
337 # Software video codecs (VP8 and VP9 through libvpx).
338 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200339]
340
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000341absl_include_config = "//third_party/abseil-cpp:absl_include_config"
342absl_define_config = "//third_party/abseil-cpp:absl_define_config"
343
mbonadei9aa3f0a2017-01-24 06:58:22 -0800344template("rtc_test") {
345 test(target_name) {
346 forward_variables_from(invoker,
347 "*",
348 [
349 "configs",
350 "public_configs",
351 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200352 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800353 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100354
355 # Always override to public because when target_os is Android the `test`
356 # template can override it to [ "*" ] and we want to avoid conditional
357 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100358 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800359 configs += invoker.configs
360 configs -= rtc_remove_configs
361 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000362 public_configs = [
363 rtc_common_inherited_config,
364 absl_include_config,
365 absl_define_config,
366 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800367 if (defined(invoker.public_configs)) {
368 public_configs += invoker.public_configs
369 }
sakald7fdb802017-05-26 01:51:53 -0700370 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800371 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
372 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700373 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800374 }
375}
376
377template("rtc_source_set") {
378 source_set(target_name) {
379 forward_variables_from(invoker,
380 "*",
381 [
382 "configs",
383 "public_configs",
384 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200385 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800386 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200387 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000388 if (!defined(visibility)) {
389 visibility = webrtc_default_visibility
390 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200391
392 # What's your poison?
393 if (defined(testonly) && testonly) {
394 assert(!defined(poisonous))
395 assert(!defined(allow_poison))
396 } else {
397 if (!defined(poisonous)) {
398 poisonous = []
399 }
400 if (!defined(allow_poison)) {
401 allow_poison = []
402 }
403 if (!defined(assert_no_deps)) {
404 assert_no_deps = []
405 }
406 if (!defined(deps)) {
407 deps = []
408 }
409 foreach(p, poisonous) {
410 deps += [ webrtc_root + ":poison_" + p ]
411 }
412 foreach(poison_type, all_poison_types) {
413 allow_dep = true
414 foreach(v, visibility) {
415 if (v == "*") {
416 allow_dep = false
417 }
418 }
419 foreach(p, allow_poison + poisonous) {
420 if (p == poison_type) {
421 allow_dep = true
422 }
423 }
424 if (!allow_dep) {
425 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
426 }
427 }
428 }
429
Mirko Bonadei96ede162018-09-06 13:45:44 +0200430 if (!defined(testonly) || !testonly) {
431 configs += rtc_prod_configs
432 }
433
mbonadei9aa3f0a2017-01-24 06:58:22 -0800434 configs += invoker.configs
435 configs -= rtc_remove_configs
436 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000437 public_configs = [
438 rtc_common_inherited_config,
439 absl_include_config,
440 absl_define_config,
441 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800442 if (defined(invoker.public_configs)) {
443 public_configs += invoker.public_configs
444 }
445 }
446}
447
448template("rtc_executable") {
449 executable(target_name) {
450 forward_variables_from(invoker,
451 "*",
452 [
453 "deps",
454 "configs",
455 "public_configs",
456 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200457 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800458 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200459 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000460 if (!defined(visibility)) {
461 visibility = webrtc_default_visibility
462 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800463 configs += invoker.configs
464 configs -= rtc_remove_configs
465 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700466 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700467
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000468 public_configs = [
469 rtc_common_inherited_config,
470 absl_include_config,
471 absl_define_config,
472 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800473 if (defined(invoker.public_configs)) {
474 public_configs += invoker.public_configs
475 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200476 if (is_win) {
477 deps += [
478 # Give executables the default manifest on Windows (a no-op elsewhere).
479 "//build/win:default_exe_manifest",
480 ]
481 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800482 }
483}
484
485template("rtc_static_library") {
486 static_library(target_name) {
487 forward_variables_from(invoker,
488 "*",
489 [
490 "configs",
491 "public_configs",
492 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200493 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800494 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200495 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000496 if (!defined(visibility)) {
497 visibility = webrtc_default_visibility
498 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200499
500 # What's your poison?
501 if (defined(testonly) && testonly) {
502 assert(!defined(poisonous))
503 assert(!defined(allow_poison))
504 } else {
505 if (!defined(poisonous)) {
506 poisonous = []
507 }
508 if (!defined(allow_poison)) {
509 allow_poison = []
510 }
511 if (!defined(assert_no_deps)) {
512 assert_no_deps = []
513 }
514 if (!defined(deps)) {
515 deps = []
516 }
517 foreach(p, poisonous) {
518 deps += [ webrtc_root + ":poison_" + p ]
519 }
520 foreach(poison_type, all_poison_types) {
521 allow_dep = true
522 foreach(v, visibility) {
523 if (v == "*") {
524 allow_dep = false
525 }
526 }
527 foreach(p, allow_poison + poisonous) {
528 if (p == poison_type) {
529 allow_dep = true
530 }
531 }
532 if (!allow_dep) {
533 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
534 }
535 }
536 }
537
Mirko Bonadei96ede162018-09-06 13:45:44 +0200538 if (!defined(testonly) || !testonly) {
539 configs += rtc_prod_configs
540 }
541
mbonadei9aa3f0a2017-01-24 06:58:22 -0800542 configs += invoker.configs
543 configs -= rtc_remove_configs
544 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000545 public_configs = [
546 rtc_common_inherited_config,
547 absl_include_config,
548 absl_define_config,
549 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800550 if (defined(invoker.public_configs)) {
551 public_configs += invoker.public_configs
552 }
553 }
554}
555
556template("rtc_shared_library") {
557 shared_library(target_name) {
558 forward_variables_from(invoker,
559 "*",
560 [
561 "configs",
562 "public_configs",
563 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200564 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800565 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200566 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000567 if (!defined(visibility)) {
568 visibility = webrtc_default_visibility
569 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200570
571 # What's your poison?
572 if (defined(testonly) && testonly) {
573 assert(!defined(poisonous))
574 assert(!defined(allow_poison))
575 } else {
576 if (!defined(poisonous)) {
577 poisonous = []
578 }
579 if (!defined(allow_poison)) {
580 allow_poison = []
581 }
582 if (!defined(assert_no_deps)) {
583 assert_no_deps = []
584 }
585 if (!defined(deps)) {
586 deps = []
587 }
588 foreach(p, poisonous) {
589 deps += [ webrtc_root + ":poison_" + p ]
590 }
591 foreach(poison_type, all_poison_types) {
592 allow_dep = true
593 foreach(v, visibility) {
594 if (v == "*") {
595 allow_dep = false
596 }
597 }
598 foreach(p, allow_poison + poisonous) {
599 if (p == poison_type) {
600 allow_dep = true
601 }
602 }
603 if (!allow_dep) {
604 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
605 }
606 }
607 }
608
mbonadei9aa3f0a2017-01-24 06:58:22 -0800609 configs += invoker.configs
610 configs -= rtc_remove_configs
611 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000612 public_configs = [
613 rtc_common_inherited_config,
614 absl_include_config,
615 absl_define_config,
616 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800617 if (defined(invoker.public_configs)) {
618 public_configs += invoker.public_configs
619 }
620 }
621}
kthelgason4065a572017-02-14 04:58:56 -0800622
623if (is_ios) {
624 set_defaults("rtc_ios_xctest_test") {
625 configs = rtc_add_configs
626 suppressed_configs = []
627 }
628
629 template("rtc_ios_xctest_test") {
630 ios_xctest_test(target_name) {
631 forward_variables_from(invoker,
632 "*",
633 [
634 "configs",
635 "public_configs",
636 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200637 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800638 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200639 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000640 if (!defined(visibility)) {
641 visibility = webrtc_default_visibility
642 }
kthelgason4065a572017-02-14 04:58:56 -0800643 configs += invoker.configs
644 configs -= rtc_remove_configs
645 configs -= invoker.suppressed_configs
646 public_configs = [ rtc_common_inherited_config ]
647 if (defined(invoker.public_configs)) {
648 public_configs += invoker.public_configs
649 }
650 }
651 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100652
653 template("ios_framework_bundle_with_umbrella_header") {
654 forward_variables_from(invoker, [ "output_name" ])
655 umbrella_header_path =
656 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
657
658 ios_framework_bundle(target_name) {
659 forward_variables_from(invoker, "*", [])
660
661 deps += [ ":copy_umbrella_header_$target_name" ]
662 }
663
664 action("umbrella_header_$target_name") {
665 forward_variables_from(invoker, [ "public_headers" ])
666
667 script = "//tools_webrtc/ios/generate_umbrella_header.py"
668
669 outputs = [
670 umbrella_header_path,
671 ]
672 args = [
673 "--out",
674 rebase_path(umbrella_header_path, root_build_dir),
675 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200676 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100677 }
678
679 copy("copy_umbrella_header_$target_name") {
680 sources = [
681 umbrella_header_path,
682 ]
683 outputs = [
684 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
685 ]
686
687 deps = [
688 ":umbrella_header_$target_name",
689 ]
690 }
691 }
692
693 set_defaults("ios_framework_bundle_with_umbrella_header") {
694 configs = default_shared_library_configs
695 }
kthelgason4065a572017-02-14 04:58:56 -0800696}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000697
Anders Carlsson37bbf792018-09-05 16:29:27 +0200698if (is_mac) {
699 template("mac_framework_bundle_with_umbrella_header") {
700 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200701 this_target_name = target_name
702 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200703
704 mac_framework_bundle(target_name) {
705 forward_variables_from(invoker, "*", [])
706
707 framework_version = "A"
708 framework_contents = [ "Headers" ]
709
710 ldflags = [
711 "-all_load",
712 "-install_name",
713 "@rpath/$output_name.framework/$output_name",
714 ]
715
716 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200717 ":copy_framework_headers_$this_target_name",
718 ":copy_umbrella_header_$this_target_name",
719 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200720 ]
721 }
722
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200723 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200724 forward_variables_from(invoker, [ "sources" ])
725
726 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200727 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200728 ]
729 }
730
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200731 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200732 forward_variables_from(invoker, [ "sources" ])
733
734 script = "//tools_webrtc/ios/generate_umbrella_header.py"
735
736 outputs = [
737 umbrella_header_path,
738 ]
739 args = [
740 "--out",
741 rebase_path(umbrella_header_path, root_build_dir),
742 "--sources",
743 ] + sources
744 }
745
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200746 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200747 sources = [
748 umbrella_header_path,
749 ]
750 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200751 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200752 ]
753
754 deps = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200755 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200756 ]
757 }
758 }
759}
760
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000761if (is_android) {
762 template("rtc_android_library") {
763 android_library(target_name) {
764 forward_variables_from(invoker,
765 "*",
766 [
767 "configs",
768 "public_configs",
769 "suppressed_configs",
770 "visibility",
771 ])
772
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100773 javac_args = []
774
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000775 # Treat warnings as errors.
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100776 javac_args += [ "-Werror" ]
777
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200778 # TODO(crbug.com/824679): Find out why this fails in Chromium
779 if (!build_with_chromium) {
780 javac_args += [
781 "-Xep:ParameterNotNullable:ERROR",
782 "-Xep:FieldMissingNullable:ERROR",
783 "-Xep:ReturnMissingNullable:ERROR",
784 ]
785 }
786
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100787 # Add any arguments defined by the invoker.
788 if (defined(invoker.javac_args)) {
789 javac_args += invoker.javac_args
790 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000791
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200792 if (!defined(deps)) {
793 deps = []
794 }
795 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
796
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000797 no_build_hooks = true
798 }
799 }
800
801 template("rtc_android_apk") {
802 android_apk(target_name) {
803 forward_variables_from(invoker,
804 "*",
805 [
806 "configs",
807 "public_configs",
808 "suppressed_configs",
809 "visibility",
810 ])
811
812 # Treat warnings as errors.
813 javac_args = [ "-Werror" ]
814
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200815 # TODO(crbug.com/824679): Find out why this fails in Chromium
816 if (!build_with_chromium) {
817 javac_args += [
818 "-Xep:ParameterNotNullable:ERROR",
819 "-Xep:FieldMissingNullable:ERROR",
820 "-Xep:ReturnMissingNullable:ERROR",
821 ]
822 }
823
824 if (!defined(deps)) {
825 deps = []
826 }
827 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
828
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000829 no_build_hooks = true
830 }
831 }
832
833 template("rtc_instrumentation_test_apk") {
834 instrumentation_test_apk(target_name) {
835 forward_variables_from(invoker,
836 "*",
837 [
838 "configs",
839 "public_configs",
840 "suppressed_configs",
841 "visibility",
842 ])
843
844 # Treat warnings as errors.
845 javac_args = [ "-Werror" ]
846
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200847 # TODO(crbug.com/824679): Find out why this fails in Chromium
848 if (!build_with_chromium) {
849 javac_args += [
850 "-Xep:ParameterNotNullable:ERROR",
851 "-Xep:FieldMissingNullable:ERROR",
852 "-Xep:ReturnMissingNullable:ERROR",
853 ]
854 }
855
856 if (!defined(deps)) {
857 deps = []
858 }
859 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
860
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000861 no_build_hooks = true
862 }
863 }
864}