blob: 71c830e2bca15032b6e477b7ce1ab97f9e7f091b [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" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200266rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800267
268set_defaults("rtc_test") {
269 configs = rtc_add_configs
270 suppressed_configs = []
271}
272
273set_defaults("rtc_source_set") {
274 configs = rtc_add_configs
275 suppressed_configs = []
276}
277
278set_defaults("rtc_executable") {
279 configs = rtc_add_configs
280 suppressed_configs = []
281}
282
283set_defaults("rtc_static_library") {
284 configs = rtc_add_configs
285 suppressed_configs = []
286}
287
288set_defaults("rtc_shared_library") {
289 configs = rtc_add_configs
290 suppressed_configs = []
291}
292
Per Kjellandera7f2d842018-01-10 15:54:53 +0000293webrtc_default_visibility = [ webrtc_root + "/*" ]
294if (build_with_chromium) {
295 # Allow Chromium's WebRTC overrides targets to bypass the regular
296 # visibility restrictions.
297 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
298}
299
Karl Wibergbb23c832018-04-22 19:55:00 +0200300# ---- Poisons ----
301#
302# The general idea is that some targets declare that they contain some
303# kind of poison, which makes it impossible for other targets to
304# depend on them (even transitively) unless they declare themselves
305# immune to that particular type of poison.
306#
307# Targets that *contain* poison of type foo should contain the line
308#
309# poisonous = [ "foo" ]
310#
311# and targets that *are immune but arent't themselves poisonous*
312# should contain
313#
314# allow_poison = [ "foo" ]
315#
316# This useful in cases where we have some large target or set of
317# targets and want to ensure that most other targets do not
318# transitively depend on them. For example, almost no high-level
319# target should depend on the audio codecs, since we want WebRTC users
320# to be able to inject any subset of them and actually end up with a
321# binary that doesn't include the codecs they didn't inject.
322#
323# Test-only targets (`testonly` set to true) and non-public targets
324# (`visibility` not containing "*") are automatically immune to all
325# types of poison.
326#
327# Here's the complete list of all types of poison. It must be kept in
328# 1:1 correspondence with the set of //:poison_* targets.
329#
330all_poison_types = [
331 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
332 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200333
334 # Software video codecs (VP8 and VP9 through libvpx).
335 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200336]
337
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000338absl_include_config = "//third_party/abseil-cpp:absl_include_config"
339absl_define_config = "//third_party/abseil-cpp:absl_define_config"
340
mbonadei9aa3f0a2017-01-24 06:58:22 -0800341template("rtc_test") {
342 test(target_name) {
343 forward_variables_from(invoker,
344 "*",
345 [
346 "configs",
347 "public_configs",
348 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200349 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800350 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100351
352 # Always override to public because when target_os is Android the `test`
353 # template can override it to [ "*" ] and we want to avoid conditional
354 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100355 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800356 configs += invoker.configs
357 configs -= rtc_remove_configs
358 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000359 public_configs = [
360 rtc_common_inherited_config,
361 absl_include_config,
362 absl_define_config,
363 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800364 if (defined(invoker.public_configs)) {
365 public_configs += invoker.public_configs
366 }
sakald7fdb802017-05-26 01:51:53 -0700367 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800368 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
369 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700370 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800371 }
372}
373
374template("rtc_source_set") {
375 source_set(target_name) {
376 forward_variables_from(invoker,
377 "*",
378 [
379 "configs",
380 "public_configs",
381 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200382 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800383 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200384 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000385 if (!defined(visibility)) {
386 visibility = webrtc_default_visibility
387 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200388
389 # What's your poison?
390 if (defined(testonly) && testonly) {
391 assert(!defined(poisonous))
392 assert(!defined(allow_poison))
393 } else {
394 if (!defined(poisonous)) {
395 poisonous = []
396 }
397 if (!defined(allow_poison)) {
398 allow_poison = []
399 }
400 if (!defined(assert_no_deps)) {
401 assert_no_deps = []
402 }
403 if (!defined(deps)) {
404 deps = []
405 }
406 foreach(p, poisonous) {
407 deps += [ webrtc_root + ":poison_" + p ]
408 }
409 foreach(poison_type, all_poison_types) {
410 allow_dep = true
411 foreach(v, visibility) {
412 if (v == "*") {
413 allow_dep = false
414 }
415 }
416 foreach(p, allow_poison + poisonous) {
417 if (p == poison_type) {
418 allow_dep = true
419 }
420 }
421 if (!allow_dep) {
422 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
423 }
424 }
425 }
426
Mirko Bonadei96ede162018-09-06 13:45:44 +0200427 if (!defined(testonly) || !testonly) {
428 configs += rtc_prod_configs
429 }
430
mbonadei9aa3f0a2017-01-24 06:58:22 -0800431 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200432 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800433 configs -= rtc_remove_configs
434 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000435 public_configs = [
436 rtc_common_inherited_config,
437 absl_include_config,
438 absl_define_config,
439 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800440 if (defined(invoker.public_configs)) {
441 public_configs += invoker.public_configs
442 }
443 }
444}
445
446template("rtc_executable") {
447 executable(target_name) {
448 forward_variables_from(invoker,
449 "*",
450 [
451 "deps",
452 "configs",
453 "public_configs",
454 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200455 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800456 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200457 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000458 if (!defined(visibility)) {
459 visibility = webrtc_default_visibility
460 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800461 configs += invoker.configs
462 configs -= rtc_remove_configs
463 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700464 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700465
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000466 public_configs = [
467 rtc_common_inherited_config,
468 absl_include_config,
469 absl_define_config,
470 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800471 if (defined(invoker.public_configs)) {
472 public_configs += invoker.public_configs
473 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200474 if (is_win) {
475 deps += [
476 # Give executables the default manifest on Windows (a no-op elsewhere).
477 "//build/win:default_exe_manifest",
478 ]
479 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800480 }
481}
482
483template("rtc_static_library") {
484 static_library(target_name) {
485 forward_variables_from(invoker,
486 "*",
487 [
488 "configs",
489 "public_configs",
490 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200491 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800492 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200493 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000494 if (!defined(visibility)) {
495 visibility = webrtc_default_visibility
496 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200497
498 # What's your poison?
499 if (defined(testonly) && testonly) {
500 assert(!defined(poisonous))
501 assert(!defined(allow_poison))
502 } else {
503 if (!defined(poisonous)) {
504 poisonous = []
505 }
506 if (!defined(allow_poison)) {
507 allow_poison = []
508 }
509 if (!defined(assert_no_deps)) {
510 assert_no_deps = []
511 }
512 if (!defined(deps)) {
513 deps = []
514 }
515 foreach(p, poisonous) {
516 deps += [ webrtc_root + ":poison_" + p ]
517 }
518 foreach(poison_type, all_poison_types) {
519 allow_dep = true
520 foreach(v, visibility) {
521 if (v == "*") {
522 allow_dep = false
523 }
524 }
525 foreach(p, allow_poison + poisonous) {
526 if (p == poison_type) {
527 allow_dep = true
528 }
529 }
530 if (!allow_dep) {
531 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
532 }
533 }
534 }
535
Mirko Bonadei96ede162018-09-06 13:45:44 +0200536 if (!defined(testonly) || !testonly) {
537 configs += rtc_prod_configs
538 }
539
mbonadei9aa3f0a2017-01-24 06:58:22 -0800540 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200541 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800542 configs -= rtc_remove_configs
543 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000544 public_configs = [
545 rtc_common_inherited_config,
546 absl_include_config,
547 absl_define_config,
548 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800549 if (defined(invoker.public_configs)) {
550 public_configs += invoker.public_configs
551 }
552 }
553}
554
555template("rtc_shared_library") {
556 shared_library(target_name) {
557 forward_variables_from(invoker,
558 "*",
559 [
560 "configs",
561 "public_configs",
562 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200563 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800564 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200565 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000566 if (!defined(visibility)) {
567 visibility = webrtc_default_visibility
568 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200569
570 # What's your poison?
571 if (defined(testonly) && testonly) {
572 assert(!defined(poisonous))
573 assert(!defined(allow_poison))
574 } else {
575 if (!defined(poisonous)) {
576 poisonous = []
577 }
578 if (!defined(allow_poison)) {
579 allow_poison = []
580 }
581 if (!defined(assert_no_deps)) {
582 assert_no_deps = []
583 }
584 if (!defined(deps)) {
585 deps = []
586 }
587 foreach(p, poisonous) {
588 deps += [ webrtc_root + ":poison_" + p ]
589 }
590 foreach(poison_type, all_poison_types) {
591 allow_dep = true
592 foreach(v, visibility) {
593 if (v == "*") {
594 allow_dep = false
595 }
596 }
597 foreach(p, allow_poison + poisonous) {
598 if (p == poison_type) {
599 allow_dep = true
600 }
601 }
602 if (!allow_dep) {
603 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
604 }
605 }
606 }
607
mbonadei9aa3f0a2017-01-24 06:58:22 -0800608 configs += invoker.configs
609 configs -= rtc_remove_configs
610 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000611 public_configs = [
612 rtc_common_inherited_config,
613 absl_include_config,
614 absl_define_config,
615 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800616 if (defined(invoker.public_configs)) {
617 public_configs += invoker.public_configs
618 }
619 }
620}
kthelgason4065a572017-02-14 04:58:56 -0800621
622if (is_ios) {
623 set_defaults("rtc_ios_xctest_test") {
624 configs = rtc_add_configs
625 suppressed_configs = []
626 }
627
628 template("rtc_ios_xctest_test") {
629 ios_xctest_test(target_name) {
630 forward_variables_from(invoker,
631 "*",
632 [
633 "configs",
634 "public_configs",
635 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200636 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800637 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200638 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000639 if (!defined(visibility)) {
640 visibility = webrtc_default_visibility
641 }
kthelgason4065a572017-02-14 04:58:56 -0800642 configs += invoker.configs
643 configs -= rtc_remove_configs
644 configs -= invoker.suppressed_configs
645 public_configs = [ rtc_common_inherited_config ]
646 if (defined(invoker.public_configs)) {
647 public_configs += invoker.public_configs
648 }
649 }
650 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100651
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400652 # TODO: Generate module.modulemap file to enable use in Swift
653 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100654 template("ios_framework_bundle_with_umbrella_header") {
655 forward_variables_from(invoker, [ "output_name" ])
656 umbrella_header_path =
657 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
658
659 ios_framework_bundle(target_name) {
660 forward_variables_from(invoker, "*", [])
661
662 deps += [ ":copy_umbrella_header_$target_name" ]
663 }
664
665 action("umbrella_header_$target_name") {
666 forward_variables_from(invoker, [ "public_headers" ])
667
668 script = "//tools_webrtc/ios/generate_umbrella_header.py"
669
670 outputs = [
671 umbrella_header_path,
672 ]
673 args = [
674 "--out",
675 rebase_path(umbrella_header_path, root_build_dir),
676 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200677 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100678 }
679
680 copy("copy_umbrella_header_$target_name") {
681 sources = [
682 umbrella_header_path,
683 ]
684 outputs = [
685 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
686 ]
687
688 deps = [
689 ":umbrella_header_$target_name",
690 ]
691 }
692 }
693
694 set_defaults("ios_framework_bundle_with_umbrella_header") {
695 configs = default_shared_library_configs
696 }
kthelgason4065a572017-02-14 04:58:56 -0800697}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000698
Anders Carlsson37bbf792018-09-05 16:29:27 +0200699if (is_mac) {
700 template("mac_framework_bundle_with_umbrella_header") {
701 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200702 this_target_name = target_name
703 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400704 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200705
706 mac_framework_bundle(target_name) {
707 forward_variables_from(invoker, "*", [])
708
709 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400710 framework_contents = [
711 "Headers",
712 "Modules",
713 "Resources",
714 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +0200715
716 ldflags = [
717 "-all_load",
718 "-install_name",
719 "@rpath/$output_name.framework/$output_name",
720 ]
721
722 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200723 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400724 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200725 ":copy_umbrella_header_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400726 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200727 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200728 ]
729 }
730
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200731 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200732 forward_variables_from(invoker, [ "sources" ])
733
734 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200735 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200736 ]
737 }
738
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400739 action("modulemap_$this_target_name") {
740 script = "//tools_webrtc/ios/generate_modulemap.py"
741 args = [
742 "--out",
743 rebase_path(modulemap_path, root_build_dir),
744 "--name",
745 output_name,
746 ]
747 outputs = [
748 modulemap_path,
749 ]
750 }
751
752 bundle_data("copy_modulemap_$this_target_name") {
753 sources = [
754 modulemap_path,
755 ]
756 outputs = [
757 "{{bundle_contents_dir}}/Modules/module.modulemap",
758 ]
759 deps = [
760 ":modulemap_$this_target_name",
761 ]
762 }
763
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200764 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200765 forward_variables_from(invoker, [ "sources" ])
766
767 script = "//tools_webrtc/ios/generate_umbrella_header.py"
768
769 outputs = [
770 umbrella_header_path,
771 ]
772 args = [
773 "--out",
774 rebase_path(umbrella_header_path, root_build_dir),
775 "--sources",
776 ] + sources
777 }
778
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200779 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200780 sources = [
781 umbrella_header_path,
782 ]
783 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200784 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200785 ]
786
787 deps = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200788 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200789 ]
790 }
791 }
792}
793
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000794if (is_android) {
795 template("rtc_android_library") {
796 android_library(target_name) {
797 forward_variables_from(invoker,
798 "*",
799 [
800 "configs",
801 "public_configs",
802 "suppressed_configs",
803 "visibility",
804 ])
805
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100806 javac_args = []
807
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000808 # Treat warnings as errors.
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100809 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
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100820 # Add any arguments defined by the invoker.
821 if (defined(invoker.javac_args)) {
822 javac_args += invoker.javac_args
823 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000824
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200825 if (!defined(deps)) {
826 deps = []
827 }
828 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
829
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000830 no_build_hooks = true
831 }
832 }
833
834 template("rtc_android_apk") {
835 android_apk(target_name) {
836 forward_variables_from(invoker,
837 "*",
838 [
839 "configs",
840 "public_configs",
841 "suppressed_configs",
842 "visibility",
843 ])
844
845 # Treat warnings as errors.
846 javac_args = [ "-Werror" ]
847
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200848 # TODO(crbug.com/824679): Find out why this fails in Chromium
849 if (!build_with_chromium) {
850 javac_args += [
851 "-Xep:ParameterNotNullable:ERROR",
852 "-Xep:FieldMissingNullable:ERROR",
853 "-Xep:ReturnMissingNullable:ERROR",
854 ]
855 }
856
857 if (!defined(deps)) {
858 deps = []
859 }
860 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
861
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000862 no_build_hooks = true
863 }
864 }
865
866 template("rtc_instrumentation_test_apk") {
867 instrumentation_test_apk(target_name) {
868 forward_variables_from(invoker,
869 "*",
870 [
871 "configs",
872 "public_configs",
873 "suppressed_configs",
874 "visibility",
875 ])
876
877 # Treat warnings as errors.
878 javac_args = [ "-Werror" ]
879
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200880 # TODO(crbug.com/824679): Find out why this fails in Chromium
881 if (!build_with_chromium) {
882 javac_args += [
883 "-Xep:ParameterNotNullable:ERROR",
884 "-Xep:FieldMissingNullable:ERROR",
885 "-Xep:ReturnMissingNullable:ERROR",
886 ]
887 }
888
889 if (!defined(deps)) {
890 deps = []
891 }
892 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
893
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000894 no_build_hooks = true
895 }
896 }
897}