blob: 61bff0a9feb1583a03c2535e635a6c3d82b7ac32 [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")
Jiawei Ou08745302019-02-12 11:36:13 -0800183
184 # When set to false, builtin audio encoder/decoder factories and all the
185 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
186 # (they will still be included in libjingle_peerconnection_so.so and
187 # WebRTC.framework)
188 rtc_include_builtin_audio_codecs = true
189
190 # When set to false, builtin video encoder/decoder factories and all the
191 # video codecs they depends on will not be included in libwebrtc.{a|lib}
192 # (they will still be included in libjingle_peerconnection_so.so and
193 # WebRTC.framework)
194 rtc_include_builtin_video_codecs = true
Dan Minor9c686132018-01-15 10:20:00 -0500195}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800196
Dan Minor9c686132018-01-15 10:20:00 -0500197if (!build_with_mozilla) {
198 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800199}
200
201# A second declare_args block, so that declarations within it can
202# depend on the possibly overridden variables in the first
203# declare_args block.
204declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500205 # Enables the use of protocol buffers for debug recordings.
206 rtc_enable_protobuf = !build_with_mozilla
207
208 # Set this to disable building with support for SCTP data channels.
209 rtc_enable_sctp = !build_with_mozilla
210
211 # Disable these to not build components which can be externally provided.
212 rtc_build_json = !build_with_mozilla
213 rtc_build_libsrtp = !build_with_mozilla
214 rtc_build_libvpx = !build_with_mozilla
215 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500216 rtc_build_opus = !build_with_mozilla
217 rtc_build_ssl = !build_with_mozilla
218 rtc_build_usrsctp = !build_with_mozilla
219
220 # Enable libevent task queues on platforms that support it.
221 # rtc_link_task_queue_impl must be set to true for this to
222 # have an effect.
Wez00cecb92018-02-09 10:41:00 -0800223 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) {
Dan Minor9c686132018-01-15 10:20:00 -0500224 rtc_enable_libevent = false
225 rtc_build_libevent = false
226 } else {
227 rtc_enable_libevent = true
228 rtc_build_libevent = !build_with_mozilla
229 }
230
Dan Minor9c686132018-01-15 10:20:00 -0500231 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
232 # build environments, even if available for Chromium builds.
233 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
234
mbonadei9aa3f0a2017-01-24 06:58:22 -0800235 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
236 rtc_include_pulse_audio = !build_with_chromium
237
238 # Chromium uses its own IO handling, so the internal ADM is only built for
239 # standalone WebRTC.
240 rtc_include_internal_audio_device = !build_with_chromium
241
242 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500243 rtc_include_tests = !build_with_chromium && !build_with_mozilla
mbonadei9aa3f0a2017-01-24 06:58:22 -0800244}
245
246# Make it possible to provide custom locations for some libraries (move these
247# up into declare_args should we need to actually use them for the GN build).
248rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800249rtc_opus_dir = "//third_party/opus"
250
251# Desktop capturer is supported only on Windows, OSX and Linux.
Robin Raymondce1b1402018-11-22 20:10:11 -0500252rtc_desktop_capture_supported = (is_win && current_os != "winuwp") || is_mac ||
253 (is_linux && (rtc_use_x11 || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800254
255###############################################################################
256# Templates
257#
258
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200259# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800260# chromium.
261# We need absolute paths for all configs in templates as they are shared in
262# different subdirectories.
263webrtc_root = get_path_info(".", "abspath")
264
265# Global configuration that should be applied to all WebRTC targets.
266# You normally shouldn't need to include this in your target as it's
267# automatically included when using the rtc_* templates.
268# It sets defines, include paths and compilation warnings accordingly,
269# both for WebRTC stand-alone builds and for the scenario when WebRTC
270# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700271rtc_common_configs = [
272 webrtc_root + ":common_config",
273 "//build/config/compiler:no_size_t_to_int_warning",
274]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800275
kthelgasonc0977102017-04-24 00:57:16 -0700276if (is_mac || is_ios) {
277 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
278}
279
mbonadei9aa3f0a2017-01-24 06:58:22 -0800280# Global public configuration that should be applied to all WebRTC targets. You
281# normally shouldn't need to include this in your target as it's automatically
282# included when using the rtc_* templates. It set the defines, include paths and
283# compilation warnings that should be propagated to dependents of the targets
284# depending on the target having this config.
285rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
286
287# Common configs to remove or add in all rtc targets.
288rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100289if (!build_with_chromium && is_clang) {
290 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
291}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800292rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200293rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200294rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800295
296set_defaults("rtc_test") {
297 configs = rtc_add_configs
298 suppressed_configs = []
299}
300
301set_defaults("rtc_source_set") {
302 configs = rtc_add_configs
303 suppressed_configs = []
304}
305
306set_defaults("rtc_executable") {
307 configs = rtc_add_configs
308 suppressed_configs = []
309}
310
311set_defaults("rtc_static_library") {
312 configs = rtc_add_configs
313 suppressed_configs = []
314}
315
316set_defaults("rtc_shared_library") {
317 configs = rtc_add_configs
318 suppressed_configs = []
319}
320
Per Kjellandera7f2d842018-01-10 15:54:53 +0000321webrtc_default_visibility = [ webrtc_root + "/*" ]
322if (build_with_chromium) {
323 # Allow Chromium's WebRTC overrides targets to bypass the regular
324 # visibility restrictions.
325 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
326}
327
Karl Wibergbb23c832018-04-22 19:55:00 +0200328# ---- Poisons ----
329#
330# The general idea is that some targets declare that they contain some
331# kind of poison, which makes it impossible for other targets to
332# depend on them (even transitively) unless they declare themselves
333# immune to that particular type of poison.
334#
335# Targets that *contain* poison of type foo should contain the line
336#
337# poisonous = [ "foo" ]
338#
339# and targets that *are immune but arent't themselves poisonous*
340# should contain
341#
342# allow_poison = [ "foo" ]
343#
344# This useful in cases where we have some large target or set of
345# targets and want to ensure that most other targets do not
346# transitively depend on them. For example, almost no high-level
347# target should depend on the audio codecs, since we want WebRTC users
348# to be able to inject any subset of them and actually end up with a
349# binary that doesn't include the codecs they didn't inject.
350#
351# Test-only targets (`testonly` set to true) and non-public targets
352# (`visibility` not containing "*") are automatically immune to all
353# types of poison.
354#
355# Here's the complete list of all types of poison. It must be kept in
356# 1:1 correspondence with the set of //:poison_* targets.
357#
358all_poison_types = [
359 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
360 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200361
362 # Software video codecs (VP8 and VP9 through libvpx).
363 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200364]
365
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000366absl_include_config = "//third_party/abseil-cpp:absl_include_config"
367absl_define_config = "//third_party/abseil-cpp:absl_define_config"
368
mbonadei9aa3f0a2017-01-24 06:58:22 -0800369template("rtc_test") {
370 test(target_name) {
371 forward_variables_from(invoker,
372 "*",
373 [
374 "configs",
375 "public_configs",
376 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200377 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800378 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100379
380 # Always override to public because when target_os is Android the `test`
381 # template can override it to [ "*" ] and we want to avoid conditional
382 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100383 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800384 configs += invoker.configs
385 configs -= rtc_remove_configs
386 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000387 public_configs = [
388 rtc_common_inherited_config,
389 absl_include_config,
390 absl_define_config,
391 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800392 if (defined(invoker.public_configs)) {
393 public_configs += invoker.public_configs
394 }
sakald7fdb802017-05-26 01:51:53 -0700395 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800396 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
397 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700398 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800399 }
400}
401
402template("rtc_source_set") {
403 source_set(target_name) {
404 forward_variables_from(invoker,
405 "*",
406 [
407 "configs",
408 "public_configs",
409 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200410 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800411 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200412 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000413 if (!defined(visibility)) {
414 visibility = webrtc_default_visibility
415 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200416
417 # What's your poison?
418 if (defined(testonly) && testonly) {
419 assert(!defined(poisonous))
420 assert(!defined(allow_poison))
421 } else {
422 if (!defined(poisonous)) {
423 poisonous = []
424 }
425 if (!defined(allow_poison)) {
426 allow_poison = []
427 }
428 if (!defined(assert_no_deps)) {
429 assert_no_deps = []
430 }
431 if (!defined(deps)) {
432 deps = []
433 }
434 foreach(p, poisonous) {
435 deps += [ webrtc_root + ":poison_" + p ]
436 }
437 foreach(poison_type, all_poison_types) {
438 allow_dep = true
439 foreach(v, visibility) {
440 if (v == "*") {
441 allow_dep = false
442 }
443 }
444 foreach(p, allow_poison + poisonous) {
445 if (p == poison_type) {
446 allow_dep = true
447 }
448 }
449 if (!allow_dep) {
450 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
451 }
452 }
453 }
454
Mirko Bonadei96ede162018-09-06 13:45:44 +0200455 if (!defined(testonly) || !testonly) {
456 configs += rtc_prod_configs
457 }
458
mbonadei9aa3f0a2017-01-24 06:58:22 -0800459 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200460 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800461 configs -= rtc_remove_configs
462 configs -= invoker.suppressed_configs
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 }
471 }
472}
473
474template("rtc_executable") {
475 executable(target_name) {
476 forward_variables_from(invoker,
477 "*",
478 [
479 "deps",
480 "configs",
481 "public_configs",
482 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200483 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800484 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200485 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000486 if (!defined(visibility)) {
487 visibility = webrtc_default_visibility
488 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800489 configs += invoker.configs
490 configs -= rtc_remove_configs
491 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700492 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700493
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000494 public_configs = [
495 rtc_common_inherited_config,
496 absl_include_config,
497 absl_define_config,
498 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800499 if (defined(invoker.public_configs)) {
500 public_configs += invoker.public_configs
501 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200502 if (is_win) {
503 deps += [
504 # Give executables the default manifest on Windows (a no-op elsewhere).
505 "//build/win:default_exe_manifest",
506 ]
507 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800508 }
509}
510
511template("rtc_static_library") {
512 static_library(target_name) {
513 forward_variables_from(invoker,
514 "*",
515 [
516 "configs",
517 "public_configs",
518 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200519 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800520 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200521 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000522 if (!defined(visibility)) {
523 visibility = webrtc_default_visibility
524 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200525
526 # What's your poison?
527 if (defined(testonly) && testonly) {
528 assert(!defined(poisonous))
529 assert(!defined(allow_poison))
530 } else {
531 if (!defined(poisonous)) {
532 poisonous = []
533 }
534 if (!defined(allow_poison)) {
535 allow_poison = []
536 }
537 if (!defined(assert_no_deps)) {
538 assert_no_deps = []
539 }
540 if (!defined(deps)) {
541 deps = []
542 }
543 foreach(p, poisonous) {
544 deps += [ webrtc_root + ":poison_" + p ]
545 }
546 foreach(poison_type, all_poison_types) {
547 allow_dep = true
548 foreach(v, visibility) {
549 if (v == "*") {
550 allow_dep = false
551 }
552 }
553 foreach(p, allow_poison + poisonous) {
554 if (p == poison_type) {
555 allow_dep = true
556 }
557 }
558 if (!allow_dep) {
559 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
560 }
561 }
562 }
563
Mirko Bonadei96ede162018-09-06 13:45:44 +0200564 if (!defined(testonly) || !testonly) {
565 configs += rtc_prod_configs
566 }
567
mbonadei9aa3f0a2017-01-24 06:58:22 -0800568 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200569 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800570 configs -= rtc_remove_configs
571 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000572 public_configs = [
573 rtc_common_inherited_config,
574 absl_include_config,
575 absl_define_config,
576 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800577 if (defined(invoker.public_configs)) {
578 public_configs += invoker.public_configs
579 }
580 }
581}
582
583template("rtc_shared_library") {
584 shared_library(target_name) {
585 forward_variables_from(invoker,
586 "*",
587 [
588 "configs",
589 "public_configs",
590 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200591 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800592 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200593 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000594 if (!defined(visibility)) {
595 visibility = webrtc_default_visibility
596 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200597
598 # What's your poison?
599 if (defined(testonly) && testonly) {
600 assert(!defined(poisonous))
601 assert(!defined(allow_poison))
602 } else {
603 if (!defined(poisonous)) {
604 poisonous = []
605 }
606 if (!defined(allow_poison)) {
607 allow_poison = []
608 }
609 if (!defined(assert_no_deps)) {
610 assert_no_deps = []
611 }
612 if (!defined(deps)) {
613 deps = []
614 }
615 foreach(p, poisonous) {
616 deps += [ webrtc_root + ":poison_" + p ]
617 }
618 foreach(poison_type, all_poison_types) {
619 allow_dep = true
620 foreach(v, visibility) {
621 if (v == "*") {
622 allow_dep = false
623 }
624 }
625 foreach(p, allow_poison + poisonous) {
626 if (p == poison_type) {
627 allow_dep = true
628 }
629 }
630 if (!allow_dep) {
631 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
632 }
633 }
634 }
635
mbonadei9aa3f0a2017-01-24 06:58:22 -0800636 configs += invoker.configs
637 configs -= rtc_remove_configs
638 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000639 public_configs = [
640 rtc_common_inherited_config,
641 absl_include_config,
642 absl_define_config,
643 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800644 if (defined(invoker.public_configs)) {
645 public_configs += invoker.public_configs
646 }
647 }
648}
kthelgason4065a572017-02-14 04:58:56 -0800649
650if (is_ios) {
651 set_defaults("rtc_ios_xctest_test") {
652 configs = rtc_add_configs
653 suppressed_configs = []
654 }
655
656 template("rtc_ios_xctest_test") {
657 ios_xctest_test(target_name) {
658 forward_variables_from(invoker,
659 "*",
660 [
661 "configs",
662 "public_configs",
663 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200664 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800665 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200666 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000667 if (!defined(visibility)) {
668 visibility = webrtc_default_visibility
669 }
kthelgason4065a572017-02-14 04:58:56 -0800670 configs += invoker.configs
671 configs -= rtc_remove_configs
672 configs -= invoker.suppressed_configs
673 public_configs = [ rtc_common_inherited_config ]
674 if (defined(invoker.public_configs)) {
675 public_configs += invoker.public_configs
676 }
677 }
678 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100679
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400680 # TODO: Generate module.modulemap file to enable use in Swift
681 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100682 template("ios_framework_bundle_with_umbrella_header") {
683 forward_variables_from(invoker, [ "output_name" ])
684 umbrella_header_path =
685 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
686
687 ios_framework_bundle(target_name) {
688 forward_variables_from(invoker, "*", [])
689
690 deps += [ ":copy_umbrella_header_$target_name" ]
691 }
692
693 action("umbrella_header_$target_name") {
694 forward_variables_from(invoker, [ "public_headers" ])
695
696 script = "//tools_webrtc/ios/generate_umbrella_header.py"
697
698 outputs = [
699 umbrella_header_path,
700 ]
701 args = [
702 "--out",
703 rebase_path(umbrella_header_path, root_build_dir),
704 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200705 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100706 }
707
708 copy("copy_umbrella_header_$target_name") {
709 sources = [
710 umbrella_header_path,
711 ]
712 outputs = [
713 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
714 ]
715
716 deps = [
717 ":umbrella_header_$target_name",
718 ]
719 }
720 }
721
722 set_defaults("ios_framework_bundle_with_umbrella_header") {
723 configs = default_shared_library_configs
724 }
kthelgason4065a572017-02-14 04:58:56 -0800725}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000726
Anders Carlsson37bbf792018-09-05 16:29:27 +0200727if (is_mac) {
728 template("mac_framework_bundle_with_umbrella_header") {
729 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200730 this_target_name = target_name
731 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400732 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200733
734 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -0800735 forward_variables_from(invoker, "*", [ "configs" ])
736 if (defined(invoker.configs)) {
737 configs += invoker.configs
738 }
Anders Carlsson37bbf792018-09-05 16:29:27 +0200739
740 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400741 framework_contents = [
742 "Headers",
743 "Modules",
744 "Resources",
745 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +0200746
747 ldflags = [
748 "-all_load",
749 "-install_name",
750 "@rpath/$output_name.framework/$output_name",
751 ]
752
753 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200754 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400755 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200756 ":copy_umbrella_header_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400757 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200758 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200759 ]
760 }
761
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200762 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200763 forward_variables_from(invoker, [ "sources" ])
764
765 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200766 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200767 ]
768 }
769
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400770 action("modulemap_$this_target_name") {
771 script = "//tools_webrtc/ios/generate_modulemap.py"
772 args = [
773 "--out",
774 rebase_path(modulemap_path, root_build_dir),
775 "--name",
776 output_name,
777 ]
778 outputs = [
779 modulemap_path,
780 ]
781 }
782
783 bundle_data("copy_modulemap_$this_target_name") {
784 sources = [
785 modulemap_path,
786 ]
787 outputs = [
788 "{{bundle_contents_dir}}/Modules/module.modulemap",
789 ]
790 deps = [
791 ":modulemap_$this_target_name",
792 ]
793 }
794
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200795 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200796 forward_variables_from(invoker, [ "sources" ])
797
798 script = "//tools_webrtc/ios/generate_umbrella_header.py"
799
800 outputs = [
801 umbrella_header_path,
802 ]
803 args = [
804 "--out",
805 rebase_path(umbrella_header_path, root_build_dir),
806 "--sources",
807 ] + sources
808 }
809
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200810 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200811 sources = [
812 umbrella_header_path,
813 ]
814 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200815 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200816 ]
817
818 deps = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200819 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200820 ]
821 }
822 }
823}
824
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000825if (is_android) {
826 template("rtc_android_library") {
827 android_library(target_name) {
828 forward_variables_from(invoker,
829 "*",
830 [
831 "configs",
832 "public_configs",
833 "suppressed_configs",
834 "visibility",
835 ])
836
Oleh Prypin05aee742018-11-23 17:29:44 +0100837 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100838
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000839 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100840 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100841
Sami Kalliomäki68d58602019-01-24 12:56:12 +0100842 # WebRTC supports API level 16 while Chromium only supports 19.
843 # (the manifest defines minimum supported SDK version)
844 if (defined(invoker.android_manifest_for_lint)) {
845 # Custom manifest defined by the target, use that one.
846 android_manifest_for_lint = invoker.android_manifest_for_lint
847 } else {
848 # Default manifest for WebRTC.
849 android_manifest_for_lint = "//sdk/android/AndroidManifest.xml"
850 }
851
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200852 # TODO(crbug.com/824679): Find out why this fails in Chromium
853 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100854 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200855 "-Xep:ParameterNotNullable:ERROR",
856 "-Xep:FieldMissingNullable:ERROR",
857 "-Xep:ReturnMissingNullable:ERROR",
858 ]
859 }
860
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100861 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +0100862 if (defined(invoker.errorprone_args)) {
863 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100864 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000865
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200866 if (!defined(deps)) {
867 deps = []
868 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200869
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000870 no_build_hooks = true
871 }
872 }
873
874 template("rtc_android_apk") {
875 android_apk(target_name) {
876 forward_variables_from(invoker,
877 "*",
878 [
879 "configs",
880 "public_configs",
881 "suppressed_configs",
882 "visibility",
883 ])
884
885 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100886 errorprone_args = [ "-Werror" ]
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000887
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200888 # TODO(crbug.com/824679): Find out why this fails in Chromium
889 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100890 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200891 "-Xep:ParameterNotNullable:ERROR",
892 "-Xep:FieldMissingNullable:ERROR",
893 "-Xep:ReturnMissingNullable:ERROR",
894 ]
895 }
896
897 if (!defined(deps)) {
898 deps = []
899 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200900
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000901 no_build_hooks = true
902 }
903 }
904
905 template("rtc_instrumentation_test_apk") {
906 instrumentation_test_apk(target_name) {
907 forward_variables_from(invoker,
908 "*",
909 [
910 "configs",
911 "public_configs",
912 "suppressed_configs",
913 "visibility",
914 ])
915
916 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100917 errorprone_args = [ "-Werror" ]
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000918
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200919 # TODO(crbug.com/824679): Find out why this fails in Chromium
920 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100921 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200922 "-Xep:ParameterNotNullable:ERROR",
923 "-Xep:FieldMissingNullable:ERROR",
924 "-Xep:ReturnMissingNullable:ERROR",
925 ]
926 }
927
928 if (!defined(deps)) {
929 deps = []
930 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200931
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000932 no_build_hooks = true
933 }
934 }
935}