blob: f09ed643b166004216fec7990dfc2d8a26d76b40 [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.
112 rtc_use_pipewire = false
113
mbonadei9aa3f0a2017-01-24 06:58:22 -0800114 # Enable to use the Mozilla internal settings.
115 build_with_mozilla = false
116
henrika883d00f2018-03-16 10:09:49 +0100117 # Enable use of Android AAudio which requires Android SDK 26 or above and
118 # NDK r16 or above.
119 rtc_enable_android_aaudio = false
120
121 # TODO(henrika): can this flag be removed?
mbonadei9aa3f0a2017-01-24 06:58:22 -0800122 rtc_enable_android_opensl = false
123
124 # Link-Time Optimizations.
125 # Executes code generation at link-time instead of compile-time.
126 # https://gcc.gnu.org/wiki/LinkTimeOptimization
127 rtc_use_lto = false
128
129 # Set to "func", "block", "edge" for coverage generation.
130 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
131 # It is recommend to set include_examples=0.
132 # Use llvm's sancov -html-report for human readable reports.
133 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
134 rtc_sanitize_coverage = ""
135
perkj650fdae2017-08-25 05:00:11 -0700136 # Links a default implementation of task queues to targets
137 # that depend on the target rtc_task_queue. Set to false to
138 # use an external implementation.
139 rtc_link_task_queue_impl = true
140
mbonadei9aa3f0a2017-01-24 06:58:22 -0800141 if (current_cpu == "arm" || current_cpu == "arm64") {
142 rtc_prefer_fixed_point = true
143 }
144
mbonadei9aa3f0a2017-01-24 06:58:22 -0800145 # Determines whether NEON code will be built.
146 rtc_build_with_neon =
147 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
148
149 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
150 # all platforms except Android and iOS. Because FFmpeg can be built
151 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
152 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Sergey Silkinfe288eb2018-06-25 16:22:38 +0200153 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800154 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
155 # http://www.openh264.org, https://www.ffmpeg.org/
Patrik Höglund3bb11942018-03-16 12:36:26 +0000156 rtc_use_h264 = proprietary_codecs && !is_android && !is_ios
mbonadei9aa3f0a2017-01-24 06:58:22 -0800157
mbonadei9aa3f0a2017-01-24 06:58:22 -0800158 # By default, use normal platform audio support or dummy audio, but don't
159 # use file-based audio playout and record.
160 rtc_use_dummy_audio_file_devices = false
161
henrika7be78832017-06-13 17:34:16 +0200162 # When set to true, replace the audio output with a sinus tone at 440Hz.
163 # The ADM will ask for audio data from WebRTC but instead of reading real
164 # audio samples from NetEQ, a sinus tone will be generated and replace the
165 # real audio samples.
166 rtc_audio_device_plays_sinus_tone = false
167
Anders Carlssondd8c1652018-01-30 10:32:13 +0100168 # Disable this to build without support for built-in software codecs.
169 rtc_use_builtin_sw_codecs = true
Anders Carlsson358f2e02018-06-04 10:24:37 +0200170
171 if (is_ios) {
172 # Build broadcast extension in AppRTCMobile for iOS. This results in the
173 # binary only running on iOS 11+, which is why it is disabled by default.
174 rtc_apprtcmobile_broadcast_extension = false
175 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200176
177 # Determines whether Metal is available on iOS/macOS.
178 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
Dan Minor9c686132018-01-15 10:20:00 -0500179}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800180
Dan Minor9c686132018-01-15 10:20:00 -0500181if (!build_with_mozilla) {
182 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800183}
184
185# A second declare_args block, so that declarations within it can
186# depend on the possibly overridden variables in the first
187# declare_args block.
188declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500189 # Enables the use of protocol buffers for debug recordings.
190 rtc_enable_protobuf = !build_with_mozilla
191
192 # Set this to disable building with support for SCTP data channels.
193 rtc_enable_sctp = !build_with_mozilla
194
195 # Disable these to not build components which can be externally provided.
196 rtc_build_json = !build_with_mozilla
197 rtc_build_libsrtp = !build_with_mozilla
198 rtc_build_libvpx = !build_with_mozilla
199 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500200 rtc_build_opus = !build_with_mozilla
201 rtc_build_ssl = !build_with_mozilla
202 rtc_build_usrsctp = !build_with_mozilla
203
204 # Enable libevent task queues on platforms that support it.
205 # rtc_link_task_queue_impl must be set to true for this to
206 # have an effect.
Wez00cecb92018-02-09 10:41:00 -0800207 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) {
Dan Minor9c686132018-01-15 10:20:00 -0500208 rtc_enable_libevent = false
209 rtc_build_libevent = false
210 } else {
211 rtc_enable_libevent = true
212 rtc_build_libevent = !build_with_mozilla
213 }
214
Dan Minor9c686132018-01-15 10:20:00 -0500215 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
216 # build environments, even if available for Chromium builds.
217 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
218
mbonadei9aa3f0a2017-01-24 06:58:22 -0800219 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
220 rtc_include_pulse_audio = !build_with_chromium
221
222 # Chromium uses its own IO handling, so the internal ADM is only built for
223 # standalone WebRTC.
224 rtc_include_internal_audio_device = !build_with_chromium
225
226 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500227 rtc_include_tests = !build_with_chromium && !build_with_mozilla
mbonadei9aa3f0a2017-01-24 06:58:22 -0800228}
229
230# Make it possible to provide custom locations for some libraries (move these
231# up into declare_args should we need to actually use them for the GN build).
232rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800233rtc_opus_dir = "//third_party/opus"
234
235# Desktop capturer is supported only on Windows, OSX and Linux.
Tomas Popela318da512018-11-13 06:32:23 +0100236rtc_desktop_capture_supported =
237 is_win || is_mac || (is_linux && (rtc_use_x11 || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800238
239###############################################################################
240# Templates
241#
242
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200243# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800244# chromium.
245# We need absolute paths for all configs in templates as they are shared in
246# different subdirectories.
247webrtc_root = get_path_info(".", "abspath")
248
249# Global configuration that should be applied to all WebRTC targets.
250# You normally shouldn't need to include this in your target as it's
251# automatically included when using the rtc_* templates.
252# It sets defines, include paths and compilation warnings accordingly,
253# both for WebRTC stand-alone builds and for the scenario when WebRTC
254# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700255rtc_common_configs = [
256 webrtc_root + ":common_config",
257 "//build/config/compiler:no_size_t_to_int_warning",
258]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800259
kthelgasonc0977102017-04-24 00:57:16 -0700260if (is_mac || is_ios) {
261 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
262}
263
mbonadei9aa3f0a2017-01-24 06:58:22 -0800264# Global public configuration that should be applied to all WebRTC targets. You
265# normally shouldn't need to include this in your target as it's automatically
266# included when using the rtc_* templates. It set the defines, include paths and
267# compilation warnings that should be propagated to dependents of the targets
268# depending on the target having this config.
269rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
270
271# Common configs to remove or add in all rtc targets.
272rtc_remove_configs = []
273rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200274rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200275rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800276
277set_defaults("rtc_test") {
278 configs = rtc_add_configs
279 suppressed_configs = []
280}
281
282set_defaults("rtc_source_set") {
283 configs = rtc_add_configs
284 suppressed_configs = []
285}
286
287set_defaults("rtc_executable") {
288 configs = rtc_add_configs
289 suppressed_configs = []
290}
291
292set_defaults("rtc_static_library") {
293 configs = rtc_add_configs
294 suppressed_configs = []
295}
296
297set_defaults("rtc_shared_library") {
298 configs = rtc_add_configs
299 suppressed_configs = []
300}
301
Per Kjellandera7f2d842018-01-10 15:54:53 +0000302webrtc_default_visibility = [ webrtc_root + "/*" ]
303if (build_with_chromium) {
304 # Allow Chromium's WebRTC overrides targets to bypass the regular
305 # visibility restrictions.
306 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
307}
308
Karl Wibergbb23c832018-04-22 19:55:00 +0200309# ---- Poisons ----
310#
311# The general idea is that some targets declare that they contain some
312# kind of poison, which makes it impossible for other targets to
313# depend on them (even transitively) unless they declare themselves
314# immune to that particular type of poison.
315#
316# Targets that *contain* poison of type foo should contain the line
317#
318# poisonous = [ "foo" ]
319#
320# and targets that *are immune but arent't themselves poisonous*
321# should contain
322#
323# allow_poison = [ "foo" ]
324#
325# This useful in cases where we have some large target or set of
326# targets and want to ensure that most other targets do not
327# transitively depend on them. For example, almost no high-level
328# target should depend on the audio codecs, since we want WebRTC users
329# to be able to inject any subset of them and actually end up with a
330# binary that doesn't include the codecs they didn't inject.
331#
332# Test-only targets (`testonly` set to true) and non-public targets
333# (`visibility` not containing "*") are automatically immune to all
334# types of poison.
335#
336# Here's the complete list of all types of poison. It must be kept in
337# 1:1 correspondence with the set of //:poison_* targets.
338#
339all_poison_types = [
340 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
341 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200342
343 # Software video codecs (VP8 and VP9 through libvpx).
344 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200345]
346
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000347absl_include_config = "//third_party/abseil-cpp:absl_include_config"
348absl_define_config = "//third_party/abseil-cpp:absl_define_config"
349
mbonadei9aa3f0a2017-01-24 06:58:22 -0800350template("rtc_test") {
351 test(target_name) {
352 forward_variables_from(invoker,
353 "*",
354 [
355 "configs",
356 "public_configs",
357 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200358 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800359 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100360
361 # Always override to public because when target_os is Android the `test`
362 # template can override it to [ "*" ] and we want to avoid conditional
363 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100364 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800365 configs += invoker.configs
366 configs -= rtc_remove_configs
367 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000368 public_configs = [
369 rtc_common_inherited_config,
370 absl_include_config,
371 absl_define_config,
372 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800373 if (defined(invoker.public_configs)) {
374 public_configs += invoker.public_configs
375 }
sakald7fdb802017-05-26 01:51:53 -0700376 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800377 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
378 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700379 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800380 }
381}
382
383template("rtc_source_set") {
384 source_set(target_name) {
385 forward_variables_from(invoker,
386 "*",
387 [
388 "configs",
389 "public_configs",
390 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200391 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800392 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200393 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000394 if (!defined(visibility)) {
395 visibility = webrtc_default_visibility
396 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200397
398 # What's your poison?
399 if (defined(testonly) && testonly) {
400 assert(!defined(poisonous))
401 assert(!defined(allow_poison))
402 } else {
403 if (!defined(poisonous)) {
404 poisonous = []
405 }
406 if (!defined(allow_poison)) {
407 allow_poison = []
408 }
409 if (!defined(assert_no_deps)) {
410 assert_no_deps = []
411 }
412 if (!defined(deps)) {
413 deps = []
414 }
415 foreach(p, poisonous) {
416 deps += [ webrtc_root + ":poison_" + p ]
417 }
418 foreach(poison_type, all_poison_types) {
419 allow_dep = true
420 foreach(v, visibility) {
421 if (v == "*") {
422 allow_dep = false
423 }
424 }
425 foreach(p, allow_poison + poisonous) {
426 if (p == poison_type) {
427 allow_dep = true
428 }
429 }
430 if (!allow_dep) {
431 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
432 }
433 }
434 }
435
Mirko Bonadei96ede162018-09-06 13:45:44 +0200436 if (!defined(testonly) || !testonly) {
437 configs += rtc_prod_configs
438 }
439
mbonadei9aa3f0a2017-01-24 06:58:22 -0800440 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200441 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800442 configs -= rtc_remove_configs
443 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000444 public_configs = [
445 rtc_common_inherited_config,
446 absl_include_config,
447 absl_define_config,
448 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800449 if (defined(invoker.public_configs)) {
450 public_configs += invoker.public_configs
451 }
452 }
453}
454
455template("rtc_executable") {
456 executable(target_name) {
457 forward_variables_from(invoker,
458 "*",
459 [
460 "deps",
461 "configs",
462 "public_configs",
463 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200464 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800465 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200466 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000467 if (!defined(visibility)) {
468 visibility = webrtc_default_visibility
469 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800470 configs += invoker.configs
471 configs -= rtc_remove_configs
472 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700473 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700474
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000475 public_configs = [
476 rtc_common_inherited_config,
477 absl_include_config,
478 absl_define_config,
479 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800480 if (defined(invoker.public_configs)) {
481 public_configs += invoker.public_configs
482 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200483 if (is_win) {
484 deps += [
485 # Give executables the default manifest on Windows (a no-op elsewhere).
486 "//build/win:default_exe_manifest",
487 ]
488 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800489 }
490}
491
492template("rtc_static_library") {
493 static_library(target_name) {
494 forward_variables_from(invoker,
495 "*",
496 [
497 "configs",
498 "public_configs",
499 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200500 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800501 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200502 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000503 if (!defined(visibility)) {
504 visibility = webrtc_default_visibility
505 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200506
507 # What's your poison?
508 if (defined(testonly) && testonly) {
509 assert(!defined(poisonous))
510 assert(!defined(allow_poison))
511 } else {
512 if (!defined(poisonous)) {
513 poisonous = []
514 }
515 if (!defined(allow_poison)) {
516 allow_poison = []
517 }
518 if (!defined(assert_no_deps)) {
519 assert_no_deps = []
520 }
521 if (!defined(deps)) {
522 deps = []
523 }
524 foreach(p, poisonous) {
525 deps += [ webrtc_root + ":poison_" + p ]
526 }
527 foreach(poison_type, all_poison_types) {
528 allow_dep = true
529 foreach(v, visibility) {
530 if (v == "*") {
531 allow_dep = false
532 }
533 }
534 foreach(p, allow_poison + poisonous) {
535 if (p == poison_type) {
536 allow_dep = true
537 }
538 }
539 if (!allow_dep) {
540 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
541 }
542 }
543 }
544
Mirko Bonadei96ede162018-09-06 13:45:44 +0200545 if (!defined(testonly) || !testonly) {
546 configs += rtc_prod_configs
547 }
548
mbonadei9aa3f0a2017-01-24 06:58:22 -0800549 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200550 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800551 configs -= rtc_remove_configs
552 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000553 public_configs = [
554 rtc_common_inherited_config,
555 absl_include_config,
556 absl_define_config,
557 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800558 if (defined(invoker.public_configs)) {
559 public_configs += invoker.public_configs
560 }
561 }
562}
563
564template("rtc_shared_library") {
565 shared_library(target_name) {
566 forward_variables_from(invoker,
567 "*",
568 [
569 "configs",
570 "public_configs",
571 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200572 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800573 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200574 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000575 if (!defined(visibility)) {
576 visibility = webrtc_default_visibility
577 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200578
579 # What's your poison?
580 if (defined(testonly) && testonly) {
581 assert(!defined(poisonous))
582 assert(!defined(allow_poison))
583 } else {
584 if (!defined(poisonous)) {
585 poisonous = []
586 }
587 if (!defined(allow_poison)) {
588 allow_poison = []
589 }
590 if (!defined(assert_no_deps)) {
591 assert_no_deps = []
592 }
593 if (!defined(deps)) {
594 deps = []
595 }
596 foreach(p, poisonous) {
597 deps += [ webrtc_root + ":poison_" + p ]
598 }
599 foreach(poison_type, all_poison_types) {
600 allow_dep = true
601 foreach(v, visibility) {
602 if (v == "*") {
603 allow_dep = false
604 }
605 }
606 foreach(p, allow_poison + poisonous) {
607 if (p == poison_type) {
608 allow_dep = true
609 }
610 }
611 if (!allow_dep) {
612 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
613 }
614 }
615 }
616
mbonadei9aa3f0a2017-01-24 06:58:22 -0800617 configs += invoker.configs
618 configs -= rtc_remove_configs
619 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000620 public_configs = [
621 rtc_common_inherited_config,
622 absl_include_config,
623 absl_define_config,
624 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800625 if (defined(invoker.public_configs)) {
626 public_configs += invoker.public_configs
627 }
628 }
629}
kthelgason4065a572017-02-14 04:58:56 -0800630
631if (is_ios) {
632 set_defaults("rtc_ios_xctest_test") {
633 configs = rtc_add_configs
634 suppressed_configs = []
635 }
636
637 template("rtc_ios_xctest_test") {
638 ios_xctest_test(target_name) {
639 forward_variables_from(invoker,
640 "*",
641 [
642 "configs",
643 "public_configs",
644 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200645 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800646 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200647 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000648 if (!defined(visibility)) {
649 visibility = webrtc_default_visibility
650 }
kthelgason4065a572017-02-14 04:58:56 -0800651 configs += invoker.configs
652 configs -= rtc_remove_configs
653 configs -= invoker.suppressed_configs
654 public_configs = [ rtc_common_inherited_config ]
655 if (defined(invoker.public_configs)) {
656 public_configs += invoker.public_configs
657 }
658 }
659 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100660
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400661 # TODO: Generate module.modulemap file to enable use in Swift
662 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100663 template("ios_framework_bundle_with_umbrella_header") {
664 forward_variables_from(invoker, [ "output_name" ])
665 umbrella_header_path =
666 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
667
668 ios_framework_bundle(target_name) {
669 forward_variables_from(invoker, "*", [])
670
671 deps += [ ":copy_umbrella_header_$target_name" ]
672 }
673
674 action("umbrella_header_$target_name") {
675 forward_variables_from(invoker, [ "public_headers" ])
676
677 script = "//tools_webrtc/ios/generate_umbrella_header.py"
678
679 outputs = [
680 umbrella_header_path,
681 ]
682 args = [
683 "--out",
684 rebase_path(umbrella_header_path, root_build_dir),
685 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200686 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100687 }
688
689 copy("copy_umbrella_header_$target_name") {
690 sources = [
691 umbrella_header_path,
692 ]
693 outputs = [
694 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
695 ]
696
697 deps = [
698 ":umbrella_header_$target_name",
699 ]
700 }
701 }
702
703 set_defaults("ios_framework_bundle_with_umbrella_header") {
704 configs = default_shared_library_configs
705 }
kthelgason4065a572017-02-14 04:58:56 -0800706}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000707
Anders Carlsson37bbf792018-09-05 16:29:27 +0200708if (is_mac) {
709 template("mac_framework_bundle_with_umbrella_header") {
710 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200711 this_target_name = target_name
712 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400713 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200714
715 mac_framework_bundle(target_name) {
716 forward_variables_from(invoker, "*", [])
717
718 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400719 framework_contents = [
720 "Headers",
721 "Modules",
722 "Resources",
723 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +0200724
725 ldflags = [
726 "-all_load",
727 "-install_name",
728 "@rpath/$output_name.framework/$output_name",
729 ]
730
731 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200732 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400733 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200734 ":copy_umbrella_header_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400735 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200736 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200737 ]
738 }
739
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200740 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200741 forward_variables_from(invoker, [ "sources" ])
742
743 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200744 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200745 ]
746 }
747
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400748 action("modulemap_$this_target_name") {
749 script = "//tools_webrtc/ios/generate_modulemap.py"
750 args = [
751 "--out",
752 rebase_path(modulemap_path, root_build_dir),
753 "--name",
754 output_name,
755 ]
756 outputs = [
757 modulemap_path,
758 ]
759 }
760
761 bundle_data("copy_modulemap_$this_target_name") {
762 sources = [
763 modulemap_path,
764 ]
765 outputs = [
766 "{{bundle_contents_dir}}/Modules/module.modulemap",
767 ]
768 deps = [
769 ":modulemap_$this_target_name",
770 ]
771 }
772
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200773 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200774 forward_variables_from(invoker, [ "sources" ])
775
776 script = "//tools_webrtc/ios/generate_umbrella_header.py"
777
778 outputs = [
779 umbrella_header_path,
780 ]
781 args = [
782 "--out",
783 rebase_path(umbrella_header_path, root_build_dir),
784 "--sources",
785 ] + sources
786 }
787
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200788 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200789 sources = [
790 umbrella_header_path,
791 ]
792 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200793 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200794 ]
795
796 deps = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200797 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200798 ]
799 }
800 }
801}
802
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000803if (is_android) {
804 template("rtc_android_library") {
805 android_library(target_name) {
806 forward_variables_from(invoker,
807 "*",
808 [
809 "configs",
810 "public_configs",
811 "suppressed_configs",
812 "visibility",
813 ])
814
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100815 javac_args = []
816
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000817 # Treat warnings as errors.
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100818 javac_args += [ "-Werror" ]
819
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200820 # TODO(crbug.com/824679): Find out why this fails in Chromium
821 if (!build_with_chromium) {
822 javac_args += [
823 "-Xep:ParameterNotNullable:ERROR",
824 "-Xep:FieldMissingNullable:ERROR",
825 "-Xep:ReturnMissingNullable:ERROR",
826 ]
827 }
828
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100829 # Add any arguments defined by the invoker.
830 if (defined(invoker.javac_args)) {
831 javac_args += invoker.javac_args
832 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000833
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200834 if (!defined(deps)) {
835 deps = []
836 }
837 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
838
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000839 no_build_hooks = true
840 }
841 }
842
843 template("rtc_android_apk") {
844 android_apk(target_name) {
845 forward_variables_from(invoker,
846 "*",
847 [
848 "configs",
849 "public_configs",
850 "suppressed_configs",
851 "visibility",
852 ])
853
854 # Treat warnings as errors.
855 javac_args = [ "-Werror" ]
856
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200857 # TODO(crbug.com/824679): Find out why this fails in Chromium
858 if (!build_with_chromium) {
859 javac_args += [
860 "-Xep:ParameterNotNullable:ERROR",
861 "-Xep:FieldMissingNullable:ERROR",
862 "-Xep:ReturnMissingNullable:ERROR",
863 ]
864 }
865
866 if (!defined(deps)) {
867 deps = []
868 }
869 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
870
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000871 no_build_hooks = true
872 }
873 }
874
875 template("rtc_instrumentation_test_apk") {
876 instrumentation_test_apk(target_name) {
877 forward_variables_from(invoker,
878 "*",
879 [
880 "configs",
881 "public_configs",
882 "suppressed_configs",
883 "visibility",
884 ])
885
886 # Treat warnings as errors.
887 javac_args = [ "-Werror" ]
888
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200889 # TODO(crbug.com/824679): Find out why this fails in Chromium
890 if (!build_with_chromium) {
891 javac_args += [
892 "-Xep:ParameterNotNullable:ERROR",
893 "-Xep:FieldMissingNullable:ERROR",
894 "-Xep:ReturnMissingNullable:ERROR",
895 ]
896 }
897
898 if (!defined(deps)) {
899 deps = []
900 }
901 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
902
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000903 no_build_hooks = true
904 }
905 }
906}