DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (c68fe15a81fc)

VCS Links

Line Code
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 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572
# 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/linux/pkg_config.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("webrtc.gni")
if (!build_with_mozilla) {
  import("//third_party/protobuf/proto_library.gni")
}
if (is_android) {
  import("//build/config/android/config.gni")
  import("//build/config/android/rules.gni")
}

if (!build_with_chromium && !build_with_mozilla) {
  group("default") {
    testonly = true
    deps = [
      ":webrtc",
      "examples",
      "rtc_tools",
    ]
    if (rtc_include_tests) {
      deps += [ ":webrtc_tests" ]
    }
  }
}

# Contains the defines and includes in common.gypi that are duplicated both as
# target_defaults and direct_dependent_settings.
config("common_inherited_config") {
  defines = []
  cflags = []
  ldflags = []
  if (build_with_mozilla) {
    defines += [ "WEBRTC_MOZILLA_BUILD" ]
  }

  # Some tests need to declare their own trace event handlers. If this define is
  # not set, the first time TRACE_EVENT_* is called it will store the return
  # value for the current handler in an static variable, so that subsequent
  # changes to the handler for that TRACE_EVENT_* will be ignored.
  # So when tests are included, we set this define, making it possible to use
  # different event handlers in different tests.
  if (rtc_include_tests) {
    defines += [ "WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=1" ]
  } else {
    defines += [ "WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0" ]
  }
  if (build_with_chromium) {
    defines += [
      # TODO(kjellander): Cleanup unused ones and move defines closer to
      # the source when webrtc:4256 is completed.
      "FEATURE_ENABLE_VOICEMAIL",
      "GTEST_RELATIVE_PATH",
      "WEBRTC_CHROMIUM_BUILD",
    ]
    include_dirs = [
      # The overrides must be included first as that is the mechanism for
      # selecting the override headers in Chromium.
      "../webrtc_overrides",

      # Allow includes to be prefixed with webrtc/ in case it is not an
      # immediate subdirectory of the top-level.
      ".",
    ]
  }
  if (is_posix) {
    defines += [ "WEBRTC_POSIX" ]
  }
  if (is_ios) {
    defines += [
      "WEBRTC_MAC",
      "WEBRTC_IOS",
    ]
  }
  if (is_linux) {
    defines += [ "WEBRTC_LINUX" ]
  }
  if (is_bsd) {
    defines += [ "WEBRTC_BSD" ]
  }
  if (is_mac) {
    defines += [ "WEBRTC_MAC" ]
  }
  if (is_win) {
    defines += [
      "WEBRTC_WIN",
      "_CRT_SECURE_NO_WARNINGS",  # Suppress warnings about _vsnprinf
    ]
  }
  if (is_android) {
    defines += [
      "WEBRTC_LINUX",
      "WEBRTC_ANDROID",
    ]

    if (build_with_mozilla) {
      defines += [ "WEBRTC_ANDROID_OPENSLES" ]
    }
  }
  if (is_chromeos) {
    defines += [ "CHROMEOS" ]
  }

  if (rtc_sanitize_coverage != "") {
    assert(is_clang, "sanitizer coverage requires clang")
    cflags += [ "-fsanitize-coverage=${rtc_sanitize_coverage}" ]
    ldflags += [ "-fsanitize-coverage=${rtc_sanitize_coverage}" ]
  }

  if (is_ubsan) {
    cflags += [ "-fsanitize=float-cast-overflow" ]
  }

  # TODO(GYP): Support these in GN.
  # if (is_bsd) {
  #   defines += [ "BSD" ]
  # }
  # if (is_openbsd) {
  #   defines += [ "OPENBSD" ]
  # }
  # if (is_freebsd) {
  #   defines += [ "FREEBSD" ]
  # }
}

