blob: 986598b8316471581d01a46a1fb65705812a3465 [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.
8
9import("//build/config/arm.gni")
10import("//build/config/features.gni")
11import("//build/config/mips.gni")
12import("//build/config/sanitizers/sanitizers.gni")
ehmaldonado0d729b32017-02-10 01:38:23 -080013import("//build/config/ui.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -080014import("//build_overrides/build.gni")
15import("//testing/test.gni")
mbonadei96606272017-03-03 19:41:59 -080016
17if (!build_with_chromium && is_component_build) {
18 print("The Gn argument `is_component_build` is currently " +
19 "ignored for WebRTC builds.")
20 print("Component builds are supported by Chromium and the argument " +
21 "`is_component_build` makes it possible to create shared libraries " +
22 "instead of static libraries.")
23 print("If an app depends on WebRTC it makes sense to just depend on the " +
24 "WebRTC static library, so there is no difference between " +
25 "`is_component_build=true` and `is_component_build=false`.")
26 print(
27 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.md")
28 assert(!is_component_build, "Component builds are not supported in WebRTC.")
29}
30
kthelgason4065a572017-02-14 04:58:56 -080031if (is_ios) {
32 import("//build/config/ios/rules.gni")
33}
mbonadei9aa3f0a2017-01-24 06:58:22 -080034
35declare_args() {
Karl Wibergeb254b42017-11-01 15:08:12 +010036 # Include the iLBC audio codec?
37 rtc_include_ilbc = true
38
mbonadei9aa3f0a2017-01-24 06:58:22 -080039 # Disable this to avoid building the Opus audio codec.
40 rtc_include_opus = true
41
minyue2e03c662017-02-01 17:31:11 -080042 # Enable this if the Opus version upon which WebRTC is built supports direct
43 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020044 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080045
mbonadei9aa3f0a2017-01-24 06:58:22 -080046 # Enable this to let the Opus audio codec change complexity on the fly.
47 rtc_opus_variable_complexity = false
48
mbonadei9aa3f0a2017-01-24 06:58:22 -080049 # Used to specify an external Jsoncpp include path when not compiling the
50 # library that comes with WebRTC (i.e. rtc_build_json == 0).
51 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
52
53 # Used to specify an external OpenSSL include path when not compiling the
54 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
55 rtc_ssl_root = ""
56
57 # Selects fixed-point code where possible.
58 rtc_prefer_fixed_point = false
59
60 # Enables the use of protocol buffers for debug recordings.
61 rtc_enable_protobuf = true
62
63 # Disable the code for the intelligibility enhancer by default.
64 rtc_enable_intelligibility_enhancer = false
65
66 # Enable when an external authentication mechanism is used for performing
67 # packet authentication for RTP packets instead of libsrtp.
68 rtc_enable_external_auth = build_with_chromium
69
70 # Selects whether debug dumps for the audio processing module
71 # should be generated.
72 apm_debug_dump = false
73
74 # Set this to true to enable BWE test logging.
75 rtc_enable_bwe_test_logging = false
76
77 # Set this to disable building with support for SCTP data channels.
78 rtc_enable_sctp = true
79
Joachim Bauch93e91342017-12-07 01:25:53 +010080 # Set this to false to skip building examples.
81 rtc_build_examples = true
82
83 # Set this to false to skip building tools.
84 rtc_build_tools = true
85
mbonadei9aa3f0a2017-01-24 06:58:22 -080086 # Disable these to not build components which can be externally provided.
mbonadei9aa3f0a2017-01-24 06:58:22 -080087 rtc_build_json = true
mbonadei9aa3f0a2017-01-24 06:58:22 -080088 rtc_build_libsrtp = true
89 rtc_build_libvpx = true
90 rtc_libvpx_build_vp9 = true
mbonadei9aa3f0a2017-01-24 06:58:22 -080091 rtc_build_openmax_dl = true
92 rtc_build_opus = true
93 rtc_build_ssl = true
94 rtc_build_usrsctp = true
95
96 # Enable to use the Mozilla internal settings.
97 build_with_mozilla = false
98
99 rtc_enable_android_opensl = false
100
101 # Link-Time Optimizations.
102 # Executes code generation at link-time instead of compile-time.
103 # https://gcc.gnu.org/wiki/LinkTimeOptimization
104 rtc_use_lto = false
105
106 # Set to "func", "block", "edge" for coverage generation.
107 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
108 # It is recommend to set include_examples=0.
109 # Use llvm's sancov -html-report for human readable reports.
110 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
111 rtc_sanitize_coverage = ""
112
perkj650fdae2017-08-25 05:00:11 -0700113 # Links a default implementation of task queues to targets
114 # that depend on the target rtc_task_queue. Set to false to
115 # use an external implementation.
116 rtc_link_task_queue_impl = true
117
mbonadei9aa3f0a2017-01-24 06:58:22 -0800118 # Enable libevent task queues on platforms that support it.
perkj650fdae2017-08-25 05:00:11 -0700119 # rtc_link_task_queue_impl must be set to true for this to
120 # have an effect.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800121 if (is_win || is_mac || is_ios || is_nacl) {
122 rtc_enable_libevent = false
123 rtc_build_libevent = false
124 } else {
125 rtc_enable_libevent = true
126 rtc_build_libevent = true
127 }
128
129 if (current_cpu == "arm" || current_cpu == "arm64") {
130 rtc_prefer_fixed_point = true
131 }
132
133 if (!is_ios && (current_cpu != "arm" || arm_version >= 7) &&
134 current_cpu != "mips64el") {
135 rtc_use_openmax_dl = true
136 } else {
137 rtc_use_openmax_dl = false
138 }
139
140 # Determines whether NEON code will be built.
141 rtc_build_with_neon =
142 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
143
144 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
145 # all platforms except Android and iOS. Because FFmpeg can be built
146 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
147 # value that includes H.264, for example "Chrome". If FFmpeg is built without
148 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize. See
149 # also: |rtc_initialize_ffmpeg|.
150 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
151 # http://www.openh264.org, https://www.ffmpeg.org/
Oleh Prypind3070f42017-12-27 11:07:19 +0100152 rtc_use_h264 =
153 is_chrome_branded && proprietary_codecs && !is_android && !is_ios
mbonadei9aa3f0a2017-01-24 06:58:22 -0800154
mbonadei9aa3f0a2017-01-24 06:58:22 -0800155 # By default, use normal platform audio support or dummy audio, but don't
156 # use file-based audio playout and record.
157 rtc_use_dummy_audio_file_devices = false
158
henrika7be78832017-06-13 17:34:16 +0200159 # When set to true, replace the audio output with a sinus tone at 440Hz.
160 # The ADM will ask for audio data from WebRTC but instead of reading real
161 # audio samples from NetEQ, a sinus tone will be generated and replace the
162 # real audio samples.
163 rtc_audio_device_plays_sinus_tone = false
164
mbonadei9aa3f0a2017-01-24 06:58:22 -0800165 # When set to true, test targets will declare the files needed to run memcheck
166 # as data dependencies. This is to enable memcheck execution on swarming bots.
167 rtc_use_memcheck = false
168
169 # FFmpeg must be initialized for |H264DecoderImpl| to work. This can be done
170 # by WebRTC during |H264DecoderImpl::InitDecode| or externally. FFmpeg must
171 # only be initialized once. Projects that initialize FFmpeg externally, such
172 # as Chromium, must turn this flag off so that WebRTC does not also
173 # initialize.
174 rtc_initialize_ffmpeg = !build_with_chromium
175
176 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
177 # build environments, even if available for Chromium builds.
178 rtc_use_gtk = !build_with_chromium
179}
180
181# A second declare_args block, so that declarations within it can
182# depend on the possibly overridden variables in the first
183# declare_args block.
184declare_args() {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800185 rtc_restrict_logging = build_with_chromium
186
187 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
188 rtc_include_pulse_audio = !build_with_chromium
189
190 # Chromium uses its own IO handling, so the internal ADM is only built for
191 # standalone WebRTC.
192 rtc_include_internal_audio_device = !build_with_chromium
193
194 # Include tests in standalone checkout.
195 rtc_include_tests = !build_with_chromium
196}
197
198# Make it possible to provide custom locations for some libraries (move these
199# up into declare_args should we need to actually use them for the GN build).
200rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800201rtc_opus_dir = "//third_party/opus"
202
203# Desktop capturer is supported only on Windows, OSX and Linux.
ehmaldonado0d729b32017-02-10 01:38:23 -0800204rtc_desktop_capture_supported = is_win || is_mac || (is_linux && use_x11)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800205
206###############################################################################
207# Templates
208#
209
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200210# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800211# chromium.
212# We need absolute paths for all configs in templates as they are shared in
213# different subdirectories.
214webrtc_root = get_path_info(".", "abspath")
215
216# Global configuration that should be applied to all WebRTC targets.
217# You normally shouldn't need to include this in your target as it's
218# automatically included when using the rtc_* templates.
219# It sets defines, include paths and compilation warnings accordingly,
220# both for WebRTC stand-alone builds and for the scenario when WebRTC
221# native code is built as part of Chromium.
222rtc_common_configs = [ webrtc_root + ":common_config" ]
223
kthelgasonc0977102017-04-24 00:57:16 -0700224if (is_mac || is_ios) {
225 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
226}
227
mbonadei9aa3f0a2017-01-24 06:58:22 -0800228# Global public configuration that should be applied to all WebRTC targets. You
229# normally shouldn't need to include this in your target as it's automatically
230# included when using the rtc_* templates. It set the defines, include paths and
231# compilation warnings that should be propagated to dependents of the targets
232# depending on the target having this config.
233rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
234
235# Common configs to remove or add in all rtc targets.
236rtc_remove_configs = []
237rtc_add_configs = rtc_common_configs
238
239set_defaults("rtc_test") {
240 configs = rtc_add_configs
241 suppressed_configs = []
242}
243
244set_defaults("rtc_source_set") {
245 configs = rtc_add_configs
246 suppressed_configs = []
247}
248
249set_defaults("rtc_executable") {
250 configs = rtc_add_configs
251 suppressed_configs = []
252}
253
254set_defaults("rtc_static_library") {
255 configs = rtc_add_configs
256 suppressed_configs = []
257}
258
259set_defaults("rtc_shared_library") {
260 configs = rtc_add_configs
261 suppressed_configs = []
262}
263
264template("rtc_test") {
265 test(target_name) {
266 forward_variables_from(invoker,
267 "*",
268 [
269 "configs",
270 "public_configs",
271 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200272 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800273 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100274
275 # Always override to public because when target_os is Android the `test`
276 # template can override it to [ "*" ] and we want to avoid conditional
277 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100278 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800279 configs += invoker.configs
280 configs -= rtc_remove_configs
281 configs -= invoker.suppressed_configs
282 public_configs = [ rtc_common_inherited_config ]
283 if (defined(invoker.public_configs)) {
284 public_configs += invoker.public_configs
285 }
sakald7fdb802017-05-26 01:51:53 -0700286 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800287 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
288 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700289 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800290 }
291}
292
293template("rtc_source_set") {
294 source_set(target_name) {
295 forward_variables_from(invoker,
296 "*",
297 [
298 "configs",
299 "public_configs",
300 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200301 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800302 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200303 forward_variables_from(invoker, [ "visibility" ])
mbonadei9aa3f0a2017-01-24 06:58:22 -0800304 configs += invoker.configs
305 configs -= rtc_remove_configs
306 configs -= invoker.suppressed_configs
307 public_configs = [ rtc_common_inherited_config ]
308 if (defined(invoker.public_configs)) {
309 public_configs += invoker.public_configs
310 }
311 }
312}
313
314template("rtc_executable") {
315 executable(target_name) {
316 forward_variables_from(invoker,
317 "*",
318 [
319 "deps",
320 "configs",
321 "public_configs",
322 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200323 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800324 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200325 forward_variables_from(invoker, [ "visibility" ])
mbonadei9aa3f0a2017-01-24 06:58:22 -0800326 configs += invoker.configs
327 configs -= rtc_remove_configs
328 configs -= invoker.suppressed_configs
329 deps = [
thomasanderson7f52f082017-05-18 23:51:46 -0700330 "//build/config:exe_and_shlib_deps",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800331 ]
332 deps += invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700333
mbonadei9aa3f0a2017-01-24 06:58:22 -0800334 public_configs = [ rtc_common_inherited_config ]
335 if (defined(invoker.public_configs)) {
336 public_configs += invoker.public_configs
337 }
338 }
339}
340
341template("rtc_static_library") {
342 static_library(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 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200351 forward_variables_from(invoker, [ "visibility" ])
mbonadei9aa3f0a2017-01-24 06:58:22 -0800352 configs += invoker.configs
353 configs -= rtc_remove_configs
354 configs -= invoker.suppressed_configs
355 public_configs = [ rtc_common_inherited_config ]
356 if (defined(invoker.public_configs)) {
357 public_configs += invoker.public_configs
358 }
359 }
360}
361
362template("rtc_shared_library") {
363 shared_library(target_name) {
364 forward_variables_from(invoker,
365 "*",
366 [
367 "configs",
368 "public_configs",
369 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200370 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800371 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200372 forward_variables_from(invoker, [ "visibility" ])
mbonadei9aa3f0a2017-01-24 06:58:22 -0800373 configs += invoker.configs
374 configs -= rtc_remove_configs
375 configs -= invoker.suppressed_configs
376 public_configs = [ rtc_common_inherited_config ]
377 if (defined(invoker.public_configs)) {
378 public_configs += invoker.public_configs
379 }
380 }
381}
kthelgason4065a572017-02-14 04:58:56 -0800382
383if (is_ios) {
384 set_defaults("rtc_ios_xctest_test") {
385 configs = rtc_add_configs
386 suppressed_configs = []
387 }
388
389 template("rtc_ios_xctest_test") {
390 ios_xctest_test(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",
kthelgason4065a572017-02-14 04:58:56 -0800398 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200399 forward_variables_from(invoker, [ "visibility" ])
kthelgason4065a572017-02-14 04:58:56 -0800400 configs += invoker.configs
401 configs -= rtc_remove_configs
402 configs -= invoker.suppressed_configs
403 public_configs = [ rtc_common_inherited_config ]
404 if (defined(invoker.public_configs)) {
405 public_configs += invoker.public_configs
406 }
407 }
408 }
409}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000410
411if (is_android) {
412 template("rtc_android_library") {
413 android_library(target_name) {
414 forward_variables_from(invoker,
415 "*",
416 [
417 "configs",
418 "public_configs",
419 "suppressed_configs",
420 "visibility",
421 ])
422
423 # Treat warnings as errors.
424 javac_args = [ "-Werror" ]
425
426 # TODO(sakal): Fix build hooks crbug.com/webrtc/8168
427 no_build_hooks = true
428 }
429 }
430
431 template("rtc_android_apk") {
432 android_apk(target_name) {
433 forward_variables_from(invoker,
434 "*",
435 [
436 "configs",
437 "public_configs",
438 "suppressed_configs",
439 "visibility",
440 ])
441
442 # Treat warnings as errors.
443 javac_args = [ "-Werror" ]
444
445 # TODO(sakal): Fix build hooks crbug.com/webrtc/8168
446 no_build_hooks = true
447 }
448 }
449
450 template("rtc_instrumentation_test_apk") {
451 instrumentation_test_apk(target_name) {
452 forward_variables_from(invoker,
453 "*",
454 [
455 "configs",
456 "public_configs",
457 "suppressed_configs",
458 "visibility",
459 ])
460
461 # Treat warnings as errors.
462 javac_args = [ "-Werror" ]
463
464 # TODO(sakal): Fix build hooks crbug.com/webrtc/8168
465 no_build_hooks = true
466 }
467 }
468}