bazelbuild / bazelbuild/rules_rust

Crates Universe: Do I need to replicate intra-workspace `Cargo.toml` dependencies in `BUILD.bazel` files?

Open
#1,923 3 comments 0 reactions 0 assignees View on GitHub
needs-triage
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

My team has a large Cargo workspace with numerous inter-dependent Cargo subpackages. We primarily use pure Cargo to develop/build code, so `Cargo.toml` files are the source of truth for capturing dependencies, but we'd also like to have the option to build with Bazel, e.g. for Python-Rust bindings (since we use Bazel to run Python code). We'd rather not duplicate all the subpackage intra-workspace dependency info already captured in `Cargo.toml` files into `BUILD.bazel` files, but I can't figure out how to avoid this...? E.g. the `Cargo.Bazel.lock` file appears to only capture external dependency info, and doesn't pick up intra-workspace dependencies, meaning `all_crate_deps()` only returns labels for external dependency targets -- is this expected?

Overall I'm wondering: Is there some way to make `Cargo.toml` files the source of truth for everything, without making/manually populating a duplicative `BUILD.bazel` for every workspace package? Sorry if I'm woefully misunderstanding how the Crates Universe rules work!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.