blob: 58631ddc7d549d52c737b5aeeddb62f2b61d1db3 [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
269
270set_defaults("rtc_test") {
271 configs = rtc_add_configs
272 suppressed_configs = []
273}
274
275set_defaults("rtc_source_set") {
276 configs = rtc_add_configs
277 suppressed_configs = []
278}
279
280set_defaults("rtc_executable") {
281 configs = rtc_add_configs
282 suppressed_configs = []
283}
284
285set_defaults("rtc_static_library") {
286 configs = rtc_add_configs
287 suppressed_configs = []
288}
289
290set_defaults("rtc_shared_library") {
291 configs = rtc_add_configs
292 suppressed_configs = []
293}
294
Per Kjellandera7f2d842018-01-10 15:54:53 +0000295webrtc_default_visibility = [ webrtc_root + "/*" ]
296if (build_with_chromium) {
297 # Allow Chromium's WebRTC overrides targets to bypass the regular
298 # visibility restrictions.
299 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
300}
301
Karl Wibergbb23c832018-04-22 19:55:00 +0200302# ---- Poisons ----
303#
304# The general idea is that some targets declare that they contain some
305# kind of poison, which makes it impossible for other targets to
306# depend on them (even transitively) unless they declare themselves
307# immune to that particular type of poison.
308#
309# Targets that *contain* poison of type foo should contain the line
310#
311# poisonous = [ "foo" ]
312#
313# and targets that *are immune but arent't themselves poisonous*
314# should contain
315#
316# allow_poison = [ "foo" ]
317#
318# This useful in cases where we have some large target or set of
319# targets and want to ensure that most other targets do not
320# transitively depend on them. For example, almost no high-level
321# target should depend on the audio codecs, since we want WebRTC users
322# to be able to inject any subset of them and actually end up with a
323# binary that doesn't include the codecs they didn't inject.
324#
325# Test-only targets (`testonly` set to true) and non-public targets
326# (`visibility` not containing "*") are automatically immune to all
327# types of poison.
328#
329# Here's the complete list of all types of poison. It must be kept in
330# 1:1 correspondence with the set of //:poison_* targets.
331#
332all_poison_types = [
333 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
334 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200335
336 # Software video codecs (VP8 and VP9 through libvpx).
337 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200338]
339
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000340absl_include_config = "//third_party/abseil-cpp:absl_include_config"
341absl_define_config = "//third_party/abseil-cpp:absl_define_config"
342
mbonadei9aa3f0a2017-01-24 06:58:22 -0800343template("rtc_test") {
344 test(target_name) {
345 forward_variables_from(invoker,
346 "*",
347 [
348 "configs",
349 "public_configs",
350 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200351 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800352 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100353
354 # Always override to public because when target_os is Android the `test`
355 # template can override it to [ "*" ] and we want to avoid conditional
356 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100357 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800358 configs += invoker.configs
359 configs -= rtc_remove_configs
360 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000361 public_configs = [
362 rtc_common_inherited_config,
363 absl_include_config,
364 absl_define_config,
365 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800366 if (defined(invoker.public_configs)) {
367 public_configs += invoker.public_configs
368 }
sakald7fdb802017-05-26 01:51:53 -0700369 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800370 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
371 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700372 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800373 }
374}
375
376template("rtc_source_set") {
377 source_set(target_name) {
378 forward_variables_from(invoker,
379 "*",
380 [
381 "configs",
382 "public_configs",
383 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200384 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800385 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200386 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000387 if (!defined(visibility)) {
388 visibility = webrtc_default_visibility
389 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200390
391 # What's your poison?
392 if (defined(testonly) && testonly) {
393 assert(!defined(poisonous))
394 assert(!defined(allow_poison))
395 } else {
396 if (!defined(poisonous)) {
397 poisonous = []
398 }
399 if (!defined(allow_poison)) {
400 allow_poison = []
401 }
402 if (!defined(assert_no_deps)) {
403 assert_no_deps = []
404 }
405 if (!defined(deps)) {
406 deps = []
407 }
408 foreach(p, poisonous) {
409 deps += [ webrtc_root + ":poison_" + p ]
410 }
411 foreach(poison_type, all_poison_types) {
412 allow_dep = true
413 foreach(v, visibility) {
414 if (v == "*") {
415 allow_dep = false
416 }
417 }
418 foreach(p, allow_poison + poisonous) {
419 if (p == poison_type) {
420 allow_dep = true
421 }
422 }
423 if (!allow_dep) {
424 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
425 }
426 }
427 }
428
mbonadei9aa3f0a2017-01-24 06:58:22 -0800429 configs += invoker.configs
430 configs -= rtc_remove_configs
431 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000432 public_configs = [
433 rtc_common_inherited_config,
434 absl_include_config,
435 absl_define_config,
436 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800437 if (defined(invoker.public_configs)) {
438 public_configs += invoker.public_configs
439 }
440 }
441}
442
443template("rtc_executable") {
444 executable(target_name) {
445 forward_variables_from(invoker,
446 "*",
447 [
448 "deps",
449 "configs",
450 "public_configs",
451 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200452 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800453 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200454 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000455 if (!defined(visibility)) {
456 visibility = webrtc_default_visibility
457 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800458 configs += invoker.configs
459 configs -= rtc_remove_configs
460 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700461 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700462
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000463 public_configs = [
464 rtc_common_inherited_config,
465 absl_include_config,
466 absl_define_config,
467 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800468 if (defined(invoker.public_configs)) {
469 public_configs += invoker.public_configs
470 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200471 if (is_win) {
472 deps += [
473 # Give executables the default manifest on Windows (a no-op elsewhere).
474 "//build/win:default_exe_manifest",
475 ]
476 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800477 }
478}
479
480template("rtc_static_library") {
481 static_library(target_name) {
482 forward_variables_from(invoker,
483 "*",
484 [
485 "configs",
486 "public_configs",
487 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200488 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800489 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200490 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000491 if (!defined(visibility)) {
492 visibility = webrtc_default_visibility
493 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200494
495 # What's your poison?
496 if (defined(testonly) && testonly) {
497 assert(!defined(poisonous))
498 assert(!defined(allow_poison))
499 } else {
500 if (!defined(poisonous)) {
501 poisonous = []
502 }
503 if (!defined(allow_poison)) {
504 allow_poison = []
505 }
506 if (!defined(assert_no_deps)) {
507 assert_no_deps = []
508 }
509 if (!defined(deps)) {
510 deps = []
511 }
512 foreach(p, poisonous) {
513 deps += [ webrtc_root + ":poison_" + p ]
514 }
515 foreach(poison_type, all_poison_types) {
516 allow_dep = true
517 foreach(v, visibility) {
518 if (v == "*") {
519 allow_dep = false
520 }
521 }
522 foreach(p, allow_poison + poisonous) {
523 if (p == poison_type) {
524 allow_dep = true
525 }
526 }
527 if (!allow_dep) {
528 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
529 }
530 }
531 }
532
mbonadei9aa3f0a2017-01-24 06:58:22 -0800533 configs += invoker.configs
534 configs -= rtc_remove_configs
535 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000536 public_configs = [
537 rtc_common_inherited_config,
538 absl_include_config,
539 absl_define_config,
540 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800541 if (defined(invoker.public_configs)) {
542 public_configs += invoker.public_configs
543 }
544 }
545}
546
547template("rtc_shared_library") {
548 shared_library(target_name) {
549 forward_variables_from(invoker,
550 "*",
551 [
552 "configs",
553 "public_configs",
554 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200555 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800556 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200557 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000558 if (!defined(visibility)) {
559 visibility = webrtc_default_visibility
560 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200561
562 # What's your poison?
563 if (defined(testonly) && testonly) {
564 assert(!defined(poisonous))
565 assert(!defined(allow_poison))
566 } else {
567 if (!defined(poisonous)) {
568 poisonous = []
569 }
570 if (!defined(allow_poison)) {
571 allow_poison = []
572 }
573 if (!defined(assert_no_deps)) {
574 assert_no_deps = []
575 }
576 if (!defined(deps)) {
577 deps = []
578 }
579 foreach(p, poisonous) {
580 deps += [ webrtc_root + ":poison_" + p ]
581 }
582 foreach(poison_type, all_poison_types) {
583 allow_dep = true
584 foreach(v, visibility) {
585 if (v == "*") {
586 allow_dep = false
587 }
588 }
589 foreach(p, allow_poison + poisonous) {
590 if (p == poison_type) {
591 allow_dep = true
592 }
593 }
594 if (!allow_dep) {
595 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
596 }
597 }
598 }
599
mbonadei9aa3f0a2017-01-24 06:58:22 -0800600 configs += invoker.configs
601 configs -= rtc_remove_configs
602 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000603 public_configs = [
604 rtc_common_inherited_config,
605 absl_include_config,
606 absl_define_config,
607 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800608 if (defined(invoker.public_configs)) {
609 public_configs += invoker.public_configs
610 }
611 }
612}
kthelgason4065a572017-02-14 04:58:56 -0800613
614if (is_ios) {
615 set_defaults("rtc_ios_xctest_test") {
616 configs = rtc_add_configs
617 suppressed_configs = []
618 }
619
620 template("rtc_ios_xctest_test") {
621 ios_xctest_test(target_name) {
622 forward_variables_from(invoker,
623 "*",
624 [
625 "configs",
626 "public_configs",
627 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200628 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800629 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200630 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000631 if (!defined(visibility)) {
632 visibility = webrtc_default_visibility
633 }
kthelgason4065a572017-02-14 04:58:56 -0800634 configs += invoker.configs
635 configs -= rtc_remove_configs
636 configs -= invoker.suppressed_configs
637 public_configs = [ rtc_common_inherited_config ]
638 if (defined(invoker.public_configs)) {
639 public_configs += invoker.public_configs
640 }
641 }
642 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100643
644 template("ios_framework_bundle_with_umbrella_header") {
645 forward_variables_from(invoker, [ "output_name" ])
646 umbrella_header_path =
647 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
648
649 ios_framework_bundle(target_name) {
650 forward_variables_from(invoker, "*", [])
651
652 deps += [ ":copy_umbrella_header_$target_name" ]
653 }
654
655 action("umbrella_header_$target_name") {
656 forward_variables_from(invoker, [ "public_headers" ])
657
658 script = "//tools_webrtc/ios/generate_umbrella_header.py"
659
660 outputs = [
661 umbrella_header_path,
662 ]
663 args = [
664 "--out",
665 rebase_path(umbrella_header_path, root_build_dir),
666 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200667 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100668 }
669
670 copy("copy_umbrella_header_$target_name") {
671 sources = [
672 umbrella_header_path,
673 ]
674 outputs = [
675 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
676 ]
677
678 deps = [
679 ":umbrella_header_$target_name",
680 ]
681 }
682 }
683
684 set_defaults("ios_framework_bundle_with_umbrella_header") {
685 configs = default_shared_library_configs
686 }
kthelgason4065a572017-02-14 04:58:56 -0800687}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000688
Anders Carlsson37bbf792018-09-05 16:29:27 +0200689if (is_mac) {
690 template("mac_framework_bundle_with_umbrella_header") {
691 forward_variables_from(invoker, [ "output_name" ])
692 umbrella_header_path =
693 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
694
695 mac_framework_bundle(target_name) {
696 forward_variables_from(invoker, "*", [])
697
698 framework_version = "A"
699 framework_contents = [ "Headers" ]
700
701 ldflags = [
702 "-all_load",
703 "-install_name",
704 "@rpath/$output_name.framework/$output_name",
705 ]
706
707 deps += [
708 ":copy_framework_headers_$target_name",
709 ":copy_umbrella_header_$target_name",
710 ]
711 }
712
713 copy("copy_framework_headers_$target_name") {
714 forward_variables_from(invoker, [ "sources" ])
715
716 outputs = [
717 "$root_out_dir/$output_name.framework/Headers/{{source_file_part}}",
718 ]
719 }
720
721 action("umbrella_header_$target_name") {
722 forward_variables_from(invoker, [ "sources" ])
723
724 script = "//tools_webrtc/ios/generate_umbrella_header.py"
725
726 outputs = [
727 umbrella_header_path,
728 ]
729 args = [
730 "--out",
731 rebase_path(umbrella_header_path, root_build_dir),
732 "--sources",
733 ] + sources
734 }
735
736 copy("copy_umbrella_header_$target_name") {
737 sources = [
738 umbrella_header_path,
739 ]
740 outputs = [
741 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
742 ]
743
744 deps = [
745 ":umbrella_header_$target_name",
746 ]
747 }
748 }
749}
750
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000751if (is_android) {
752 template("rtc_android_library") {
753 android_library(target_name) {
754 forward_variables_from(invoker,
755 "*",
756 [
757 "configs",
758 "public_configs",
759 "suppressed_configs",
760 "visibility",
761 ])
762
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100763 javac_args = []
764
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000765 # Treat warnings as errors.
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100766 javac_args += [ "-Werror" ]
767
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200768 # TODO(crbug.com/824679): Find out why this fails in Chromium
769 if (!build_with_chromium) {
770 javac_args += [
771 "-Xep:ParameterNotNullable:ERROR",
772 "-Xep:FieldMissingNullable:ERROR",
773 "-Xep:ReturnMissingNullable:ERROR",
774 ]
775 }
776
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100777 # Add any arguments defined by the invoker.
778 if (defined(invoker.javac_args)) {
779 javac_args += invoker.javac_args
780 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000781
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200782 if (!defined(deps)) {
783 deps = []
784 }
785 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
786
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000787 no_build_hooks = true
788 }
789 }
790
791 template("rtc_android_apk") {
792 android_apk(target_name) {
793 forward_variables_from(invoker,
794 "*",
795 [
796 "configs",
797 "public_configs",
798 "suppressed_configs",
799 "visibility",
800 ])
801
802 # Treat warnings as errors.
803 javac_args = [ "-Werror" ]
804
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200805 # TODO(crbug.com/824679): Find out why this fails in Chromium
806 if (!build_with_chromium) {
807 javac_args += [
808 "-Xep:ParameterNotNullable:ERROR",
809 "-Xep:FieldMissingNullable:ERROR",
810 "-Xep:ReturnMissingNullable:ERROR",
811 ]
812 }
813
814 if (!defined(deps)) {
815 deps = []
816 }
817 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
818
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000819 no_build_hooks = true
820 }
821 }
822
823 template("rtc_instrumentation_test_apk") {
824 instrumentation_test_apk(target_name) {
825 forward_variables_from(invoker,
826 "*",
827 [
828 "configs",
829 "public_configs",
830 "suppressed_configs",
831 "visibility",
832 ])
833
834 # Treat warnings as errors.
835 javac_args = [ "-Werror" ]
836
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200837 # TODO(crbug.com/824679): Find out why this fails in Chromium
838 if (!build_with_chromium) {
839 javac_args += [
840 "-Xep:ParameterNotNullable:ERROR",
841 "-Xep:FieldMissingNullable:ERROR",
842 "-Xep:ReturnMissingNullable:ERROR",
843 ]
844 }
845
846 if (!defined(deps)) {
847 deps = []
848 }
849 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
850
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000851 no_build_hooks = true
852 }
853 }
854}