mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 1 | # 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 | |
| 9 | import("//build/config/arm.gni") |
| 10 | import("//build/config/features.gni") |
| 11 | import("//build/config/mips.gni") |
| 12 | import("//build/config/sanitizers/sanitizers.gni") |
ehmaldonado | 0d729b3 | 2017-02-10 01:38:23 -0800 | [diff] [blame] | 13 | import("//build/config/ui.gni") |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 14 | import("//build_overrides/build.gni") |
| 15 | import("//testing/test.gni") |
mbonadei | 9660627 | 2017-03-03 19:41:59 -0800 | [diff] [blame] | 16 | |
| 17 | if (!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 | |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 31 | if (is_ios) { |
| 32 | import("//build/config/ios/rules.gni") |
| 33 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 34 | |
| 35 | declare_args() { |
| 36 | # Disable this to avoid building the Opus audio codec. |
| 37 | rtc_include_opus = true |
| 38 | |
minyue | 2e03c66 | 2017-02-01 17:31:11 -0800 | [diff] [blame] | 39 | # Enable this if the Opus version upon which WebRTC is built supports direct |
| 40 | # encoding of 120 ms packets. |
minyue-webrtc | 516711c | 2017-07-27 17:45:49 +0200 | [diff] [blame] | 41 | rtc_opus_support_120ms_ptime = true |
minyue | 2e03c66 | 2017-02-01 17:31:11 -0800 | [diff] [blame] | 42 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 43 | # Enable this to let the Opus audio codec change complexity on the fly. |
| 44 | rtc_opus_variable_complexity = false |
| 45 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 46 | # Used to specify an external Jsoncpp include path when not compiling the |
| 47 | # library that comes with WebRTC (i.e. rtc_build_json == 0). |
| 48 | rtc_jsoncpp_root = "//third_party/jsoncpp/source/include" |
| 49 | |
| 50 | # Used to specify an external OpenSSL include path when not compiling the |
| 51 | # library that comes with WebRTC (i.e. rtc_build_ssl == 0). |
| 52 | rtc_ssl_root = "" |
| 53 | |
| 54 | # Selects fixed-point code where possible. |
| 55 | rtc_prefer_fixed_point = false |
| 56 | |
| 57 | # Enables the use of protocol buffers for debug recordings. |
| 58 | rtc_enable_protobuf = true |
| 59 | |
| 60 | # Disable the code for the intelligibility enhancer by default. |
| 61 | rtc_enable_intelligibility_enhancer = false |
| 62 | |
| 63 | # Enable when an external authentication mechanism is used for performing |
| 64 | # packet authentication for RTP packets instead of libsrtp. |
| 65 | rtc_enable_external_auth = build_with_chromium |
| 66 | |
| 67 | # Selects whether debug dumps for the audio processing module |
| 68 | # should be generated. |
| 69 | apm_debug_dump = false |
| 70 | |
| 71 | # Set this to true to enable BWE test logging. |
| 72 | rtc_enable_bwe_test_logging = false |
| 73 | |
| 74 | # Set this to disable building with support for SCTP data channels. |
| 75 | rtc_enable_sctp = true |
| 76 | |
| 77 | # Disable these to not build components which can be externally provided. |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 78 | rtc_build_json = true |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 79 | rtc_build_libsrtp = true |
| 80 | rtc_build_libvpx = true |
| 81 | rtc_libvpx_build_vp9 = true |
| 82 | rtc_build_libyuv = true |
| 83 | rtc_build_openmax_dl = true |
| 84 | rtc_build_opus = true |
| 85 | rtc_build_ssl = true |
| 86 | rtc_build_usrsctp = true |
| 87 | |
| 88 | # Enable to use the Mozilla internal settings. |
| 89 | build_with_mozilla = false |
| 90 | |
| 91 | rtc_enable_android_opensl = false |
| 92 | |
| 93 | # Link-Time Optimizations. |
| 94 | # Executes code generation at link-time instead of compile-time. |
| 95 | # https://gcc.gnu.org/wiki/LinkTimeOptimization |
| 96 | rtc_use_lto = false |
| 97 | |
| 98 | # Set to "func", "block", "edge" for coverage generation. |
| 99 | # At unit test runtime set UBSAN_OPTIONS="coverage=1". |
| 100 | # It is recommend to set include_examples=0. |
| 101 | # Use llvm's sancov -html-report for human readable reports. |
| 102 | # See http://clang.llvm.org/docs/SanitizerCoverage.html . |
| 103 | rtc_sanitize_coverage = "" |
| 104 | |
perkj | 650fdae | 2017-08-25 05:00:11 -0700 | [diff] [blame] | 105 | # Links a default implementation of task queues to targets |
| 106 | # that depend on the target rtc_task_queue. Set to false to |
| 107 | # use an external implementation. |
| 108 | rtc_link_task_queue_impl = true |
| 109 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 110 | # Enable libevent task queues on platforms that support it. |
perkj | 650fdae | 2017-08-25 05:00:11 -0700 | [diff] [blame] | 111 | # rtc_link_task_queue_impl must be set to true for this to |
| 112 | # have an effect. |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 113 | if (is_win || is_mac || is_ios || is_nacl) { |
| 114 | rtc_enable_libevent = false |
| 115 | rtc_build_libevent = false |
| 116 | } else { |
| 117 | rtc_enable_libevent = true |
| 118 | rtc_build_libevent = true |
| 119 | } |
| 120 | |
| 121 | if (current_cpu == "arm" || current_cpu == "arm64") { |
| 122 | rtc_prefer_fixed_point = true |
| 123 | } |
| 124 | |
| 125 | if (!is_ios && (current_cpu != "arm" || arm_version >= 7) && |
| 126 | current_cpu != "mips64el") { |
| 127 | rtc_use_openmax_dl = true |
| 128 | } else { |
| 129 | rtc_use_openmax_dl = false |
| 130 | } |
| 131 | |
| 132 | # Determines whether NEON code will be built. |
| 133 | rtc_build_with_neon = |
| 134 | (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64" |
| 135 | |
| 136 | # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on |
| 137 | # all platforms except Android and iOS. Because FFmpeg can be built |
| 138 | # with/without H.264 support, |ffmpeg_branding| has to separately be set to a |
| 139 | # value that includes H.264, for example "Chrome". If FFmpeg is built without |
| 140 | # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize. See |
| 141 | # also: |rtc_initialize_ffmpeg|. |
| 142 | # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING. |
| 143 | # http://www.openh264.org, https://www.ffmpeg.org/ |
| 144 | rtc_use_h264 = proprietary_codecs && !is_android && !is_ios |
| 145 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 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 | |
henrika | 7be7883 | 2017-06-13 17:34:16 +0200 | [diff] [blame] | 150 | # When set to true, replace the audio output with a sinus tone at 440Hz. |
| 151 | # The ADM will ask for audio data from WebRTC but instead of reading real |
| 152 | # audio samples from NetEQ, a sinus tone will be generated and replace the |
| 153 | # real audio samples. |
| 154 | rtc_audio_device_plays_sinus_tone = false |
| 155 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 156 | # When set to true, test targets will declare the files needed to run memcheck |
| 157 | # as data dependencies. This is to enable memcheck execution on swarming bots. |
| 158 | rtc_use_memcheck = false |
| 159 | |
| 160 | # FFmpeg must be initialized for |H264DecoderImpl| to work. This can be done |
| 161 | # by WebRTC during |H264DecoderImpl::InitDecode| or externally. FFmpeg must |
| 162 | # only be initialized once. Projects that initialize FFmpeg externally, such |
| 163 | # as Chromium, must turn this flag off so that WebRTC does not also |
| 164 | # initialize. |
| 165 | rtc_initialize_ffmpeg = !build_with_chromium |
| 166 | |
| 167 | # Build sources requiring GTK. NOTICE: This is not present in Chrome OS |
| 168 | # build environments, even if available for Chromium builds. |
| 169 | rtc_use_gtk = !build_with_chromium |
| 170 | } |
| 171 | |
| 172 | # A second declare_args block, so that declarations within it can |
| 173 | # depend on the possibly overridden variables in the first |
| 174 | # declare_args block. |
| 175 | declare_args() { |
| 176 | # Include the iLBC audio codec? |
| 177 | rtc_include_ilbc = !(build_with_chromium || build_with_mozilla) |
| 178 | |
| 179 | rtc_restrict_logging = build_with_chromium |
| 180 | |
| 181 | # Excluded in Chromium since its prerequisites don't require Pulse Audio. |
| 182 | rtc_include_pulse_audio = !build_with_chromium |
| 183 | |
| 184 | # Chromium uses its own IO handling, so the internal ADM is only built for |
| 185 | # standalone WebRTC. |
| 186 | rtc_include_internal_audio_device = !build_with_chromium |
| 187 | |
| 188 | # Include tests in standalone checkout. |
| 189 | rtc_include_tests = !build_with_chromium |
| 190 | } |
| 191 | |
| 192 | # Make it possible to provide custom locations for some libraries (move these |
| 193 | # up into declare_args should we need to actually use them for the GN build). |
| 194 | rtc_libvpx_dir = "//third_party/libvpx" |
| 195 | rtc_libyuv_dir = "//third_party/libyuv" |
| 196 | rtc_opus_dir = "//third_party/opus" |
| 197 | |
| 198 | # Desktop capturer is supported only on Windows, OSX and Linux. |
ehmaldonado | 0d729b3 | 2017-02-10 01:38:23 -0800 | [diff] [blame] | 199 | rtc_desktop_capture_supported = is_win || is_mac || (is_linux && use_x11) |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 200 | |
| 201 | ############################################################################### |
| 202 | # Templates |
| 203 | # |
| 204 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 205 | # Points to // in webrtc stand-alone or to //third_party/webrtc/ in |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 206 | # chromium. |
| 207 | # We need absolute paths for all configs in templates as they are shared in |
| 208 | # different subdirectories. |
| 209 | webrtc_root = get_path_info(".", "abspath") |
| 210 | |
| 211 | # Global configuration that should be applied to all WebRTC targets. |
| 212 | # You normally shouldn't need to include this in your target as it's |
| 213 | # automatically included when using the rtc_* templates. |
| 214 | # It sets defines, include paths and compilation warnings accordingly, |
| 215 | # both for WebRTC stand-alone builds and for the scenario when WebRTC |
| 216 | # native code is built as part of Chromium. |
| 217 | rtc_common_configs = [ webrtc_root + ":common_config" ] |
| 218 | |
kthelgason | c097710 | 2017-04-24 00:57:16 -0700 | [diff] [blame] | 219 | if (is_mac || is_ios) { |
| 220 | rtc_common_configs += [ "//build/config/compiler:enable_arc" ] |
| 221 | } |
| 222 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 223 | # Global public configuration that should be applied to all WebRTC targets. You |
| 224 | # normally shouldn't need to include this in your target as it's automatically |
| 225 | # included when using the rtc_* templates. It set the defines, include paths and |
| 226 | # compilation warnings that should be propagated to dependents of the targets |
| 227 | # depending on the target having this config. |
| 228 | rtc_common_inherited_config = webrtc_root + ":common_inherited_config" |
| 229 | |
| 230 | # Common configs to remove or add in all rtc targets. |
| 231 | rtc_remove_configs = [] |
| 232 | rtc_add_configs = rtc_common_configs |
| 233 | |
| 234 | set_defaults("rtc_test") { |
| 235 | configs = rtc_add_configs |
| 236 | suppressed_configs = [] |
| 237 | } |
| 238 | |
| 239 | set_defaults("rtc_source_set") { |
| 240 | configs = rtc_add_configs |
| 241 | suppressed_configs = [] |
| 242 | } |
| 243 | |
| 244 | set_defaults("rtc_executable") { |
| 245 | configs = rtc_add_configs |
| 246 | suppressed_configs = [] |
| 247 | } |
| 248 | |
| 249 | set_defaults("rtc_static_library") { |
| 250 | configs = rtc_add_configs |
| 251 | suppressed_configs = [] |
| 252 | } |
| 253 | |
| 254 | set_defaults("rtc_shared_library") { |
| 255 | configs = rtc_add_configs |
| 256 | suppressed_configs = [] |
| 257 | } |
| 258 | |
| 259 | template("rtc_test") { |
| 260 | test(target_name) { |
| 261 | forward_variables_from(invoker, |
| 262 | "*", |
| 263 | [ |
| 264 | "configs", |
| 265 | "public_configs", |
| 266 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 267 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 268 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 269 | forward_variables_from(invoker, [ "visibility" ]) |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 270 | configs += invoker.configs |
| 271 | configs -= rtc_remove_configs |
| 272 | configs -= invoker.suppressed_configs |
| 273 | public_configs = [ rtc_common_inherited_config ] |
| 274 | if (defined(invoker.public_configs)) { |
| 275 | public_configs += invoker.public_configs |
| 276 | } |
sakal | d7fdb80 | 2017-05-26 01:51:53 -0700 | [diff] [blame] | 277 | if (!build_with_chromium && is_android) { |
Jianjun Zhu | 037f3e4 | 2017-08-15 21:48:37 +0800 | [diff] [blame] | 278 | android_manifest = webrtc_root + "test/android/AndroidManifest.xml" |
| 279 | deps += [ webrtc_root + "test:native_test_java" ] |
sakal | d7fdb80 | 2017-05-26 01:51:53 -0700 | [diff] [blame] | 280 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 281 | } |
| 282 | } |
| 283 | |
| 284 | template("rtc_source_set") { |
| 285 | source_set(target_name) { |
| 286 | forward_variables_from(invoker, |
| 287 | "*", |
| 288 | [ |
| 289 | "configs", |
| 290 | "public_configs", |
| 291 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 292 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 293 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 294 | forward_variables_from(invoker, [ "visibility" ]) |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 295 | configs += invoker.configs |
| 296 | configs -= rtc_remove_configs |
| 297 | configs -= invoker.suppressed_configs |
| 298 | public_configs = [ rtc_common_inherited_config ] |
| 299 | if (defined(invoker.public_configs)) { |
| 300 | public_configs += invoker.public_configs |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | template("rtc_executable") { |
| 306 | executable(target_name) { |
| 307 | forward_variables_from(invoker, |
| 308 | "*", |
| 309 | [ |
| 310 | "deps", |
| 311 | "configs", |
| 312 | "public_configs", |
| 313 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 314 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 315 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 316 | forward_variables_from(invoker, [ "visibility" ]) |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 317 | configs += invoker.configs |
| 318 | configs -= rtc_remove_configs |
| 319 | configs -= invoker.suppressed_configs |
| 320 | deps = [ |
thomasanderson | 7f52f08 | 2017-05-18 23:51:46 -0700 | [diff] [blame] | 321 | "//build/config:exe_and_shlib_deps", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 322 | ] |
| 323 | deps += invoker.deps |
perkj | 650fdae | 2017-08-25 05:00:11 -0700 | [diff] [blame] | 324 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 325 | public_configs = [ rtc_common_inherited_config ] |
| 326 | if (defined(invoker.public_configs)) { |
| 327 | public_configs += invoker.public_configs |
| 328 | } |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | template("rtc_static_library") { |
| 333 | static_library(target_name) { |
| 334 | forward_variables_from(invoker, |
| 335 | "*", |
| 336 | [ |
| 337 | "configs", |
| 338 | "public_configs", |
| 339 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 340 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 341 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 342 | forward_variables_from(invoker, [ "visibility" ]) |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 343 | configs += invoker.configs |
| 344 | configs -= rtc_remove_configs |
| 345 | configs -= invoker.suppressed_configs |
| 346 | public_configs = [ rtc_common_inherited_config ] |
| 347 | if (defined(invoker.public_configs)) { |
| 348 | public_configs += invoker.public_configs |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | template("rtc_shared_library") { |
| 354 | shared_library(target_name) { |
| 355 | forward_variables_from(invoker, |
| 356 | "*", |
| 357 | [ |
| 358 | "configs", |
| 359 | "public_configs", |
| 360 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 361 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 362 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 363 | forward_variables_from(invoker, [ "visibility" ]) |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 364 | configs += invoker.configs |
| 365 | configs -= rtc_remove_configs |
| 366 | configs -= invoker.suppressed_configs |
| 367 | public_configs = [ rtc_common_inherited_config ] |
| 368 | if (defined(invoker.public_configs)) { |
| 369 | public_configs += invoker.public_configs |
| 370 | } |
| 371 | } |
| 372 | } |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 373 | |
| 374 | if (is_ios) { |
| 375 | set_defaults("rtc_ios_xctest_test") { |
| 376 | configs = rtc_add_configs |
| 377 | suppressed_configs = [] |
| 378 | } |
| 379 | |
| 380 | template("rtc_ios_xctest_test") { |
| 381 | ios_xctest_test(target_name) { |
| 382 | forward_variables_from(invoker, |
| 383 | "*", |
| 384 | [ |
| 385 | "configs", |
| 386 | "public_configs", |
| 387 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 388 | "visibility", |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 389 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 390 | forward_variables_from(invoker, [ "visibility" ]) |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 391 | configs += invoker.configs |
| 392 | configs -= rtc_remove_configs |
| 393 | configs -= invoker.suppressed_configs |
| 394 | public_configs = [ rtc_common_inherited_config ] |
| 395 | if (defined(invoker.public_configs)) { |
| 396 | public_configs += invoker.public_configs |
| 397 | } |
| 398 | } |
| 399 | } |
| 400 | } |