blob: dc0c7b5c0098e0a8348ae40380a2525477e49ce4 [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
Mirko Bonadei45157932018-09-17 11:34:58 +020057 # WARNING: This argument doesn't have any effect on the WebRTC build until
58 # https://webrtc-review.googlesource.com/c/src/+/100640 will land.
59 # Setting this to true will define
60 # WEBRTC_EXCLUDE_RUNTIME_ENABLED_FEATURES_DEFAULT which will tell the
61 # pre-processor to remove the default definition of symbols needed to use
62 # runtime_enabled_features. In that case a new implementation needs to be
63 # provided.
64 if (build_with_chromium) {
65 # When WebRTC is built as part of Chromium it should exclude the default
66 # implementation of runtime_enabled_features unless it is building for NACL or
67 # Chromecast.
68 rtc_exclude_runtime_enabled_features_default = !is_nacl && !is_chromecast
69 } else {
70 rtc_exclude_runtime_enabled_features_default = false
71 }
72
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070073 # Setting this to false will require the API user to pass in their own
74 # SSLCertificateVerifier to verify the certificates presented from a
75 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
76 rtc_builtin_ssl_root_certificates = true
77
Karl Wibergeb254b42017-11-01 15:08:12 +010078 # Include the iLBC audio codec?
79 rtc_include_ilbc = true
80
mbonadei9aa3f0a2017-01-24 06:58:22 -080081 # Disable this to avoid building the Opus audio codec.
82 rtc_include_opus = true
83
minyue2e03c662017-02-01 17:31:11 -080084 # Enable this if the Opus version upon which WebRTC is built supports direct
85 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020086 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080087
mbonadei9aa3f0a2017-01-24 06:58:22 -080088 # Enable this to let the Opus audio codec change complexity on the fly.
89 rtc_opus_variable_complexity = false
90
mbonadei9aa3f0a2017-01-24 06:58:22 -080091 # Used to specify an external Jsoncpp include path when not compiling the
92 # library that comes with WebRTC (i.e. rtc_build_json == 0).
93 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
94
95 # Used to specify an external OpenSSL include path when not compiling the
96 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
97 rtc_ssl_root = ""
98
99 # Selects fixed-point code where possible.
100 rtc_prefer_fixed_point = false
101
mbonadei9aa3f0a2017-01-24 06:58:22 -0800102 # Enable when an external authentication mechanism is used for performing
103 # packet authentication for RTP packets instead of libsrtp.
104 rtc_enable_external_auth = build_with_chromium
105
106 # Selects whether debug dumps for the audio processing module
107 # should be generated.
108 apm_debug_dump = false
109
110 # Set this to true to enable BWE test logging.
111 rtc_enable_bwe_test_logging = false
112
Joachim Bauch93e91342017-12-07 01:25:53 +0100113 # Set this to false to skip building examples.
114 rtc_build_examples = true
115
116 # Set this to false to skip building tools.
117 rtc_build_tools = true
118
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100119 # Set this to false to skip building code that requires X11.
120 rtc_use_x11 = use_x11
121
mbonadei9aa3f0a2017-01-24 06:58:22 -0800122 # Enable to use the Mozilla internal settings.
123 build_with_mozilla = false
124
henrika883d00f2018-03-16 10:09:49 +0100125 # Enable use of Android AAudio which requires Android SDK 26 or above and
126 # NDK r16 or above.
127 rtc_enable_android_aaudio = false
128
129 # TODO(henrika): can this flag be removed?
mbonadei9aa3f0a2017-01-24 06:58:22 -0800130 rtc_enable_android_opensl = false
131
132 # Link-Time Optimizations.
133 # Executes code generation at link-time instead of compile-time.
134 # https://gcc.gnu.org/wiki/LinkTimeOptimization
135 rtc_use_lto = false
136
137 # Set to "func", "block", "edge" for coverage generation.
138 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
139 # It is recommend to set include_examples=0.
140 # Use llvm's sancov -html-report for human readable reports.
141 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
142 rtc_sanitize_coverage = ""
143
perkj650fdae2017-08-25 05:00:11 -0700144 # Links a default implementation of task queues to targets
145 # that depend on the target rtc_task_queue. Set to false to
146 # use an external implementation.
147 rtc_link_task_queue_impl = true
148
mbonadei9aa3f0a2017-01-24 06:58:22 -0800149 if (current_cpu == "arm" || current_cpu == "arm64") {
150 rtc_prefer_fixed_point = true
151 }
152
mbonadei9aa3f0a2017-01-24 06:58:22 -0800153 # Determines whether NEON code will be built.
154 rtc_build_with_neon =
155 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
156
157 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
158 # all platforms except Android and iOS. Because FFmpeg can be built
159 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
160 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Sergey Silkinfe288eb2018-06-25 16:22:38 +0200161 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800162 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
163 # http://www.openh264.org, https://www.ffmpeg.org/
Patrik Höglund3bb11942018-03-16 12:36:26 +0000164 rtc_use_h264 = proprietary_codecs && !is_android && !is_ios
mbonadei9aa3f0a2017-01-24 06:58:22 -0800165
mbonadei9aa3f0a2017-01-24 06:58:22 -0800166 # By default, use normal platform audio support or dummy audio, but don't
167 # use file-based audio playout and record.
168 rtc_use_dummy_audio_file_devices = false
169
henrika7be78832017-06-13 17:34:16 +0200170 # When set to true, replace the audio output with a sinus tone at 440Hz.
171 # The ADM will ask for audio data from WebRTC but instead of reading real
172 # audio samples from NetEQ, a sinus tone will be generated and replace the
173 # real audio samples.
174 rtc_audio_device_plays_sinus_tone = false
175
Anders Carlssondd8c1652018-01-30 10:32:13 +0100176 # Disable this to build without support for built-in software codecs.
177 rtc_use_builtin_sw_codecs = true
Anders Carlsson358f2e02018-06-04 10:24:37 +0200178
179 if (is_ios) {
180 # Build broadcast extension in AppRTCMobile for iOS. This results in the
181 # binary only running on iOS 11+, which is why it is disabled by default.
182 rtc_apprtcmobile_broadcast_extension = false
183 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200184
185 # Determines whether Metal is available on iOS/macOS.
186 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
Dan Minor9c686132018-01-15 10:20:00 -0500187}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800188
Dan Minor9c686132018-01-15 10:20:00 -0500189if (!build_with_mozilla) {
190 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800191}
192
193# A second declare_args block, so that declarations within it can
194# depend on the possibly overridden variables in the first
195# declare_args block.
196declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500197 # Enables the use of protocol buffers for debug recordings.
198 rtc_enable_protobuf = !build_with_mozilla
199
200 # Set this to disable building with support for SCTP data channels.
201 rtc_enable_sctp = !build_with_mozilla
202
203 # Disable these to not build components which can be externally provided.
204 rtc_build_json = !build_with_mozilla
205 rtc_build_libsrtp = !build_with_mozilla
206 rtc_build_libvpx = !build_with_mozilla
207 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500208 rtc_build_opus = !build_with_mozilla
209 rtc_build_ssl = !build_with_mozilla
210 rtc_build_usrsctp = !build_with_mozilla
211
212 # Enable libevent task queues on platforms that support it.
213 # rtc_link_task_queue_impl must be set to true for this to
214 # have an effect.
Wez00cecb92018-02-09 10:41:00 -0800215 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) {
Dan Minor9c686132018-01-15 10:20:00 -0500216 rtc_enable_libevent = false
217 rtc_build_libevent = false
218 } else {
219 rtc_enable_libevent = true
220 rtc_build_libevent = !build_with_mozilla
221 }
222
Dan Minor9c686132018-01-15 10:20:00 -0500223 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
224 # build environments, even if available for Chromium builds.
225 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
226
mbonadei9aa3f0a2017-01-24 06:58:22 -0800227 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
228 rtc_include_pulse_audio = !build_with_chromium
229
230 # Chromium uses its own IO handling, so the internal ADM is only built for
231 # standalone WebRTC.
232 rtc_include_internal_audio_device = !build_with_chromium
233
234 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500235 rtc_include_tests = !build_with_chromium && !build_with_mozilla
mbonadei9aa3f0a2017-01-24 06:58:22 -0800236}
237
238# Make it possible to provide custom locations for some libraries (move these
239# up into declare_args should we need to actually use them for the GN build).
240rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800241rtc_opus_dir = "//third_party/opus"
242
243# Desktop capturer is supported only on Windows, OSX and Linux.
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100244rtc_desktop_capture_supported = is_win || is_mac || (is_linux && rtc_use_x11)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800245
246###############################################################################
247# Templates
248#
249
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200250# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800251# chromium.
252# We need absolute paths for all configs in templates as they are shared in
253# different subdirectories.
254webrtc_root = get_path_info(".", "abspath")
255
256# Global configuration that should be applied to all WebRTC targets.
257# You normally shouldn't need to include this in your target as it's
258# automatically included when using the rtc_* templates.
259# It sets defines, include paths and compilation warnings accordingly,
260# both for WebRTC stand-alone builds and for the scenario when WebRTC
261# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700262rtc_common_configs = [
263 webrtc_root + ":common_config",
264 "//build/config/compiler:no_size_t_to_int_warning",
265]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800266
kthelgasonc0977102017-04-24 00:57:16 -0700267if (is_mac || is_ios) {
268 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
269}
270
mbonadei9aa3f0a2017-01-24 06:58:22 -0800271# Global public configuration that should be applied to all WebRTC targets. You
272# normally shouldn't need to include this in your target as it's automatically
273# included when using the rtc_* templates. It set the defines, include paths and
274# compilation warnings that should be propagated to dependents of the targets
275# depending on the target having this config.
276rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
277
278# Common configs to remove or add in all rtc targets.
279rtc_remove_configs = []
280rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200281rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200282rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800283
284set_defaults("rtc_test") {
285 configs = rtc_add_configs
286 suppressed_configs = []
287}
288
289set_defaults("rtc_source_set") {
290 configs = rtc_add_configs
291 suppressed_configs = []
292}
293
294set_defaults("rtc_executable") {
295 configs = rtc_add_configs
296 suppressed_configs = []
297}
298
299set_defaults("rtc_static_library") {
300 configs = rtc_add_configs
301 suppressed_configs = []
302}
303
304set_defaults("rtc_shared_library") {
305 configs = rtc_add_configs
306 suppressed_configs = []
307}
308
Per Kjellandera7f2d842018-01-10 15:54:53 +0000309webrtc_default_visibility = [ webrtc_root + "/*" ]
310if (build_with_chromium) {
311 # Allow Chromium's WebRTC overrides targets to bypass the regular
312 # visibility restrictions.
313 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
314}
315
Karl Wibergbb23c832018-04-22 19:55:00 +0200316# ---- Poisons ----
317#
318# The general idea is that some targets declare that they contain some
319# kind of poison, which makes it impossible for other targets to
320# depend on them (even transitively) unless they declare themselves
321# immune to that particular type of poison.
322#
323# Targets that *contain* poison of type foo should contain the line
324#
325# poisonous = [ "foo" ]
326#
327# and targets that *are immune but arent't themselves poisonous*
328# should contain
329#
330# allow_poison = [ "foo" ]
331#
332# This useful in cases where we have some large target or set of
333# targets and want to ensure that most other targets do not
334# transitively depend on them. For example, almost no high-level
335# target should depend on the audio codecs, since we want WebRTC users
336# to be able to inject any subset of them and actually end up with a
337# binary that doesn't include the codecs they didn't inject.
338#
339# Test-only targets (`testonly` set to true) and non-public targets
340# (`visibility` not containing "*") are automatically immune to all
341# types of poison.
342#
343# Here's the complete list of all types of poison. It must be kept in
344# 1:1 correspondence with the set of //:poison_* targets.
345#
346all_poison_types = [
347 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
348 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200349
350 # Software video codecs (VP8 and VP9 through libvpx).
351 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200352]
353
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000354absl_include_config = "//third_party/abseil-cpp:absl_include_config"
355absl_define_config = "//third_party/abseil-cpp:absl_define_config"
356
mbonadei9aa3f0a2017-01-24 06:58:22 -0800357template("rtc_test") {
358 test(target_name) {
359 forward_variables_from(invoker,
360 "*",
361 [
362 "configs",
363 "public_configs",
364 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200365 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800366 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100367
368 # Always override to public because when target_os is Android the `test`
369 # template can override it to [ "*" ] and we want to avoid conditional
370 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100371 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800372 configs += invoker.configs
373 configs -= rtc_remove_configs
374 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000375 public_configs = [
376 rtc_common_inherited_config,
377 absl_include_config,
378 absl_define_config,
379 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800380 if (defined(invoker.public_configs)) {
381 public_configs += invoker.public_configs
382 }
sakald7fdb802017-05-26 01:51:53 -0700383 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800384 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
385 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700386 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800387 }
388}
389
390template("rtc_source_set") {
391 source_set(target_name) {
392 forward_variables_from(invoker,
393 "*",
394 [
395 "configs",
396 "public_configs",
397 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200398 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800399 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200400 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000401 if (!defined(visibility)) {
402 visibility = webrtc_default_visibility
403 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200404
405 # What's your poison?
406 if (defined(testonly) && testonly) {
407 assert(!defined(poisonous))
408 assert(!defined(allow_poison))
409 } else {
410 if (!defined(poisonous)) {
411 poisonous = []
412 }
413 if (!defined(allow_poison)) {
414 allow_poison = []
415 }
416 if (!defined(assert_no_deps)) {
417 assert_no_deps = []
418 }
419 if (!defined(deps)) {
420 deps = []
421 }
422 foreach(p, poisonous) {
423 deps += [ webrtc_root + ":poison_" + p ]
424 }
425 foreach(poison_type, all_poison_types) {
426 allow_dep = true
427 foreach(v, visibility) {
428 if (v == "*") {
429 allow_dep = false
430 }
431 }
432 foreach(p, allow_poison + poisonous) {
433 if (p == poison_type) {
434 allow_dep = true
435 }
436 }
437 if (!allow_dep) {
438 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
439 }
440 }
441 }
442
Mirko Bonadei96ede162018-09-06 13:45:44 +0200443 if (!defined(testonly) || !testonly) {
444 configs += rtc_prod_configs
445 }
446
mbonadei9aa3f0a2017-01-24 06:58:22 -0800447 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200448 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800449 configs -= rtc_remove_configs
450 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000451 public_configs = [
452 rtc_common_inherited_config,
453 absl_include_config,
454 absl_define_config,
455 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800456 if (defined(invoker.public_configs)) {
457 public_configs += invoker.public_configs
458 }
459 }
460}
461
462template("rtc_executable") {
463 executable(target_name) {
464 forward_variables_from(invoker,
465 "*",
466 [
467 "deps",
468 "configs",
469 "public_configs",
470 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200471 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800472 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200473 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000474 if (!defined(visibility)) {
475 visibility = webrtc_default_visibility
476 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800477 configs += invoker.configs
478 configs -= rtc_remove_configs
479 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700480 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700481
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000482 public_configs = [
483 rtc_common_inherited_config,
484 absl_include_config,
485 absl_define_config,
486 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800487 if (defined(invoker.public_configs)) {
488 public_configs += invoker.public_configs
489 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200490 if (is_win) {
491 deps += [
492 # Give executables the default manifest on Windows (a no-op elsewhere).
493 "//build/win:default_exe_manifest",
494 ]
495 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800496 }
497}
498
499template("rtc_static_library") {
500 static_library(target_name) {
501 forward_variables_from(invoker,
502 "*",
503 [
504 "configs",
505 "public_configs",
506 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200507 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800508 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200509 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000510 if (!defined(visibility)) {
511 visibility = webrtc_default_visibility
512 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200513
514 # What's your poison?
515 if (defined(testonly) && testonly) {
516 assert(!defined(poisonous))
517 assert(!defined(allow_poison))
518 } else {
519 if (!defined(poisonous)) {
520 poisonous = []
521 }
522 if (!defined(allow_poison)) {
523 allow_poison = []
524 }
525 if (!defined(assert_no_deps)) {
526 assert_no_deps = []
527 }
528 if (!defined(deps)) {
529 deps = []
530 }
531 foreach(p, poisonous) {
532 deps += [ webrtc_root + ":poison_" + p ]
533 }
534 foreach(poison_type, all_poison_types) {
535 allow_dep = true
536 foreach(v, visibility) {
537 if (v == "*") {
538 allow_dep = false
539 }
540 }
541 foreach(p, allow_poison + poisonous) {
542 if (p == poison_type) {
543 allow_dep = true
544 }
545 }
546 if (!allow_dep) {
547 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
548 }
549 }
550 }
551
Mirko Bonadei96ede162018-09-06 13:45:44 +0200552 if (!defined(testonly) || !testonly) {
553 configs += rtc_prod_configs
554 }
555
mbonadei9aa3f0a2017-01-24 06:58:22 -0800556 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200557 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800558 configs -= rtc_remove_configs
559 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000560 public_configs = [
561 rtc_common_inherited_config,
562 absl_include_config,
563 absl_define_config,
564 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800565 if (defined(invoker.public_configs)) {
566 public_configs += invoker.public_configs
567 }
568 }
569}
570
571template("rtc_shared_library") {
572 shared_library(target_name) {
573 forward_variables_from(invoker,
574 "*",
575 [
576 "configs",
577 "public_configs",
578 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200579 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800580 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200581 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000582 if (!defined(visibility)) {
583 visibility = webrtc_default_visibility
584 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200585
586 # What's your poison?
587 if (defined(testonly) && testonly) {
588 assert(!defined(poisonous))
589 assert(!defined(allow_poison))
590 } else {
591 if (!defined(poisonous)) {
592 poisonous = []
593 }
594 if (!defined(allow_poison)) {
595 allow_poison = []
596 }
597 if (!defined(assert_no_deps)) {
598 assert_no_deps = []
599 }
600 if (!defined(deps)) {
601 deps = []
602 }
603 foreach(p, poisonous) {
604 deps += [ webrtc_root + ":poison_" + p ]
605 }
606 foreach(poison_type, all_poison_types) {
607 allow_dep = true
608 foreach(v, visibility) {
609 if (v == "*") {
610 allow_dep = false
611 }
612 }
613 foreach(p, allow_poison + poisonous) {
614 if (p == poison_type) {
615 allow_dep = true
616 }
617 }
618 if (!allow_dep) {
619 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
620 }
621 }
622 }
623
mbonadei9aa3f0a2017-01-24 06:58:22 -0800624 configs += invoker.configs
625 configs -= rtc_remove_configs
626 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000627 public_configs = [
628 rtc_common_inherited_config,
629 absl_include_config,
630 absl_define_config,
631 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800632 if (defined(invoker.public_configs)) {
633 public_configs += invoker.public_configs
634 }
635 }
636}
kthelgason4065a572017-02-14 04:58:56 -0800637
638if (is_ios) {
639 set_defaults("rtc_ios_xctest_test") {
640 configs = rtc_add_configs
641 suppressed_configs = []
642 }
643
644 template("rtc_ios_xctest_test") {
645 ios_xctest_test(target_name) {
646 forward_variables_from(invoker,
647 "*",
648 [
649 "configs",
650 "public_configs",
651 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200652 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800653 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200654 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000655 if (!defined(visibility)) {
656 visibility = webrtc_default_visibility
657 }
kthelgason4065a572017-02-14 04:58:56 -0800658 configs += invoker.configs
659 configs -= rtc_remove_configs
660 configs -= invoker.suppressed_configs
661 public_configs = [ rtc_common_inherited_config ]
662 if (defined(invoker.public_configs)) {
663 public_configs += invoker.public_configs
664 }
665 }
666 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100667
668 template("ios_framework_bundle_with_umbrella_header") {
669 forward_variables_from(invoker, [ "output_name" ])
670 umbrella_header_path =
671 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
672
673 ios_framework_bundle(target_name) {
674 forward_variables_from(invoker, "*", [])
675
676 deps += [ ":copy_umbrella_header_$target_name" ]
677 }
678
679 action("umbrella_header_$target_name") {
680 forward_variables_from(invoker, [ "public_headers" ])
681
682 script = "//tools_webrtc/ios/generate_umbrella_header.py"
683
684 outputs = [
685 umbrella_header_path,
686 ]
687 args = [
688 "--out",
689 rebase_path(umbrella_header_path, root_build_dir),
690 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200691 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100692 }
693
694 copy("copy_umbrella_header_$target_name") {
695 sources = [
696 umbrella_header_path,
697 ]
698 outputs = [
699 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
700 ]
701
702 deps = [
703 ":umbrella_header_$target_name",
704 ]
705 }
706 }
707
708 set_defaults("ios_framework_bundle_with_umbrella_header") {
709 configs = default_shared_library_configs
710 }
kthelgason4065a572017-02-14 04:58:56 -0800711}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000712
Anders Carlsson37bbf792018-09-05 16:29:27 +0200713if (is_mac) {
714 template("mac_framework_bundle_with_umbrella_header") {
715 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200716 this_target_name = target_name
717 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200718
719 mac_framework_bundle(target_name) {
720 forward_variables_from(invoker, "*", [])
721
722 framework_version = "A"
723 framework_contents = [ "Headers" ]
724
725 ldflags = [
726 "-all_load",
727 "-install_name",
728 "@rpath/$output_name.framework/$output_name",
729 ]
730
731 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200732 ":copy_framework_headers_$this_target_name",
733 ":copy_umbrella_header_$this_target_name",
734 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200735 ]
736 }
737
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200738 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200739 forward_variables_from(invoker, [ "sources" ])
740
741 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200742 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200743 ]
744 }
745
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200746 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200747 forward_variables_from(invoker, [ "sources" ])
748
749 script = "//tools_webrtc/ios/generate_umbrella_header.py"
750
751 outputs = [
752 umbrella_header_path,
753 ]
754 args = [
755 "--out",
756 rebase_path(umbrella_header_path, root_build_dir),
757 "--sources",
758 ] + sources
759 }
760
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200761 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200762 sources = [
763 umbrella_header_path,
764 ]
765 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200766 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200767 ]
768
769 deps = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200770 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200771 ]
772 }
773 }
774}
775
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000776if (is_android) {
777 template("rtc_android_library") {
778 android_library(target_name) {
779 forward_variables_from(invoker,
780 "*",
781 [
782 "configs",
783 "public_configs",
784 "suppressed_configs",
785 "visibility",
786 ])
787
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100788 javac_args = []
789
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000790 # Treat warnings as errors.
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100791 javac_args += [ "-Werror" ]
792
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200793 # TODO(crbug.com/824679): Find out why this fails in Chromium
794 if (!build_with_chromium) {
795 javac_args += [
796 "-Xep:ParameterNotNullable:ERROR",
797 "-Xep:FieldMissingNullable:ERROR",
798 "-Xep:ReturnMissingNullable:ERROR",
799 ]
800 }
801
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100802 # Add any arguments defined by the invoker.
803 if (defined(invoker.javac_args)) {
804 javac_args += invoker.javac_args
805 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000806
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200807 if (!defined(deps)) {
808 deps = []
809 }
810 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
811
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000812 no_build_hooks = true
813 }
814 }
815
816 template("rtc_android_apk") {
817 android_apk(target_name) {
818 forward_variables_from(invoker,
819 "*",
820 [
821 "configs",
822 "public_configs",
823 "suppressed_configs",
824 "visibility",
825 ])
826
827 # Treat warnings as errors.
828 javac_args = [ "-Werror" ]
829
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200830 # TODO(crbug.com/824679): Find out why this fails in Chromium
831 if (!build_with_chromium) {
832 javac_args += [
833 "-Xep:ParameterNotNullable:ERROR",
834 "-Xep:FieldMissingNullable:ERROR",
835 "-Xep:ReturnMissingNullable:ERROR",
836 ]
837 }
838
839 if (!defined(deps)) {
840 deps = []
841 }
842 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
843
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000844 no_build_hooks = true
845 }
846 }
847
848 template("rtc_instrumentation_test_apk") {
849 instrumentation_test_apk(target_name) {
850 forward_variables_from(invoker,
851 "*",
852 [
853 "configs",
854 "public_configs",
855 "suppressed_configs",
856 "visibility",
857 ])
858
859 # Treat warnings as errors.
860 javac_args = [ "-Werror" ]
861
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200862 # TODO(crbug.com/824679): Find out why this fails in Chromium
863 if (!build_with_chromium) {
864 javac_args += [
865 "-Xep:ParameterNotNullable:ERROR",
866 "-Xep:FieldMissingNullable:ERROR",
867 "-Xep:ReturnMissingNullable:ERROR",
868 ]
869 }
870
871 if (!defined(deps)) {
872 deps = []
873 }
874 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
875
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000876 no_build_hooks = true
877 }
878 }
879}