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

Unable to use build_event_stream.proto as external dependency #16335

Closed
JSGette opened this issue Sep 24, 2022 · 10 comments
Closed

Unable to use build_event_stream.proto as external dependency #16335

JSGette opened this issue Sep 24, 2022 · 10 comments
Labels
awaiting-user-response Awaiting a response from the author team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: bug untriaged

Comments

@JSGette
Copy link

JSGette commented Sep 24, 2022

Description of the bug:

Instead of putting build_event_stream.proto directly into my project to implement build event service I want to consume all required proto files by putting bazel as external dependency in WORKSPACE file of my project:

http_archive(
   name = "bazel",
    build_file = "bazel.BUILD",
    sha256 = "149d475bd48cee245a3365bb523b6a702101800025dbf9aba217d059f3b6ef35",
    urls = ["https://github.com/bazelbuild/bazel/archive/refs/tags/5.3.1.tar.gz"],
    strip_prefix = "bazel-5.3.1",
)

Content of external/bazel.BUILD:

package(default_visibility = ["//visibility:public"])
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

java_proto_library(
    name = "build_event_stream_java_proto",
    deps = ["build_event_stream_proto"],
)

proto_library(
    name = "command_line_proto",
    srcs = ["//src/main/protobuf/command_line.proto"],
    deps = [":option_filters_proto"],
)

proto_library(
    name = "option_filters_proto",
    srcs = ["//src/main/protobuf/option_filters.proto"],
)

proto_library(
    name = "failure_details_proto",
    srcs = ["//src/main/protobuf/failure_details.proto"],
    deps = ["@com_google_protobuf//:descriptor_proto"],
)

proto_library(
    name = "invocation_policy_proto",
    srcs = ["//src/main/protobuf/invocation_policy.proto"],
)

proto_library(
    name = "build_event_stream_proto",
    srcs = ["src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto"],
    deps = [
        ":command_line_proto",
        ":failure_details_proto",
        ":invocation_policy_proto",
        "@com_google_protobuf//:duration_proto",
        "@com_google_protobuf//:timestamp_proto",
    ],
)

This doesn't work as in BUILD default visibility is defined to subpackages of src package within bazel.

package(default_visibility = ["//src:__subpackages__"])

Hence, it isn't possible to access proto-files directly without "patching" cloned repository and removing BUILD file.

Error:

BUILD.bazel:32:14: 
Label '@bazel//:src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto' 
is invalid because '@bazel//src/main/java/com/google/devtools/build/lib/buildeventstream/proto' is a subpackage;
perhaps you meant to put the colon here: '@bazel//src/main/java/com/google/devtools/build/lib/buildeventstream/proto:build_event_stream.proto'?

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

No response

Which operating system are you running Bazel on?

WSL2 (Ubuntu)

What is the output of bazel info release?

release 5.3.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@sgowroji sgowroji added type: bug untriaged team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website labels Sep 26, 2022
@sgowroji
Copy link
Member

Adding the similar bug #15874. Not the dupe.

@meteorcloudy meteorcloudy added team-Performance Issues for Performance teams and removed team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website labels Sep 27, 2022
@larsrc-google
Copy link
Contributor

Seems very similar to bug #15874, so assigning to its team.

@larsrc-google larsrc-google added team-Core Skyframe, bazel query, BEP, options parsing, bazelrc and removed team-Performance Issues for Performance teams labels Sep 28, 2022
@haxorz
Copy link
Contributor

haxorz commented Sep 29, 2022

Indeed #15874 sounds similar, thanks @sgowroji for noting the connection!

@JSGette, why do you want to consume all the required proto files? Would instead consuming an appropriate x_proto_library target work for your purposes? If so, what's your x? If not, what are you doing and do you really need visibility of the .proto file targets themselves?

@haxorz haxorz added the awaiting-user-response Awaiting a response from the author label Sep 29, 2022
@haxorz
Copy link
Contributor

haxorz commented Sep 29, 2022

@michaeledgar fyi

@brentleyjones
Copy link
Contributor

I also need this to be visible. Mine is swift_proto_library. The proto itself doesn't need to be visible, but the proto_librarys do, otherwise I have to copy over the files and do this: https://github.com/buildbuddy-io/rules_xcodeproj/blob/62316bcfcc5ed56a83cf0f4771d57cf16a8e222a/tools/bep_parser/bep/BUILD#L7-L43

@JSGette
Copy link
Author

JSGette commented Feb 11, 2023

@haxorz I wanted to consume this target:
@bazel//src/main/java/com/google/devtools/build/lib/buildeventstream/proto:build_event_stream.proto

@cameron-martin
Copy link
Contributor

cameron-martin commented May 22, 2023

Related to #3684. Possibly even a dupe.

@Zemnmez
Copy link

Zemnmez commented Jan 16, 2024

I had this same issue today trying to make something that would consume BEP and make the appropriate output for github actions.

@michaeledgar
Copy link
Contributor

This looks easy to correct. I'll check around for some historical context, but AFAICT this seems like a totally fine change to make: https://bazel-review.googlesource.com/c/bazel/+/238093

I'm not terribly persuaded that the BEP protobufs need to live in a different repository, though perhaps they belong with the other protobufs.

cameron-martin added a commit to cameron-martin/bazel that referenced this issue Feb 4, 2024
This makes the build event stream and starlark debugging proto libraries public. This is for consumption by the vscode-bazel plugin, which already uses these but in a very hacky way.

Fixes bazelbuild#16335
Fixes bazelbuild#3684
bazel-io pushed a commit to bazel-io/bazel that referenced this issue Apr 11, 2024
This makes the build event stream and starlark debugging proto libraries public. This is for consumption by the vscode-bazel plugin, which already uses these but in a very hacky way.

Fixes bazelbuild#16335
Fixes bazelbuild#3684

Closes bazelbuild#21196.

PiperOrigin-RevId: 623740758
Change-Id: Ic47d6dd05fcf2af8beec4d9212d4c7fd65bcda44
github-merge-queue bot pushed a commit that referenced this issue Apr 15, 2024
This makes the build event stream and starlark debugging proto libraries
public. This is for consumption by the vscode-bazel plugin, which
already uses these but in a very hacky way.

Fixes #16335
Fixes #3684

Closes #21196.

PiperOrigin-RevId: 623740758
Change-Id: Ic47d6dd05fcf2af8beec4d9212d4c7fd65bcda44

Commit
adfe016

Co-authored-by: Cameron Martin <[email protected]>
Kila2 pushed a commit to Kila2/bazel that referenced this issue May 13, 2024
This makes the build event stream and starlark debugging proto libraries public. This is for consumption by the vscode-bazel plugin, which already uses these but in a very hacky way.

Fixes bazelbuild#16335
Fixes bazelbuild#3684

Closes bazelbuild#21196.

PiperOrigin-RevId: 623740758
Change-Id: Ic47d6dd05fcf2af8beec4d9212d4c7fd65bcda44
@iancha1992
Copy link
Member

A fix for this issue has been included in Bazel 7.2.0 RC1. Please test out the release candidate and report any issues as soon as possible.
If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=7.2.0rc1. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-user-response Awaiting a response from the author team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: bug untriaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants