blob: 2239d61eba59d62779eedeaaa56460de56f5aee0 [file] [log] [blame]
mbonadei9aa3f0a2017-01-24 14:58:221# 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 14:58:228import("//build/config/arm.gni")
9import("//build/config/features.gni")
10import("//build/config/mips.gni")
11import("//build/config/sanitizers/sanitizers.gni")
Tomas Popela318da512018-11-13 05:32:2312import("//build/config/sysroot.gni")
ehmaldonado0d729b32017-02-10 09:38:2313import("//build/config/ui.gni")
mbonadei9aa3f0a2017-01-24 14:58:2214import("//build_overrides/build.gni")
mbonadei96606272017-03-04 03:41:5915
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
kthelgason4065a5762017-02-14 12:58:5630if (is_ios) {
31 import("//build/config/ios/rules.gni")
32}
mbonadei9aa3f0a2017-01-24 14:58:2233
Anders Carlsson37bbf792018-09-05 14:29:2734if (is_mac) {
35 import("//build/config/mac/rules.gni")
36}
37
mbonadei9aa3f0a2017-01-24 14:58:2238declare_args() {
Mirko Bonadei028248c2018-10-10 10:19:0239 # 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 08:37:1143 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 13:44:2844 # 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 08:37:1147 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 13:44:2855
Mirko Bonadei906add42018-09-05 14:03:1656 # 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 20:12:2562 # 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 14:08:1267 # Include the iLBC audio codec?
68 rtc_include_ilbc = true
69
mbonadei9aa3f0a2017-01-24 14:58:2270 # Disable this to avoid building the Opus audio codec.
71 rtc_include_opus = true
72
minyue2e03c662017-02-02 01:31:1173 # Enable this if the Opus version upon which WebRTC is built supports direct
74 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 15:45:4975 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-02 01:31:1176
mbonadei9aa3f0a2017-01-24 14:58:2277 # Enable this to let the Opus audio codec change complexity on the fly.
78 rtc_opus_variable_complexity = false
79
mbonadei9aa3f0a2017-01-24 14:58:2280 # 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 14:58:2291 # 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 00:25:53102 # 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 20:25:47108 # Set this to false to skip building code that requires X11.
109 rtc_use_x11 = use_x11
110
Tomas Popela318da512018-11-13 05:32:23111 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 13:37:51112 # 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 05:32:23119
mbonadei9aa3f0a2017-01-24 14:58:22120 # Enable to use the Mozilla internal settings.
121 build_with_mozilla = false
122
henrika883d00f2018-03-16 09:09:49123 # 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 14:58:22127 # 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 12:00:11139 # 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 14:58:22144 if (current_cpu == "arm" || current_cpu == "arm64") {
145 rtc_prefer_fixed_point = true
146 }
147
mbonadei9aa3f0a2017-01-24 14:58:22148 # 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 14:22:38156 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 14:58:22157 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
158 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 09:47:18159 #
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 14:58:22164
mbonadei9aa3f0a2017-01-24 14:58:22165 # 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 15:34:16169 # 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 08:24:37175 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 07:30:29180
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 15:20:00183}
mbonadei9aa3f0a2017-01-24 14:58:22184
Dan Minor9c686132018-01-15 15:20:00185if (!build_with_mozilla) {
186 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 14:58:22187}
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 15:20:00193 # 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 15:20:00204 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 18:41:00211 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) {
Dan Minor9c686132018-01-15 15:20:00212 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 15:20:00219 # 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 14:58:22223 # 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 15:20:00231 rtc_include_tests = !build_with_chromium && !build_with_mozilla
mbonadei9aa3f0a2017-01-24 14:58:22232}
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 14:58:22237rtc_opus_dir = "//third_party/opus"
238
239# Desktop capturer is supported only on Windows, OSX and Linux.
Robin Raymondce1b1402018-11-23 01:10:11240rtc_desktop_capture_supported = (is_win && current_os != "winuwp") || is_mac ||
241 (is_linux && (rtc_use_x11 || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 14:58:22242
243###############################################################################
244# Templates
245#
246
Mirko Bonadei92ea95e2017-09-15 04:47:31247# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 14:58:22248# 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 20:56:00259rtc_common_configs = [
260 webrtc_root + ":common_config",
261 "//build/config/compiler:no_size_t_to_int_warning",
262]
mbonadei9aa3f0a2017-01-24 14:58:22263
kthelgasonc0977102017-04-24 07:57:16264if (is_mac || is_ios) {
265 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
266}
267
mbonadei9aa3f0a2017-01-24 14:58:22268# 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 Bonadei96ede16a2018-09-06 11:45:44278rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 11:15:54279rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 14:58:22280
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:53306webrtc_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 17:55:00313# ---- 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 14:39:05346
347 # Software video codecs (VP8 and VP9 through libvpx).
348 "software_video_codecs",
Karl Wibergbb23c832018-04-22 17:55:00349]
350
Mirko Bonadei9a89a492018-05-29 14:22:32351absl_include_config = "//third_party/abseil-cpp:absl_include_config"
352absl_define_config = "//third_party/abseil-cpp:absl_define_config"
353
mbonadei9aa3f0a2017-01-24 14:58:22354template("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 09:16:19362 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22363 ])
Mirko Bonadeidd411942017-11-21 14:35:27364
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 11:47:34368 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 14:58:22369 configs += invoker.configs
370 configs -= rtc_remove_configs
371 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32372 public_configs = [
373 rtc_common_inherited_config,
374 absl_include_config,
375 absl_define_config,
376 ]
mbonadei9aa3f0a2017-01-24 14:58:22377 if (defined(invoker.public_configs)) {
378 public_configs += invoker.public_configs
379 }
sakald7fdb802017-05-26 08:51:53380 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 13:48:37381 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
382 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 08:51:53383 }
mbonadei9aa3f0a2017-01-24 14:58:22384 }
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 09:16:19395 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22396 ])
Karl Wiberg138d4ac2017-10-16 09:16:19397 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53398 if (!defined(visibility)) {
399 visibility = webrtc_default_visibility
400 }
Karl Wibergbb23c832018-04-22 17:55:00401
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 Bonadei96ede16a2018-09-06 11:45:44440 if (!defined(testonly) || !testonly) {
441 configs += rtc_prod_configs
442 }
443
mbonadei9aa3f0a2017-01-24 14:58:22444 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 11:15:54445 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 14:58:22446 configs -= rtc_remove_configs
447 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32448 public_configs = [
449 rtc_common_inherited_config,
450 absl_include_config,
451 absl_define_config,
452 ]
mbonadei9aa3f0a2017-01-24 14:58:22453 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 09:16:19468 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22469 ])
Karl Wiberg138d4ac2017-10-16 09:16:19470 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53471 if (!defined(visibility)) {
472 visibility = webrtc_default_visibility
473 }
mbonadei9aa3f0a2017-01-24 14:58:22474 configs += invoker.configs
475 configs -= rtc_remove_configs
476 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 22:10:34477 deps = invoker.deps
perkj650fdae2017-08-25 12:00:11478
Mirko Bonadei9a89a492018-05-29 14:22:32479 public_configs = [
480 rtc_common_inherited_config,
481 absl_include_config,
482 absl_define_config,
483 ]
mbonadei9aa3f0a2017-01-24 14:58:22484 if (defined(invoker.public_configs)) {
485 public_configs += invoker.public_configs
486 }
Mirko Bonadei9427f482018-08-28 12:39:27487 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 14:58:22493 }
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 09:16:19504 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22505 ])
Karl Wiberg138d4ac2017-10-16 09:16:19506 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53507 if (!defined(visibility)) {
508 visibility = webrtc_default_visibility
509 }
Karl Wibergbb23c832018-04-22 17:55:00510
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 Bonadei96ede16a2018-09-06 11:45:44549 if (!defined(testonly) || !testonly) {
550 configs += rtc_prod_configs
551 }
552
mbonadei9aa3f0a2017-01-24 14:58:22553 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 11:15:54554 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 14:58:22555 configs -= rtc_remove_configs
556 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32557 public_configs = [
558 rtc_common_inherited_config,
559 absl_include_config,
560 absl_define_config,
561 ]
mbonadei9aa3f0a2017-01-24 14:58:22562 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 09:16:19576 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22577 ])
Karl Wiberg138d4ac2017-10-16 09:16:19578 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53579 if (!defined(visibility)) {
580 visibility = webrtc_default_visibility
581 }
Karl Wibergbb23c832018-04-22 17:55:00582
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 14:58:22621 configs += invoker.configs
622 configs -= rtc_remove_configs
623 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32624 public_configs = [
625 rtc_common_inherited_config,
626 absl_include_config,
627 absl_define_config,
628 ]
mbonadei9aa3f0a2017-01-24 14:58:22629 if (defined(invoker.public_configs)) {
630 public_configs += invoker.public_configs
631 }
632 }
633}
kthelgason4065a5762017-02-14 12:58:56634
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 09:16:19649 "visibility",
kthelgason4065a5762017-02-14 12:58:56650 ])
Karl Wiberg138d4ac2017-10-16 09:16:19651 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53652 if (!defined(visibility)) {
653 visibility = webrtc_default_visibility
654 }
kthelgason4065a5762017-02-14 12:58:56655 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 12:31:03664
Joel Sutherlandd2fb1bf2018-10-02 20:08:25665 # TODO: Generate module.modulemap file to enable use in Swift
666 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 12:31:03667 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 07:30:29690 ] + public_headers
Anders Carlssondc6b4772018-01-15 12:31:03691 }
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 }
kthelgason4065a5762017-02-14 12:58:56710}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33711
Anders Carlsson37bbf792018-09-05 14:29:27712if (is_mac) {
713 template("mac_framework_bundle_with_umbrella_header") {
714 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 13:48:17715 this_target_name = target_name
716 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 20:08:25717 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 14:29:27718
719 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 18:40:29720 forward_variables_from(invoker, "*", [ "configs" ])
721 if (defined(invoker.configs)) {
722 configs += invoker.configs
723 }
Anders Carlsson37bbf792018-09-05 14:29:27724
725 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 20:08:25726 framework_contents = [
727 "Headers",
728 "Modules",
729 "Resources",
730 ]
Anders Carlsson37bbf792018-09-05 14:29:27731
732 ldflags = [
733 "-all_load",
734 "-install_name",
735 "@rpath/$output_name.framework/$output_name",
736 ]
737
738 deps += [
Anders Carlsson95c56ee2018-09-06 13:48:17739 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 20:08:25740 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 13:48:17741 ":copy_umbrella_header_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 20:08:25742 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 13:48:17743 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 14:29:27744 ]
745 }
746
Anders Carlsson95c56ee2018-09-06 13:48:17747 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 14:29:27748 forward_variables_from(invoker, [ "sources" ])
749
750 outputs = [
Anders Carlsson95c56ee2018-09-06 13:48:17751 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 14:29:27752 ]
753 }
754
Joel Sutherlandd2fb1bf2018-10-02 20:08:25755 action("modulemap_$this_target_name") {
756 script = "//tools_webrtc/ios/generate_modulemap.py"
757 args = [
758 "--out",
759 rebase_path(modulemap_path, root_build_dir),
760 "--name",
761 output_name,
762 ]
763 outputs = [
764 modulemap_path,
765 ]
766 }
767
768 bundle_data("copy_modulemap_$this_target_name") {
769 sources = [
770 modulemap_path,
771 ]
772 outputs = [
773 "{{bundle_contents_dir}}/Modules/module.modulemap",
774 ]
775 deps = [
776 ":modulemap_$this_target_name",
777 ]
778 }
779
Anders Carlsson95c56ee2018-09-06 13:48:17780 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 14:29:27781 forward_variables_from(invoker, [ "sources" ])
782
783 script = "//tools_webrtc/ios/generate_umbrella_header.py"
784
785 outputs = [
786 umbrella_header_path,
787 ]
788 args = [
789 "--out",
790 rebase_path(umbrella_header_path, root_build_dir),
791 "--sources",
792 ] + sources
793 }
794
Anders Carlsson95c56ee2018-09-06 13:48:17795 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 14:29:27796 sources = [
797 umbrella_header_path,
798 ]
799 outputs = [
Anders Carlsson95c56ee2018-09-06 13:48:17800 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 14:29:27801 ]
802
803 deps = [
Anders Carlsson95c56ee2018-09-06 13:48:17804 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 14:29:27805 ]
806 }
807 }
808}
809
Mirko Bonadeifbb3b7d2017-11-07 15:36:33810if (is_android) {
811 template("rtc_android_library") {
812 android_library(target_name) {
813 forward_variables_from(invoker,
814 "*",
815 [
816 "configs",
817 "public_configs",
818 "suppressed_configs",
819 "visibility",
820 ])
821
Oleh Prypin05aee742018-11-23 16:29:44822 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 15:32:49823
Mirko Bonadeifbb3b7d2017-11-07 15:36:33824 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 16:29:44825 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 15:32:49826
Sami Kalliomäki68d58602019-01-24 11:56:12827 # WebRTC supports API level 16 while Chromium only supports 19.
828 # (the manifest defines minimum supported SDK version)
829 if (defined(invoker.android_manifest_for_lint)) {
830 # Custom manifest defined by the target, use that one.
831 android_manifest_for_lint = invoker.android_manifest_for_lint
832 } else {
833 # Default manifest for WebRTC.
834 android_manifest_for_lint = "//sdk/android/AndroidManifest.xml"
835 }
836
Sami Kalliomäkidc526512018-03-27 15:07:27837 # TODO(crbug.com/824679): Find out why this fails in Chromium
838 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 16:29:44839 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 15:07:27840 "-Xep:ParameterNotNullable:ERROR",
841 "-Xep:FieldMissingNullable:ERROR",
842 "-Xep:ReturnMissingNullable:ERROR",
843 ]
844 }
845
Sami Kalliomäkie7fac682018-03-20 15:32:49846 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 16:29:44847 if (defined(invoker.errorprone_args)) {
848 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 15:32:49849 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33850
Sami Kalliomäkidc526512018-03-27 15:07:27851 if (!defined(deps)) {
852 deps = []
853 }
Sami Kalliomäkidc526512018-03-27 15:07:27854
Mirko Bonadeifbb3b7d2017-11-07 15:36:33855 no_build_hooks = true
856 }
857 }
858
859 template("rtc_android_apk") {
860 android_apk(target_name) {
861 forward_variables_from(invoker,
862 "*",
863 [
864 "configs",
865 "public_configs",
866 "suppressed_configs",
867 "visibility",
868 ])
869
870 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 16:29:44871 errorprone_args = [ "-Werror" ]
Mirko Bonadeifbb3b7d2017-11-07 15:36:33872
Sami Kalliomäkidc526512018-03-27 15:07:27873 # TODO(crbug.com/824679): Find out why this fails in Chromium
874 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 16:29:44875 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 15:07:27876 "-Xep:ParameterNotNullable:ERROR",
877 "-Xep:FieldMissingNullable:ERROR",
878 "-Xep:ReturnMissingNullable:ERROR",
879 ]
880 }
881
882 if (!defined(deps)) {
883 deps = []
884 }
Sami Kalliomäkidc526512018-03-27 15:07:27885
Mirko Bonadeifbb3b7d2017-11-07 15:36:33886 no_build_hooks = true
887 }
888 }
889
890 template("rtc_instrumentation_test_apk") {
891 instrumentation_test_apk(target_name) {
892 forward_variables_from(invoker,
893 "*",
894 [
895 "configs",
896 "public_configs",
897 "suppressed_configs",
898 "visibility",
899 ])
900
901 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 16:29:44902 errorprone_args = [ "-Werror" ]
Mirko Bonadeifbb3b7d2017-11-07 15:36:33903
Sami Kalliomäkidc526512018-03-27 15:07:27904 # TODO(crbug.com/824679): Find out why this fails in Chromium
905 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 16:29:44906 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 15:07:27907 "-Xep:ParameterNotNullable:ERROR",
908 "-Xep:FieldMissingNullable:ERROR",
909 "-Xep:ReturnMissingNullable:ERROR",
910 ]
911 }
912
913 if (!defined(deps)) {
914 deps = []
915 }
Sami Kalliomäkidc526512018-03-27 15:07:27916
Mirko Bonadeifbb3b7d2017-11-07 15:36:33917 no_build_hooks = true
918 }
919 }
920}