config("common_config") {
  cflags = []
  cflags_cc = []
  defines = []

  if (rtc_enable_protobuf) {
    defines += [ "WEBRTC_ENABLE_PROTOBUF=1" ]
  } else {
    defines += [ "WEBRTC_ENABLE_PROTOBUF=0" ]
  }

  if (rtc_restrict_logging) {
    defines += [ "WEBRTC_RESTRICT_LOGGING" ]
  }

  if (rtc_include_internal_audio_device) {
    defines += [ "WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE" ]
  }

  if (!rtc_libvpx_build_vp9) {
    defines += [ "RTC_DISABLE_VP9" ]
  }

  if (rtc_enable_sctp) {
    defines += [ "HAVE_SCTP" ]
  }

  if (rtc_enable_external_auth) {
    defines += [ "ENABLE_EXTERNAL_AUTH" ]
  }

  if (build_with_chromium) {
    defines += [
      # NOTICE: Since common_inherited_config is used in public_configs for our
      # targets, there's no point including the defines in that config here.
      # TODO(kjellander): Cleanup unused ones and move defines closer to the
      # source when webrtc:4256 is completed.
      "HAVE_WEBRTC_VIDEO",
      "HAVE_WEBRTC_VOICE",
      "LOGGING_INSIDE_WEBRTC",
      "USE_WEBRTC_DEV_BRANCH",
    ]
  } else {
    if (is_posix) {
      # Enable more warnings: -Wextra is currently disabled in Chromium.
      cflags = [
        "-Wextra",

        # Repeat some flags that get overridden by -Wextra.
        "-Wno-unused-parameter",
        "-Wno-missing-field-initializers",
        "-Wno-strict-overflow",
      ]
      cflags_cc = [
        "-Wnon-virtual-dtor",

        # This is enabled for clang; enable for gcc as well.
        "-Woverloaded-virtual",
      ]
    }

    if (is_clang) {
      cflags += [
        "-Wc++11-narrowing",
        "-Wimplicit-fallthrough",
        "-Wthread-safety",
        "-Winconsistent-missing-override",
        "-Wundef",
      ]

      # use_xcode_clang only refers to the iOS toolchain, host binaries use
      # chromium's clang always.
      if (!is_nacl &&
          (!use_xcode_clang || current_toolchain == host_toolchain)) {
        # Flags NaCl (Clang 3.7) and Xcode 7.3 (Clang clang-703.0.31) do not
        # recognize.
        cflags += [ "-Wunused-lambda-capture" ]
      }
    }
  }

  if (current_cpu == "arm64") {
    defines += [ "WEBRTC_ARCH_ARM64" ]
    defines += [ "WEBRTC_HAS_NEON" ]
  }

  if (current_cpu == "arm") {
    defines += [ "WEBRTC_ARCH_ARM" ]
    if (arm_version >= 7) {
      defines += [ "WEBRTC_ARCH_ARM_V7" ]
      if (arm_use_neon) {
        defines += [ "WEBRTC_HAS_NEON" ]
      }
    }
  }

  if (current_cpu == "mipsel") {
    defines += [ "MIPS32_LE" ]
    if (mips_float_abi == "hard") {
      defines += [ "MIPS_FPU_LE" ]
    }
    if (mips_arch_variant == "r2") {
      defines += [ "MIPS32_R2_LE" ]
    }
    if (mips_dsp_rev == 1) {
      defines += [ "MIPS_DSP_R1_LE" ]
    } else if (mips_dsp_rev == 2) {
      defines += [
        "MIPS_DSP_R1_LE",
        "MIPS_DSP_R2_LE",
      ]
    }
  }

  if (is_android && !is_clang) {
    # The Android NDK doesn"t provide optimized versions of these
    # functions. Ensure they are disabled for all compilers.
    cflags += [
      "-fno-builtin-cos",
      "-fno-builtin-sin",
      "-fno-builtin-cosf",
      "-fno-builtin-sinf",
    ]
  }

  if (use_libfuzzer || use_drfuzz || use_afl) {
    # Used in Chromium's overrides to disable logging
    defines += [ "WEBRTC_UNSAFE_FUZZER_MODE" ]
  }
}

config("common_objc") {
  libs = [ "Foundation.framework" ]
}

