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 bazel meta build system auto generates build files for crate dependencies of a project using the
rules_rustbazel 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_scriptthat is autogenerated forprotobuf-srcas a dependency:The data portion globs all files in the directory - this should include the
protobufc project directory. The includedprotobufdirectory has a BUILD.bazel file as do some of its subdirectories.If the included
protobufdir and all nested dirs simple didn't have BUILD.bazel files it would compile cleanly as a dependency in a rust project compiled withrules_rust.