GN: New conventions, default target and refactorings

Introduce a convention on categorizing GN targets:
1. Production code
2. Tests
3. Examples
4. Tools
The first two have targets spread out all over the tree,
while the latter are isolated to examples/ and tools/ directories.

Another new convention: Each directory's BUILD.gn file shall contain
a target named similar to the directory name. This target shall
contain the 'most common' production code, i.e. so that most
consumers of the directory can depend on only the directory
(which implicitly means that target in GN).

//webrtc:webrtc_tests is changed to depend on all WebRTC tests.
From now on, it's necessary to add new test targets to this dependency
tree in order to get them compiled.

Two new group targets are created:
//webrtc/modules/audio_coding:audio_coding_tests
//webrtc/modules/audio_processing:audio_processing_tests
to reduce the long list of tests in //webrtc:webrtc_tests.

Visibility on //webrtc:webrtc and  //webrtc:webrtc_tests is restricted
to the root target, to avoid circular dependencies due to the monolithic
property of these targets (a problem we've had in the past).

The 'root' target at the top level is renamed to 'default', which means GN will
build this target instead of _all_ generated targets
(see https://chromium.googlesource.com/chromium/src/+/master/tools/gn/docs/faq.md#Can-I-control-what-targets-are-built-by-default).
This target now depends on everything we want to build, meaning all targets now
explicitly needs to be wired up from the root target in order to get build.
Having this, the number of compiled objects on Android is decreased from 8855 to 6276. It also gives us better control over our build.

BUG=webrtc:6440
TESTED=git cl try --clobber
NOTRY=True

Review-Url: https://codereview.webrtc.org/2441383002
Cr-Commit-Position: refs/heads/master@{#14821}
This commit is contained in:
kjellander
2016-10-28 05:44:03 -07:00
committed by Commit bot
parent 9f4a4a096b
commit 6ceab08322
13 changed files with 220 additions and 45 deletions

View File

@ -6,10 +6,12 @@
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
# This file is copied and modified from Chromium (src/BUILD.gn).
group("root") {
group("default") {
testonly = true
deps = [
"//webrtc",
"//webrtc:webrtc_tests",
"//webrtc/examples",
"//webrtc/tools",
]
}

View File

@ -243,8 +243,12 @@ config("common_objc") {
precompiled_source = "sdk/objc/WebRTC-Prefix.pch"
}
if (!is_ios || !build_with_chromium) {
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(kjellander): Remove this whenever possible. GN's static_library
# target type requires at least one object to avoid errors linking.
@ -258,37 +262,84 @@ if (!is_ios || !build_with_chromium) {
deps = [
":webrtc_common",
"api",
"audio",
"base:rtc_base",
"base",
"call",
"common_audio",
"common_video",
"libjingle/xmllite",
"libjingle/xmpp",
"logging",
"media",
"modules",
"modules/video_capture:video_capture_internal_impl",
"p2p",
"pc",
"sdk",
"stats",
"system_wrappers",
"tools",
"video",
"voice_engine",
]
if (build_with_chromium) {
deps += [ "modules/video_capture" ]
} else {
# TODO(kjellander): Enable for Chromium as well when bugs.webrtc.org/4256
# is fixed. Right now it's not possible due to circular dependencies.
deps += [
"api",
"media",
"p2p",
"pc",
]
}
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",
":xmllite_xmpp_unittests",
"api:peerconnection_unittests",
"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/rtp_rtcp:test_packet_masks_metrics",
"modules/video_capture:video_capture_internal_impl",
"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:voe_cmd_test",
"voice_engine:voice_engine_unittests",
]
if (is_android) {
deps += [
":android_junit_tests",
"api: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",
]
}
}
}
}
rtc_static_library("webrtc_common") {
@ -637,15 +688,6 @@ if (rtc_include_tests) {
}
}
rtc_executable("webrtc_tests") {
testonly = true
deps = [
":webrtc",
"modules/video_capture:video_capture_internal_impl",
"test",
]
}
rtc_test("webrtc_perf_tests") {
testonly = true
configs += [ ":rtc_unittests_config" ]

View File

@ -16,6 +16,12 @@ group("api") {
public_deps = [
":libjingle_peerconnection",
]
if (is_android && !build_with_chromium) {
public_deps += [
":libjingle_peerconnection_java",
":libjingle_peerconnection_so",
]
}
}
rtc_source_set("call_api") {

View File

@ -19,6 +19,17 @@ if (is_win) {
import("//build/config/clang/clang.gni")
}
group("base") {
public_deps = [
":rtc_base",
":rtc_base_approved",
":rtc_task_queue",
]
if (is_android) {
public_deps += [ ":base_java" ]
}
}
config("rtc_base_approved_all_dependent_config") {
if (is_mac && !build_with_chromium) {
libs = [ "Foundation.framework" ] # needed for logging_mac.mm

View File

@ -20,12 +20,22 @@ if (is_linux) {
}
group("examples") {
# This target shall build all targets in examples.
testonly = true
public_deps = []
if (is_android) {
public_deps += [
":AppRTCMobile",
":AppRTCMobileTest",
]
}
if (is_ios || (is_mac && target_cpu != "x86")) {
public_deps += [ ":AppRTCMobile" ]
}
if (is_linux) {
if (is_linux || is_win) {
public_deps += [
":peerconnection_client",
":peerconnection_server",

View File

@ -13,6 +13,15 @@ if (is_android) {
import("//build/config/android/rules.gni")
}
group("logging") {
public_deps = [
":rtc_event_log_impl",
]
if (rtc_enable_protobuf) {
public_deps += [ ":rtc_event_log_parser" ]
}
}
rtc_source_set("rtc_event_log_api") {
sources = [
"rtc_event_log/rtc_event_log.h",

View File

@ -19,13 +19,17 @@ group("modules") {
"audio_coding",
"audio_conference_mixer",
"audio_device",
"audio_mixer:audio_mixer_impl",
"audio_mixer",
"audio_processing",
"bitrate_controller",
"congestion_controller",
"desktop_capture",
"media_file",
"pacing",
"remote_bitrate_estimator",
"rtp_rtcp",
"utility",
"video_capture",
"video_coding",
"video_processing",
]
@ -625,7 +629,7 @@ if (rtc_include_tests) {
"../base:rtc_base", # TODO(kjellander): Cleanup in bugs.webrtc.org/3806.
"../common_audio",
"../common_video",
"../system_wrappers:system_wrappers",
"../system_wrappers",
"../test:rtp_test_utils",
"../test:test_common",
"../test:test_support",
@ -645,8 +649,7 @@ if (rtc_include_tests) {
"audio_coding:webrtc_opus",
"audio_conference_mixer",
"audio_device",
"audio_mixer:audio_frame_manipulator",
"audio_mixer:audio_mixer_impl",
"audio_mixer",
"audio_processing",
"audio_processing:audioproc_test_utils",
"bitrate_controller",

View File

@ -913,6 +913,42 @@ rtc_source_set("neteq_test_minimal") {
}
if (rtc_include_tests) {
group("audio_coding_tests") {
testonly = true
public_deps = [
":RTPchange",
":RTPencode",
":RTPjitter",
":RTPtimeshift",
":acm_receive_test",
":acm_send_test",
":audio_classifier_test",
":audio_codec_speed_tests",
":audio_decoder_unittests",
":audio_decoder_unittests",
":delay_test",
":g711_test",
":g722_test",
":ilbc_test",
":insert_packet_with_timing",
":isac_api_test",
":isac_fix_test",
":isac_switch_samprate_test",
":isac_test",
":neteq_ilbc_quality_test",
":neteq_isac_quality_test",
":neteq_opus_quality_test",
":neteq_pcmu_quality_test",
":neteq_speed_test",
":rtp_analyze",
":rtpcat",
":webrtc_opus_fec_test",
]
if (rtc_enable_protobuf) {
public_deps += [ ":neteq_rtpplay" ]
}
}
rtc_source_set("acm_receive_test") {
testonly = true
sources = [
@ -1028,7 +1064,7 @@ if (rtc_include_tests) {
":isac_fix",
":neteq",
":neteq_unittest_tools",
"../../common_audio/",
"../../common_audio",
"../../test:test_support_main",
"//testing/gtest",
]
@ -1128,7 +1164,7 @@ if (rtc_include_tests) {
":webrtc_opus",
"../../system_wrappers:system_wrappers_default",
"../../test:test_support_main",
"../audio_processing/",
"../audio_processing",
"//testing/gtest",
]
}

View File

@ -8,6 +8,13 @@
import("../../build/webrtc.gni")
group("audio_mixer") {
public_deps = [
":audio_frame_manipulator",
":audio_mixer_impl",
]
}
rtc_static_library("audio_mixer_impl") {
visibility = [
"../../audio:audio",

View File

@ -315,6 +315,26 @@ if (rtc_build_with_neon) {
}
if (rtc_include_tests) {
group("audio_processing_tests") {
testonly = true
public_deps = [
":audioproc_f",
":audioproc_test_utils",
":click_annotate",
":nonlinear_beamformer_test",
":transient_suppression_test",
":unpack_aecdump",
]
if (rtc_enable_intelligibility_enhancer) {
public_deps += [ ":intelligibility_proc" ]
}
if (rtc_enable_protobuf) {
public_deps += [ ":audioproc_unittest_proto" ]
}
}
rtc_executable("unpack_aecdump") {
testonly = true
sources = [

View File

@ -10,8 +10,13 @@ import("../build/webrtc.gni")
group("p2p") {
public_deps = [
":libstunprober",
":rtc_p2p",
]
if (!build_with_chromium) {
# TODO(kjellander): Move this to examples or tools.
public_deps += [ ":stun_prober" ]
}
}
config("rtc_p2p_inherited_config") {

View File

@ -15,6 +15,14 @@ if (is_ios) {
import("//build/config/ios/rules.gni")
}
group("sdk") {
if (is_ios || (is_mac && mac_deployment_target == "10.7")) {
public_deps = [
":rtc_sdk_framework_objc",
]
}
}
if (is_ios || (is_mac && mac_deployment_target == "10.7")) {
config("rtc_sdk_common_objc_config") {
include_dirs = [

View File

@ -10,16 +10,32 @@ import("//third_party/protobuf/proto_library.gni")
import("../build/webrtc.gni")
group("tools") {
deps = [
":command_line_parser",
]
# This target shall build all targets in tools/.
testonly = true
if (!build_with_chromium) {
# TODO(kjellander): Enable these when webrtc:5970 is fixed.
deps += [
":frame_analyzer",
":rgba_to_i420_converter",
public_deps = [
":command_line_parser",
":frame_analyzer",
":frame_editor",
":psnr_ssim_analyzer",
":rgba_to_i420_converter",
]
if (rtc_include_internal_audio_device) {
public_deps += [ ":force_mic_volume_max" ]
}
if (rtc_enable_protobuf) {
public_deps += [ ":chart_proto" ]
}
if (rtc_include_tests) {
public_deps += [
":activity_metric",
":rtp_analyzer",
":tools_unittests",
]
if (rtc_enable_protobuf) {
public_deps += [ ":event_log_visualizer" ]
}
}
}
@ -129,7 +145,7 @@ if (rtc_include_internal_audio_device) {
}
deps = [
"../modules/audio_device:audio_device",
"../modules/audio_device",
"../system_wrappers:system_wrappers_default",
"//build/win:default_exe_manifest",
]
@ -163,8 +179,8 @@ if (rtc_enable_protobuf) {
deps = [
"../logging:rtc_event_log_impl",
"../logging:rtc_event_log_parser",
"../modules/congestion_controller:congestion_controller",
"../modules/rtp_rtcp:rtp_rtcp",
"../modules/congestion_controller",
"../modules/rtp_rtcp",
"../system_wrappers:system_wrappers_default",
"//build/config/sanitizers:deps",
]