Respect `crate_name` attribute when setting CARGO_CRATE_NAME. (#669)

As part of this change, I've moved the formerly private `_crate_name`
function from rust.bzl to utils.bzl and renamed it to
`crate_name_from_attr.

I've also had to add a `hasattr(attr, "crate_name")` check to this
function because `rustc_compile_action` (which calls through to
`_get_rustc_env`) gets called from the implementation of the Rust proto
rules, and those don't have a `crate_name` attribute (and it wouldn't
make sense to add one either).
5 files changed
tree: bc9b56aa648e3a2205a670c0925b04bd746c0592
  1. .bazelci/
  2. bindgen/
  3. cargo/
  4. crate_universe/
  5. docs/
  6. examples/
  7. proto/
  8. rust/
  9. test/
  10. tools/
  11. util/
  12. wasm_bindgen/
  13. .bazelignore
  14. .gitignore
  15. ARCHITECTURE.md
  16. AUTHORS
  17. BUILD.bazel
  18. CODEOWNERS
  19. CONTRIBUTING.md
  20. CONTRIBUTORS
  21. LICENSE.txt
  22. README.md
  23. WORKSPACE.bazel
  24. workspace.bzl
README.md

Rust Rules

  • Postsubmit Build status
  • Postsubmit + Current Bazel Incompatible Flags Build status

Overview

This repository provides rules for building Rust projects with Bazel.

Community

Please refer to the full documentation.