Skip to content
New issue

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

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

Already on GitHub? # to your account

Support build_file or build_file_content for http_file #25383

Open
fzakaria opened this issue Feb 25, 2025 · 0 comments
Open

Support build_file or build_file_content for http_file #25383

fzakaria opened this issue Feb 25, 2025 · 0 comments
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request untriaged

Comments

@fzakaria
Copy link
Contributor

fzakaria commented Feb 25, 2025

Description of the feature request:

I would like to use http_file to download a single proto file.

http_file(
    name = "fake_proto",
    sha256 = "abc1234",
    url = "https://raw.githubusercontent.com/myorg/myrepo/src/path/probo/fake.proto
    downloaded_file_path = "fake.proto",
)

I cannot use this natively in a proto_library due to the following via https://github.com/protocolbuffers/protobuf/blob/2d6ab3ce45f85af6bffd694659148062ba9aecde/bazel/private/bazel_proto_library_rule.bzl#L24C5-L24C24

Error in fail: Proto source with label '@@_main~_repo_rules~fake_proto//file:fake.proto' must be in same package as consuming rule.

You can get around this in two ways:

A dummy genrule to copy it to local package

genrule(
    name = "fake_proto_file",
    srcs = ["@fake_proto//file:fake.proto"],
    outs = ["fake.proto"],
    cmd = """
        cp $< $@
    """,
)

http_archive with custom build_file
The custom build_file_content can create the proto_library and therefore be in the same package.

Both of these feels unnecessary; pulling in protobuf files should be a straightforward UX in Bazel.

@sgowroji sgowroji added the team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. label Feb 26, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request untriaged
Projects
None yet
Development

No branches or pull requests

4 participants