blob: a10b953cd7c7ca4fa5e85041932865064056f58e [file] [log] [blame]
# 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.
# TODO(kjellander): Rebase this to webrtc/build/common.gypi changes after r6330.
import("//build/config/linux/pkg_config.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("webrtc.gni")
import("//third_party/protobuf/proto_library.gni")
if (is_android) {
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
}
# 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" ]
}
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",
"EXPAT_RELATIVE_PATH",
"GTEST_RELATIVE_PATH",
"NO_SOUND_SYSTEM",
"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_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 (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}" ]
}
# 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_restrict_logging) {
defines += [ "WEBRTC_RESTRICT_LOGGING" ]
}
if (rtc_include_internal_audio_device) {
defines += [ "WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE" ]
}
if (rtc_relative_path) {
defines += [ "EXPAT_RELATIVE_PATH" ]
}
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 += [
"-Wimplicit-fallthrough",
"-Wthread-safety",
"-Winconsistent-missing-override",
"-Wundef",
]
}
}
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 = [
# TODO(ossu): Keep this here until donwstream projects have updated.
# http://bugs.webrtc.org/6716
"call.h",
"config.h",
]
complete_static_lib = true
defines = []
deps = [
":webrtc_common",
"api",
"api:transport_api",
"audio",
"base",
"call",
"common_audio",
"common_video",
"logging",
"media",
"modules",
"modules/video_capture:video_capture_internal_impl",
"ortc",
"p2p",
"pc",
"sdk",
"stats",
"system_wrappers",
"video",
"voice_engine",
]
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",
"api:rtc_api_unittests",
"base:rtc_base_tests_utils",
"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",
"modules/video_coding:plot_videoprocessor_integrationtest",
"ortc:ortc_unittests",
"pc:peerconnection_unittests",
"pc:rtc_pc_unittests",
"stats:rtc_stats_unittests",
"system_wrappers:system_wrappers_unittests",
"test",
"video:screenshare_loopback",
"video:video_loopback",
"video:video_tests",
"voice_engine:voice_engine_unittests",
]
if (is_android) {
deps += [
":android_junit_tests",
"//webrtc/sdk/android:libjingle_peerconnection_android_unittest",
]
} else {
deps += [ "modules/video_capture:video_capture_tests" ]
}
if (!is_ios) {
deps += [
"modules/audio_device:audio_device_tests",
"voice_engine:voe_auto_test",
]
}
if (rtc_enable_protobuf) {
deps += [ "logging:rtc_event_log2rtp_dump" ]
}
}
}
}
rtc_static_library("webrtc_common") {
sources = [
"common_types.cc",
"common_types.h",
"config.cc",
"config.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 = [
"api:rtc_api_unittests",
"base:rtc_base_approved_unittests",
"base:rtc_base_unittests",
"base:rtc_numerics_unittests",
"base:rtc_task_queue_unittests",
"p2p:libstunprober_unittests",
"p2p:rtc_p2p_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:rtc_sdk_peerconnection_objc_unittests" ]
}
}
# 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",
"base:rtc_base_tests_utils",
"call:call_tests",
"modules/video_capture",
"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 = [
"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",
"video:video_quality_test",
]
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 = [
"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 = [
"//base:base_java_test_support",
"//webrtc/examples:AppRTCMobile_javalib",
"//webrtc/sdk/android:libjingle_peerconnection_java",
]
}
}
}