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