gn: Remove the need for absl_deps

Abseil deps are automatically filtered and replaced by the catch-all
Abseil dependency when built within Chromium. This removes the need to
have special handling for Abseil dependencies in our rules and facilitates
tooling.

Bug: webrtc:341803749
Change-Id: I07425e85d9eeccb66ad423fb1db8b59527a0956a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/351003
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Auto-Submit: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42365}
This commit is contained in:
Florent Castelli 2024-05-20 09:57:05 +00:00 committed by WebRTC LUCI CQ
parent 1d7d0e6e2c
commit 3ffa0e8b6f
3 changed files with 39 additions and 48 deletions

View File

@ -376,39 +376,6 @@ def CheckNoSourcesAbove(input_api, gn_files, output_api):
return []
def CheckAbseilDependencies(input_api, gn_files, output_api):
"""Checks that Abseil dependencies are declared in `absl_deps`."""
absl_re = re.compile(r'third_party/abseil-cpp', re.MULTILINE | re.DOTALL)
target_types_to_check = [
'rtc_library',
'rtc_source_set',
'rtc_static_library',
'webrtc_fuzzer_test',
]
error_msg = ('Abseil dependencies in target "%s" (file: %s) '
'should be moved to the "absl_deps" parameter.')
errors = []
# pylint: disable=too-many-nested-blocks
for gn_file in gn_files:
gn_file_content = input_api.ReadFile(gn_file)
for target_match in TARGET_RE.finditer(gn_file_content):
target_type = target_match.group('target_type')
target_name = target_match.group('target_name')
target_contents = target_match.group('target_contents')
if target_type in target_types_to_check:
for deps_match in DEPS_RE.finditer(target_contents):
deps = deps_match.group('deps').splitlines()
for dep in deps:
if re.search(absl_re, dep):
errors.append(
output_api.PresubmitError(
error_msg %
(target_name, gn_file.LocalPath())))
break # no need to warn more than once per target
return errors
def CheckNoMixingSources(input_api, gn_files, output_api):
"""Disallow mixing C, C++ and Obj-C/Obj-C++ in the same target.
@ -671,7 +638,6 @@ def CheckGnChanges(input_api, output_api):
if gn_files:
result.extend(CheckNoSourcesAbove(input_api, gn_files, output_api))
result.extend(CheckNoMixingSources(input_api, gn_files, output_api))
result.extend(CheckAbseilDependencies(input_api, gn_files, output_api))
result.extend(
CheckNoPackageBoundaryViolations(input_api, gn_files, output_api))
result.extend(CheckPublicDepsIsNotUsed(gn_files, input_api,

View File

@ -115,8 +115,8 @@ rtc_library("rtp_headers") {
":array_view",
"units:timestamp",
"video:video_rtp_headers",
"//third_party/abseil-cpp/absl/types:optional",
]
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
}
rtc_library("rtp_packet_info") {

View File

@ -413,6 +413,7 @@ set_defaults("rtc_test") {
configs = rtc_add_configs
public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
suppressed_configs = []
absl_deps = []
}
set_defaults("rtc_library") {
@ -564,14 +565,20 @@ template("rtc_test") {
# If absl_deps is [], no action is needed. If not [], then it needs to be
# converted to //third_party/abseil-cpp:absl when build_with_chromium=true
# otherwise it just needs to be added to deps.
if (defined(absl_deps) && absl_deps != []) {
if (absl_deps != []) {
if (!defined(deps)) {
deps = []
}
if (build_with_chromium) {
deps += absl_deps
}
if (build_with_chromium && defined(deps)) {
absl_dependencies = filter_labels_include(deps, ["//third_party/abseil-cpp/*"])
if (absl_dependencies != []) {
filtered_deps = filter_labels_exclude(deps, ["//third_party/abseil-cpp/*"])
deps = []
deps = filtered_deps
deps += [ "//third_party/abseil-cpp:absl" ]
} else {
deps += absl_deps
}
}
@ -682,10 +689,16 @@ template("rtc_source_set") {
if (!defined(deps)) {
deps = []
}
if (build_with_chromium) {
deps += absl_deps
}
if (build_with_chromium && defined(deps)) {
absl_dependencies = filter_labels_include(deps, ["//third_party/abseil-cpp/*"])
if (absl_dependencies != []) {
filtered_deps = filter_labels_exclude(deps, ["//third_party/abseil-cpp/*"])
deps = []
deps = filtered_deps
deps += [ "//third_party/abseil-cpp:absl" ]
} else {
deps += absl_deps
}
}
}
@ -771,10 +784,16 @@ template("rtc_static_library") {
if (!defined(deps)) {
deps = []
}
if (build_with_chromium) {
deps += absl_deps
}
if (build_with_chromium && defined(deps)) {
absl_dependencies = filter_labels_include(deps, ["//third_party/abseil-cpp/*"])
if (absl_dependencies != []) {
filtered_deps = filter_labels_exclude(deps, ["//third_party/abseil-cpp/*"])
deps = []
deps = filtered_deps
deps += [ "//third_party/abseil-cpp:absl" ]
} else {
deps += absl_deps
}
}
}
@ -910,10 +929,16 @@ template("rtc_library") {
if (!defined(deps)) {
deps = []
}
if (build_with_chromium) {
deps += absl_deps
}
if (build_with_chromium && defined(deps)) {
absl_dependencies = filter_labels_include(deps, ["//third_party/abseil-cpp/*"])
if (absl_dependencies != []) {
filtered_deps = filter_labels_exclude(deps, ["//third_party/abseil-cpp/*"])
deps = []
deps = filtered_deps
deps += [ "//third_party/abseil-cpp:absl" ]
} else {
deps += absl_deps
}
}
}