Skip to content

protobuf-src incompatible with Bazel build systems #11

@lithiumFlower

Description

@lithiumFlower

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions