Skip to content

Add bazel rules for existing rust code#106

Draft
cfrantz wants to merge 1 commit intoOpenPRoT:mainfrom
cfrantz:rules_rust
Draft

Add bazel rules for existing rust code#106
cfrantz wants to merge 1 commit intoOpenPRoT:mainfrom
cfrantz:rules_rust

Conversation

@cfrantz
Copy link
Collaborator

@cfrantz cfrantz commented Feb 17, 2026

Addresses: #105

Addresses: OpenPRoT#105

Signed-off-by: Chris Frantz <cfrantz@google.com>
@cfrantz cfrantz requested review from moidx and rusty1968 February 17, 2026 23:07
@cfrantz
Copy link
Collaborator Author

cfrantz commented Feb 17, 2026

This is still a WIP, but soliciting feedback. This is a naive conversion of the build system to bazel for the existing code in the repo.

This commit converts all of the existing rust crates over to rules_rust except the xtask and openprot crates.

  • I've named all of the rules the same name as their bazel package (e.g. sort-of "subdir"). This means that bazel labels like //hal/blocking are equivalent to //hal/blocking:blocking.
  • I've used the crate_name attribute to give the crates the same crate name as the name in their Cargo.toml.
  • I've put all upstream crate deps into //third_party/crates_io/Cargo.toml, which is processed by bazel rules_rust (see MODULE.bazel to see how that happens).

Not yet done:

  • I haven't yet removed the various Cargo.toml files. We have a couple of options:
    • Remove the Cargo.toml files and become a pure bazel repo.
    • Try to keep the Cargo.toml files and be a bazel+cargo repo. I consider this unlikely to work once we start integrating with the pigweed kernel or code from other languages (e.g. C/C++ code). Pigweed is not cargo compatible. Integrating rust with C/C++ code for both bazel and cargo will quickly turn into an exercise in frustration.

The build system conversion in this PR does not address #95, #97 or #98.

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

Successfully merging this pull request may close these issues.

1 participant

Comments