blob: d4acaf526884ed977558d7f987457001814c51ce [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() {
36 # Disable this to avoid building the Opus audio codec.
37 rtc_include_opus = true
38
minyue2e03c662017-02-01 17:31:11 -080039 # Enable this if the Opus version upon which WebRTC is built supports direct
40 # encoding of 120 ms packets.
41 rtc_opus_support_120ms_ptime = false
42
mbonadei9aa3f0a2017-01-24 06:58:22 -080043 # Enable this to let the Opus audio codec change complexity on the fly.
44 rtc_opus_variable_complexity = false
45
46 # Disable to use absolute header paths for some libraries.
47 rtc_relative_path = true
48
49 # 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
80 # Disable these to not build components which can be externally provided.
mbonadei9aa3f0a2017-01-24 06:58:22 -080081 rtc_build_json = true
82 rtc_build_libjpeg = true
83 rtc_build_libsrtp = true
84 rtc_build_libvpx = true
85 rtc_libvpx_build_vp9 = true
86 rtc_build_libyuv = true
87 rtc_build_openmax_dl = true
88 rtc_build_opus = true
89 rtc_build_ssl = true
90 rtc_build_usrsctp = true
91
92 # Enable to use the Mozilla internal settings.
93 build_with_mozilla = false
94
95 rtc_enable_android_opensl = false
96
97 # Link-Time Optimizations.
98 # Executes code generation at link-time instead of compile-time.
99 # https://gcc.gnu.org/wiki/LinkTimeOptimization
100 rtc_use_lto = false
101
102 # Set to "func", "block", "edge" for coverage generation.
103 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
104 # It is recommend to set include_examples=0.
105 # Use llvm's sancov -html-report for human readable reports.
106 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
107 rtc_sanitize_coverage = ""
108
109 # Enable libevent task queues on platforms that support it.
110 if (is_win || is_mac || is_ios || is_nacl) {
111 rtc_enable_libevent = false
112 rtc_build_libevent = false
113 } else {
114 rtc_enable_libevent = true
115 rtc_build_libevent = true
116 }
117
118 if (current_cpu == "arm" || current_cpu == "arm64") {
119 rtc_prefer_fixed_point = true
120 }
121
122 if (!is_ios && (current_cpu != "arm" || arm_version >= 7) &&
123 current_cpu != "mips64el") {
124 rtc_use_openmax_dl = true
125 } else {
126 rtc_use_openmax_dl = false
127 }
128
129 # Determines whether NEON code will be built.
130 rtc_build_with_neon =
131 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
132
133 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
134 # all platforms except Android and iOS. Because FFmpeg can be built
135 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
136 # value that includes H.264, for example "Chrome". If FFmpeg is built without
137 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize. See
138 # also: |rtc_initialize_ffmpeg|.
139 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
140 # http://www.openh264.org, https://www.ffmpeg.org/
141 rtc_use_h264 = proprietary_codecs && !is_android && !is_ios
142
143 # Determines whether QUIC code will be built.
144 rtc_use_quic = false
145
146 # By default, use normal platform audio support or dummy audio, but don't
147 # use file-based audio playout and record.
148 rtc_use_dummy_audio_file_devices = false
149
150 # When set to true, test targets will declare the files needed to run memcheck
151 # as data dependencies. This is to enable memcheck execution on swarming bots.
152 rtc_use_memcheck = false
153
154 # FFmpeg must be initialized for |H264DecoderImpl| to work. This can be done
155 # by WebRTC during |H264DecoderImpl::InitDecode| or externally. FFmpeg must
156 # only be initialized once. Projects that initialize FFmpeg externally, such
157 # as Chromium, must turn this flag off so that WebRTC does not also
158 # initialize.
159 rtc_initialize_ffmpeg = !build_with_chromium
160
161 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
162 # build environments, even if available for Chromium builds.
163 rtc_use_gtk = !build_with_chromium
164}
165
166# A second declare_args block, so that declarations within it can
167# depend on the possibly overridden variables in the first
168# declare_args block.
169declare_args() {
170 # Include the iLBC audio codec?
171 rtc_include_ilbc = !(build_with_chromium || build_with_mozilla)
172
173 rtc_restrict_logging = build_with_chromium
174
175 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
176 rtc_include_pulse_audio = !build_with_chromium
177
178 # Chromium uses its own IO handling, so the internal ADM is only built for
179 # standalone WebRTC.
180 rtc_include_internal_audio_device = !build_with_chromium
181
182 # Include tests in standalone checkout.
183 rtc_include_tests = !build_with_chromium
184}
185
186# Make it possible to provide custom locations for some libraries (move these
187# up into declare_args should we need to actually use them for the GN build).
188rtc_libvpx_dir = "//third_party/libvpx"
189rtc_libyuv_dir = "//third_party/libyuv"
190rtc_opus_dir = "//third_party/opus"
191
192# Desktop capturer is supported only on Windows, OSX and Linux.
ehmaldonado0d729b32017-02-10 01:38:23 -0800193rtc_desktop_capture_supported = is_win || is_mac || (is_linux && use_x11)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800194
195###############################################################################
196# Templates
197#
198
199# Points to //webrtc/ in webrtc stand-alone or to //third_party/webrtc/ in
200# chromium.
201# We need absolute paths for all configs in templates as they are shared in
202# different subdirectories.
203webrtc_root = get_path_info(".", "abspath")
204
205# Global configuration that should be applied to all WebRTC targets.
206# You normally shouldn't need to include this in your target as it's
207# automatically included when using the rtc_* templates.
208# It sets defines, include paths and compilation warnings accordingly,
209# both for WebRTC stand-alone builds and for the scenario when WebRTC
210# native code is built as part of Chromium.
211rtc_common_configs = [ webrtc_root + ":common_config" ]
212
kthelgasonc0977102017-04-24 00:57:16 -0700213if (is_mac || is_ios) {
214 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
215}
216
mbonadei9aa3f0a2017-01-24 06:58:22 -0800217# Global public configuration that should be applied to all WebRTC targets. You
218# normally shouldn't need to include this in your target as it's automatically
219# included when using the rtc_* templates. It set the defines, include paths and
220# compilation warnings that should be propagated to dependents of the targets
221# depending on the target having this config.
222rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
223
224# Common configs to remove or add in all rtc targets.
225rtc_remove_configs = []
226rtc_add_configs = rtc_common_configs
227
228set_defaults("rtc_test") {
229 configs = rtc_add_configs
230 suppressed_configs = []
231}
232
233set_defaults("rtc_source_set") {
234 configs = rtc_add_configs
235 suppressed_configs = []
236}
237
238set_defaults("rtc_executable") {
239 configs = rtc_add_configs
240 suppressed_configs = []
241}
242
243set_defaults("rtc_static_library") {
244 configs = rtc_add_configs
245 suppressed_configs = []
246}
247
248set_defaults("rtc_shared_library") {
249 configs = rtc_add_configs
250 suppressed_configs = []
251}
252
253template("rtc_test") {
254 test(target_name) {
255 forward_variables_from(invoker,
256 "*",
257 [
258 "configs",
259 "public_configs",
260 "suppressed_configs",
261 ])
262 configs += invoker.configs
263 configs -= rtc_remove_configs
264 configs -= invoker.suppressed_configs
265 public_configs = [ rtc_common_inherited_config ]
266 if (defined(invoker.public_configs)) {
267 public_configs += invoker.public_configs
268 }
sakald7fdb802017-05-26 01:51:53 -0700269 if (!build_with_chromium && is_android) {
270 android_manifest = "//webrtc/test/android/AndroidManifest.xml"
271 deps += [ "//webrtc/test:native_test_java" ]
272 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800273 }
274}
275
276template("rtc_source_set") {
277 source_set(target_name) {
278 forward_variables_from(invoker,
279 "*",
280 [
281 "configs",
282 "public_configs",
283 "suppressed_configs",
284 ])
285 configs += invoker.configs
286 configs -= rtc_remove_configs
287 configs -= invoker.suppressed_configs
288 public_configs = [ rtc_common_inherited_config ]
289 if (defined(invoker.public_configs)) {
290 public_configs += invoker.public_configs
291 }
292 }
293}
294
295template("rtc_executable") {
296 executable(target_name) {
297 forward_variables_from(invoker,
298 "*",
299 [
300 "deps",
301 "configs",
302 "public_configs",
303 "suppressed_configs",
304 ])
305 configs += invoker.configs
306 configs -= rtc_remove_configs
307 configs -= invoker.suppressed_configs
308 deps = [
thomasanderson7f52f082017-05-18 23:51:46 -0700309 "//build/config:exe_and_shlib_deps",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800310 ]
311 deps += invoker.deps
312 public_configs = [ rtc_common_inherited_config ]
313 if (defined(invoker.public_configs)) {
314 public_configs += invoker.public_configs
315 }
316 }
317}
318
319template("rtc_static_library") {
320 static_library(target_name) {
321 forward_variables_from(invoker,
322 "*",
323 [
324 "configs",
325 "public_configs",
326 "suppressed_configs",
327 ])
328 configs += invoker.configs
329 configs -= rtc_remove_configs
330 configs -= invoker.suppressed_configs
331 public_configs = [ rtc_common_inherited_config ]
332 if (defined(invoker.public_configs)) {
333 public_configs += invoker.public_configs
334 }
335 }
336}
337
338template("rtc_shared_library") {
339 shared_library(target_name) {
340 forward_variables_from(invoker,
341 "*",
342 [
343 "configs",
344 "public_configs",
345 "suppressed_configs",
346 ])
347 configs += invoker.configs
348 configs -= rtc_remove_configs
349 configs -= invoker.suppressed_configs
350 public_configs = [ rtc_common_inherited_config ]
351 if (defined(invoker.public_configs)) {
352 public_configs += invoker.public_configs
353 }
354 }
355}
kthelgason4065a572017-02-14 04:58:56 -0800356
357if (is_ios) {
358 set_defaults("rtc_ios_xctest_test") {
359 configs = rtc_add_configs
360 suppressed_configs = []
361 }
362
363 template("rtc_ios_xctest_test") {
364 ios_xctest_test(target_name) {
365 forward_variables_from(invoker,
366 "*",
367 [
368 "configs",
369 "public_configs",
370 "suppressed_configs",
371 ])
372 configs += invoker.configs
373 configs -= rtc_remove_configs
374 configs -= invoker.suppressed_configs
375 public_configs = [ rtc_common_inherited_config ]
376 if (defined(invoker.public_configs)) {
377 public_configs += invoker.public_configs
378 }
379 }
380 }
381}