blob: 150599f8e9fcee0fb2efa1edc44404c79c8a1706 [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" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800282
283set_defaults("rtc_test") {
284 configs = rtc_add_configs
285 suppressed_configs = []
286}
287
288set_defaults("rtc_source_set") {
289 configs = rtc_add_configs
290 suppressed_configs = []
291}
292
293set_defaults("rtc_executable") {
294 configs = rtc_add_configs
295 suppressed_configs = []
296}
297
298set_defaults("rtc_static_library") {
299 configs = rtc_add_configs
300 suppressed_configs = []
301}
302
303set_defaults("rtc_shared_library") {
304 configs = rtc_add_configs
305 suppressed_configs = []
306}
307
Per Kjellandera7f2d842018-01-10 15:54:53 +0000308webrtc_default_visibility = [ webrtc_root + "/*" ]
309if (build_with_chromium) {
310 # Allow Chromium's WebRTC overrides targets to bypass the regular
311 # visibility restrictions.
312 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
313}
314
Karl Wibergbb23c832018-04-22 19:55:00 +0200315# ---- Poisons ----
316#
317# The general idea is that some targets declare that they contain some
318# kind of poison, which makes it impossible for other targets to
319# depend on them (even transitively) unless they declare themselves
320# immune to that particular type of poison.
321#
322# Targets that *contain* poison of type foo should contain the line
323#
324# poisonous = [ "foo" ]
325#
326# and targets that *are immune but arent't themselves poisonous*
327# should contain
328#
329# allow_poison = [ "foo" ]
330#
331# This useful in cases where we have some large target or set of
332# targets and want to ensure that most other targets do not
333# transitively depend on them. For example, almost no high-level
334# target should depend on the audio codecs, since we want WebRTC users
335# to be able to inject any subset of them and actually end up with a
336# binary that doesn't include the codecs they didn't inject.
337#
338# Test-only targets (`testonly` set to true) and non-public targets
339# (`visibility` not containing "*") are automatically immune to all
340# types of poison.
341#
342# Here's the complete list of all types of poison. It must be kept in
343# 1:1 correspondence with the set of //:poison_* targets.
344#
345all_poison_types = [
346 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
347 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200348
349 # Software video codecs (VP8 and VP9 through libvpx).
350 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200351]
352
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000353absl_include_config = "//third_party/abseil-cpp:absl_include_config"
354absl_define_config = "//third_party/abseil-cpp:absl_define_config"
355
mbonadei9aa3f0a2017-01-24 06:58:22 -0800356template("rtc_test") {
357 test(target_name) {
358 forward_variables_from(invoker,
359 "*",
360 [
361 "configs",
362 "public_configs",
363 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200364 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800365 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100366
367 # Always override to public because when target_os is Android the `test`
368 # template can override it to [ "*" ] and we want to avoid conditional
369 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100370 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800371 configs += invoker.configs
372 configs -= rtc_remove_configs
373 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000374 public_configs = [
375 rtc_common_inherited_config,
376 absl_include_config,
377 absl_define_config,
378 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800379 if (defined(invoker.public_configs)) {
380 public_configs += invoker.public_configs
381 }
sakald7fdb802017-05-26 01:51:53 -0700382 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800383 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
384 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700385 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800386 }
387}
388
389template("rtc_source_set") {
390 source_set(target_name) {
391 forward_variables_from(invoker,
392 "*",
393 [
394 "configs",
395 "public_configs",
396 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200397 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800398 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200399 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000400 if (!defined(visibility)) {
401 visibility = webrtc_default_visibility
402 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200403
404 # What's your poison?
405 if (defined(testonly) && testonly) {
406 assert(!defined(poisonous))
407 assert(!defined(allow_poison))
408 } else {
409 if (!defined(poisonous)) {
410 poisonous = []
411 }
412 if (!defined(allow_poison)) {
413 allow_poison = []
414 }
415 if (!defined(assert_no_deps)) {
416 assert_no_deps = []
417 }
418 if (!defined(deps)) {
419 deps = []
420 }
421 foreach(p, poisonous) {
422 deps += [ webrtc_root + ":poison_" + p ]
423 }
424 foreach(poison_type, all_poison_types) {
425 allow_dep = true
426 foreach(v, visibility) {
427 if (v == "*") {
428 allow_dep = false
429 }
430 }
431 foreach(p, allow_poison + poisonous) {
432 if (p == poison_type) {
433 allow_dep = true
434 }
435 }
436 if (!allow_dep) {
437 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
438 }
439 }
440 }
441
Mirko Bonadei96ede162018-09-06 13:45:44 +0200442 if (!defined(testonly) || !testonly) {
443 configs += rtc_prod_configs
444 }
445
mbonadei9aa3f0a2017-01-24 06:58:22 -0800446 configs += invoker.configs
447 configs -= rtc_remove_configs
448 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000449 public_configs = [
450 rtc_common_inherited_config,
451 absl_include_config,
452 absl_define_config,
453 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800454 if (defined(invoker.public_configs)) {
455 public_configs += invoker.public_configs
456 }
457 }
458}
459
460template("rtc_executable") {
461 executable(target_name) {
462 forward_variables_from(invoker,
463 "*",
464 [
465 "deps",
466 "configs",
467 "public_configs",
468 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200469 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800470 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200471 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000472 if (!defined(visibility)) {
473 visibility = webrtc_default_visibility
474 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800475 configs += invoker.configs
476 configs -= rtc_remove_configs
477 configs -= invoker.suppressed_configs
Tom Anderson9614a312018-06-11 15:10:34 -0700478 deps = invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700479
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000480 public_configs = [
481 rtc_common_inherited_config,
482 absl_include_config,
483 absl_define_config,
484 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800485 if (defined(invoker.public_configs)) {
486 public_configs += invoker.public_configs
487 }
Mirko Bonadei9427f482018-08-28 14:39:27 +0200488 if (is_win) {
489 deps += [
490 # Give executables the default manifest on Windows (a no-op elsewhere).
491 "//build/win:default_exe_manifest",
492 ]
493 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800494 }
495}
496
497template("rtc_static_library") {
498 static_library(target_name) {
499 forward_variables_from(invoker,
500 "*",
501 [
502 "configs",
503 "public_configs",
504 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200505 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800506 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200507 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000508 if (!defined(visibility)) {
509 visibility = webrtc_default_visibility
510 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200511
512 # What's your poison?
513 if (defined(testonly) && testonly) {
514 assert(!defined(poisonous))
515 assert(!defined(allow_poison))
516 } else {
517 if (!defined(poisonous)) {
518 poisonous = []
519 }
520 if (!defined(allow_poison)) {
521 allow_poison = []
522 }
523 if (!defined(assert_no_deps)) {
524 assert_no_deps = []
525 }
526 if (!defined(deps)) {
527 deps = []
528 }
529 foreach(p, poisonous) {
530 deps += [ webrtc_root + ":poison_" + p ]
531 }
532 foreach(poison_type, all_poison_types) {
533 allow_dep = true
534 foreach(v, visibility) {
535 if (v == "*") {
536 allow_dep = false
537 }
538 }
539 foreach(p, allow_poison + poisonous) {
540 if (p == poison_type) {
541 allow_dep = true
542 }
543 }
544 if (!allow_dep) {
545 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
546 }
547 }
548 }
549
Mirko Bonadei96ede162018-09-06 13:45:44 +0200550 if (!defined(testonly) || !testonly) {
551 configs += rtc_prod_configs
552 }
553
mbonadei9aa3f0a2017-01-24 06:58:22 -0800554 configs += invoker.configs
555 configs -= rtc_remove_configs
556 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000557 public_configs = [
558 rtc_common_inherited_config,
559 absl_include_config,
560 absl_define_config,
561 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800562 if (defined(invoker.public_configs)) {
563 public_configs += invoker.public_configs
564 }
565 }
566}
567
568template("rtc_shared_library") {
569 shared_library(target_name) {
570 forward_variables_from(invoker,
571 "*",
572 [
573 "configs",
574 "public_configs",
575 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200576 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800577 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200578 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000579 if (!defined(visibility)) {
580 visibility = webrtc_default_visibility
581 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200582
583 # What's your poison?
584 if (defined(testonly) && testonly) {
585 assert(!defined(poisonous))
586 assert(!defined(allow_poison))
587 } else {
588 if (!defined(poisonous)) {
589 poisonous = []
590 }
591 if (!defined(allow_poison)) {
592 allow_poison = []
593 }
594 if (!defined(assert_no_deps)) {
595 assert_no_deps = []
596 }
597 if (!defined(deps)) {
598 deps = []
599 }
600 foreach(p, poisonous) {
601 deps += [ webrtc_root + ":poison_" + p ]
602 }
603 foreach(poison_type, all_poison_types) {
604 allow_dep = true
605 foreach(v, visibility) {
606 if (v == "*") {
607 allow_dep = false
608 }
609 }
610 foreach(p, allow_poison + poisonous) {
611 if (p == poison_type) {
612 allow_dep = true
613 }
614 }
615 if (!allow_dep) {
616 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
617 }
618 }
619 }
620
mbonadei9aa3f0a2017-01-24 06:58:22 -0800621 configs += invoker.configs
622 configs -= rtc_remove_configs
623 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000624 public_configs = [
625 rtc_common_inherited_config,
626 absl_include_config,
627 absl_define_config,
628 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800629 if (defined(invoker.public_configs)) {
630 public_configs += invoker.public_configs
631 }
632 }
633}
kthelgason4065a572017-02-14 04:58:56 -0800634
635if (is_ios) {
636 set_defaults("rtc_ios_xctest_test") {
637 configs = rtc_add_configs
638 suppressed_configs = []
639 }
640
641 template("rtc_ios_xctest_test") {
642 ios_xctest_test(target_name) {
643 forward_variables_from(invoker,
644 "*",
645 [
646 "configs",
647 "public_configs",
648 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200649 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800650 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200651 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000652 if (!defined(visibility)) {
653 visibility = webrtc_default_visibility
654 }
kthelgason4065a572017-02-14 04:58:56 -0800655 configs += invoker.configs
656 configs -= rtc_remove_configs
657 configs -= invoker.suppressed_configs
658 public_configs = [ rtc_common_inherited_config ]
659 if (defined(invoker.public_configs)) {
660 public_configs += invoker.public_configs
661 }
662 }
663 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100664
665 template("ios_framework_bundle_with_umbrella_header") {
666 forward_variables_from(invoker, [ "output_name" ])
667 umbrella_header_path =
668 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
669
670 ios_framework_bundle(target_name) {
671 forward_variables_from(invoker, "*", [])
672
673 deps += [ ":copy_umbrella_header_$target_name" ]
674 }
675
676 action("umbrella_header_$target_name") {
677 forward_variables_from(invoker, [ "public_headers" ])
678
679 script = "//tools_webrtc/ios/generate_umbrella_header.py"
680
681 outputs = [
682 umbrella_header_path,
683 ]
684 args = [
685 "--out",
686 rebase_path(umbrella_header_path, root_build_dir),
687 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200688 ] + public_headers
Anders Carlssondc6b4772018-01-15 13:31:03 +0100689 }
690
691 copy("copy_umbrella_header_$target_name") {
692 sources = [
693 umbrella_header_path,
694 ]
695 outputs = [
696 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
697 ]
698
699 deps = [
700 ":umbrella_header_$target_name",
701 ]
702 }
703 }
704
705 set_defaults("ios_framework_bundle_with_umbrella_header") {
706 configs = default_shared_library_configs
707 }
kthelgason4065a572017-02-14 04:58:56 -0800708}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000709
Anders Carlsson37bbf792018-09-05 16:29:27 +0200710if (is_mac) {
711 template("mac_framework_bundle_with_umbrella_header") {
712 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200713 this_target_name = target_name
714 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200715
716 mac_framework_bundle(target_name) {
717 forward_variables_from(invoker, "*", [])
718
719 framework_version = "A"
720 framework_contents = [ "Headers" ]
721
722 ldflags = [
723 "-all_load",
724 "-install_name",
725 "@rpath/$output_name.framework/$output_name",
726 ]
727
728 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200729 ":copy_framework_headers_$this_target_name",
730 ":copy_umbrella_header_$this_target_name",
731 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200732 ]
733 }
734
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200735 bundle_data("copy_framework_headers_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200736 forward_variables_from(invoker, [ "sources" ])
737
738 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200739 "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200740 ]
741 }
742
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200743 action("umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200744 forward_variables_from(invoker, [ "sources" ])
745
746 script = "//tools_webrtc/ios/generate_umbrella_header.py"
747
748 outputs = [
749 umbrella_header_path,
750 ]
751 args = [
752 "--out",
753 rebase_path(umbrella_header_path, root_build_dir),
754 "--sources",
755 ] + sources
756 }
757
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200758 bundle_data("copy_umbrella_header_$this_target_name") {
Anders Carlsson37bbf792018-09-05 16:29:27 +0200759 sources = [
760 umbrella_header_path,
761 ]
762 outputs = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200763 "{{bundle_contents_dir}}/Headers/$output_name.h",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200764 ]
765
766 deps = [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200767 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +0200768 ]
769 }
770 }
771}
772
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000773if (is_android) {
774 template("rtc_android_library") {
775 android_library(target_name) {
776 forward_variables_from(invoker,
777 "*",
778 [
779 "configs",
780 "public_configs",
781 "suppressed_configs",
782 "visibility",
783 ])
784
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100785 javac_args = []
786
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000787 # Treat warnings as errors.
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100788 javac_args += [ "-Werror" ]
789
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200790 # TODO(crbug.com/824679): Find out why this fails in Chromium
791 if (!build_with_chromium) {
792 javac_args += [
793 "-Xep:ParameterNotNullable:ERROR",
794 "-Xep:FieldMissingNullable:ERROR",
795 "-Xep:ReturnMissingNullable:ERROR",
796 ]
797 }
798
Sami Kalliomäkie7fac682018-03-20 16:32:49 +0100799 # Add any arguments defined by the invoker.
800 if (defined(invoker.javac_args)) {
801 javac_args += invoker.javac_args
802 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000803
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200804 if (!defined(deps)) {
805 deps = []
806 }
807 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
808
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000809 no_build_hooks = true
810 }
811 }
812
813 template("rtc_android_apk") {
814 android_apk(target_name) {
815 forward_variables_from(invoker,
816 "*",
817 [
818 "configs",
819 "public_configs",
820 "suppressed_configs",
821 "visibility",
822 ])
823
824 # Treat warnings as errors.
825 javac_args = [ "-Werror" ]
826
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200827 # TODO(crbug.com/824679): Find out why this fails in Chromium
828 if (!build_with_chromium) {
829 javac_args += [
830 "-Xep:ParameterNotNullable:ERROR",
831 "-Xep:FieldMissingNullable:ERROR",
832 "-Xep:ReturnMissingNullable:ERROR",
833 ]
834 }
835
836 if (!defined(deps)) {
837 deps = []
838 }
839 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
840
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000841 no_build_hooks = true
842 }
843 }
844
845 template("rtc_instrumentation_test_apk") {
846 instrumentation_test_apk(target_name) {
847 forward_variables_from(invoker,
848 "*",
849 [
850 "configs",
851 "public_configs",
852 "suppressed_configs",
853 "visibility",
854 ])
855
856 # Treat warnings as errors.
857 javac_args = [ "-Werror" ]
858
Sami Kalliomäkidc526512018-03-27 17:07:27 +0200859 # TODO(crbug.com/824679): Find out why this fails in Chromium
860 if (!build_with_chromium) {
861 javac_args += [
862 "-Xep:ParameterNotNullable:ERROR",
863 "-Xep:FieldMissingNullable:ERROR",
864 "-Xep:ReturnMissingNullable:ERROR",
865 ]
866 }
867
868 if (!defined(deps)) {
869 deps = []
870 }
871 deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
872
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000873 no_build_hooks = true
874 }
875 }
876}