blob: c843c2472becbe2507ce0f727fcfc85a3dd4e1f9 [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
127 # TODO(henrika): can this flag be removed?
mbonadei9aa3f0a2017-01-24 06:58:22 -0800128 rtc_enable_android_opensl = false
129
130 # Link-Time Optimizations.
131 # Executes code generation at link-time instead of compile-time.
132 # https://gcc.gnu.org/wiki/LinkTimeOptimization
133 rtc_use_lto = false
134
135 # Set to "func", "block", "edge" for coverage generation.
136 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
137 # It is recommend to set include_examples=0.
138 # Use llvm's sancov -html-report for human readable reports.
139 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
140 rtc_sanitize_coverage = ""
141
perkj650fdae2017-08-25 05:00:11 -0700142 # Links a default implementation of task queues to targets
143 # that depend on the target rtc_task_queue. Set to false to
144 # use an external implementation.
145 rtc_link_task_queue_impl = true
146
mbonadei9aa3f0a2017-01-24 06:58:22 -0800147 if (current_cpu == "arm" || current_cpu == "arm64") {
148 rtc_prefer_fixed_point = true
149 }
150
mbonadei9aa3f0a2017-01-24 06:58:22 -0800151 # Determines whether NEON code will be built.
152 rtc_build_with_neon =
153 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
154
155 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
156 # all platforms except Android and iOS. Because FFmpeg can be built
157 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
158 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Sergey Silkinfe288eb2018-06-25 16:22:38 +0200159 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800160 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
161 # http://www.openh264.org, https://www.ffmpeg.org/
Patrik Höglund3bb11942018-03-16 12:36:26 +0000162 rtc_use_h264 = proprietary_codecs && !is_android && !is_ios
mbonadei9aa3f0a2017-01-24 06:58:22 -0800163
mbonadei9aa3f0a2017-01-24 06:58:22 -0800164 # By default, use normal platform audio support or dummy audio, but don't
165 # use file-based audio playout and record.
166 rtc_use_dummy_audio_file_devices = false
167
henrika7be78832017-06-13 17:34:16 +0200168 # When set to true, replace the audio output with a sinus tone at 440Hz.
169 # The ADM will ask for audio data from WebRTC but instead of reading real
170 # audio samples from NetEQ, a sinus tone will be generated and replace the
171 # real audio samples.
172 rtc_audio_device_plays_sinus_tone = false
173
Anders Carlssondd8c1652018-01-30 10:32:13 +0100174 # Disable this to build without support for built-in software codecs.
175 rtc_use_builtin_sw_codecs = true
Anders Carlsson358f2e02018-06-04 10:24:37 +0200176
177 if (is_ios) {
178 # Build broadcast extension in AppRTCMobile for iOS. This results in the
179 # binary only running on iOS 11+, which is why it is disabled by default.
180 rtc_apprtcmobile_broadcast_extension = false
181 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200182
183 # Determines whether Metal is available on iOS/macOS.
184 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
Dan Minor9c686132018-01-15 10:20:00 -0500185}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800186
Dan Minor9c686132018-01-15 10:20:00 -0500187if (!build_with_mozilla) {
188 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800189}
190
191# A second declare_args block, so that declarations within it can
192# depend on the possibly overridden variables in the first
193# declare_args block.
194declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500195 # Enables the use of protocol buffers for debug recordings.
196 rtc_enable_protobuf = !build_with_mozilla
197
198 # Set this to disable building with support for SCTP data channels.
199 rtc_enable_sctp = !build_with_mozilla
200
201 # Disable these to not build components which can be externally provided.
202 rtc_build_json = !build_with_mozilla
203 rtc_build_libsrtp = !build_with_mozilla
204 rtc_build_libvpx = !build_with_mozilla
205 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500206 rtc_build_opus = !build_with_mozilla
207 rtc_build_ssl = !build_with_mozilla
208 rtc_build_usrsctp = !build_with_mozilla
209
210 # Enable libevent task queues on platforms that support it.
211 # rtc_link_task_queue_impl must be set to true for this to
212 # have an effect.
Wez00cecb92018-02-09 10:41:00 -0800213 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) {
Dan Minor9c686132018-01-15 10:20:00 -0500214 rtc_enable_libevent = false
215 rtc_build_libevent = false
216 } else {
217 rtc_enable_libevent = true
218 rtc_build_libevent = !build_with_mozilla
219 }
220
Dan Minor9c686132018-01-15 10:20:00 -0500221 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
222 # build environments, even if available for Chromium builds.
223 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
224
mbonadei9aa3f0a2017-01-24 06:58:22 -0800225 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
226 rtc_include_pulse_audio = !build_with_chromium
227
228 # Chromium uses its own IO handling, so the internal ADM is only built for
229 # standalone WebRTC.
230 rtc_include_internal_audio_device = !build_with_chromium
231
232 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500233 rtc_include_tests = !build_with_chromium && !build_with_mozilla
mbonadei9aa3f0a2017-01-24 06:58:22 -0800234}
235
236# Make it possible to provide custom locations for some libraries (move these
237# up into declare_args should we need to actually use them for the GN build).
238rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800239rtc_opus_dir = "//third_party/opus"
240
241# Desktop capturer is supported only on Windows, OSX and Linux.
Robin Raymondce1b1402018-11-22 20:10:11 -0500242rtc_desktop_capture_supported = (is_win && current_os != "winuwp") || is_mac ||
243 (is_linux && (rtc_use_x11 || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800244
245###############################################################################
246# Templates
247#
248
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200249# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800250# chromium.
251# We need absolute paths for all configs in templates as they are shared in
252# different subdirectories.
253webrtc_root = get_path_info(".", "abspath")
254
255# Global configuration that should be applied to all WebRTC targets.
256# You normally shouldn't need to include this in your target as it's
257# automatically included when using the rtc_* templates.
258# It sets defines, include paths and compilation warnings accordingly,
259# both for WebRTC stand-alone builds and for the scenario when WebRTC
260# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700261rtc_common_configs = [
262 webrtc_root + ":common_config",
263 "//build/config/compiler:no_size_t_to_int_warning",
264]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800265
kthelgasonc0977102017-04-24 00:57:16 -0700266if (is_mac || is_ios) {
267 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
268}
269
mbonadei9aa3f0a2017-01-24 06:58:22 -0800270# Global public configuration that should be applied to all WebRTC targets. You
271# normally shouldn't need to include this in your target as it's automatically
272# included when using the rtc_* templates. It set the defines, include paths and
273# compilation warnings that should be propagated to dependents of the targets
274# depending on the target having this config.
275rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
276
277# Common configs to remove or add in all rtc targets.
278rtc_remove_configs = []
279rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200280rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200281rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800282
283set_defaults("rtc_test") {
284 configs = rtc_add_configs
285 suppressed_configs = []
286}
287
288set_defaults("rtc_source_set") {
289 configs = rtc_add_configs
290 suppressed_configs = []
291}
292
293set_defaults("rtc_executable") {
294 configs = rtc_add_configs
295 suppressed_configs = []
296}
297
298set_defaults("rtc_static_library") {
299 configs = rtc_add_configs
300 suppressed_configs = []
301}
302
303set_defaults("rtc_shared_library") {
304 configs = rtc_add_configs
305 suppressed_configs = []
306}
307
Per Kjellandera7f2d842018-01-10 15:54:53 +0000308webrtc_default_visibility = [ webrtc_root + "/*" ]
309if (build_with_chromium) {
310 # Allow Chromium's WebRTC overrides targets to bypass the regular
311 # visibility restrictions.
312 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
313}
314
Karl Wibergbb23c832018-04-22 19:55:00 +0200315# ---- Poisons ----
316#
317# The general idea is that some targets declare that they contain some
318# kind of poison, which makes it impossible for other targets to
319# depend on them (even transitively) unless they declare themselves
320# immune to that particular type of poison.
321#
322# Targets that *contain* poison of type foo should contain the line
323#
324# poisonous = [ "foo" ]
325#
326# and targets that *are immune but arent't themselves poisonous*
327# should contain
328#
329# allow_poison = [ "foo" ]
330#
331# This useful in cases where we have some large target or set of
332# targets and want to ensure that most other targets do not
333# transitively depend on them. For example, almost no high-level
334# target should depend on the audio codecs, since we want WebRTC users
335# to be able to inject any subset of them and actually end up with a
336# binary that doesn't include the codecs they didn't inject.
337#
338# Test-only targets (`testonly` set to true) and non-public targets
339# (`visibility` not containing "*") are automatically immune to all
340# types of poison.
341#
342# Here's the complete list of all types of poison. It must be kept in
343# 1:1 correspondence with the set of //:poison_* targets.
344#
345all_poison_types = [
346 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
347 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200348
349 # Software video codecs (VP8 and VP9 through libvpx).
350 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200351]
352
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000353absl_include_config = "//third_party/abseil-cpp:absl_include_config"
354absl_define_config = "//third_party/abseil-cpp:absl_define_config"
355
mbonadei9aa3f0a2017-01-24 06:58:22 -0800356template("rtc_test") {
357 test(target_name) {
358 forward_variables_from(invoker,
359 "*",
360 [
361 "configs",
362 "public_configs",
363 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200364 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800365 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100366
367 # Always override to public because when target_os is Android the `test`
368 # template can override it to [ "*" ] and we want to avoid conditional
369 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100370 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800371 configs += invoker.configs
372 configs -= rtc_remove_configs
373 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000374 public_configs = [
375 rtc_common_inherited_config,
376 absl_include_config,
377 absl_define_config,
378 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800379 if (defined(invoker.public_configs)) {
380 public_configs += invoker.public_configs
381 }
sakald7fdb802017-05-26 01:51:53 -0700382 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800383 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
384 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700385 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800386 }
387}
388
389template("rtc_source_set") {
390 source_set(target_name) {
391 forward_variables_from(invoker,
392 "*",
393 [
394 "configs",
395 "public_configs",
396 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200397 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800398 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200399 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000400 if (!defined(visibility)) {
401 visibility = webrtc_default_visibility
402 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200403
404 # What's your poison?
405 if (defined(testonly) && testonly) {
406 assert(!defined(poisonous))
407 assert(!defined(allow_poison))
408 } else {
409 if (!defined(poisonous)) {
410 poisonous = []
411 }
412 if (!defined(allow_poison)) {
413 allow_poison = []
414 }
415 if (!defined(assert_no_deps)) {
416 assert_no_deps = []
417 }
418 if (!defined(deps)) {
419 deps = []
420 }
421 foreach(p, poisonous) {
422 deps += [ webrtc_root + ":poison_" + p ]
423 }
424 foreach(poison_type, all_poison_types) {
425 allow_dep = true
426 foreach(v, visibility) {
427 if (v == "*") {
428 allow_dep = false
429 }
430 }
431 foreach(p, allow_poison + poisonous) {
432 if (p == poison_type) {
433 allow_dep = true
434 }
435 }
436 if (!allow_dep) {
437 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
438 }
439 }
440 }
441
Mirko Bonadei96ede162018-09-06 13:45:44 +0200442 if (!defined(testonly) || !testonly) {
443 configs += rtc_prod_configs
444 }
445
mbonadei9aa3f0a2017-01-24 06:58:22 -0800446 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200447 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800448 configs -= rtc_remove_configs
449 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000450 public_configs = [
451 rtc_common_inherited_config,
452 absl_include_config,
453 absl_define_config,
454 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800455 if (defined(invoker.public_configs)) {
456 public_configs += invoker.public_configs
457 }
458 }
459}
460
461template("rtc_executable") {
462 executable(target_name) {
463 forward_variables_from(invoker,
464 "*",
465 [
466 "deps",
467 "configs",
468 "public_configs",
469 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200470 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800471 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200472 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000473 if (!defined(visibility)) {
474 visibility = webrtc_default_visibility
475 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800476 configs += invoker.configs
477 configs -= rtc_remove_configs
478 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700479 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700480
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000481 public_configs = [
482 rtc_common_inherited_config,
483 absl_include_config,
484 absl_define_config,
485 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800486 if (defined(invoker.public_configs)) {
487 public_configs += invoker.public_configs
488 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200489 if (is_win) {
490 deps += [
491 # Give executables the default manifest on Windows (a no-op elsewhere).
492 "//build/win:default_exe_manifest",
493 ]
494 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800495 }
496}
497
498template("rtc_static_library") {
499 static_library(target_name) {
500 forward_variables_from(invoker,
501 "*",
502 [
503 "configs",
504 "public_configs",
505 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200506 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800507 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200508 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000509 if (!defined(visibility)) {
510 visibility = webrtc_default_visibility
511 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200512
513 # What's your poison?
514 if (defined(testonly) && testonly) {
515 assert(!defined(poisonous))
516 assert(!defined(allow_poison))
517 } else {
518 if (!defined(poisonous)) {
519 poisonous = []
520 }
521 if (!defined(allow_poison)) {
522 allow_poison = []
523 }
524 if (!defined(assert_no_deps)) {
525 assert_no_deps = []
526 }
527 if (!defined(deps)) {
528 deps = []
529 }
530 foreach(p, poisonous) {
531 deps += [ webrtc_root + ":poison_" + p ]
532 }
533 foreach(poison_type, all_poison_types) {
534 allow_dep = true
535 foreach(v, visibility) {
536 if (v == "*") {
537 allow_dep = false
538 }
539 }
540 foreach(p, allow_poison + poisonous) {
541 if (p == poison_type) {
542 allow_dep = true
543 }
544 }
545 if (!allow_dep) {
546 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
547 }
548 }
549 }
550
Mirko Bonadei96ede162018-09-06 13:45:44 +0200551 if (!defined(testonly) || !testonly) {
552 configs += rtc_prod_configs
553 }
554
mbonadei9aa3f0a2017-01-24 06:58:22 -0800555 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200556 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800557 configs -= rtc_remove_configs
558 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000559 public_configs = [
560 rtc_common_inherited_config,
561 absl_include_config,
562 absl_define_config,
563 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800564 if (defined(invoker.public_configs)) {
565 public_configs += invoker.public_configs
566 }
567 }
568}
569
570template("rtc_shared_library") {
571 shared_library(target_name) {
572 forward_variables_from(invoker,
573 "*",
574 [
575 "configs",
576 "public_configs",
577 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200578 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800579 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200580 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000581 if (!defined(visibility)) {
582 visibility = webrtc_default_visibility
583 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200584
585 # What's your poison?
586 if (defined(testonly) && testonly) {
587 assert(!defined(poisonous))
588 assert(!defined(allow_poison))
589 } else {
590 if (!defined(poisonous)) {
591 poisonous = []
592 }
593 if (!defined(allow_poison)) {
594 allow_poison = []
595 }
596 if (!defined(assert_no_deps)) {
597 assert_no_deps = []
598 }
599 if (!defined(deps)) {
600 deps = []
601 }
602 foreach(p, poisonous) {
603 deps += [ webrtc_root + ":poison_" + p ]
604 }
605 foreach(poison_type, all_poison_types) {
606 allow_dep = true
607 foreach(v, visibility) {
608 if (v == "*") {
609 allow_dep = false
610 }
611 }
612 foreach(p, allow_poison + poisonous) {
613 if (p == poison_type) {
614 allow_dep = true
615 }
616 }
617 if (!allow_dep) {
618 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
619 }
620 }
621 }
622
mbonadei9aa3f0a2017-01-24 06:58:22 -0800623 configs += invoker.configs
624 configs -= rtc_remove_configs
625 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000626 public_configs = [
627 rtc_common_inherited_config,
628 absl_include_config,
629 absl_define_config,
630 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800631 if (defined(invoker.public_configs)) {
632 public_configs += invoker.public_configs
633 }
634 }
635}
kthelgason4065a572017-02-14 04:58:56 -0800636
637if (is_ios) {
638 set_defaults("rtc_ios_xctest_test") {
639 configs = rtc_add_configs
640 suppressed_configs = []
641 }
642
643 template("rtc_ios_xctest_test") {
644 ios_xctest_test(target_name) {
645 forward_variables_from(invoker,
646 "*",
647 [
648 "configs",
649 "public_configs",
650 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200651 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800652 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200653 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000654 if (!defined(visibility)) {
655 visibility = webrtc_default_visibility
656 }
kthelgason4065a572017-02-14 04:58:56 -0800657 configs += invoker.configs
658 configs -= rtc_remove_configs
659 configs -= invoker.suppressed_configs
660 public_configs = [ rtc_common_inherited_config ]
661 if (defined(invoker.public_configs)) {
662 public_configs += invoker.public_configs
663 }
664 }
665 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100666
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400667 # TODO: Generate module.modulemap file to enable use in Swift
668 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100669 template("ios_framework_bundle_with_umbrella_header") {
670 forward_variables_from(invoker, [ "output_name" ])
671 umbrella_header_path =
672 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
673
674 ios_framework_bundle(target_name) {
675 forward_variables_from(invoker, "*", [])
676
677 deps += [ ":copy_umbrella_header_$target_name" ]
678 }
679
680 action("umbrella_header_$target_name") {
681 forward_variables_from(invoker, [ "public_headers" ])
682
683 script = "//tools_webrtc/ios/generate_umbrella_header.py"
684
685 outputs = [
686 umbrella_header_path,
687 ]
688 args = [
689 "--out",
690 rebase_path(umbrella_header_path, root_build_dir),
691 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200692 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100693 }
694
695 copy("copy_umbrella_header_$target_name") {
696 sources = [
697 umbrella_header_path,
698 ]
699 outputs = [
700 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
701 ]
702
703 deps = [
704 ":umbrella_header_$target_name",
705 ]
706 }
707 }
708
709 set_defaults("ios_framework_bundle_with_umbrella_header") {
710 configs = default_shared_library_configs
711 }
kthelgason4065a572017-02-14 04:58:56 -0800712}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000713
Anders Carlsson37bbf792018-09-05 16:29:27 +0200714if (is_mac) {
715 template("mac_framework_bundle_with_umbrella_header") {
716 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200717 this_target_name = target_name
718 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400719 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200720
721 mac_framework_bundle(target_name) {
722 forward_variables_from(invoker, "*", [])
723
724 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400725 framework_contents = [
726 "Headers",
727 "Modules",
728 "Resources",
729 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +0200730
731 ldflags = [
732 "-all_load",
733 "-install_name",
734 "@rpath/$output_name.framework/$output_name",
735 ]
736
737 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200738 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400739 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200740 ":copy_umbrella_header_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400741 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200742 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200743 ]
744 }
745
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200746 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200747 forward_variables_from(invoker, [ "sources" ])
748
749 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200750 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200751 ]
752 }
753
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400754 action("modulemap_$this_target_name") {
755 script = "//tools_webrtc/ios/generate_modulemap.py"
756 args = [
757 "--out",
758 rebase_path(modulemap_path, root_build_dir),
759 "--name",
760 output_name,
761 ]
762 outputs = [
763 modulemap_path,
764 ]
765 }
766
767 bundle_data("copy_modulemap_$this_target_name") {
768 sources = [
769 modulemap_path,
770 ]
771 outputs = [
772 "{{bundle_contents_dir}}/Modules/module.modulemap",
773 ]
774 deps = [
775 ":modulemap_$this_target_name",
776 ]
777 }
778
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200779 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200780 forward_variables_from(invoker, [ "sources" ])
781
782 script = "//tools_webrtc/ios/generate_umbrella_header.py"
783
784 outputs = [
785 umbrella_header_path,
786 ]
787 args = [
788 "--out",
789 rebase_path(umbrella_header_path, root_build_dir),
790 "--sources",
791 ] + sources
792 }
793
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200794 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200795 sources = [
796 umbrella_header_path,
797 ]
798 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200799 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200800 ]
801
802 deps = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200803 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200804 ]
805 }
806 }
807}
808
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000809if (is_android) {
810 template("rtc_android_library") {
811 android_library(target_name) {
812 forward_variables_from(invoker,
813 "*",
814 [
815 "configs",
816 "public_configs",
817 "suppressed_configs",
818 "visibility",
819 ])
820
Oleh Prypin05aee742018-11-23 17:29:44 +0100821 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100822
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000823 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100824 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100825
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200826 # TODO(crbug.com/824679): Find out why this fails in Chromium
827 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100828 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200829 "-Xep:ParameterNotNullable:ERROR",
830 "-Xep:FieldMissingNullable:ERROR",
831 "-Xep:ReturnMissingNullable:ERROR",
832 ]
833 }
834
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100835 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +0100836 if (defined(invoker.errorprone_args)) {
837 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100838 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000839
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200840 if (!defined(deps)) {
841 deps = []
842 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200843
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000844 no_build_hooks = true
845 }
846 }
847
848 template("rtc_android_apk") {
849 android_apk(target_name) {
850 forward_variables_from(invoker,
851 "*",
852 [
853 "configs",
854 "public_configs",
855 "suppressed_configs",
856 "visibility",
857 ])
858
859 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100860 errorprone_args = [ "-Werror" ]
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000861
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200862 # TODO(crbug.com/824679): Find out why this fails in Chromium
863 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100864 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200865 "-Xep:ParameterNotNullable:ERROR",
866 "-Xep:FieldMissingNullable:ERROR",
867 "-Xep:ReturnMissingNullable:ERROR",
868 ]
869 }
870
871 if (!defined(deps)) {
872 deps = []
873 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200874
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000875 no_build_hooks = true
876 }
877 }
878
879 template("rtc_instrumentation_test_apk") {
880 instrumentation_test_apk(target_name) {
881 forward_variables_from(invoker,
882 "*",
883 [
884 "configs",
885 "public_configs",
886 "suppressed_configs",
887 "visibility",
888 ])
889
890 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +0100891 errorprone_args = [ "-Werror" ]
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000892
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200893 # TODO(crbug.com/824679): Find out why this fails in Chromium
894 if (!build_with_chromium) {
Oleh Prypin05aee742018-11-23 17:29:44 +0100895 errorprone_args += [
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200896 "-Xep:ParameterNotNullable:ERROR",
897 "-Xep:FieldMissingNullable:ERROR",
898 "-Xep:ReturnMissingNullable:ERROR",
899 ]
900 }
901
902 if (!defined(deps)) {
903 deps = []
904 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200905
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000906 no_build_hooks = true
907 }
908 }
909}