if (!build_with_chromium) {
  # Target to build all the WebRTC production code.
  rtc_static_library("webrtc") {
    # Only the root target should depend on this.
    visibility = [ "//:default" ]

    sources = []
    complete_static_lib = true
    defines = []

    deps = [
      ":webrtc_common",
      "api:transport_api",
      "audio",
      "call",
      "common_audio",
      "common_video",
      "media",
      "modules",
      "modules/video_capture:video_capture_internal_impl",
      "rtc_base",
      "system_wrappers:system_wrappers_default",
      "video",
      "voice_engine",
    ]

    if (build_with_mozilla) {
      deps += [
        "api:base_peerconnection_api",
        "api:video_frame_api",
        "system_wrappers:field_trial_default",
        "system_wrappers:metrics_default",
      ]
    } else {
      deps += [
        "api",
        "logging",
        "ortc",
        "p2p",
        "pc",
        "sdk",
        "stats",
      ]
    }

    if (rtc_enable_protobuf) {
      defines += [ "ENABLE_RTC_EVENT_LOG" ]
      deps += [ "logging:rtc_event_log_proto" ]
    }
  }

  if (rtc_include_tests) {
    # Target to build all the WebRTC tests (but not examples or tools).
    # Executable in order to get a target that links all WebRTC code.
    rtc_executable("webrtc_tests") {
      testonly = true

      # Only the root target should depend on this.
      visibility = [ "//:default" ]

      deps = [
        ":rtc_unittests",
        ":video_engine_tests",
        ":webrtc_nonparallel_tests",
        ":webrtc_perf_tests",
        "common_audio:common_audio_unittests",
        "common_video:common_video_unittests",
        "media:rtc_media_unittests",
        "modules:modules_tests",
        "modules:modules_unittests",
        "modules/audio_coding:audio_coding_tests",
        "modules/audio_processing:audio_processing_tests",
        "modules/remote_bitrate_estimator:bwe_simulations_tests",
        "modules/rtp_rtcp:test_packet_masks_metrics",
        "modules/video_capture:video_capture_internal_impl",
        "ortc:ortc_unittests",
        "pc:peerconnection_unittests",
        "pc:rtc_pc_unittests",
        "rtc_base:rtc_base_tests_utils",
        "stats:rtc_stats_unittests",
        "system_wrappers:system_wrappers_unittests",
        "test",
        "video:screenshare_loopback",
        "video:video_loopback",
        "voice_engine:voice_engine_unittests",
      ]
      if (is_android) {
        deps += [
          ":android_junit_tests",
          "sdk/android:libjingle_peerconnection_android_unittest",
        ]
      } else {
        deps += [ "modules/video_capture:video_capture_tests" ]
      }
      if (rtc_enable_protobuf) {
        deps += [
          "audio:low_bandwidth_audio_test",
          "logging:rtc_event_log2rtp_dump",
        ]
      }
    }
  }
}

rtc_static_library("webrtc_common") {
  # TODO(mbonadei): Remove (bugs.webrtc.org/7745)
  # Enabling GN check triggers cyclic dependency error:
  # :webrtc_common ->
  # api:video_frame_api ->
  # system_wrappers:system_wrappers ->
  # webrtc_common
  check_includes = false
  sources = [
    "common_types.cc",
    "common_types.h",
    "typedefs.h",
  ]

  if (!build_with_chromium && is_clang) {
    # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
    suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
  }
}

if (use_libfuzzer || use_drfuzz || use_afl) {
  # This target is only here for gn to discover fuzzer build targets under
  # webrtc/test/fuzzers/.
  group("webrtc_fuzzers_dummy") {
    testonly = true
    deps = [
      "test/fuzzers:webrtc_fuzzer_main",
    ]
  }
}

