Replace slashes with underscores in default crate names. (#1336)

This is another attempt at #1334, which sought to make "/" characters legal in Rust target names.

This PR differs from #1334 in how it handles build artifacts that are based on `crate_info.output`. There are a few places that currently assume that calling `ctx.actions.declare_file(...)` will always declare a file in the same directory as `crate_info.output`, i.e. as `ctx.actions.declare_file(ctx.label.name + ...)`. In a world where label names may include slashes (which is the case today!), this is not a safe assumption, since a slash in the target name causes bazel to create a subdirectory for the output.

Specifically, this PR fixes incorrect locations for the following items (when the target name includes a slash):
* PDB files
* dSYM files
* .lib files

This leaves a few things that look like they make the same assumption, but I'm not sure how they're used or if they should be updated:
* `"_ambiguous_libs/" + crate_info.output.basename + "/" + symlink_name` for ambiguous libraries
* The linkstamp output path (`"_objs/" + crate_info.output.basename + "/" + ...`)
3 files changed
tree: d03efa36051e28e01f11a1e5afc88e873e3586dd
  1. .bazelci/
  2. .github/
  3. bindgen/
  4. cargo/
  5. crate_universe/
  6. distro/
  7. docs/
  8. examples/
  9. proto/
  10. rust/
  11. test/
  12. tools/
  13. util/
  14. wasm_bindgen/
  15. .bazelignore
  16. .bazelrc
  17. .gitignore
  18. ARCHITECTURE.md
  19. AUTHORS
  20. BUILD.bazel
  21. CODEOWNERS
  22. COMPATIBILITY.md
  23. CONTRIBUTING.md
  24. CONTRIBUTORS
  25. LICENSE.txt
  26. README.md
  27. version.bzl
  28. WORKSPACE.bazel
  29. workspace.bzl
README.md

Rust Rules

  • Postsubmit Build status

Overview

This repository provides rules for building Rust projects with Bazel.

Community

General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust.

Documentation

Please refer to the full documentation.