crate_universe: declare a crate's identity and license as package metadata (#4455) This change makes `generate_rules_license_metadata` declare every generated crate through the `package_metadata` module: a `package_metadata` target with the crate's `purl`, `pkg:cargo/<name>@<version>`, which the package's `default_package_metadata` attaches to every target of the crate, and a `license` attribute with the SPDX kind of the crate's license and its license text when the crate ships one. The module records one license per package and has no model for a choice of licenses yet, so a crate offered under several is recorded under the first of them the module has a kind for. Each hub subpackage aliases both targets, so `@crates//serde:license` and `@crates//serde:package_metadata` name serde's. Generated BUILD files load the rules through `@rules_rust//crate_universe/private:package_metadata.bzl`, like everything else they load. The purl is a literal: a crate name needs no encoding and of a version only the `+` before build metadata does, which is written `%2B` as the module's builder would. rules_rust depends on `package_metadata` in place of rules_license, whose rules it rendered before. A kind must exist as a target, and the module does not export the BUILD file declaring them, so the `spdx_license_kinds` repository of the development extension reads it and records the names in `kinds.json`. `spdx_license_kinds_diff_test` keeps `src/rendering/spdx_license_kinds.json` in step with it and `spdx_license_kinds.install` updates the table, replacing the generated table's subcommand. The setting stays off by default: the lockfile digest covers the render settings, so turning it on for everyone would repin every workspace on upgrade.
This repository provides rules for building Rust projects with Bazel.
The fastest way to try this in an empty project is to click the green “Use this template” button on https://github.com/bazel-starters/rust.
General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust.
Please refer to the full documentation.