Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(textproto): workaround upstream proto path bug #5307

Merged
merged 2 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion kythe/cxx/indexer/proto/testdata/proto_verifier_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,17 @@ def get_proto_files_and_proto_paths(protolibs):
for src in info.direct_sources:
toplevel_srcs.append(src)
all_srcs = depset([], transitive = [lib[ProtoInfo].transitive_sources for lib in protolibs])
proto_paths = depset(transitive = [lib[ProtoInfo].transitive_proto_path for lib in protolibs])
proto_paths = depset(
transitive = [lib[ProtoInfo].transitive_proto_path for lib in protolibs] +
# Workaround for https://github.com/bazelbuild/bazel/issues/7964.
# Since we can't rely on ProtoInfo to provide accurate roots, generate them here.
[depset([
src.root.path
for src in depset(toplevel_srcs, transitive = [all_srcs], order = "postorder").to_list()
if src.root.path
])],
order = "postorder",
)
return toplevel_srcs, all_srcs, proto_paths

def _proto_extract_kzip_impl(ctx):
Expand Down
27 changes: 27 additions & 0 deletions kythe/cxx/indexer/textproto/testdata/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ textproto_verifier_test(
textprotos = ["imports.pbtxt"],
)

textproto_verifier_test(
name = "imports_generated_test",
protos = [
":generated_proto",
":imports_generated_proto",
],
textprotos = ["generated_imports.pbtxt"],
)

textproto_verifier_test(
name = "extensions_test",
protos = [":extensions_proto"],
Expand Down Expand Up @@ -108,3 +117,21 @@ proto_library(
name = "repeated_extension_proto",
srcs = ["repeated_extension.proto"],
)

genrule(
name = "generate_proto",
srcs = ["example.proto"],
outs = ["generated.proto"],
cmd = "cp $< $@",
)

proto_library(
name = "generated_proto",
srcs = [":generated.proto"],
)

proto_library(
name = "imports_generated_proto",
srcs = ["imports_generated.proto"],
deps = [":generated_proto"],
)
8 changes: 8 additions & 0 deletions kythe/cxx/indexer/textproto/testdata/generated_imports.pbtxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# proto-message: example2.OuterMessage
# proto-file: kythe/cxx/indexer/textproto/testdata/imports_generated.proto

#- @inner_msg ref OuterMessageInnerMsg
inner_msg {
#- @field1 ref Field1
shahms marked this conversation as resolved.
Show resolved Hide resolved
field1: "hello"
}
10 changes: 10 additions & 0 deletions kythe/cxx/indexer/textproto/testdata/imports_generated.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
syntax = "proto2";

package example2;

import "kythe/cxx/indexer/textproto/testdata/generated.proto";

message OuterMessage {
//- @inner_msg defines/binding OuterMessageInnerMsg
optional example.Message2 inner_msg = 1;
};