if (rtc_include_tests) {
  config("rtc_unittests_config") {
    # GN orders flags on a target before flags from configs. The default config
    # adds -Wall, and this flag have to be after -Wall -- so they need to
    # come from a config and can"t be on the target directly.
    if (is_clang) {
      cflags = [
        "-Wno-sign-compare",
        "-Wno-unused-const-variable",
      ]
    }
  }

  rtc_test("rtc_unittests") {
    testonly = true

    deps = [
      ":webrtc_common",
      "api:rtc_api_unittests",
      "api/audio_codecs/test:audio_codecs_api_unittests",
      "p2p:libstunprober_unittests",
      "p2p:rtc_p2p_unittests",
      "rtc_base:rtc_base_approved_unittests",
      "rtc_base:rtc_base_tests_main",
      "rtc_base:rtc_base_tests_utils",
      "rtc_base:rtc_base_unittests",
      "rtc_base:rtc_numerics_unittests",
      "rtc_base:rtc_task_queue_unittests",
      "rtc_base:sequenced_task_checker_unittests",
      "rtc_base:weak_ptr_unittests",
      "system_wrappers:metrics_default",
    ]

    if (rtc_enable_protobuf) {
      deps += [ "logging:rtc_event_log_tests" ]
    }

    if (is_android) {
      deps += [ "//testing/android/native_test:native_test_support" ]
      shard_timeout = 900
    }

    if (is_ios || is_mac) {
      deps += [ "sdk:sdk_unittests_objc" ]
    }
  }

  # TODO(pbos): Rename test suite, this is no longer "just" for video targets.
  video_engine_tests_resources = [
    "resources/foreman_cif_short.yuv",
    "resources/voice_engine/audio_long16.pcm",
  ]

  if (is_ios) {
    bundle_data("video_engine_tests_bundle_data") {
      testonly = true
      sources = video_engine_tests_resources
      outputs = [
        "{{bundle_resources_dir}}/{{source_file_part}}",
      ]
    }
  }

  rtc_test("video_engine_tests") {
    testonly = true
    deps = [
      "audio:audio_tests",

      # TODO(eladalon): call_tests aren't actually video-specific, so we
      # should move them to a more appropriate test suite.
      "call:call_tests",
      "modules/video_capture",
      "rtc_base:rtc_base_tests_utils",
      "test:test_common",
      "test:test_main",
      "test:video_test_common",
      "video:video_tests",
    ]
    data = video_engine_tests_resources
    if (!build_with_chromium && is_clang) {
      # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
      suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
    }
    if (is_android) {
      deps += [ "//testing/android/native_test:native_test_native_code" ]
      shard_timeout = 900
    }
    if (is_ios) {
      deps += [ ":video_engine_tests_bundle_data" ]
    }
  }

  webrtc_perf_tests_resources = [
    "resources/audio_coding/speech_mono_16kHz.pcm",
    "resources/audio_coding/speech_mono_32_48kHz.pcm",
    "resources/audio_coding/testfile32kHz.pcm",
    "resources/ConferenceMotion_1280_720_50.yuv",
    "resources/difficult_photo_1850_1110.yuv",
    "resources/foreman_cif.yuv",
    "resources/google-wifi-3mbps.rx",
    "resources/paris_qcif.yuv",
    "resources/photo_1850_1110.yuv",
    "resources/presentation_1850_1110.yuv",
    "resources/verizon4g-downlink.rx",
    "resources/voice_engine/audio_long16.pcm",
    "resources/web_screenshot_1850_1110.yuv",
  ]

  if (is_ios) {
    bundle_data("webrtc_perf_tests_bundle_data") {
      testonly = true
      sources = webrtc_perf_tests_resources
      outputs = [
        "{{bundle_resources_dir}}/{{source_file_part}}",
      ]
    }
  }

  rtc_test("webrtc_perf_tests") {
    testonly = true
    configs += [ ":rtc_unittests_config" ]

    deps = [
      "audio:audio_perf_tests",
      "call:call_perf_tests",
      "modules/audio_coding:audio_coding_perf_tests",
      "modules/audio_processing:audio_processing_perf_tests",
      "modules/remote_bitrate_estimator:remote_bitrate_estimator_perf_tests",
      "test:test_main",
      "video:video_full_stack_tests",
    ]

    data = webrtc_perf_tests_resources
    if (is_android) {
      deps += [ "//testing/android/native_test:native_test_native_code" ]
      shard_timeout = 2700
    }
    if (is_ios) {
      deps += [ ":webrtc_perf_tests_bundle_data" ]
    }
  }

  rtc_test("webrtc_nonparallel_tests") {
    testonly = true
    deps = [
      "rtc_base:rtc_base_nonparallel_tests",
    ]
    if (is_android) {
      deps += [ "//testing/android/native_test:native_test_support" ]
      shard_timeout = 900
    }
  }

  if (is_android) {
    junit_binary("android_junit_tests") {
      java_files = [
        "examples/androidjunit/src/org/appspot/apprtc/BluetoothManagerTest.java",
        "examples/androidjunit/src/org/appspot/apprtc/DirectRTCClientTest.java",
        "examples/androidjunit/src/org/appspot/apprtc/TCPChannelClientTest.java",
        "sdk/android/tests/src/org/webrtc/CameraEnumerationTest.java",
      ]

      deps = [
        "examples:AppRTCMobile_javalib",
        "sdk/android:libjingle_peerconnection_java",
        "//base:base_java_test_support",
      ]
    }
  }
}