aboutsummaryrefslogtreecommitdiff
path: root/webrtc.gni
blob: a4b7c1881fe2b9e73891513942a553f8d559f875 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS.  All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.

import("//build/config/arm.gni")
import("//build/config/features.gni")
import("//build/config/mips.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/ui.gni")
import("//build_overrides/build.gni")
import("//testing/test.gni")

if (!build_with_chromium && is_component_build) {
  print("The Gn argument `is_component_build` is currently " +
        "ignored for WebRTC builds.")
  print("Component builds are supported by Chromium and the argument " +
        "`is_component_build` makes it possible to create shared libraries " +
        "instead of static libraries.")
  print("If an app depends on WebRTC it makes sense to just depend on the " +
        "WebRTC static library, so there is no difference between " +
        "`is_component_build=true` and `is_component_build=false`.")
  print(
      "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.md")
  assert(!is_component_build, "Component builds are not supported in WebRTC.")
}

if (is_ios) {
  import("//build/config/ios/rules.gni")
}

declare_args() {
  # Include the iLBC audio codec?
  rtc_include_ilbc = true

  # Disable this to avoid building the Opus audio codec.
  rtc_include_opus = true

  # Enable this if the Opus version upon which WebRTC is built supports direct
  # encoding of 120 ms packets.
  rtc_opus_support_120ms_ptime = true

  # Enable this to let the Opus audio codec change complexity on the fly.
  rtc_opus_variable_complexity = false

  # Used to specify an external Jsoncpp include path when not compiling the
  # library that comes with WebRTC (i.e. rtc_build_json == 0).
  rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"

  # Used to specify an external OpenSSL include path when not compiling the
  # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
  rtc_ssl_root = ""

  # Selects fixed-point code where possible.
  rtc_prefer_fixed_point = false

  # Enables the use of protocol buffers for debug recordings.
  rtc_enable_protobuf = true

  # Disable the code for the intelligibility enhancer by default.
  rtc_enable_intelligibility_enhancer = false

  # Enable when an external authentication mechanism is used for performing
  # packet authentication for RTP packets instead of libsrtp.
  rtc_enable_external_auth = build_with_chromium

  # Selects whether debug dumps for the audio processing module
  # should be generated.
  apm_debug_dump = false

  # Set this to true to enable BWE test logging.
  rtc_enable_bwe_test_logging = false

  # Set this to disable building with support for SCTP data channels.
  rtc_enable_sctp = true

  # Disable these to not build components which can be externally provided.
  rtc_build_json = true
  rtc_build_libsrtp = true
  rtc_build_libvpx = true
  rtc_libvpx_build_vp9 = true
  rtc_build_libyuv = true
  rtc_build_openmax_dl = true
  rtc_build_opus = true
  rtc_build_ssl = true
  rtc_build_usrsctp = true

  # Enable to use the Mozilla internal settings.
  build_with_mozilla = false

  rtc_enable_android_opensl = false

  # Link-Time Optimizations.
  # Executes code generation at link-time instead of compile-time.
  # https://gcc.gnu.org/wiki/LinkTimeOptimization
  rtc_use_lto = false

  # Set to "func", "block", "edge" for coverage generation.
  # At unit test runtime set UBSAN_OPTIONS="coverage=1".
  # It is recommend to set include_examples=0.
  # Use llvm's sancov -html-report for human readable reports.
  # See http://clang.llvm.org/docs/SanitizerCoverage.html .
  rtc_sanitize_coverage = ""

  # Links a default implementation of task queues to targets
  # that depend on the target rtc_task_queue. Set to false to
  # use an external implementation.
  rtc_link_task_queue_impl = true

  # Enable libevent task queues on platforms that support it.
  # rtc_link_task_queue_impl must be set to true for this to
  # have an effect.
  if (is_win || is_mac || is_ios || is_nacl) {
    rtc_enable_libevent = false
    rtc_build_libevent = false
  } else {
    rtc_enable_libevent = true
    rtc_build_libevent = true
  }

  if (current_cpu == "arm" || current_cpu == "arm64") {
    rtc_prefer_fixed_point = true
  }

  if (!is_ios && (current_cpu != "arm" || arm_version >= 7) &&
      current_cpu != "mips64el") {
    rtc_use_openmax_dl = true
  } else {
    rtc_use_openmax_dl = false
  }

  # Determines whether NEON code will be built.
  rtc_build_with_neon =
      (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"

  # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
  # all platforms except Android and iOS. Because FFmpeg can be built
  # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
  # value that includes H.264, for example "Chrome". If FFmpeg is built without
  # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize. See
  # also: |rtc_initialize_ffmpeg|.
  # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
  # http://www.openh264.org, https://www.ffmpeg.org/
  rtc_use_h264 = proprietary_codecs && !is_android && !is_ios

  # By default, use normal platform audio support or dummy audio, but don't
  # use file-based audio playout and record.
  rtc_use_dummy_audio_file_devices = false

  # When set to true, replace the audio output with a sinus tone at 440Hz.
  # The ADM will ask for audio data from WebRTC but instead of reading real
  # audio samples from NetEQ, a sinus tone will be generated and replace the
  # real audio samples.
  rtc_audio_device_plays_sinus_tone = false

  # When set to true, test targets will declare the files needed to run memcheck
  # as data dependencies. This is to enable memcheck execution on swarming bots.
  rtc_use_memcheck = false

  # FFmpeg must be initialized for |H264DecoderImpl| to work. This can be done
  # by WebRTC during |H264DecoderImpl::InitDecode| or externally. FFmpeg must
  # only be initialized once. Projects that initialize FFmpeg externally, such
  # as Chromium, must turn this flag off so that WebRTC does not also
  # initialize.
  rtc_initialize_ffmpeg = !build_with_chromium

  # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
  # build environments, even if available for Chromium builds.
  rtc_use_gtk = !build_with_chromium
}

# A second declare_args block, so that declarations within it can
# depend on the possibly overridden variables in the first
# declare_args block.
declare_args() {
  rtc_restrict_logging = build_with_chromium

  # Excluded in Chromium since its prerequisites don't require Pulse Audio.
  rtc_include_pulse_audio = !build_with_chromium

  # Chromium uses its own IO handling, so the internal ADM is only built for
  # standalone WebRTC.
  rtc_include_internal_audio_device = !build_with_chromium

  # Include tests in standalone checkout.
  rtc_include_tests = !build_with_chromium
}

# Make it possible to provide custom locations for some libraries (move these
# up into declare_args should we need to actually use them for the GN build).
rtc_libvpx_dir = "//third_party/libvpx"
rtc_libyuv_dir = "//third_party/libyuv"
rtc_opus_dir = "//third_party/opus"

# Desktop capturer is supported only on Windows, OSX and Linux.
rtc_desktop_capture_supported = is_win || is_mac || (is_linux && use_x11)

###############################################################################
# Templates
#

# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
# chromium.
# We need absolute paths for all configs in templates as they are shared in
# different subdirectories.
webrtc_root = get_path_info(".", "abspath")

# Global configuration that should be applied to all WebRTC targets.
# You normally shouldn't need to include this in your target as it's
# automatically included when using the rtc_* templates.
# It sets defines, include paths and compilation warnings accordingly,
# both for WebRTC stand-alone builds and for the scenario when WebRTC
# native code is built as part of Chromium.
rtc_common_configs = [ webrtc_root + ":common_config" ]

if (is_mac || is_ios) {
  rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
}

# Global public configuration that should be applied to all WebRTC targets. You
# normally shouldn't need to include this in your target as it's automatically
# included when using the rtc_* templates. It set the defines, include paths and
# compilation warnings that should be propagated to dependents of the targets
# depending on the target having this config.
rtc_common_inherited_config = webrtc_root + ":common_inherited_config"

# Common configs to remove or add in all rtc targets.
rtc_remove_configs = []
rtc_add_configs = rtc_common_configs

set_defaults("rtc_test") {
  configs = rtc_add_configs
  suppressed_configs = []
}

set_defaults("rtc_source_set") {
  configs = rtc_add_configs
  suppressed_configs = []
}

set_defaults("rtc_executable") {
  configs = rtc_add_configs
  suppressed_configs = []
}

set_defaults("rtc_static_library") {
  configs = rtc_add_configs
  suppressed_configs = []
}

set_defaults("rtc_shared_library") {
  configs = rtc_add_configs
  suppressed_configs = []
}

template("rtc_test") {
  test(target_name) {
    forward_variables_from(invoker,
                           "*",
                           [
                             "configs",
                             "public_configs",
                             "suppressed_configs",
                             "visibility",
                           ])
    forward_variables_from(invoker, [ "visibility" ])
    configs += invoker.configs
    configs -= rtc_remove_configs
    configs -= invoker.suppressed_configs
    public_configs = [ rtc_common_inherited_config ]
    if (defined(invoker.public_configs)) {
      public_configs += invoker.public_configs
    }
    if (!build_with_chromium && is_android) {
      android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
      deps += [ webrtc_root + "test:native_test_java" ]
    }
  }
}

template("rtc_source_set") {
  source_set(target_name) {
    forward_variables_from(invoker,
                           "*",
                           [
                             "configs",
                             "public_configs",
                             "suppressed_configs",
                             "visibility",
                           ])
    forward_variables_from(invoker, [ "visibility" ])
    configs += invoker.configs
    configs -= rtc_remove_configs
    configs -= invoker.suppressed_configs
    public_configs = [ rtc_common_inherited_config ]
    if (defined(invoker.public_configs)) {
      public_configs += invoker.public_configs
    }
  }
}

template("rtc_executable") {
  executable(target_name) {
    forward_variables_from(invoker,
                           "*",
                           [
                             "deps",
                             "configs",
                             "public_configs",
                             "suppressed_configs",
                             "visibility",
                           ])
    forward_variables_from(invoker, [ "visibility" ])
    configs += invoker.configs
    configs -= rtc_remove_configs
    configs -= invoker.suppressed_configs
    deps = [
      "//build/config:exe_and_shlib_deps",
    ]
    deps += invoker.deps

    public_configs = [ rtc_common_inherited_config ]
    if (defined(invoker.public_configs)) {
      public_configs += invoker.public_configs
    }
  }
}

template("rtc_static_library") {
  static_library(target_name) {
    forward_variables_from(invoker,
                           "*",
                           [
                             "configs",
                             "public_configs",
                             "suppressed_configs",
                             "visibility",
                           ])
    forward_variables_from(invoker, [ "visibility" ])
    configs += invoker.configs
    configs -= rtc_remove_configs
    configs -= invoker.suppressed_configs
    public_configs = [ rtc_common_inherited_config ]
    if (defined(invoker.public_configs)) {
      public_configs += invoker.public_configs
    }
  }
}

template("rtc_shared_library") {
  shared_library(target_name) {
    forward_variables_from(invoker,
                           "*",
                           [
                             "configs",
                             "public_configs",
                             "suppressed_configs",
                             "visibility",
                           ])
    forward_variables_from(invoker, [ "visibility" ])
    configs += invoker.configs
    configs -= rtc_remove_configs
    configs -= invoker.suppressed_configs
    public_configs = [ rtc_common_inherited_config ]
    if (defined(invoker.public_configs)) {
      public_configs += invoker.public_configs
    }
  }
}

if (is_ios) {
  set_defaults("rtc_ios_xctest_test") {
    configs = rtc_add_configs
    suppressed_configs = []
  }

  template("rtc_ios_xctest_test") {
    ios_xctest_test(target_name) {
      forward_variables_from(invoker,
                             "*",
                             [
                               "configs",
                               "public_configs",
                               "suppressed_configs",
                               "visibility",
                             ])
      forward_variables_from(invoker, [ "visibility" ])
      configs += invoker.configs
      configs -= rtc_remove_configs
      configs -= invoker.suppressed_configs
      public_configs = [ rtc_common_inherited_config ]
      if (defined(invoker.public_configs)) {
        public_configs += invoker.public_configs
      }
    }
  }
}