tree: 1801458ecc2dae379c3815c58ce7aa5cbce05c08 [path history] [tgz]
  1. alchemy_crates/
  2. examples/
  3. ide_support/
  4. runfiles/
  5. BUILD.bazel
  6. README.md
  7. rust_prebuilt.bzl
rust/README.md

Working with rust

Our rust toolchain is very different from cargo, and fits into bazel's norms.

Creating a new 1st-party crate

Similar to any other language, create a .rs file, and then create a rust_library/binary target which lists that file as it's srcs.

Adding dependencies on crates

1st-party crates

Add the corresponding target to your deps.

3rd-party crates

Add a dep on @crates//:<crate name> (for chromeos) or @alchemy-crates//:<crate name> (for infra).

If the crate doesn't exist, or if the version needs to be updated, then:

@alchemy-crates

Modify the //bazel/Cargo.toml, then cd to the directory that contains it and run cargo update --workspace to update the lockfile.

@crates

Modify //third_party/rust_crates/projects/.../Cargo.toml, then run third_party/rust_crates/vendor.py.