blob: 65975210b04e9d47a8757010b0cf025230a297a5 [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")
Tomas Popela318da512018-11-13 06:32:23 +010012import("//build/config/sysroot.gni")
ehmaldonado0d729b32017-02-10 01:38:23 -080013import("//build/config/ui.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -080014import("//build_overrides/build.gni")
mbonadei96606272017-03-03 19:41:59 -080015
16if (!build_with_chromium && is_component_build) {
17 print("The Gn argument `is_component_build` is currently " +
18 "ignored for WebRTC builds.")
19 print("Component builds are supported by Chromium and the argument " +
20 "`is_component_build` makes it possible to create shared libraries " +
21 "instead of static libraries.")
22 print("If an app depends on WebRTC it makes sense to just depend on the " +
23 "WebRTC static library, so there is no difference between " +
24 "`is_component_build=true` and `is_component_build=false`.")
25 print(
26 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.md")
27 assert(!is_component_build, "Component builds are not supported in WebRTC.")
28}
29
kthelgason4065a572017-02-14 04:58:56 -080030if (is_ios) {
31 import("//build/config/ios/rules.gni")
32}
mbonadei9aa3f0a2017-01-24 06:58:22 -080033
Anders Carlsson37bbf792018-09-05 16:29:27 +020034if (is_mac) {
35 import("//build/config/mac/rules.gni")
36}
37
mbonadei9aa3f0a2017-01-24 06:58:22 -080038declare_args() {
Mirko Bonadei028248c2018-10-10 12:19:02 +020039 # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h)
40 # expand to code that will manage symbols visibility.
41 rtc_enable_symbol_export = false
42
Mirko Bonadei31b0b452018-08-22 10:37:11 +020043 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 15:44:28 +020044 # will tell the pre-processor to remove the default definition of symbols
45 # needed to use field_trial. In that case a new implementation needs to be
46 # provided.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020047 if (build_with_chromium) {
48 # When WebRTC is built as part of Chromium it should exclude the default
49 # implementation of field_trial unless it is building for NACL or
50 # Chromecast.
51 rtc_exclude_field_trial_default = !is_nacl && !is_chromecast
52 } else {
53 rtc_exclude_field_trial_default = false
54 }
Mirko Bonadei70400902018-08-21 15:44:28 +020055
Mirko Bonadei906add42018-09-05 16:03:16 +020056 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
57 # will tell the pre-processor to remove the default definition of symbols
58 # needed to use metrics. In that case a new implementation needs to be
59 # provided.
60 rtc_exclude_metrics_default = build_with_chromium
61
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070062 # Setting this to false will require the API user to pass in their own
63 # SSLCertificateVerifier to verify the certificates presented from a
64 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
65 rtc_builtin_ssl_root_certificates = true
66
Karl Wibergeb254b42017-11-01 15:08:12 +010067 # Include the iLBC audio codec?
68 rtc_include_ilbc = true
69
mbonadei9aa3f0a2017-01-24 06:58:22 -080070 # Disable this to avoid building the Opus audio codec.
71 rtc_include_opus = true
72
minyue2e03c662017-02-01 17:31:11 -080073 # Enable this if the Opus version upon which WebRTC is built supports direct
74 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020075 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080076
mbonadei9aa3f0a2017-01-24 06:58:22 -080077 # Enable this to let the Opus audio codec change complexity on the fly.
78 rtc_opus_variable_complexity = false
79
mbonadei9aa3f0a2017-01-24 06:58:22 -080080 # Used to specify an external Jsoncpp include path when not compiling the
81 # library that comes with WebRTC (i.e. rtc_build_json == 0).
82 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
83
84 # Used to specify an external OpenSSL include path when not compiling the
85 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
86 rtc_ssl_root = ""
87
88 # Selects fixed-point code where possible.
89 rtc_prefer_fixed_point = false
90
mbonadei9aa3f0a2017-01-24 06:58:22 -080091 # Enable when an external authentication mechanism is used for performing
92 # packet authentication for RTP packets instead of libsrtp.
93 rtc_enable_external_auth = build_with_chromium
94
95 # Selects whether debug dumps for the audio processing module
96 # should be generated.
97 apm_debug_dump = false
98
99 # Set this to true to enable BWE test logging.
100 rtc_enable_bwe_test_logging = false
101
Joachim Bauch93e91342017-12-07 01:25:53 +0100102 # Set this to false to skip building examples.
103 rtc_build_examples = true
104
105 # Set this to false to skip building tools.
106 rtc_build_tools = true
107
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100108 # Set this to false to skip building code that requires X11.
109 rtc_use_x11 = use_x11
110
Tomas Popela318da512018-11-13 06:32:23 +0100111 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 14:37:51 +0100112 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
113 # only when using the sysroot as PipeWire is not available in older and
114 # supported Ubuntu and Debian distributions.
115 rtc_use_pipewire = is_desktop_linux && use_sysroot
116
117 # Set this to link PipeWire directly instead of using the dlopen.
118 rtc_link_pipewire = false
Tomas Popela318da512018-11-13 06:32:23 +0100119
mbonadei9aa3f0a2017-01-24 06:58:22 -0800120 # Enable to use the Mozilla internal settings.
121 build_with_mozilla = false
122
henrika883d00f2018-03-16 10:09:49 +0100123 # Enable use of Android AAudio which requires Android SDK 26 or above and
124 # NDK r16 or above.
125 rtc_enable_android_aaudio = false
126
mbonadei9aa3f0a2017-01-24 06:58:22 -0800127 # Link-Time Optimizations.
128 # Executes code generation at link-time instead of compile-time.
129 # https://gcc.gnu.org/wiki/LinkTimeOptimization
130 rtc_use_lto = false
131
132 # Set to "func", "block", "edge" for coverage generation.
133 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
134 # It is recommend to set include_examples=0.
135 # Use llvm's sancov -html-report for human readable reports.
136 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
137 rtc_sanitize_coverage = ""
138
perkj650fdae2017-08-25 05:00:11 -0700139 # Links a default implementation of task queues to targets
140 # that depend on the target rtc_task_queue. Set to false to
141 # use an external implementation.
142 rtc_link_task_queue_impl = true
143
mbonadei9aa3f0a2017-01-24 06:58:22 -0800144 if (current_cpu == "arm" || current_cpu == "arm64") {
145 rtc_prefer_fixed_point = true
146 }
147
mbonadei9aa3f0a2017-01-24 06:58:22 -0800148 # Determines whether NEON code will be built.
149 rtc_build_with_neon =
150 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
151
152 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
153 # all platforms except Android and iOS. Because FFmpeg can be built
154 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
155 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Sergey Silkinfe288eb2018-06-25 16:22:38 +0200156 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800157 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
158 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 10:47:18 +0100159 #
160 # Enabling H264 when building with MSVC is currently not supported, see
161 # bugs.webrtc.org/9213#c13 for more info.
162 rtc_use_h264 =
163 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800164
mbonadei9aa3f0a2017-01-24 06:58:22 -0800165 # By default, use normal platform audio support or dummy audio, but don't
166 # use file-based audio playout and record.
167 rtc_use_dummy_audio_file_devices = false
168
henrika7be78832017-06-13 17:34:16 +0200169 # When set to true, replace the audio output with a sinus tone at 440Hz.
170 # The ADM will ask for audio data from WebRTC but instead of reading real
171 # audio samples from NetEQ, a sinus tone will be generated and replace the
172 # real audio samples.
173 rtc_audio_device_plays_sinus_tone = false
174
Anders Carlsson358f2e02018-06-04 10:24:37 +0200175 if (is_ios) {
176 # Build broadcast extension in AppRTCMobile for iOS. This results in the
177 # binary only running on iOS 11+, which is why it is disabled by default.
178 rtc_apprtcmobile_broadcast_extension = false
179 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200180
181 # Determines whether Metal is available on iOS/macOS.
182 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
Dan Minor9c686132018-01-15 10:20:00 -0500183}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800184
Dan Minor9c686132018-01-15 10:20:00 -0500185if (!build_with_mozilla) {
186 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800187}
188
189# A second declare_args block, so that declarations within it can
190# depend on the possibly overridden variables in the first
191# declare_args block.
192declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500193 # Enables the use of protocol buffers for debug recordings.
194 rtc_enable_protobuf = !build_with_mozilla
195
196 # Set this to disable building with support for SCTP data channels.
197 rtc_enable_sctp = !build_with_mozilla
198
199 # Disable these to not build components which can be externally provided.
200 rtc_build_json = !build_with_mozilla
201 rtc_build_libsrtp = !build_with_mozilla
202 rtc_build_libvpx = !build_with_mozilla
203 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500204 rtc_build_opus = !build_with_mozilla
205 rtc_build_ssl = !build_with_mozilla
206 rtc_build_usrsctp = !build_with_mozilla
207
208 # Enable libevent task queues on platforms that support it.
209 # rtc_link_task_queue_impl must be set to true for this to
210 # have an effect.
Wez00cecb92018-02-09 10:41:00 -0800211 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) {
Dan Minor9c686132018-01-15 10:20:00 -0500212 rtc_enable_libevent = false
213 rtc_build_libevent = false
214 } else {
215 rtc_enable_libevent = true
216 rtc_build_libevent = !build_with_mozilla
217 }
218
Dan Minor9c686132018-01-15 10:20:00 -0500219 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
220 # build environments, even if available for Chromium builds.
221 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
222
mbonadei9aa3f0a2017-01-24 06:58:22 -0800223 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
224 rtc_include_pulse_audio = !build_with_chromium
225
226 # Chromium uses its own IO handling, so the internal ADM is only built for
227 # standalone WebRTC.
228 rtc_include_internal_audio_device = !build_with_chromium
229
230 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500231 rtc_include_tests = !build_with_chromium && !build_with_mozilla
mbonadei9aa3f0a2017-01-24 06:58:22 -0800232}
233
234# Make it possible to provide custom locations for some libraries (move these
235# up into declare_args should we need to actually use them for the GN build).
236rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800237rtc_opus_dir = "//third_party/opus"
238
239# Desktop capturer is supported only on Windows, OSX and Linux.
Robin Raymondce1b1402018-11-22 20:10:11 -0500240rtc_desktop_capture_supported = (is_win && current_os != "winuwp") || is_mac ||
241 (is_linux && (rtc_use_x11 || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800242
243###############################################################################
244# Templates
245#
246
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200247# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800248# chromium.
249# We need absolute paths for all configs in templates as they are shared in
250# different subdirectories.
251webrtc_root = get_path_info(".", "abspath")
252
253# Global configuration that should be applied to all WebRTC targets.
254# You normally shouldn't need to include this in your target as it's
255# automatically included when using the rtc_* templates.
256# It sets defines, include paths and compilation warnings accordingly,
257# both for WebRTC stand-alone builds and for the scenario when WebRTC
258# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700259rtc_common_configs = [
260 webrtc_root + ":common_config",
261 "//build/config/compiler:no_size_t_to_int_warning",
262]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800263
kthelgasonc0977102017-04-24 00:57:16 -0700264if (is_mac || is_ios) {
265 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
266}
267
mbonadei9aa3f0a2017-01-24 06:58:22 -0800268# Global public configuration that should be applied to all WebRTC targets. You
269# normally shouldn't need to include this in your target as it's automatically
270# included when using the rtc_* templates. It set the defines, include paths and
271# compilation warnings that should be propagated to dependents of the targets
272# depending on the target having this config.
273rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
274
275# Common configs to remove or add in all rtc targets.
276rtc_remove_configs = []
277rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200278rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200279rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800280
281set_defaults("rtc_test") {
282 configs = rtc_add_configs
283 suppressed_configs = []
284}
285
286set_defaults("rtc_source_set") {
287 configs = rtc_add_configs
288 suppressed_configs = []
289}
290
291set_defaults("rtc_executable") {
292 configs = rtc_add_configs
293 suppressed_configs = []
294}
295
296set_defaults("rtc_static_library") {
297 configs = rtc_add_configs
298 suppressed_configs = []
299}
300
301set_defaults("rtc_shared_library") {
302 configs = rtc_add_configs
303 suppressed_configs = []
304}
305
Per Kjellandera7f2d842018-01-10 15:54:53 +0000306webrtc_default_visibility = [ webrtc_root + "/*" ]
307if (build_with_chromium) {
308 # Allow Chromium's WebRTC overrides targets to bypass the regular
309 # visibility restrictions.
310 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
311}
312
Karl Wibergbb23c832018-04-22 19:55:00 +0200313# ---- Poisons ----
314#
315# The general idea is that some targets declare that they contain some
316# kind of poison, which makes it impossible for other targets to
317# depend on them (even transitively) unless they declare themselves
318# immune to that particular type of poison.
319#
320# Targets that *contain* poison of type foo should contain the line
321#
322# poisonous = [ "foo" ]
323#
324# and targets that *are immune but arent't themselves poisonous*
325# should contain
326#
327# allow_poison = [ "foo" ]
328#
329# This useful in cases where we have some large target or set of
330# targets and want to ensure that most other targets do not
331# transitively depend on them. For example, almost no high-level
332# target should depend on the audio codecs, since we want WebRTC users
333# to be able to inject any subset of them and actually end up with a
334# binary that doesn't include the codecs they didn't inject.
335#
336# Test-only targets (`testonly` set to true) and non-public targets
337# (`visibility` not containing "*") are automatically immune to all
338# types of poison.
339#
340# Here's the complete list of all types of poison. It must be kept in
341# 1:1 correspondence with the set of //:poison_* targets.
342#
343all_poison_types = [
344 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
345 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200346
347 # Software video codecs (VP8 and VP9 through libvpx).
348 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200349]
350
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000351absl_include_config = "//third_party/abseil-cpp:absl_include_config"
352absl_define_config = "//third_party/abseil-cpp:absl_define_config"
353
mbonadei9aa3f0a2017-01-24 06:58:22 -0800354template("rtc_test") {
355 test(target_name) {
356 forward_variables_from(invoker,
357 "*",
358 [
359 "configs",
360 "public_configs",
361 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200362 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800363 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100364
365 # Always override to public because when target_os is Android the `test`
366 # template can override it to [ "*" ] and we want to avoid conditional
367 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100368 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800369 configs += invoker.configs
370 configs -= rtc_remove_configs
371 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000372 public_configs = [
373 rtc_common_inherited_config,
374 absl_include_config,
375 absl_define_config,
376 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800377 if (defined(invoker.public_configs)) {
378 public_configs += invoker.public_configs
379 }
sakald7fdb802017-05-26 01:51:53 -0700380 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800381 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
382 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700383 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800384 }
385}
386
387template("rtc_source_set") {
388 source_set(target_name) {
389 forward_variables_from(invoker,
390 "*",
391 [
392 "configs",
393 "public_configs",
394 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200395 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800396 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200397 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000398 if (!defined(visibility)) {
399 visibility = webrtc_default_visibility
400 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200401
402 # What's your poison?
403 if (defined(testonly) && testonly) {
404 assert(!defined(poisonous))
405 assert(!defined(allow_poison))
406 } else {
407 if (!defined(poisonous)) {
408 poisonous = []
409 }
410 if (!defined(allow_poison)) {
411 allow_poison = []
412 }
413 if (!defined(assert_no_deps)) {
414 assert_no_deps = []
415 }
416 if (!defined(deps)) {
417 deps = []
418 }
419 foreach(p, poisonous) {
420 deps += [ webrtc_root + ":poison_" + p ]
421 }
422 foreach(poison_type, all_poison_types) {
423 allow_dep = true
424 foreach(v, visibility) {
425 if (v == "*") {
426 allow_dep = false
427 }
428 }
429 foreach(p, allow_poison + poisonous) {
430 if (p == poison_type) {
431 allow_dep = true
432 }
433 }
434 if (!allow_dep) {
435 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
436 }
437 }
438 }
439
Mirko Bonadei96ede162018-09-06 13:45:44 +0200440 if (!defined(testonly) || !testonly) {
441 configs += rtc_prod_configs
442 }
443
mbonadei9aa3f0a2017-01-24 06:58:22 -0800444 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200445 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800446 configs -= rtc_remove_configs
447 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000448 public_configs = [
449 rtc_common_inherited_config,
450 absl_include_config,
451 absl_define_config,
452 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800453 if (defined(invoker.public_configs)) {
454 public_configs += invoker.public_configs
455 }
456 }
457}
458
459template("rtc_executable") {
460 executable(target_name) {
461 forward_variables_from(invoker,
462 "*",
463 [
464 "deps",
465 "configs",
466 "public_configs",
467 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200468 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800469 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200470 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000471 if (!defined(visibility)) {
472 visibility = webrtc_default_visibility
473 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800474 configs += invoker.configs
475 configs -= rtc_remove_configs
476 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700477 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700478
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000479 public_configs = [
480 rtc_common_inherited_config,
481 absl_include_config,
482 absl_define_config,
483 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800484 if (defined(invoker.public_configs)) {
485 public_configs += invoker.public_configs
486 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200487 if (is_win) {
488 deps += [
489 # Give executables the default manifest on Windows (a no-op elsewhere).
490 "//build/win:default_exe_manifest",
491 ]
492 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800493 }
494}
495
496template("rtc_static_library") {
497 static_library(target_name) {
498 forward_variables_from(invoker,
499 "*",
500 [
501 "configs",
502 "public_configs",
503 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200504 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800505 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200506 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000507 if (!defined(visibility)) {
508 visibility = webrtc_default_visibility
509 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200510
511 # What's your poison?
512 if (defined(testonly) && testonly) {
513 assert(!defined(poisonous))
514 assert(!defined(allow_poison))
515 } else {
516 if (!defined(poisonous)) {
517 poisonous = []
518 }
519 if (!defined(allow_poison)) {
520 allow_poison = []
521 }
522 if (!defined(assert_no_deps)) {
523 assert_no_deps = []
524 }
525 if (!defined(deps)) {
526 deps = []
527 }
528 foreach(p, poisonous) {
529 deps += [ webrtc_root + ":poison_" + p ]
530 }
531 foreach(poison_type, all_poison_types) {
532 allow_dep = true
533 foreach(v, visibility) {
534 if (v == "*") {
535 allow_dep = false
536 }
537 }
538 foreach(p, allow_poison + poisonous) {
539 if (p == poison_type) {
540 allow_dep = true
541 }
542 }
543 if (!allow_dep) {
544 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
545 }
546 }
547 }
548
Mirko Bonadei96ede162018-09-06 13:45:44 +0200549 if (!defined(testonly) || !testonly) {
550 configs += rtc_prod_configs
551 }
552
mbonadei9aa3f0a2017-01-24 06:58:22 -0800553 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200554 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800555 configs -= rtc_remove_configs
556 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000557 public_configs = [
558 rtc_common_inherited_config,
559 absl_include_config,
560 absl_define_config,
561 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800562 if (defined(invoker.public_configs)) {
563 public_configs += invoker.public_configs
564 }
565 }
566}
567
568template("rtc_shared_library") {
569 shared_library(target_name) {
570 forward_variables_from(invoker,
571 "*",
572 [
573 "configs",
574 "public_configs",
575 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200576 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800577 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200578 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000579 if (!defined(visibility)) {
580 visibility = webrtc_default_visibility
581 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200582
583 # What's your poison?
584 if (defined(testonly) && testonly) {
585 assert(!defined(poisonous))
586 assert(!defined(allow_poison))
587 } else {
588 if (!defined(poisonous)) {
589 poisonous = []
590 }
591 if (!defined(allow_poison)) {
592 allow_poison = []
593 }
594 if (!defined(assert_no_deps)) {
595 assert_no_deps = []
596 }
597 if (!defined(deps)) {
598 deps = []
599 }
600 foreach(p, poisonous) {
601 deps += [ webrtc_root + ":poison_" + p ]
602 }
603 foreach(poison_type, all_poison_types) {
604 allow_dep = true
605 foreach(v, visibility) {
606 if (v == "*") {
607 allow_dep = false
608 }
609 }
610 foreach(p, allow_poison + poisonous) {
611 if (p == poison_type) {
612 allow_dep = true
613 }
614 }
615 if (!allow_dep) {
616 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
617 }
618 }
619 }
620
mbonadei9aa3f0a2017-01-24 06:58:22 -0800621 configs += invoker.configs
622 configs -= rtc_remove_configs
623 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000624 public_configs = [
625 rtc_common_inherited_config,
626 absl_include_config,
627 absl_define_config,
628 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800629 if (defined(invoker.public_configs)) {
630 public_configs += invoker.public_configs
631 }
632 }
633}
kthelgason4065a572017-02-14 04:58:56 -0800634
635if (is_ios) {
636 set_defaults("rtc_ios_xctest_test") {
637 configs = rtc_add_configs
638 suppressed_configs = []
639 }
640
641 template("rtc_ios_xctest_test") {
642 ios_xctest_test(target_name) {
643 forward_variables_from(invoker,
644 "*",
645 [
646 "configs",
647 "public_configs",
648 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200649 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800650 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200651 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000652 if (!defined(visibility)) {
653 visibility = webrtc_default_visibility
654 }
kthelgason4065a572017-02-14 04:58:56 -0800655 configs += invoker.configs
656 configs -= rtc_remove_configs
657 configs -= invoker.suppressed_configs
658 public_configs = [ rtc_common_inherited_config ]
659 if (defined(invoker.public_configs)) {
660 public_configs += invoker.public_configs
661 }
662 }
663 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100664
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400665 # TODO: Generate module.modulemap file to enable use in Swift
666 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100667 template("ios_framework_bundle_with_umbrella_header") {
668 forward_variables_from(invoker, [ "output_name" ])
669 umbrella_header_path =
670 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
671
672 ios_framework_bundle(target_name) {
673 forward_variables_from(invoker, "*", [])
674
675 deps += [ ":copy_umbrella_header_$target_name" ]
676 }
677
678 action("umbrella_header_$target_name") {
679 forward_variables_from(invoker, [ "public_headers" ])
680
681 script = "//tools_webrtc/ios/generate_umbrella_header.py"
682
683 outputs = [
684 umbrella_header_path,
685 ]
686 args = [
687 "--out",
688 rebase_path(umbrella_header_path, root_build_dir),
689 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200690 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100691 }
692
693 copy("copy_umbrella_header_$target_name") {
694 sources = [
695 umbrella_header_path,
696 ]
697 outputs = [
698 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
699 ]
700
701 deps = [
702 ":umbrella_header_$target_name",
703 ]
704 }
705 }
706
707 set_defaults("ios_framework_bundle_with_umbrella_header") {
708 configs = default_shared_library_configs
709 }
kthelgason4065a572017-02-14 04:58:56 -0800710}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000711
Anders Carlsson37bbf792018-09-05 16:29:27 +0200712if (is_mac) {
713 template("mac_framework_bundle_with_umbrella_header") {
714 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200715 this_target_name = target_name
716 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400717 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200718
719 mac_framework_bundle(target_name) {
720 forward_variables_from(invoker, "*", [])
721
722 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400723 framework_contents = [
724 "Headers",
725 "Modules",
726 "Resources",
727 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +0200728
729 ldflags = [
730 "-all_load",
731 "-install_name",
732 "@rpath/$output_name.framework/$output_name",
733 ]
734
735 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200736 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400737 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200738 ":copy_umbrella_header_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400739 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200740 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200741 ]
742 }
743
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200744 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200745 forward_variables_from(invoker, [ "sources" ])
746
747 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200748 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200749 ]
750 }
751
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400752 action("modulemap_$this_target_name") {
753 script = "//tools_webrtc/ios/generate_modulemap.py"
754 args = [
755 "--out",
756 rebase_path(modulemap_path, root_build_dir),
757 "--name",
758 output_name,
759 ]
760 outputs = [
761 modulemap_path,
762 ]
763 }
764
765 bundle_data("copy_modulemap_$this_target_name") {
766 sources = [
767 modulemap_path,
768 ]
769 outputs = [
770 "{{bundle_contents_dir}}/Modules/module.modulemap",
771 ]
772 deps = [
773 ":modulemap_$this_target_name",
774 ]
775 }
776
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200777 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200778 forward_variables_from(invoker, [ "sources" ])
779
780 script = "//tools_webrtc/ios/generate_umbrella_header.py"
781
782 outputs = [
783 umbrella_header_path,
784 ]
785 args = [
786 "--out",
787 rebase_path(umbrella_header_path, root_build_dir),
788 "--sources",
789 ] + sources
790 }
791
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200792 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200793 sources = [
794 umbrella_header_path,
795 ]
796 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200797 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200798 ]
799
800 deps = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200801 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200802 ]
803 }
804 }
805}
806
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000807if (is_android) {
808 template("rtc_android_library") {
809 android_library(target_name) {
810 forward_variables_from(invoker,
811 "*",
812 [
813 "configs",
814 "public_configs",
815 "suppressed_configs",
816 "visibility",
817 ])
818
Oleh Prypin05aee742018-11-23 17:29:44 +0100819 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100820
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000821 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100822 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100823
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200824 # TODO(crbug.com/824679): Find out why this fails in Chromium
825 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100826 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200827 "-Xep:ParameterNotNullable:ERROR",
828 "-Xep:FieldMissingNullable:ERROR",
829 "-Xep:ReturnMissingNullable:ERROR",
830 ]
831 }
832
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100833 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +0100834 if (defined(invoker.errorprone_args)) {
835 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100836 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000837
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200838 if (!defined(deps)) {
839 deps = []
840 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200841
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000842 no_build_hooks = true
843 }
844 }
845
846 template("rtc_android_apk") {
847 android_apk(target_name) {
848 forward_variables_from(invoker,
849 "*",
850 [
851 "configs",
852 "public_configs",
853 "suppressed_configs",
854 "visibility",
855 ])
856
857 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100858 errorprone_args = [ "-Werror" ]
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000859
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200860 # TODO(crbug.com/824679): Find out why this fails in Chromium
861 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100862 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200863 "-Xep:ParameterNotNullable:ERROR",
864 "-Xep:FieldMissingNullable:ERROR",
865 "-Xep:ReturnMissingNullable:ERROR",
866 ]
867 }
868
869 if (!defined(deps)) {
870 deps = []
871 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200872
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000873 no_build_hooks = true
874 }
875 }
876
877 template("rtc_instrumentation_test_apk") {
878 instrumentation_test_apk(target_name) {
879 forward_variables_from(invoker,
880 "*",
881 [
882 "configs",
883 "public_configs",
884 "suppressed_configs",
885 "visibility",
886 ])
887
888 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100889 errorprone_args = [ "-Werror" ]
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000890
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200891 # TODO(crbug.com/824679): Find out why this fails in Chromium
892 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100893 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200894 "-Xep:ParameterNotNullable:ERROR",
895 "-Xep:FieldMissingNullable:ERROR",
896 "-Xep:ReturnMissingNullable:ERROR",
897 ]
898 }
899
900 if (!defined(deps)) {
901 deps = []
902 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200903
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000904 no_build_hooks = true
905 }
906 }
907}