blob: 5ed137fa8e8f17f8707053a7effb7d59e99d44fc [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 Bonadei31b0b452018-08-22 10:37:11 +020038 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 15:44:28 +020039 # will tell the pre-processor to remove the default definition of symbols
40 # needed to use field_trial. In that case a new implementation needs to be
41 # provided.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020042 if (build_with_chromium) {
43 # When WebRTC is built as part of Chromium it should exclude the default
44 # implementation of field_trial unless it is building for NACL or
45 # Chromecast.
46 rtc_exclude_field_trial_default = !is_nacl && !is_chromecast
47 } else {
48 rtc_exclude_field_trial_default = false
49 }
Mirko Bonadei70400902018-08-21 15:44:28 +020050
Mirko Bonadei906add42018-09-05 16:03:16 +020051 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
52 # will tell the pre-processor to remove the default definition of symbols
53 # needed to use metrics. In that case a new implementation needs to be
54 # provided.
55 rtc_exclude_metrics_default = build_with_chromium
56
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070057 # Setting this to false will require the API user to pass in their own
58 # SSLCertificateVerifier to verify the certificates presented from a
59 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
60 rtc_builtin_ssl_root_certificates = true
61
Karl Wibergeb254b42017-11-01 15:08:12 +010062 # Include the iLBC audio codec?
63 rtc_include_ilbc = true
64
mbonadei9aa3f0a2017-01-24 06:58:22 -080065 # Disable this to avoid building the Opus audio codec.
66 rtc_include_opus = true
67
minyue2e03c662017-02-01 17:31:11 -080068 # Enable this if the Opus version upon which WebRTC is built supports direct
69 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020070 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080071
mbonadei9aa3f0a2017-01-24 06:58:22 -080072 # Enable this to let the Opus audio codec change complexity on the fly.
73 rtc_opus_variable_complexity = false
74
mbonadei9aa3f0a2017-01-24 06:58:22 -080075 # Used to specify an external Jsoncpp include path when not compiling the
76 # library that comes with WebRTC (i.e. rtc_build_json == 0).
77 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
78
79 # Used to specify an external OpenSSL include path when not compiling the
80 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
81 rtc_ssl_root = ""
82
83 # Selects fixed-point code where possible.
84 rtc_prefer_fixed_point = false
85
mbonadei9aa3f0a2017-01-24 06:58:22 -080086 # Enable when an external authentication mechanism is used for performing
87 # packet authentication for RTP packets instead of libsrtp.
88 rtc_enable_external_auth = build_with_chromium
89
90 # Selects whether debug dumps for the audio processing module
91 # should be generated.
92 apm_debug_dump = false
93
94 # Set this to true to enable BWE test logging.
95 rtc_enable_bwe_test_logging = false
96
Joachim Bauch93e91342017-12-07 01:25:53 +010097 # Set this to false to skip building examples.
98 rtc_build_examples = true
99
100 # Set this to false to skip building tools.
101 rtc_build_tools = true
102
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100103 # Set this to false to skip building code that requires X11.
104 rtc_use_x11 = use_x11
105
mbonadei9aa3f0a2017-01-24 06:58:22 -0800106 # Enable to use the Mozilla internal settings.
107 build_with_mozilla = false
108
henrika883d00f2018-03-16 10:09:49 +0100109 # Enable use of Android AAudio which requires Android SDK 26 or above and
110 # NDK r16 or above.
111 rtc_enable_android_aaudio = false
112
113 # TODO(henrika): can this flag be removed?
mbonadei9aa3f0a2017-01-24 06:58:22 -0800114 rtc_enable_android_opensl = false
115
116 # Link-Time Optimizations.
117 # Executes code generation at link-time instead of compile-time.
118 # https://gcc.gnu.org/wiki/LinkTimeOptimization
119 rtc_use_lto = false
120
121 # Set to "func", "block", "edge" for coverage generation.
122 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
123 # It is recommend to set include_examples=0.
124 # Use llvm's sancov -html-report for human readable reports.
125 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
126 rtc_sanitize_coverage = ""
127
perkj650fdae2017-08-25 05:00:11 -0700128 # Links a default implementation of task queues to targets
129 # that depend on the target rtc_task_queue. Set to false to
130 # use an external implementation.
131 rtc_link_task_queue_impl = true
132
mbonadei9aa3f0a2017-01-24 06:58:22 -0800133 if (current_cpu == "arm" || current_cpu == "arm64") {
134 rtc_prefer_fixed_point = true
135 }
136
mbonadei9aa3f0a2017-01-24 06:58:22 -0800137 # Determines whether NEON code will be built.
138 rtc_build_with_neon =
139 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
140
141 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
142 # all platforms except Android and iOS. Because FFmpeg can be built
143 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
144 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Sergey Silkinfe288eb2018-06-25 16:22:38 +0200145 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800146 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
147 # http://www.openh264.org, https://www.ffmpeg.org/
Patrik Höglund3bb11942018-03-16 12:36:26 +0000148 rtc_use_h264 = proprietary_codecs && !is_android && !is_ios
mbonadei9aa3f0a2017-01-24 06:58:22 -0800149
mbonadei9aa3f0a2017-01-24 06:58:22 -0800150 # By default, use normal platform audio support or dummy audio, but don't
151 # use file-based audio playout and record.
152 rtc_use_dummy_audio_file_devices = false
153
henrika7be78832017-06-13 17:34:16 +0200154 # When set to true, replace the audio output with a sinus tone at 440Hz.
155 # The ADM will ask for audio data from WebRTC but instead of reading real
156 # audio samples from NetEQ, a sinus tone will be generated and replace the
157 # real audio samples.
158 rtc_audio_device_plays_sinus_tone = false
159
Anders Carlssondd8c1652018-01-30 10:32:13 +0100160 # Disable this to build without support for built-in software codecs.
161 rtc_use_builtin_sw_codecs = true
Anders Carlsson358f2e02018-06-04 10:24:37 +0200162
163 if (is_ios) {
164 # Build broadcast extension in AppRTCMobile for iOS. This results in the
165 # binary only running on iOS 11+, which is why it is disabled by default.
166 rtc_apprtcmobile_broadcast_extension = false
167 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200168
169 # Determines whether Metal is available on iOS/macOS.
170 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
Dan Minor9c686132018-01-15 10:20:00 -0500171}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800172
Dan Minor9c686132018-01-15 10:20:00 -0500173if (!build_with_mozilla) {
174 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800175}
176
177# A second declare_args block, so that declarations within it can
178# depend on the possibly overridden variables in the first
179# declare_args block.
180declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500181 # Enables the use of protocol buffers for debug recordings.
182 rtc_enable_protobuf = !build_with_mozilla
183
184 # Set this to disable building with support for SCTP data channels.
185 rtc_enable_sctp = !build_with_mozilla
186
187 # Disable these to not build components which can be externally provided.
188 rtc_build_json = !build_with_mozilla
189 rtc_build_libsrtp = !build_with_mozilla
190 rtc_build_libvpx = !build_with_mozilla
191 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500192 rtc_build_opus = !build_with_mozilla
193 rtc_build_ssl = !build_with_mozilla
194 rtc_build_usrsctp = !build_with_mozilla
195
196 # Enable libevent task queues on platforms that support it.
197 # rtc_link_task_queue_impl must be set to true for this to
198 # have an effect.
Wez00cecb92018-02-09 10:41:00 -0800199 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) {
Dan Minor9c686132018-01-15 10:20:00 -0500200 rtc_enable_libevent = false
201 rtc_build_libevent = false
202 } else {
203 rtc_enable_libevent = true
204 rtc_build_libevent = !build_with_mozilla
205 }
206
Dan Minor9c686132018-01-15 10:20:00 -0500207 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
208 # build environments, even if available for Chromium builds.
209 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
210
mbonadei9aa3f0a2017-01-24 06:58:22 -0800211 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
212 rtc_include_pulse_audio = !build_with_chromium
213
214 # Chromium uses its own IO handling, so the internal ADM is only built for
215 # standalone WebRTC.
216 rtc_include_internal_audio_device = !build_with_chromium
217
218 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500219 rtc_include_tests = !build_with_chromium && !build_with_mozilla
mbonadei9aa3f0a2017-01-24 06:58:22 -0800220}
221
222# Make it possible to provide custom locations for some libraries (move these
223# up into declare_args should we need to actually use them for the GN build).
224rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800225rtc_opus_dir = "//third_party/opus"
226
227# Desktop capturer is supported only on Windows, OSX and Linux.
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100228rtc_desktop_capture_supported = is_win || is_mac || (is_linux && rtc_use_x11)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800229
230###############################################################################
231# Templates
232#
233
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200234# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800235# chromium.
236# We need absolute paths for all configs in templates as they are shared in
237# different subdirectories.
238webrtc_root = get_path_info(".", "abspath")
239
240# Global configuration that should be applied to all WebRTC targets.
241# You normally shouldn't need to include this in your target as it's
242# automatically included when using the rtc_* templates.
243# It sets defines, include paths and compilation warnings accordingly,
244# both for WebRTC stand-alone builds and for the scenario when WebRTC
245# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700246rtc_common_configs = [
247 webrtc_root + ":common_config",
248 "//build/config/compiler:no_size_t_to_int_warning",
249]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800250
kthelgasonc0977102017-04-24 00:57:16 -0700251if (is_mac || is_ios) {
252 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
253}
254
mbonadei9aa3f0a2017-01-24 06:58:22 -0800255# Global public configuration that should be applied to all WebRTC targets. You
256# normally shouldn't need to include this in your target as it's automatically
257# included when using the rtc_* templates. It set the defines, include paths and
258# compilation warnings that should be propagated to dependents of the targets
259# depending on the target having this config.
260rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
261
262# Common configs to remove or add in all rtc targets.
263rtc_remove_configs = []
264rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200265rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800266
267set_defaults("rtc_test") {
268 configs = rtc_add_configs
269 suppressed_configs = []
270}
271
272set_defaults("rtc_source_set") {
273 configs = rtc_add_configs
274 suppressed_configs = []
275}
276
277set_defaults("rtc_executable") {
278 configs = rtc_add_configs
279 suppressed_configs = []
280}
281
282set_defaults("rtc_static_library") {
283 configs = rtc_add_configs
284 suppressed_configs = []
285}
286
287set_defaults("rtc_shared_library") {
288 configs = rtc_add_configs
289 suppressed_configs = []
290}
291
Per Kjellandera7f2d842018-01-10 15:54:53 +0000292webrtc_default_visibility = [ webrtc_root + "/*" ]
293if (build_with_chromium) {
294 # Allow Chromium's WebRTC overrides targets to bypass the regular
295 # visibility restrictions.
296 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
297}
298
Karl Wibergbb23c832018-04-22 19:55:00 +0200299# ---- Poisons ----
300#
301# The general idea is that some targets declare that they contain some
302# kind of poison, which makes it impossible for other targets to
303# depend on them (even transitively) unless they declare themselves
304# immune to that particular type of poison.
305#
306# Targets that *contain* poison of type foo should contain the line
307#
308# poisonous = [ "foo" ]
309#
310# and targets that *are immune but arent't themselves poisonous*
311# should contain
312#
313# allow_poison = [ "foo" ]
314#
315# This useful in cases where we have some large target or set of
316# targets and want to ensure that most other targets do not
317# transitively depend on them. For example, almost no high-level
318# target should depend on the audio codecs, since we want WebRTC users
319# to be able to inject any subset of them and actually end up with a
320# binary that doesn't include the codecs they didn't inject.
321#
322# Test-only targets (`testonly` set to true) and non-public targets
323# (`visibility` not containing "*") are automatically immune to all
324# types of poison.
325#
326# Here's the complete list of all types of poison. It must be kept in
327# 1:1 correspondence with the set of //:poison_* targets.
328#
329all_poison_types = [
330 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
331 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200332
333 # Software video codecs (VP8 and VP9 through libvpx).
334 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200335]
336
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000337absl_include_config = "//third_party/abseil-cpp:absl_include_config"
338absl_define_config = "//third_party/abseil-cpp:absl_define_config"
339
mbonadei9aa3f0a2017-01-24 06:58:22 -0800340template("rtc_test") {
341 test(target_name) {
342 forward_variables_from(invoker,
343 "*",
344 [
345 "configs",
346 "public_configs",
347 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200348 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800349 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100350
351 # Always override to public because when target_os is Android the `test`
352 # template can override it to [ "*" ] and we want to avoid conditional
353 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100354 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800355 configs += invoker.configs
356 configs -= rtc_remove_configs
357 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000358 public_configs = [
359 rtc_common_inherited_config,
360 absl_include_config,
361 absl_define_config,
362 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800363 if (defined(invoker.public_configs)) {
364 public_configs += invoker.public_configs
365 }
sakald7fdb802017-05-26 01:51:53 -0700366 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800367 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
368 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700369 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800370 }
371}
372
373template("rtc_source_set") {
374 source_set(target_name) {
375 forward_variables_from(invoker,
376 "*",
377 [
378 "configs",
379 "public_configs",
380 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200381 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800382 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200383 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000384 if (!defined(visibility)) {
385 visibility = webrtc_default_visibility
386 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200387
388 # What's your poison?
389 if (defined(testonly) && testonly) {
390 assert(!defined(poisonous))
391 assert(!defined(allow_poison))
392 } else {
393 if (!defined(poisonous)) {
394 poisonous = []
395 }
396 if (!defined(allow_poison)) {
397 allow_poison = []
398 }
399 if (!defined(assert_no_deps)) {
400 assert_no_deps = []
401 }
402 if (!defined(deps)) {
403 deps = []
404 }
405 foreach(p, poisonous) {
406 deps += [ webrtc_root + ":poison_" + p ]
407 }
408 foreach(poison_type, all_poison_types) {
409 allow_dep = true
410 foreach(v, visibility) {
411 if (v == "*") {
412 allow_dep = false
413 }
414 }
415 foreach(p, allow_poison + poisonous) {
416 if (p == poison_type) {
417 allow_dep = true
418 }
419 }
420 if (!allow_dep) {
421 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
422 }
423 }
424 }
425
Mirko Bonadei96ede162018-09-06 13:45:44 +0200426 if (!defined(testonly) || !testonly) {
427 configs += rtc_prod_configs
428 }
429
mbonadei9aa3f0a2017-01-24 06:58:22 -0800430 configs += invoker.configs
431 configs -= rtc_remove_configs
432 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000433 public_configs = [
434 rtc_common_inherited_config,
435 absl_include_config,
436 absl_define_config,
437 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800438 if (defined(invoker.public_configs)) {
439 public_configs += invoker.public_configs
440 }
441 }
442}
443
444template("rtc_executable") {
445 executable(target_name) {
446 forward_variables_from(invoker,
447 "*",
448 [
449 "deps",
450 "configs",
451 "public_configs",
452 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200453 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800454 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200455 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000456 if (!defined(visibility)) {
457 visibility = webrtc_default_visibility
458 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800459 configs += invoker.configs
460 configs -= rtc_remove_configs
461 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700462 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700463
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000464 public_configs = [
465 rtc_common_inherited_config,
466 absl_include_config,
467 absl_define_config,
468 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800469 if (defined(invoker.public_configs)) {
470 public_configs += invoker.public_configs
471 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200472 if (is_win) {
473 deps += [
474 # Give executables the default manifest on Windows (a no-op elsewhere).
475 "//build/win:default_exe_manifest",
476 ]
477 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800478 }
479}
480
481template("rtc_static_library") {
482 static_library(target_name) {
483 forward_variables_from(invoker,
484 "*",
485 [
486 "configs",
487 "public_configs",
488 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200489 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800490 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200491 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000492 if (!defined(visibility)) {
493 visibility = webrtc_default_visibility
494 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200495
496 # What's your poison?
497 if (defined(testonly) && testonly) {
498 assert(!defined(poisonous))
499 assert(!defined(allow_poison))
500 } else {
501 if (!defined(poisonous)) {
502 poisonous = []
503 }
504 if (!defined(allow_poison)) {
505 allow_poison = []
506 }
507 if (!defined(assert_no_deps)) {
508 assert_no_deps = []
509 }
510 if (!defined(deps)) {
511 deps = []
512 }
513 foreach(p, poisonous) {
514 deps += [ webrtc_root + ":poison_" + p ]
515 }
516 foreach(poison_type, all_poison_types) {
517 allow_dep = true
518 foreach(v, visibility) {
519 if (v == "*") {
520 allow_dep = false
521 }
522 }
523 foreach(p, allow_poison + poisonous) {
524 if (p == poison_type) {
525 allow_dep = true
526 }
527 }
528 if (!allow_dep) {
529 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
530 }
531 }
532 }
533
Mirko Bonadei96ede162018-09-06 13:45:44 +0200534 if (!defined(testonly) || !testonly) {
535 configs += rtc_prod_configs
536 }
537
mbonadei9aa3f0a2017-01-24 06:58:22 -0800538 configs += invoker.configs
539 configs -= rtc_remove_configs
540 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000541 public_configs = [
542 rtc_common_inherited_config,
543 absl_include_config,
544 absl_define_config,
545 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800546 if (defined(invoker.public_configs)) {
547 public_configs += invoker.public_configs
548 }
549 }
550}
551
552template("rtc_shared_library") {
553 shared_library(target_name) {
554 forward_variables_from(invoker,
555 "*",
556 [
557 "configs",
558 "public_configs",
559 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200560 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800561 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200562 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000563 if (!defined(visibility)) {
564 visibility = webrtc_default_visibility
565 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200566
567 # What's your poison?
568 if (defined(testonly) && testonly) {
569 assert(!defined(poisonous))
570 assert(!defined(allow_poison))
571 } else {
572 if (!defined(poisonous)) {
573 poisonous = []
574 }
575 if (!defined(allow_poison)) {
576 allow_poison = []
577 }
578 if (!defined(assert_no_deps)) {
579 assert_no_deps = []
580 }
581 if (!defined(deps)) {
582 deps = []
583 }
584 foreach(p, poisonous) {
585 deps += [ webrtc_root + ":poison_" + p ]
586 }
587 foreach(poison_type, all_poison_types) {
588 allow_dep = true
589 foreach(v, visibility) {
590 if (v == "*") {
591 allow_dep = false
592 }
593 }
594 foreach(p, allow_poison + poisonous) {
595 if (p == poison_type) {
596 allow_dep = true
597 }
598 }
599 if (!allow_dep) {
600 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
601 }
602 }
603 }
604
mbonadei9aa3f0a2017-01-24 06:58:22 -0800605 configs += invoker.configs
606 configs -= rtc_remove_configs
607 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000608 public_configs = [
609 rtc_common_inherited_config,
610 absl_include_config,
611 absl_define_config,
612 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800613 if (defined(invoker.public_configs)) {
614 public_configs += invoker.public_configs
615 }
616 }
617}
kthelgason4065a572017-02-14 04:58:56 -0800618
619if (is_ios) {
620 set_defaults("rtc_ios_xctest_test") {
621 configs = rtc_add_configs
622 suppressed_configs = []
623 }
624
625 template("rtc_ios_xctest_test") {
626 ios_xctest_test(target_name) {
627 forward_variables_from(invoker,
628 "*",
629 [
630 "configs",
631 "public_configs",
632 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200633 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800634 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200635 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000636 if (!defined(visibility)) {
637 visibility = webrtc_default_visibility
638 }
kthelgason4065a572017-02-14 04:58:56 -0800639 configs += invoker.configs
640 configs -= rtc_remove_configs
641 configs -= invoker.suppressed_configs
642 public_configs = [ rtc_common_inherited_config ]
643 if (defined(invoker.public_configs)) {
644 public_configs += invoker.public_configs
645 }
646 }
647 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100648
649 template("ios_framework_bundle_with_umbrella_header") {
650 forward_variables_from(invoker, [ "output_name" ])
651 umbrella_header_path =
652 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
653
654 ios_framework_bundle(target_name) {
655 forward_variables_from(invoker, "*", [])
656
657 deps += [ ":copy_umbrella_header_$target_name" ]
658 }
659
660 action("umbrella_header_$target_name") {
661 forward_variables_from(invoker, [ "public_headers" ])
662
663 script = "//tools_webrtc/ios/generate_umbrella_header.py"
664
665 outputs = [
666 umbrella_header_path,
667 ]
668 args = [
669 "--out",
670 rebase_path(umbrella_header_path, root_build_dir),
671 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200672 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100673 }
674
675 copy("copy_umbrella_header_$target_name") {
676 sources = [
677 umbrella_header_path,
678 ]
679 outputs = [
680 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
681 ]
682
683 deps = [
684 ":umbrella_header_$target_name",
685 ]
686 }
687 }
688
689 set_defaults("ios_framework_bundle_with_umbrella_header") {
690 configs = default_shared_library_configs
691 }
kthelgason4065a572017-02-14 04:58:56 -0800692}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000693
Anders Carlsson37bbf792018-09-05 16:29:27 +0200694if (is_mac) {
695 template("mac_framework_bundle_with_umbrella_header") {
696 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200697 this_target_name = target_name
698 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200699
700 mac_framework_bundle(target_name) {
701 forward_variables_from(invoker, "*", [])
702
703 framework_version = "A"
704 framework_contents = [ "Headers" ]
705
706 ldflags = [
707 "-all_load",
708 "-install_name",
709 "@rpath/$output_name.framework/$output_name",
710 ]
711
712 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200713 ":copy_framework_headers_$this_target_name",
714 ":copy_umbrella_header_$this_target_name",
715 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200716 ]
717 }
718
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200719 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200720 forward_variables_from(invoker, [ "sources" ])
721
722 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200723 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200724 ]
725 }
726
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200727 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200728 forward_variables_from(invoker, [ "sources" ])
729
730 script = "//tools_webrtc/ios/generate_umbrella_header.py"
731
732 outputs = [
733 umbrella_header_path,
734 ]
735 args = [
736 "--out",
737 rebase_path(umbrella_header_path, root_build_dir),
738 "--sources",
739 ] + sources
740 }
741
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200742 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200743 sources = [
744 umbrella_header_path,
745 ]
746 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200747 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200748 ]
749
750 deps = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200751 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200752 ]
753 }
754 }
755}
756
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000757if (is_android) {
758 template("rtc_android_library") {
759 android_library(target_name) {
760 forward_variables_from(invoker,
761 "*",
762 [
763 "configs",
764 "public_configs",
765 "suppressed_configs",
766 "visibility",
767 ])
768
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100769 javac_args = []
770
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000771 # Treat warnings as errors.
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100772 javac_args += [ "-Werror" ]
773
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200774 # TODO(crbug.com/824679): Find out why this fails in Chromium
775 if (!build_with_chromium) {
776 javac_args += [
777 "-Xep:ParameterNotNullable:ERROR",
778 "-Xep:FieldMissingNullable:ERROR",
779 "-Xep:ReturnMissingNullable:ERROR",
780 ]
781 }
782
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100783 # Add any arguments defined by the invoker.
784 if (defined(invoker.javac_args)) {
785 javac_args += invoker.javac_args
786 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000787
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200788 if (!defined(deps)) {
789 deps = []
790 }
791 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
792
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000793 no_build_hooks = true
794 }
795 }
796
797 template("rtc_android_apk") {
798 android_apk(target_name) {
799 forward_variables_from(invoker,
800 "*",
801 [
802 "configs",
803 "public_configs",
804 "suppressed_configs",
805 "visibility",
806 ])
807
808 # Treat warnings as errors.
809 javac_args = [ "-Werror" ]
810
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200811 # TODO(crbug.com/824679): Find out why this fails in Chromium
812 if (!build_with_chromium) {
813 javac_args += [
814 "-Xep:ParameterNotNullable:ERROR",
815 "-Xep:FieldMissingNullable:ERROR",
816 "-Xep:ReturnMissingNullable:ERROR",
817 ]
818 }
819
820 if (!defined(deps)) {
821 deps = []
822 }
823 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
824
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000825 no_build_hooks = true
826 }
827 }
828
829 template("rtc_instrumentation_test_apk") {
830 instrumentation_test_apk(target_name) {
831 forward_variables_from(invoker,
832 "*",
833 [
834 "configs",
835 "public_configs",
836 "suppressed_configs",
837 "visibility",
838 ])
839
840 # Treat warnings as errors.
841 javac_args = [ "-Werror" ]
842
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200843 # TODO(crbug.com/824679): Find out why this fails in Chromium
844 if (!build_with_chromium) {
845 javac_args += [
846 "-Xep:ParameterNotNullable:ERROR",
847 "-Xep:FieldMissingNullable:ERROR",
848 "-Xep:ReturnMissingNullable:ERROR",
849 ]
850 }
851
852 if (!defined(deps)) {
853 deps = []
854 }
855 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
856
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000857 no_build_hooks = true
858 }
859 }
860}