crates[_std]: Move to top level, redo directory structure

This change reworks the repository directory structure and how we house
crates. Previously, there were the following directories in play:

- `//crates`: vendored no_std crates
- `//crates_std`: vendored std crates
- `//stub_crates/crates`: template project for std crate vendoring
- `//stub_crates/crates_std`: template project for no_std crate vendoring

We are keeping these directories, but changing their locations. The new
locations are:

- `//crates`: template project for no_std crate vendoring
- `//crates/vendor`: vendored no_std crates
- `//crates_std`: template project for std crate vendoring
- `//crates_std/vendor`: vendored std crates

Top level aliases will continue to exist where they are so that users
can access crates via easy to use monikers (e.g. `//:cortex-m`).
However, this makes for a clearer and simpler directory structure.
Moreover, this helps us integrate Cargo GNaw which requires vendored
crates to be in a subdirectory of the template project itself. While it
is possible to modify Cargo GNaw to ignore this requirement, we borrow
Cargo GNaw from the Fuchsia team and don't want to make too drastic or
incompatible changes within it at the moment.

Change-Id: Ibc6c1655e855a96391b44fb0bf69118795bb0ebe
Reviewed-on: https://pigweed-review.googlesource.com/c/third_party/rust_crates/+/144091
Reviewed-by: Erik Gilling <konkers@google.com>
2652 files changed
tree: 1555d61fdb4620ff0f8b0e964711b764121fb3af
  1. crates/
  2. crates_std/
  3. src/
  4. .gitignore
  5. aliases.bzl
  6. BUILD.bazel
  7. Cargo.Bazel.lock-std
  8. Cargo.lock
  9. Cargo.toml
  10. config.toml
  11. README.md
  12. rustfmt.toml
  13. WORKSPACE
README.md

Pigweed Rust Third Party Crates

This is a repository to vendor and provide build rules for the third party crates that Pigweed's rust code depends on. Currently only Bazel build rules are provided.

std and no_std

This repository provides two separate sets of crates. One for std environments and one for no_std environments. The set that is used is determined by the //:std_enabled constraint setting and defaults to std. To use no_std add @rust_crates//:no_std to your platform definition.

Adding and Updating the Crates

The list of vendored crates is defined by the dependencies listed in //crates/Cargo.toml and //crates_std/Cargo.toml. The contents of the //crates and //crates_std directories are generated by the //:crates_vendor and //:crates_vendor_std targets.

To update the vendored crates, build files, and aliases to match run the following commands from the top level directory of the repository:

bazel run //:crates_vendor -- --repin
bazel run //:crates_vendor_std -- --repin
cargo run -- --config config.toml > aliases.bzl

Licenses can be checked with cargo license -d in the appropriate stub_crate.

Markdown Formatting

We keep this, and all Markdown files in this repository, in a consistent Markdown format using mdformat. To install and format, use the following commands:

pip install mdformat-gfm
mdformat README.md

FAQ

collect2: fatal error: cannot find ‘ld’ error

  = note: collect2: fatal error: cannot find 'ld'
          compilation terminated.

If you get the above error when running bazel run //:crates_vendor -- --repin, ensure lld is installed on your system. For instance, on Debian based systems:

sudo apt install lld