blob: fb1d77cadfcfa74ff6e589f7acde42f44a02b439 [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
33declare_args() {
Karl Wibergeb254b42017-11-01 15:08:12 +010034 # Include the iLBC audio codec?
35 rtc_include_ilbc = true
36
mbonadei9aa3f0a2017-01-24 06:58:22 -080037 # Disable this to avoid building the Opus audio codec.
38 rtc_include_opus = true
39
minyue2e03c662017-02-01 17:31:11 -080040 # Enable this if the Opus version upon which WebRTC is built supports direct
41 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020042 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080043
mbonadei9aa3f0a2017-01-24 06:58:22 -080044 # Enable this to let the Opus audio codec change complexity on the fly.
45 rtc_opus_variable_complexity = false
46
mbonadei9aa3f0a2017-01-24 06:58:22 -080047 # Used to specify an external Jsoncpp include path when not compiling the
48 # library that comes with WebRTC (i.e. rtc_build_json == 0).
49 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
50
51 # Used to specify an external OpenSSL include path when not compiling the
52 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
53 rtc_ssl_root = ""
54
55 # Selects fixed-point code where possible.
56 rtc_prefer_fixed_point = false
57
mbonadei9aa3f0a2017-01-24 06:58:22 -080058 # Disable the code for the intelligibility enhancer by default.
59 rtc_enable_intelligibility_enhancer = false
60
61 # Enable when an external authentication mechanism is used for performing
62 # packet authentication for RTP packets instead of libsrtp.
63 rtc_enable_external_auth = build_with_chromium
64
65 # Selects whether debug dumps for the audio processing module
66 # should be generated.
67 apm_debug_dump = false
68
69 # Set this to true to enable BWE test logging.
70 rtc_enable_bwe_test_logging = false
71
Joachim Bauch93e91342017-12-07 01:25:53 +010072 # Set this to false to skip building examples.
73 rtc_build_examples = true
74
75 # Set this to false to skip building tools.
76 rtc_build_tools = true
77
Joachim Bauch75f18fc2017-12-20 21:25:47 +010078 # Set this to false to skip building code that requires X11.
79 rtc_use_x11 = use_x11
80
mbonadei9aa3f0a2017-01-24 06:58:22 -080081 # Enable to use the Mozilla internal settings.
82 build_with_mozilla = false
83
84 rtc_enable_android_opensl = false
85
86 # Link-Time Optimizations.
87 # Executes code generation at link-time instead of compile-time.
88 # https://gcc.gnu.org/wiki/LinkTimeOptimization
89 rtc_use_lto = false
90
91 # Set to "func", "block", "edge" for coverage generation.
92 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
93 # It is recommend to set include_examples=0.
94 # Use llvm's sancov -html-report for human readable reports.
95 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
96 rtc_sanitize_coverage = ""
97
perkj650fdae2017-08-25 05:00:11 -070098 # Links a default implementation of task queues to targets
99 # that depend on the target rtc_task_queue. Set to false to
100 # use an external implementation.
101 rtc_link_task_queue_impl = true
102
mbonadei9aa3f0a2017-01-24 06:58:22 -0800103 if (current_cpu == "arm" || current_cpu == "arm64") {
104 rtc_prefer_fixed_point = true
105 }
106
mbonadei9aa3f0a2017-01-24 06:58:22 -0800107 # Determines whether NEON code will be built.
108 rtc_build_with_neon =
109 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
110
111 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
112 # all platforms except Android and iOS. Because FFmpeg can be built
113 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
114 # value that includes H.264, for example "Chrome". If FFmpeg is built without
115 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize. See
116 # also: |rtc_initialize_ffmpeg|.
117 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
118 # http://www.openh264.org, https://www.ffmpeg.org/
Oleh Prypind3070f42017-12-27 11:07:19 +0100119 rtc_use_h264 =
120 is_chrome_branded && proprietary_codecs && !is_android && !is_ios
mbonadei9aa3f0a2017-01-24 06:58:22 -0800121
mbonadei9aa3f0a2017-01-24 06:58:22 -0800122 # By default, use normal platform audio support or dummy audio, but don't
123 # use file-based audio playout and record.
124 rtc_use_dummy_audio_file_devices = false
125
henrika7be78832017-06-13 17:34:16 +0200126 # When set to true, replace the audio output with a sinus tone at 440Hz.
127 # The ADM will ask for audio data from WebRTC but instead of reading real
128 # audio samples from NetEQ, a sinus tone will be generated and replace the
129 # real audio samples.
130 rtc_audio_device_plays_sinus_tone = false
131
mbonadei9aa3f0a2017-01-24 06:58:22 -0800132 # When set to true, test targets will declare the files needed to run memcheck
133 # as data dependencies. This is to enable memcheck execution on swarming bots.
134 rtc_use_memcheck = false
135
136 # FFmpeg must be initialized for |H264DecoderImpl| to work. This can be done
137 # by WebRTC during |H264DecoderImpl::InitDecode| or externally. FFmpeg must
138 # only be initialized once. Projects that initialize FFmpeg externally, such
139 # as Chromium, must turn this flag off so that WebRTC does not also
140 # initialize.
141 rtc_initialize_ffmpeg = !build_with_chromium
Dan Minor9c686132018-01-15 10:20:00 -0500142}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800143
Dan Minor9c686132018-01-15 10:20:00 -0500144if (!build_with_mozilla) {
145 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800146}
147
148# A second declare_args block, so that declarations within it can
149# depend on the possibly overridden variables in the first
150# declare_args block.
151declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500152 # Enables the use of protocol buffers for debug recordings.
153 rtc_enable_protobuf = !build_with_mozilla
154
155 # Set this to disable building with support for SCTP data channels.
156 rtc_enable_sctp = !build_with_mozilla
157
158 # Disable these to not build components which can be externally provided.
159 rtc_build_json = !build_with_mozilla
160 rtc_build_libsrtp = !build_with_mozilla
161 rtc_build_libvpx = !build_with_mozilla
162 rtc_libvpx_build_vp9 = !build_with_mozilla
163 rtc_build_openmax_dl = !build_with_mozilla
164 rtc_build_opus = !build_with_mozilla
165 rtc_build_ssl = !build_with_mozilla
166 rtc_build_usrsctp = !build_with_mozilla
167
168 # Enable libevent task queues on platforms that support it.
169 # rtc_link_task_queue_impl must be set to true for this to
170 # have an effect.
171 if (is_win || is_mac || is_ios || is_nacl) {
172 rtc_enable_libevent = false
173 rtc_build_libevent = false
174 } else {
175 rtc_enable_libevent = true
176 rtc_build_libevent = !build_with_mozilla
177 }
178
179 if (!is_ios && (current_cpu != "arm" || arm_version >= 7) &&
180 current_cpu != "mips64el" && !build_with_mozilla) {
181 rtc_use_openmax_dl = true
182 } else {
183 rtc_use_openmax_dl = false
184 }
185
186 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
187 # build environments, even if available for Chromium builds.
188 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
189
190 rtc_restrict_logging = build_with_chromium || build_with_mozilla
mbonadei9aa3f0a2017-01-24 06:58:22 -0800191
192 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
193 rtc_include_pulse_audio = !build_with_chromium
194
195 # Chromium uses its own IO handling, so the internal ADM is only built for
196 # standalone WebRTC.
197 rtc_include_internal_audio_device = !build_with_chromium
198
199 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500200 rtc_include_tests = !build_with_chromium && !build_with_mozilla
mbonadei9aa3f0a2017-01-24 06:58:22 -0800201}
202
203# Make it possible to provide custom locations for some libraries (move these
204# up into declare_args should we need to actually use them for the GN build).
205rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800206rtc_opus_dir = "//third_party/opus"
207
208# Desktop capturer is supported only on Windows, OSX and Linux.
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100209rtc_desktop_capture_supported = is_win || is_mac || (is_linux && rtc_use_x11)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800210
211###############################################################################
212# Templates
213#
214
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200215# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800216# chromium.
217# We need absolute paths for all configs in templates as they are shared in
218# different subdirectories.
219webrtc_root = get_path_info(".", "abspath")
220
221# Global configuration that should be applied to all WebRTC targets.
222# You normally shouldn't need to include this in your target as it's
223# automatically included when using the rtc_* templates.
224# It sets defines, include paths and compilation warnings accordingly,
225# both for WebRTC stand-alone builds and for the scenario when WebRTC
226# native code is built as part of Chromium.
227rtc_common_configs = [ webrtc_root + ":common_config" ]
228
kthelgasonc0977102017-04-24 00:57:16 -0700229if (is_mac || is_ios) {
230 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
231}
232
mbonadei9aa3f0a2017-01-24 06:58:22 -0800233# Global public configuration that should be applied to all WebRTC targets. You
234# normally shouldn't need to include this in your target as it's automatically
235# included when using the rtc_* templates. It set the defines, include paths and
236# compilation warnings that should be propagated to dependents of the targets
237# depending on the target having this config.
238rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
239
240# Common configs to remove or add in all rtc targets.
241rtc_remove_configs = []
242rtc_add_configs = rtc_common_configs
243
244set_defaults("rtc_test") {
245 configs = rtc_add_configs
246 suppressed_configs = []
247}
248
249set_defaults("rtc_source_set") {
250 configs = rtc_add_configs
251 suppressed_configs = []
252}
253
254set_defaults("rtc_executable") {
255 configs = rtc_add_configs
256 suppressed_configs = []
257}
258
259set_defaults("rtc_static_library") {
260 configs = rtc_add_configs
261 suppressed_configs = []
262}
263
264set_defaults("rtc_shared_library") {
265 configs = rtc_add_configs
266 suppressed_configs = []
267}
268
Per Kjellandera7f2d842018-01-10 15:54:53 +0000269webrtc_default_visibility = [ webrtc_root + "/*" ]
270if (build_with_chromium) {
271 # Allow Chromium's WebRTC overrides targets to bypass the regular
272 # visibility restrictions.
273 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
274}
275
mbonadei9aa3f0a2017-01-24 06:58:22 -0800276template("rtc_test") {
277 test(target_name) {
278 forward_variables_from(invoker,
279 "*",
280 [
281 "configs",
282 "public_configs",
283 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200284 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800285 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100286
287 # Always override to public because when target_os is Android the `test`
288 # template can override it to [ "*" ] and we want to avoid conditional
289 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100290 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800291 configs += invoker.configs
292 configs -= rtc_remove_configs
293 configs -= invoker.suppressed_configs
294 public_configs = [ rtc_common_inherited_config ]
295 if (defined(invoker.public_configs)) {
296 public_configs += invoker.public_configs
297 }
sakald7fdb802017-05-26 01:51:53 -0700298 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800299 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
300 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700301 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800302 }
303}
304
305template("rtc_source_set") {
306 source_set(target_name) {
307 forward_variables_from(invoker,
308 "*",
309 [
310 "configs",
311 "public_configs",
312 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200313 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800314 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200315 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000316 if (!defined(visibility)) {
317 visibility = webrtc_default_visibility
318 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800319 configs += invoker.configs
320 configs -= rtc_remove_configs
321 configs -= invoker.suppressed_configs
322 public_configs = [ rtc_common_inherited_config ]
323 if (defined(invoker.public_configs)) {
324 public_configs += invoker.public_configs
325 }
326 }
327}
328
329template("rtc_executable") {
330 executable(target_name) {
331 forward_variables_from(invoker,
332 "*",
333 [
334 "deps",
335 "configs",
336 "public_configs",
337 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200338 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800339 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200340 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000341 if (!defined(visibility)) {
342 visibility = webrtc_default_visibility
343 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800344 configs += invoker.configs
345 configs -= rtc_remove_configs
346 configs -= invoker.suppressed_configs
347 deps = [
thomasanderson7f52f082017-05-18 23:51:46 -0700348 "//build/config:exe_and_shlib_deps",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800349 ]
350 deps += invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700351
mbonadei9aa3f0a2017-01-24 06:58:22 -0800352 public_configs = [ rtc_common_inherited_config ]
353 if (defined(invoker.public_configs)) {
354 public_configs += invoker.public_configs
355 }
356 }
357}
358
359template("rtc_static_library") {
360 static_library(target_name) {
361 forward_variables_from(invoker,
362 "*",
363 [
364 "configs",
365 "public_configs",
366 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200367 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800368 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200369 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000370 if (!defined(visibility)) {
371 visibility = webrtc_default_visibility
372 }
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}
382
383template("rtc_shared_library") {
384 shared_library(target_name) {
385 forward_variables_from(invoker,
386 "*",
387 [
388 "configs",
389 "public_configs",
390 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200391 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800392 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200393 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000394 if (!defined(visibility)) {
395 visibility = webrtc_default_visibility
396 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800397 configs += invoker.configs
398 configs -= rtc_remove_configs
399 configs -= invoker.suppressed_configs
400 public_configs = [ rtc_common_inherited_config ]
401 if (defined(invoker.public_configs)) {
402 public_configs += invoker.public_configs
403 }
404 }
405}
kthelgason4065a572017-02-14 04:58:56 -0800406
407if (is_ios) {
408 set_defaults("rtc_ios_xctest_test") {
409 configs = rtc_add_configs
410 suppressed_configs = []
411 }
412
413 template("rtc_ios_xctest_test") {
414 ios_xctest_test(target_name) {
415 forward_variables_from(invoker,
416 "*",
417 [
418 "configs",
419 "public_configs",
420 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200421 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800422 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200423 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000424 if (!defined(visibility)) {
425 visibility = webrtc_default_visibility
426 }
kthelgason4065a572017-02-14 04:58:56 -0800427 configs += invoker.configs
428 configs -= rtc_remove_configs
429 configs -= invoker.suppressed_configs
430 public_configs = [ rtc_common_inherited_config ]
431 if (defined(invoker.public_configs)) {
432 public_configs += invoker.public_configs
433 }
434 }
435 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100436
437 template("ios_framework_bundle_with_umbrella_header") {
438 forward_variables_from(invoker, [ "output_name" ])
439 umbrella_header_path =
440 "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
441
442 ios_framework_bundle(target_name) {
443 forward_variables_from(invoker, "*", [])
444
445 deps += [ ":copy_umbrella_header_$target_name" ]
446 }
447
448 action("umbrella_header_$target_name") {
449 forward_variables_from(invoker, [ "public_headers" ])
450
451 script = "//tools_webrtc/ios/generate_umbrella_header.py"
452
453 outputs = [
454 umbrella_header_path,
455 ]
456 args = [
457 "--out",
458 rebase_path(umbrella_header_path, root_build_dir),
459 "--sources",
460 ] + rebase_path(public_headers, "objc/Framework/Headers/")
461 }
462
463 copy("copy_umbrella_header_$target_name") {
464 sources = [
465 umbrella_header_path,
466 ]
467 outputs = [
468 "$root_out_dir/$output_name.framework/Headers/$output_name.h",
469 ]
470
471 deps = [
472 ":umbrella_header_$target_name",
473 ]
474 }
475 }
476
477 set_defaults("ios_framework_bundle_with_umbrella_header") {
478 configs = default_shared_library_configs
479 }
kthelgason4065a572017-02-14 04:58:56 -0800480}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000481
482if (is_android) {
483 template("rtc_android_library") {
484 android_library(target_name) {
485 forward_variables_from(invoker,
486 "*",
487 [
488 "configs",
489 "public_configs",
490 "suppressed_configs",
491 "visibility",
492 ])
493
494 # Treat warnings as errors.
495 javac_args = [ "-Werror" ]
496
497 # TODO(sakal): Fix build hooks crbug.com/webrtc/8168
498 no_build_hooks = true
499 }
500 }
501
502 template("rtc_android_apk") {
503 android_apk(target_name) {
504 forward_variables_from(invoker,
505 "*",
506 [
507 "configs",
508 "public_configs",
509 "suppressed_configs",
510 "visibility",
511 ])
512
513 # Treat warnings as errors.
514 javac_args = [ "-Werror" ]
515
516 # TODO(sakal): Fix build hooks crbug.com/webrtc/8168
517 no_build_hooks = true
518 }
519 }
520
521 template("rtc_instrumentation_test_apk") {
522 instrumentation_test_apk(target_name) {
523 forward_variables_from(invoker,
524 "*",
525 [
526 "configs",
527 "public_configs",
528 "suppressed_configs",
529 "visibility",
530 ])
531
532 # Treat warnings as errors.
533 javac_args = [ "-Werror" ]
534
535 # TODO(sakal): Fix build hooks crbug.com/webrtc/8168
536 no_build_hooks = true
537 }
538 }
539}