blob: b8ceb8e0f0e1591cead330134bed01d16f273b88 [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
Joachim Bauch75f18fc2017-12-20 21:25:47 +010086 # Set this to false to skip building code that requires X11.
87 rtc_use_x11 = use_x11
88
mbonadei9aa3f0a2017-01-24 06:58:22 -080089 # Disable these to not build components which can be externally provided.
mbonadei9aa3f0a2017-01-24 06:58:22 -080090 rtc_build_json = true
mbonadei9aa3f0a2017-01-24 06:58:22 -080091 rtc_build_libsrtp = true
92 rtc_build_libvpx = true
93 rtc_libvpx_build_vp9 = true
mbonadei9aa3f0a2017-01-24 06:58:22 -080094 rtc_build_openmax_dl = true
95 rtc_build_opus = true
96 rtc_build_ssl = true
97 rtc_build_usrsctp = true
98
99 # Enable to use the Mozilla internal settings.
100 build_with_mozilla = false
101
102 rtc_enable_android_opensl = false
103
104 # Link-Time Optimizations.
105 # Executes code generation at link-time instead of compile-time.
106 # https://gcc.gnu.org/wiki/LinkTimeOptimization
107 rtc_use_lto = false
108
109 # Set to "func", "block", "edge" for coverage generation.
110 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
111 # It is recommend to set include_examples=0.
112 # Use llvm's sancov -html-report for human readable reports.
113 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
114 rtc_sanitize_coverage = ""
115
perkj650fdae2017-08-25 05:00:11 -0700116 # Links a default implementation of task queues to targets
117 # that depend on the target rtc_task_queue. Set to false to
118 # use an external implementation.
119 rtc_link_task_queue_impl = true
120
mbonadei9aa3f0a2017-01-24 06:58:22 -0800121 # Enable libevent task queues on platforms that support it.
perkj650fdae2017-08-25 05:00:11 -0700122 # rtc_link_task_queue_impl must be set to true for this to
123 # have an effect.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800124 if (is_win || is_mac || is_ios || is_nacl) {
125 rtc_enable_libevent = false
126 rtc_build_libevent = false
127 } else {
128 rtc_enable_libevent = true
129 rtc_build_libevent = true
130 }
131
132 if (current_cpu == "arm" || current_cpu == "arm64") {
133 rtc_prefer_fixed_point = true
134 }
135
136 if (!is_ios && (current_cpu != "arm" || arm_version >= 7) &&
137 current_cpu != "mips64el") {
138 rtc_use_openmax_dl = true
139 } else {
140 rtc_use_openmax_dl = false
141 }
142
143 # Determines whether NEON code will be built.
144 rtc_build_with_neon =
145 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
146
147 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
148 # all platforms except Android and iOS. Because FFmpeg can be built
149 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
150 # value that includes H.264, for example "Chrome". If FFmpeg is built without
151 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize. See
152 # also: |rtc_initialize_ffmpeg|.
153 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
154 # http://www.openh264.org, https://www.ffmpeg.org/
Oleh Prypind3070f42017-12-27 11:07:19 +0100155 rtc_use_h264 =
156 is_chrome_branded && proprietary_codecs && !is_android && !is_ios
mbonadei9aa3f0a2017-01-24 06:58:22 -0800157
mbonadei9aa3f0a2017-01-24 06:58:22 -0800158 # By default, use normal platform audio support or dummy audio, but don't
159 # use file-based audio playout and record.
160 rtc_use_dummy_audio_file_devices = false
161
henrika7be78832017-06-13 17:34:16 +0200162 # When set to true, replace the audio output with a sinus tone at 440Hz.
163 # The ADM will ask for audio data from WebRTC but instead of reading real
164 # audio samples from NetEQ, a sinus tone will be generated and replace the
165 # real audio samples.
166 rtc_audio_device_plays_sinus_tone = false
167
mbonadei9aa3f0a2017-01-24 06:58:22 -0800168 # When set to true, test targets will declare the files needed to run memcheck
169 # as data dependencies. This is to enable memcheck execution on swarming bots.
170 rtc_use_memcheck = false
171
172 # FFmpeg must be initialized for |H264DecoderImpl| to work. This can be done
173 # by WebRTC during |H264DecoderImpl::InitDecode| or externally. FFmpeg must
174 # only be initialized once. Projects that initialize FFmpeg externally, such
175 # as Chromium, must turn this flag off so that WebRTC does not also
176 # initialize.
177 rtc_initialize_ffmpeg = !build_with_chromium
178
179 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
180 # build environments, even if available for Chromium builds.
181 rtc_use_gtk = !build_with_chromium
182}
183
184# A second declare_args block, so that declarations within it can
185# depend on the possibly overridden variables in the first
186# declare_args block.
187declare_args() {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800188 rtc_restrict_logging = build_with_chromium
189
190 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
191 rtc_include_pulse_audio = !build_with_chromium
192
193 # Chromium uses its own IO handling, so the internal ADM is only built for
194 # standalone WebRTC.
195 rtc_include_internal_audio_device = !build_with_chromium
196
197 # Include tests in standalone checkout.
198 rtc_include_tests = !build_with_chromium
199}
200
201# Make it possible to provide custom locations for some libraries (move these
202# up into declare_args should we need to actually use them for the GN build).
203rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800204rtc_opus_dir = "//third_party/opus"
205
206# Desktop capturer is supported only on Windows, OSX and Linux.
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100207rtc_desktop_capture_supported = is_win || is_mac || (is_linux && rtc_use_x11)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800208
209###############################################################################
210# Templates
211#
212
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200213# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800214# chromium.
215# We need absolute paths for all configs in templates as they are shared in
216# different subdirectories.
217webrtc_root = get_path_info(".", "abspath")
218
219# Global configuration that should be applied to all WebRTC targets.
220# You normally shouldn't need to include this in your target as it's
221# automatically included when using the rtc_* templates.
222# It sets defines, include paths and compilation warnings accordingly,
223# both for WebRTC stand-alone builds and for the scenario when WebRTC
224# native code is built as part of Chromium.
225rtc_common_configs = [ webrtc_root + ":common_config" ]
226
kthelgasonc0977102017-04-24 00:57:16 -0700227if (is_mac || is_ios) {
228 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
229}
230
mbonadei9aa3f0a2017-01-24 06:58:22 -0800231# Global public configuration that should be applied to all WebRTC targets. You
232# normally shouldn't need to include this in your target as it's automatically
233# included when using the rtc_* templates. It set the defines, include paths and
234# compilation warnings that should be propagated to dependents of the targets
235# depending on the target having this config.
236rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
237
238# Common configs to remove or add in all rtc targets.
239rtc_remove_configs = []
240rtc_add_configs = rtc_common_configs
241
242set_defaults("rtc_test") {
243 configs = rtc_add_configs
244 suppressed_configs = []
245}
246
247set_defaults("rtc_source_set") {
248 configs = rtc_add_configs
249 suppressed_configs = []
250}
251
252set_defaults("rtc_executable") {
253 configs = rtc_add_configs
254 suppressed_configs = []
255}
256
257set_defaults("rtc_static_library") {
258 configs = rtc_add_configs
259 suppressed_configs = []
260}
261
262set_defaults("rtc_shared_library") {
263 configs = rtc_add_configs
264 suppressed_configs = []
265}
266
267template("rtc_test") {
268 test(target_name) {
269 forward_variables_from(invoker,
270 "*",
271 [
272 "configs",
273 "public_configs",
274 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200275 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800276 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100277
278 # Always override to public because when target_os is Android the `test`
279 # template can override it to [ "*" ] and we want to avoid conditional
280 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100281 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800282 configs += invoker.configs
283 configs -= rtc_remove_configs
284 configs -= invoker.suppressed_configs
285 public_configs = [ rtc_common_inherited_config ]
286 if (defined(invoker.public_configs)) {
287 public_configs += invoker.public_configs
288 }
sakald7fdb802017-05-26 01:51:53 -0700289 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800290 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
291 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700292 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800293 }
294}
295
296template("rtc_source_set") {
297 source_set(target_name) {
298 forward_variables_from(invoker,
299 "*",
300 [
301 "configs",
302 "public_configs",
303 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200304 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800305 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200306 forward_variables_from(invoker, [ "visibility" ])
mbonadei9aa3f0a2017-01-24 06:58:22 -0800307 configs += invoker.configs
308 configs -= rtc_remove_configs
309 configs -= invoker.suppressed_configs
310 public_configs = [ rtc_common_inherited_config ]
311 if (defined(invoker.public_configs)) {
312 public_configs += invoker.public_configs
313 }
314 }
315}
316
317template("rtc_executable") {
318 executable(target_name) {
319 forward_variables_from(invoker,
320 "*",
321 [
322 "deps",
323 "configs",
324 "public_configs",
325 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200326 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800327 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200328 forward_variables_from(invoker, [ "visibility" ])
mbonadei9aa3f0a2017-01-24 06:58:22 -0800329 configs += invoker.configs
330 configs -= rtc_remove_configs
331 configs -= invoker.suppressed_configs
332 deps = [
thomasanderson7f52f082017-05-18 23:51:46 -0700333 "//build/config:exe_and_shlib_deps",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800334 ]
335 deps += invoker.deps
perkj650fdae2017-08-25 05:00:11 -0700336
mbonadei9aa3f0a2017-01-24 06:58:22 -0800337 public_configs = [ rtc_common_inherited_config ]
338 if (defined(invoker.public_configs)) {
339 public_configs += invoker.public_configs
340 }
341 }
342}
343
344template("rtc_static_library") {
345 static_library(target_name) {
346 forward_variables_from(invoker,
347 "*",
348 [
349 "configs",
350 "public_configs",
351 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200352 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800353 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200354 forward_variables_from(invoker, [ "visibility" ])
mbonadei9aa3f0a2017-01-24 06:58:22 -0800355 configs += invoker.configs
356 configs -= rtc_remove_configs
357 configs -= invoker.suppressed_configs
358 public_configs = [ rtc_common_inherited_config ]
359 if (defined(invoker.public_configs)) {
360 public_configs += invoker.public_configs
361 }
362 }
363}
364
365template("rtc_shared_library") {
366 shared_library(target_name) {
367 forward_variables_from(invoker,
368 "*",
369 [
370 "configs",
371 "public_configs",
372 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200373 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800374 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200375 forward_variables_from(invoker, [ "visibility" ])
mbonadei9aa3f0a2017-01-24 06:58:22 -0800376 configs += invoker.configs
377 configs -= rtc_remove_configs
378 configs -= invoker.suppressed_configs
379 public_configs = [ rtc_common_inherited_config ]
380 if (defined(invoker.public_configs)) {
381 public_configs += invoker.public_configs
382 }
383 }
384}
kthelgason4065a572017-02-14 04:58:56 -0800385
386if (is_ios) {
387 set_defaults("rtc_ios_xctest_test") {
388 configs = rtc_add_configs
389 suppressed_configs = []
390 }
391
392 template("rtc_ios_xctest_test") {
393 ios_xctest_test(target_name) {
394 forward_variables_from(invoker,
395 "*",
396 [
397 "configs",
398 "public_configs",
399 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200400 "visibility",
kthelgason4065a572017-02-14 04:58:56 -0800401 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200402 forward_variables_from(invoker, [ "visibility" ])
kthelgason4065a572017-02-14 04:58:56 -0800403 configs += invoker.configs
404 configs -= rtc_remove_configs
405 configs -= invoker.suppressed_configs
406 public_configs = [ rtc_common_inherited_config ]
407 if (defined(invoker.public_configs)) {
408 public_configs += invoker.public_configs
409 }
410 }
411 }
412}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000413
414if (is_android) {
415 template("rtc_android_library") {
416 android_library(target_name) {
417 forward_variables_from(invoker,
418 "*",
419 [
420 "configs",
421 "public_configs",
422 "suppressed_configs",
423 "visibility",
424 ])
425
426 # Treat warnings as errors.
427 javac_args = [ "-Werror" ]
428
429 # TODO(sakal): Fix build hooks crbug.com/webrtc/8168
430 no_build_hooks = true
431 }
432 }
433
434 template("rtc_android_apk") {
435 android_apk(target_name) {
436 forward_variables_from(invoker,
437 "*",
438 [
439 "configs",
440 "public_configs",
441 "suppressed_configs",
442 "visibility",
443 ])
444
445 # Treat warnings as errors.
446 javac_args = [ "-Werror" ]
447
448 # TODO(sakal): Fix build hooks crbug.com/webrtc/8168
449 no_build_hooks = true
450 }
451 }
452
453 template("rtc_instrumentation_test_apk") {
454 instrumentation_test_apk(target_name) {
455 forward_variables_from(invoker,
456 "*",
457 [
458 "configs",
459 "public_configs",
460 "suppressed_configs",
461 "visibility",
462 ])
463
464 # Treat warnings as errors.
465 javac_args = [ "-Werror" ]
466
467 # TODO(sakal): Fix build hooks crbug.com/webrtc/8168
468 no_build_hooks = true
469 }
470 }
471}