blob: bba336912d55721f85a810e41136b205aaab57df [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")
ehmaldonado0d729b32017-02-10 01:38:23 -080012import("//build/config/ui.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -080013import("//build_overrides/build.gni")
mbonadei96606272017-03-03 19:41:59 -080014
15if (!build_with_chromium && is_component_build) {
16 print("The Gn argument `is_component_build` is currently " +
17 "ignored for WebRTC builds.")
18 print("Component builds are supported by Chromium and the argument " +
19 "`is_component_build` makes it possible to create shared libraries " +
20 "instead of static libraries.")
21 print("If an app depends on WebRTC it makes sense to just depend on the " +
22 "WebRTC static library, so there is no difference between " +
23 "`is_component_build=true` and `is_component_build=false`.")
24 print(
25 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.md")
26 assert(!is_component_build, "Component builds are not supported in WebRTC.")
27}
28
kthelgason4065a572017-02-14 04:58:56 -080029if (is_ios) {
30 import("//build/config/ios/rules.gni")
31}
mbonadei9aa3f0a2017-01-24 06:58:22 -080032
Anders Carlsson37bbf792018-09-05 16:29:27 +020033if (is_mac) {
34 import("//build/config/mac/rules.gni")
35}
36
mbonadei9aa3f0a2017-01-24 06:58:22 -080037declare_args() {
Mirko Bonadei028248c2018-10-10 12:19:02 +020038 # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h)
39 # expand to code that will manage symbols visibility.
40 rtc_enable_symbol_export = false
41
Mirko Bonadei31b0b452018-08-22 10:37:11 +020042 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 15:44:28 +020043 # will tell the pre-processor to remove the default definition of symbols
44 # needed to use field_trial. In that case a new implementation needs to be
45 # provided.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020046 if (build_with_chromium) {
47 # When WebRTC is built as part of Chromium it should exclude the default
48 # implementation of field_trial unless it is building for NACL or
49 # Chromecast.
50 rtc_exclude_field_trial_default = !is_nacl && !is_chromecast
51 } else {
52 rtc_exclude_field_trial_default = false
53 }
Mirko Bonadei70400902018-08-21 15:44:28 +020054
Mirko Bonadei906add42018-09-05 16:03:16 +020055 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
56 # will tell the pre-processor to remove the default definition of symbols
57 # needed to use metrics. In that case a new implementation needs to be
58 # provided.
59 rtc_exclude_metrics_default = build_with_chromium
60
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070061 # Setting this to false will require the API user to pass in their own
62 # SSLCertificateVerifier to verify the certificates presented from a
63 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
64 rtc_builtin_ssl_root_certificates = true
65
Karl Wibergeb254b42017-11-01 15:08:12 +010066 # Include the iLBC audio codec?
67 rtc_include_ilbc = true
68
mbonadei9aa3f0a2017-01-24 06:58:22 -080069 # Disable this to avoid building the Opus audio codec.
70 rtc_include_opus = true
71
minyue2e03c662017-02-01 17:31:11 -080072 # Enable this if the Opus version upon which WebRTC is built supports direct
73 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020074 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080075
mbonadei9aa3f0a2017-01-24 06:58:22 -080076 # Enable this to let the Opus audio codec change complexity on the fly.
77 rtc_opus_variable_complexity = false
78
mbonadei9aa3f0a2017-01-24 06:58:22 -080079 # Used to specify an external Jsoncpp include path when not compiling the
80 # library that comes with WebRTC (i.e. rtc_build_json == 0).
81 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
82
83 # Used to specify an external OpenSSL include path when not compiling the
84 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
85 rtc_ssl_root = ""
86
87 # Selects fixed-point code where possible.
88 rtc_prefer_fixed_point = false
89
mbonadei9aa3f0a2017-01-24 06:58:22 -080090 # Enable when an external authentication mechanism is used for performing
91 # packet authentication for RTP packets instead of libsrtp.
92 rtc_enable_external_auth = build_with_chromium
93
94 # Selects whether debug dumps for the audio processing module
95 # should be generated.
96 apm_debug_dump = false
97
98 # Set this to true to enable BWE test logging.
99 rtc_enable_bwe_test_logging = false
100
Joachim Bauch93e91342017-12-07 01:25:53 +0100101 # Set this to false to skip building examples.
102 rtc_build_examples = true
103
104 # Set this to false to skip building tools.
105 rtc_build_tools = true
106
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100107 # Set this to false to skip building code that requires X11.
108 rtc_use_x11 = use_x11
109
mbonadei9aa3f0a2017-01-24 06:58:22 -0800110 # Enable to use the Mozilla internal settings.
111 build_with_mozilla = false
112
henrika883d00f2018-03-16 10:09:49 +0100113 # Enable use of Android AAudio which requires Android SDK 26 or above and
114 # NDK r16 or above.
115 rtc_enable_android_aaudio = false
116
117 # TODO(henrika): can this flag be removed?
mbonadei9aa3f0a2017-01-24 06:58:22 -0800118 rtc_enable_android_opensl = false
119
120 # Link-Time Optimizations.
121 # Executes code generation at link-time instead of compile-time.
122 # https://gcc.gnu.org/wiki/LinkTimeOptimization
123 rtc_use_lto = false
124
125 # Set to "func", "block", "edge" for coverage generation.
126 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
127 # It is recommend to set include_examples=0.
128 # Use llvm's sancov -html-report for human readable reports.
129 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
130 rtc_sanitize_coverage = ""
131
perkj650fdae2017-08-25 05:00:11 -0700132 # Links a default implementation of task queues to targets
133 # that depend on the target rtc_task_queue. Set to false to
134 # use an external implementation.
135 rtc_link_task_queue_impl = true
136
mbonadei9aa3f0a2017-01-24 06:58:22 -0800137 if (current_cpu == "arm" || current_cpu == "arm64") {
138 rtc_prefer_fixed_point = true
139 }
140
mbonadei9aa3f0a2017-01-24 06:58:22 -0800141 # Determines whether NEON code will be built.
142 rtc_build_with_neon =
143 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
144
145 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
146 # all platforms except Android and iOS. Because FFmpeg can be built
147 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
148 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Sergey Silkinfe288eb2018-06-25 16:22:38 +0200149 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800150 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
151 # http://www.openh264.org, https://www.ffmpeg.org/
Patrik Höglund3bb11942018-03-16 12:36:26 +0000152 rtc_use_h264 = proprietary_codecs && !is_android && !is_ios
mbonadei9aa3f0a2017-01-24 06:58:22 -0800153
mbonadei9aa3f0a2017-01-24 06:58:22 -0800154 # By default, use normal platform audio support or dummy audio, but don't
155 # use file-based audio playout and record.
156 rtc_use_dummy_audio_file_devices = false
157
henrika7be78832017-06-13 17:34:16 +0200158 # When set to true, replace the audio output with a sinus tone at 440Hz.
159 # The ADM will ask for audio data from WebRTC but instead of reading real
160 # audio samples from NetEQ, a sinus tone will be generated and replace the
161 # real audio samples.
162 rtc_audio_device_plays_sinus_tone = false
163
Anders Carlssondd8c1652018-01-30 10:32:13 +0100164 # Disable this to build without support for built-in software codecs.
165 rtc_use_builtin_sw_codecs = true
Anders Carlsson358f2e02018-06-04 10:24:37 +0200166
167 if (is_ios) {
168 # Build broadcast extension in AppRTCMobile for iOS. This results in the
169 # binary only running on iOS 11+, which is why it is disabled by default.
170 rtc_apprtcmobile_broadcast_extension = false
171 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200172
173 # Determines whether Metal is available on iOS/macOS.
174 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
Dan Minor9c686132018-01-15 10:20:00 -0500175}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800176
Dan Minor9c686132018-01-15 10:20:00 -0500177if (!build_with_mozilla) {
178 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800179}
180
181# A second declare_args block, so that declarations within it can
182# depend on the possibly overridden variables in the first
183# declare_args block.
184declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500185 # Enables the use of protocol buffers for debug recordings.
186 rtc_enable_protobuf = !build_with_mozilla
187
188 # Set this to disable building with support for SCTP data channels.
189 rtc_enable_sctp = !build_with_mozilla
190
191 # Disable these to not build components which can be externally provided.
192 rtc_build_json = !build_with_mozilla
193 rtc_build_libsrtp = !build_with_mozilla
194 rtc_build_libvpx = !build_with_mozilla
195 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500196 rtc_build_opus = !build_with_mozilla
197 rtc_build_ssl = !build_with_mozilla
198 rtc_build_usrsctp = !build_with_mozilla
199
200 # Enable libevent task queues on platforms that support it.
201 # rtc_link_task_queue_impl must be set to true for this to
202 # have an effect.
Wez00cecb92018-02-09 10:41:00 -0800203 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) {
Dan Minor9c686132018-01-15 10:20:00 -0500204 rtc_enable_libevent = false
205 rtc_build_libevent = false
206 } else {
207 rtc_enable_libevent = true
208 rtc_build_libevent = !build_with_mozilla
209 }
210
Dan Minor9c686132018-01-15 10:20:00 -0500211 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
212 # build environments, even if available for Chromium builds.
213 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
214
mbonadei9aa3f0a2017-01-24 06:58:22 -0800215 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
216 rtc_include_pulse_audio = !build_with_chromium
217
218 # Chromium uses its own IO handling, so the internal ADM is only built for
219 # standalone WebRTC.
220 rtc_include_internal_audio_device = !build_with_chromium
221
222 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500223 rtc_include_tests = !build_with_chromium && !build_with_mozilla
mbonadei9aa3f0a2017-01-24 06:58:22 -0800224}
225
226# Make it possible to provide custom locations for some libraries (move these
227# up into declare_args should we need to actually use them for the GN build).
228rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800229rtc_opus_dir = "//third_party/opus"
230
231# Desktop capturer is supported only on Windows, OSX and Linux.
Patrik Höglund3ddaf3c2018-11-06 13:22:54 +0000232rtc_desktop_capture_supported = is_win || is_mac || (is_linux && rtc_use_x11)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800233
234###############################################################################
235# Templates
236#
237
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200238# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800239# chromium.
240# We need absolute paths for all configs in templates as they are shared in
241# different subdirectories.
242webrtc_root = get_path_info(".", "abspath")
243
244# Global configuration that should be applied to all WebRTC targets.
245# You normally shouldn't need to include this in your target as it's
246# automatically included when using the rtc_* templates.
247# It sets defines, include paths and compilation warnings accordingly,
248# both for WebRTC stand-alone builds and for the scenario when WebRTC
249# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700250rtc_common_configs = [
251 webrtc_root + ":common_config",
252 "//build/config/compiler:no_size_t_to_int_warning",
253]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800254
kthelgasonc0977102017-04-24 00:57:16 -0700255if (is_mac || is_ios) {
256 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
257}
258
mbonadei9aa3f0a2017-01-24 06:58:22 -0800259# Global public configuration that should be applied to all WebRTC targets. You
260# normally shouldn't need to include this in your target as it's automatically
261# included when using the rtc_* templates. It set the defines, include paths and
262# compilation warnings that should be propagated to dependents of the targets
263# depending on the target having this config.
264rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
265
266# Common configs to remove or add in all rtc targets.
267rtc_remove_configs = []
268rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200269rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200270rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800271
272set_defaults("rtc_test") {
273 configs = rtc_add_configs
274 suppressed_configs = []
275}
276
277set_defaults("rtc_source_set") {
278 configs = rtc_add_configs
279 suppressed_configs = []
280}
281
282set_defaults("rtc_executable") {
283 configs = rtc_add_configs
284 suppressed_configs = []
285}
286
287set_defaults("rtc_static_library") {
288 configs = rtc_add_configs
289 suppressed_configs = []
290}
291
292set_defaults("rtc_shared_library") {
293 configs = rtc_add_configs
294 suppressed_configs = []
295}
296
Per Kjellandera7f2d842018-01-10 15:54:53 +0000297webrtc_default_visibility = [ webrtc_root + "/*" ]
298if (build_with_chromium) {
299 # Allow Chromium's WebRTC overrides targets to bypass the regular
300 # visibility restrictions.
301 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
302}
303
Karl Wibergbb23c832018-04-22 19:55:00 +0200304# ---- Poisons ----
305#
306# The general idea is that some targets declare that they contain some
307# kind of poison, which makes it impossible for other targets to
308# depend on them (even transitively) unless they declare themselves
309# immune to that particular type of poison.
310#
311# Targets that *contain* poison of type foo should contain the line
312#
313# poisonous = [ "foo" ]
314#
315# and targets that *are immune but arent't themselves poisonous*
316# should contain
317#
318# allow_poison = [ "foo" ]
319#
320# This useful in cases where we have some large target or set of
321# targets and want to ensure that most other targets do not
322# transitively depend on them. For example, almost no high-level
323# target should depend on the audio codecs, since we want WebRTC users
324# to be able to inject any subset of them and actually end up with a
325# binary that doesn't include the codecs they didn't inject.
326#
327# Test-only targets (`testonly` set to true) and non-public targets
328# (`visibility` not containing "*") are automatically immune to all
329# types of poison.
330#
331# Here's the complete list of all types of poison. It must be kept in
332# 1:1 correspondence with the set of //:poison_* targets.
333#
334all_poison_types = [
335 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
336 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200337
338 # Software video codecs (VP8 and VP9 through libvpx).
339 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200340]
341
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000342absl_include_config = "//third_party/abseil-cpp:absl_include_config"
343absl_define_config = "//third_party/abseil-cpp:absl_define_config"
344
mbonadei9aa3f0a2017-01-24 06:58:22 -0800345template("rtc_test") {
346 test(target_name) {
347 forward_variables_from(invoker,
348 "*",
349 [
350 "configs",
351 "public_configs",
352 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200353 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800354 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100355
356 # Always override to public because when target_os is Android the `test`
357 # template can override it to [ "*" ] and we want to avoid conditional
358 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100359 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800360 configs += invoker.configs
361 configs -= rtc_remove_configs
362 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000363 public_configs = [
364 rtc_common_inherited_config,
365 absl_include_config,
366 absl_define_config,
367 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800368 if (defined(invoker.public_configs)) {
369 public_configs += invoker.public_configs
370 }
sakald7fdb802017-05-26 01:51:53 -0700371 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800372 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
373 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700374 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800375 }
376}
377
378template("rtc_source_set") {
379 source_set(target_name) {
380 forward_variables_from(invoker,
381 "*",
382 [
383 "configs",
384 "public_configs",
385 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200386 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800387 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200388 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000389 if (!defined(visibility)) {
390 visibility = webrtc_default_visibility
391 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200392
393 # What's your poison?
394 if (defined(testonly) && testonly) {
395 assert(!defined(poisonous))
396 assert(!defined(allow_poison))
397 } else {
398 if (!defined(poisonous)) {
399 poisonous = []
400 }
401 if (!defined(allow_poison)) {
402 allow_poison = []
403 }
404 if (!defined(assert_no_deps)) {
405 assert_no_deps = []
406 }
407 if (!defined(deps)) {
408 deps = []
409 }
410 foreach(p, poisonous) {
411 deps += [ webrtc_root + ":poison_" + p ]
412 }
413 foreach(poison_type, all_poison_types) {
414 allow_dep = true
415 foreach(v, visibility) {
416 if (v == "*") {
417 allow_dep = false
418 }
419 }
420 foreach(p, allow_poison + poisonous) {
421 if (p == poison_type) {
422 allow_dep = true
423 }
424 }
425 if (!allow_dep) {
426 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
427 }
428 }
429 }
430
Mirko Bonadei96ede162018-09-06 13:45:44 +0200431 if (!defined(testonly) || !testonly) {
432 configs += rtc_prod_configs
433 }
434
mbonadei9aa3f0a2017-01-24 06:58:22 -0800435 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200436 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800437 configs -= rtc_remove_configs
438 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000439 public_configs = [
440 rtc_common_inherited_config,
441 absl_include_config,
442 absl_define_config,
443 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800444 if (defined(invoker.public_configs)) {
445 public_configs += invoker.public_configs
446 }
447 }
448}
449
450template("rtc_executable") {
451 executable(target_name) {
452 forward_variables_from(invoker,
453 "*",
454 [
455 "deps",
456 "configs",
457 "public_configs",
458 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200459 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800460 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200461 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000462 if (!defined(visibility)) {
463 visibility = webrtc_default_visibility
464 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800465 configs += invoker.configs
466 configs -= rtc_remove_configs
467 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700468 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700469
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000470 public_configs = [
471 rtc_common_inherited_config,
472 absl_include_config,
473 absl_define_config,
474 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800475 if (defined(invoker.public_configs)) {
476 public_configs += invoker.public_configs
477 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200478 if (is_win) {
479 deps += [
480 # Give executables the default manifest on Windows (a no-op elsewhere).
481 "//build/win:default_exe_manifest",
482 ]
483 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800484 }
485}
486
487template("rtc_static_library") {
488 static_library(target_name) {
489 forward_variables_from(invoker,
490 "*",
491 [
492 "configs",
493 "public_configs",
494 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200495 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800496 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200497 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000498 if (!defined(visibility)) {
499 visibility = webrtc_default_visibility
500 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200501
502 # What's your poison?
503 if (defined(testonly) && testonly) {
504 assert(!defined(poisonous))
505 assert(!defined(allow_poison))
506 } else {
507 if (!defined(poisonous)) {
508 poisonous = []
509 }
510 if (!defined(allow_poison)) {
511 allow_poison = []
512 }
513 if (!defined(assert_no_deps)) {
514 assert_no_deps = []
515 }
516 if (!defined(deps)) {
517 deps = []
518 }
519 foreach(p, poisonous) {
520 deps += [ webrtc_root + ":poison_" + p ]
521 }
522 foreach(poison_type, all_poison_types) {
523 allow_dep = true
524 foreach(v, visibility) {
525 if (v == "*") {
526 allow_dep = false
527 }
528 }
529 foreach(p, allow_poison + poisonous) {
530 if (p == poison_type) {
531 allow_dep = true
532 }
533 }
534 if (!allow_dep) {
535 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
536 }
537 }
538 }
539
Mirko Bonadei96ede162018-09-06 13:45:44 +0200540 if (!defined(testonly) || !testonly) {
541 configs += rtc_prod_configs
542 }
543
mbonadei9aa3f0a2017-01-24 06:58:22 -0800544 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200545 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800546 configs -= rtc_remove_configs
547 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000548 public_configs = [
549 rtc_common_inherited_config,
550 absl_include_config,
551 absl_define_config,
552 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800553 if (defined(invoker.public_configs)) {
554 public_configs += invoker.public_configs
555 }
556 }
557}
558
559template("rtc_shared_library") {
560 shared_library(target_name) {
561 forward_variables_from(invoker,
562 "*",
563 [
564 "configs",
565 "public_configs",
566 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200567 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800568 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200569 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000570 if (!defined(visibility)) {
571 visibility = webrtc_default_visibility
572 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200573
574 # What's your poison?
575 if (defined(testonly) && testonly) {
576 assert(!defined(poisonous))
577 assert(!defined(allow_poison))
578 } else {
579 if (!defined(poisonous)) {
580 poisonous = []
581 }
582 if (!defined(allow_poison)) {
583 allow_poison = []
584 }
585 if (!defined(assert_no_deps)) {
586 assert_no_deps = []
587 }
588 if (!defined(deps)) {
589 deps = []
590 }
591 foreach(p, poisonous) {
592 deps += [ webrtc_root + ":poison_" + p ]
593 }
594 foreach(poison_type, all_poison_types) {
595 allow_dep = true
596 foreach(v, visibility) {
597 if (v == "*") {
598 allow_dep = false
599 }
600 }
601 foreach(p, allow_poison + poisonous) {
602 if (p == poison_type) {
603 allow_dep = true
604 }
605 }
606 if (!allow_dep) {
607 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
608 }
609 }
610 }
611
mbonadei9aa3f0a2017-01-24 06:58:22 -0800612 configs += invoker.configs
613 configs -= rtc_remove_configs
614 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000615 public_configs = [
616 rtc_common_inherited_config,
617 absl_include_config,
618 absl_define_config,
619 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800620 if (defined(invoker.public_configs)) {
621 public_configs += invoker.public_configs
622 }
623 }
624}
kthelgason4065a572017-02-14 04:58:56 -0800625
626if (is_ios) {
627 set_defaults("rtc_ios_xctest_test") {
628 configs = rtc_add_configs
629 suppressed_configs = []
630 }
631
632 template("rtc_ios_xctest_test") {
633 ios_xctest_test(target_name) {
634 forward_variables_from(invoker,
635 "*",
636 [
637 "configs",
638 "public_configs",
639 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200640 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800641 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200642 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000643 if (!defined(visibility)) {
644 visibility = webrtc_default_visibility
645 }
kthelgason4065a572017-02-14 04:58:56 -0800646 configs += invoker.configs
647 configs -= rtc_remove_configs
648 configs -= invoker.suppressed_configs
649 public_configs = [ rtc_common_inherited_config ]
650 if (defined(invoker.public_configs)) {
651 public_configs += invoker.public_configs
652 }
653 }
654 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100655
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400656 # TODO: Generate module.modulemap file to enable use in Swift
657 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100658 template("ios_framework_bundle_with_umbrella_header") {
659 forward_variables_from(invoker, [ "output_name" ])
660 umbrella_header_path =
661 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
662
663 ios_framework_bundle(target_name) {
664 forward_variables_from(invoker, "*", [])
665
666 deps += [ ":copy_umbrella_header_$target_name" ]
667 }
668
669 action("umbrella_header_$target_name") {
670 forward_variables_from(invoker, [ "public_headers" ])
671
672 script = "//tools_webrtc/ios/generate_umbrella_header.py"
673
674 outputs = [
675 umbrella_header_path,
676 ]
677 args = [
678 "--out",
679 rebase_path(umbrella_header_path, root_build_dir),
680 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200681 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100682 }
683
684 copy("copy_umbrella_header_$target_name") {
685 sources = [
686 umbrella_header_path,
687 ]
688 outputs = [
689 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
690 ]
691
692 deps = [
693 ":umbrella_header_$target_name",
694 ]
695 }
696 }
697
698 set_defaults("ios_framework_bundle_with_umbrella_header") {
699 configs = default_shared_library_configs
700 }
kthelgason4065a572017-02-14 04:58:56 -0800701}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000702
Anders Carlsson37bbf792018-09-05 16:29:27 +0200703if (is_mac) {
704 template("mac_framework_bundle_with_umbrella_header") {
705 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200706 this_target_name = target_name
707 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400708 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200709
710 mac_framework_bundle(target_name) {
711 forward_variables_from(invoker, "*", [])
712
713 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400714 framework_contents = [
715 "Headers",
716 "Modules",
717 "Resources",
718 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +0200719
720 ldflags = [
721 "-all_load",
722 "-install_name",
723 "@rpath/$output_name.framework/$output_name",
724 ]
725
726 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200727 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400728 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200729 ":copy_umbrella_header_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400730 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200731 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200732 ]
733 }
734
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200735 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200736 forward_variables_from(invoker, [ "sources" ])
737
738 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200739 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200740 ]
741 }
742
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400743 action("modulemap_$this_target_name") {
744 script = "//tools_webrtc/ios/generate_modulemap.py"
745 args = [
746 "--out",
747 rebase_path(modulemap_path, root_build_dir),
748 "--name",
749 output_name,
750 ]
751 outputs = [
752 modulemap_path,
753 ]
754 }
755
756 bundle_data("copy_modulemap_$this_target_name") {
757 sources = [
758 modulemap_path,
759 ]
760 outputs = [
761 "{{bundle_contents_dir}}/Modules/module.modulemap",
762 ]
763 deps = [
764 ":modulemap_$this_target_name",
765 ]
766 }
767
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200768 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200769 forward_variables_from(invoker, [ "sources" ])
770
771 script = "//tools_webrtc/ios/generate_umbrella_header.py"
772
773 outputs = [
774 umbrella_header_path,
775 ]
776 args = [
777 "--out",
778 rebase_path(umbrella_header_path, root_build_dir),
779 "--sources",
780 ] + sources
781 }
782
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200783 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200784 sources = [
785 umbrella_header_path,
786 ]
787 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200788 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200789 ]
790
791 deps = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200792 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200793 ]
794 }
795 }
796}
797
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000798if (is_android) {
799 template("rtc_android_library") {
800 android_library(target_name) {
801 forward_variables_from(invoker,
802 "*",
803 [
804 "configs",
805 "public_configs",
806 "suppressed_configs",
807 "visibility",
808 ])
809
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100810 javac_args = []
811
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000812 # Treat warnings as errors.
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100813 javac_args += [ "-Werror" ]
814
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200815 # TODO(crbug.com/824679): Find out why this fails in Chromium
816 if (!build_with_chromium) {
817 javac_args += [
818 "-Xep:ParameterNotNullable:ERROR",
819 "-Xep:FieldMissingNullable:ERROR",
820 "-Xep:ReturnMissingNullable:ERROR",
821 ]
822 }
823
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100824 # Add any arguments defined by the invoker.
825 if (defined(invoker.javac_args)) {
826 javac_args += invoker.javac_args
827 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000828
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200829 if (!defined(deps)) {
830 deps = []
831 }
832 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
833
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000834 no_build_hooks = true
835 }
836 }
837
838 template("rtc_android_apk") {
839 android_apk(target_name) {
840 forward_variables_from(invoker,
841 "*",
842 [
843 "configs",
844 "public_configs",
845 "suppressed_configs",
846 "visibility",
847 ])
848
849 # Treat warnings as errors.
850 javac_args = [ "-Werror" ]
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) {
854 javac_args += [
855 "-Xep:ParameterNotNullable:ERROR",
856 "-Xep:FieldMissingNullable:ERROR",
857 "-Xep:ReturnMissingNullable:ERROR",
858 ]
859 }
860
861 if (!defined(deps)) {
862 deps = []
863 }
864 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
865
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000866 no_build_hooks = true
867 }
868 }
869
870 template("rtc_instrumentation_test_apk") {
871 instrumentation_test_apk(target_name) {
872 forward_variables_from(invoker,
873 "*",
874 [
875 "configs",
876 "public_configs",
877 "suppressed_configs",
878 "visibility",
879 ])
880
881 # Treat warnings as errors.
882 javac_args = [ "-Werror" ]
883
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200884 # TODO(crbug.com/824679): Find out why this fails in Chromium
885 if (!build_with_chromium) {
886 javac_args += [
887 "-Xep:ParameterNotNullable:ERROR",
888 "-Xep:FieldMissingNullable:ERROR",
889 "-Xep:ReturnMissingNullable:ERROR",
890 ]
891 }
892
893 if (!defined(deps)) {
894 deps = []
895 }
896 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
897
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000898 no_build_hooks = true
899 }
900 }
901}