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

protobuf-src incompatible with Bazel build systems #11

Open
lithiumFlower opened this issue Oct 27, 2023 · 1 comment
Open

protobuf-src incompatible with Bazel build systems #11

lithiumFlower opened this issue Oct 27, 2023 · 1 comment

Comments

@lithiumFlower
Copy link

The bazel meta build system auto generates build files for crate dependencies of a project using the rules_rust bazel package https://bazelbuild.github.io/rules_rust.

A feature of bazel is that its glob function will ignore subdirectories with BUILD or BUILD.bazel files in them. When bazel autogenerates the BUILD files for crate dependencies the method it uses to collect files is glob. For example here is the cargo_build_script that is autogenerated for protobuf-src as a dependency:

 85 cargo_build_script(
 86     name = "protobuf-src_build_script",
 87     crate_name = "build_script_build",
 88     crate_root = "build.rs",
 89     data = glob(
 90         include = ["**"],
 91         exclude = [
 92             "BUILD",
 93             "BUILD.bazel",
 94             "WORKSPACE",
 95             "WORKSPACE.bazel",
 96         ],
 97     ),
 98     deps = [
 99         "@crate_index__autotools-0.2.6//:autotools",
100     ],
101     edition = "2021",
102     links = "protobuf-src",
103     rustc_flags = [
104         "--cap-lints=allow",
105     ],
106     srcs = glob(["**/*.rs"]),
107     tags = [
108         "cargo-bazel",
109         "crate-name=protobuf-src",
110         "manual",
111         "noclippy",
112         "norustfmt",
113     ],
114     version = "1.1.0+21.5",
115     visibility = ["//visibility:private"],
116 )

The data portion globs all files in the directory - this should include the protobuf c project directory. The included protobuf directory has a BUILD.bazel file as do some of its subdirectories.

If the included protobuf dir and all nested dirs simple didn't have BUILD.bazel files it would compile cleanly as a dependency in a rust project compiled with rules_rust.

@benesch
Copy link
Member

benesch commented May 13, 2024

Happy to take a PR to fix this! Probably just need to update bin/update-protobuf to include a find command that removes the problematic files, e.g.:

find protobuf -name '*.orig' -delete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants