Skip to content

Commit c00072e

Browse files
zhangskzcopybara-github
authored andcommitted
Clean up redundant internal _direct_proto_sources, _transitive_proto_sources, and _exported_sources (sort-of).
PiperOrigin-RevId: 758755911
1 parent 62643e3 commit c00072e

File tree

4 files changed

+5
-31
lines changed

4 files changed

+5
-31
lines changed

bazel/common/proto_common.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def _experimental_filter_sources(proto_info, proto_lang_toolchain_info):
246246
provided_paths[path] = None
247247

248248
# Filter proto files
249-
proto_files = proto_info._direct_proto_sources
249+
proto_files = proto_info.direct_sources
250250
excluded = []
251251
included = []
252252
for proto_file in proto_files:

bazel/private/proto_info.bzl

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
Definition of ProtoInfo provider.
1010
"""
1111

12-
_warning = """ Don't use this field. It's intended for internal use and will be changed or removed
13-
without warning."""
14-
1512
def _uniq(iterable):
1613
unique_elements = {element: None for element in iterable}
1714
return list(unique_elements.keys())
@@ -74,12 +71,6 @@ def _create_proto_info(*, srcs, deps, descriptor_set, proto_path = "", workspace
7471
if not bin_dir:
7572
fail("bin_dir parameter should be set when _virtual_imports are used")
7673

77-
direct_proto_sources = srcs
78-
transitive_proto_sources = depset(
79-
direct = direct_proto_sources,
80-
transitive = [dep._transitive_proto_sources for dep in deps],
81-
order = "preorder",
82-
)
8374
transitive_sources = depset(
8475
direct = srcs,
8576
transitive = [dep.transitive_sources for dep in deps],
@@ -104,12 +95,6 @@ def _create_proto_info(*, srcs, deps, descriptor_set, proto_path = "", workspace
10495
transitive = [dep.transitive_descriptor_sets for dep in deps],
10596
)
10697

107-
# Layering checks.
108-
if srcs:
109-
exported_sources = depset(direct = direct_proto_sources)
110-
else:
111-
exported_sources = depset(transitive = [dep._exported_sources for dep in deps])
112-
11398
if "_virtual_imports/" in proto_path:
11499
#TODO: remove bin_dir from proto_source_root (when users assuming it's there are migrated)
115100
proto_source_root = _empty_to_dot(_from_root(bin_dir, workspace_root, proto_path))
@@ -127,9 +112,6 @@ def _create_proto_info(*, srcs, deps, descriptor_set, proto_path = "", workspace
127112
transitive_proto_path = transitive_proto_path,
128113
check_deps_sources = check_deps_sources,
129114
transitive_imports = transitive_sources,
130-
_direct_proto_sources = direct_proto_sources,
131-
_transitive_proto_sources = transitive_proto_sources,
132-
_exported_sources = exported_sources,
133115
)
134116
if allow_exports:
135117
proto_info["allow_exports"] = allow_exports
@@ -173,14 +155,6 @@ ProtoInfo, _ = provider(
173155

174156
# Deprecated fields:
175157
"transitive_imports": """(depset[File]) Deprecated: use `transitive_sources` instead.""",
176-
177-
# Internal fields:
178-
"_direct_proto_sources": """(list[File]) The `ProtoSourceInfo`s from the `srcs`
179-
attribute.""" + _warning,
180-
"_transitive_proto_sources": """(depset[File]) The `ProtoSourceInfo`s from this
181-
rule and all its dependent protocol buffer rules.""" + _warning,
182-
"_exported_sources": """(depset[File]) A set of `ProtoSourceInfo`s that may be
183-
imported by another `proto_library` depending on this one.""" + _warning,
184158
},
185159
init = _create_proto_info,
186160
)

bazel/private/proto_lang_toolchain_rule.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ load("//bazel/common:proto_lang_toolchain_info.bzl", "ProtoLangToolchainInfo")
1414
load("//bazel/private:toolchain_helpers.bzl", "toolchains")
1515

1616
def _rule_impl(ctx):
17-
provided_proto_sources = depset(transitive = [bp[ProtoInfo]._transitive_proto_sources for bp in ctx.attr.blacklisted_protos]).to_list()
17+
provided_proto_sources = depset(transitive = [bp[ProtoInfo].transitive_sources for bp in ctx.attr.blacklisted_protos]).to_list()
1818

1919
flag = ctx.attr.command_line
2020
if flag.find("$(PLUGIN_OUT)") > -1:

bazel/private/proto_library_rule.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ def _write_descriptor_set(ctx, proto_info, deps, exports, descriptor_set):
172172
if strict_deps:
173173
if proto_info.direct_sources:
174174
strict_importable_sources = depset(
175-
direct = proto_info._direct_proto_sources,
176-
transitive = [dep._exported_sources for dep in deps],
175+
direct = proto_info.direct_sources,
176+
transitive = [dep.check_deps_sources for dep in deps],
177177
)
178178
else:
179179
strict_importable_sources = None
@@ -195,7 +195,7 @@ def _write_descriptor_set(ctx, proto_info, deps, exports, descriptor_set):
195195

196196
strict_imports = ctx.attr._strict_public_imports[BuildSettingInfo].value
197197
if strict_imports:
198-
public_import_protos = depset(transitive = [export._exported_sources for export in exports])
198+
public_import_protos = depset(transitive = [export.check_deps_sources for export in exports])
199199
if not public_import_protos:
200200
# This line is necessary to trigger the check.
201201
args.add("--allowed_public_imports=")

0 commit comments

Comments
 (0)