google / cargo-raze

Generate Bazel BUILD from Cargo dependencies!
Apache License 2.0
480 stars 104 forks source link

Incompatible with rules_rust whose version is 0.8.0 or later #522

Closed pddg closed 1 year ago

pddg commented 2 years ago

Overview

cargo-raze requires rules_rust, however it incompatible with rules_rust whose version is 0.8.0 or later. bazel run @cargo_raze//:raze fails when rules_rust is 0.8.0 or later.

Environment

Expected

bazel run @cargo_raze//:raze should succeed if rules_rust is latest.

❯ bazel run @cargo_raze//:raze -- --manifest-path=$PWD/Cargo.toml
INFO: Analyzed target @cargo_raze//:raze (0 packages loaded, 435 targets configured).
INFO: Found 1 target...
Target @cargo_raze//tools:raze up-to-date:
  bazel-bin/external/cargo_raze/tools/raze
INFO: Elapsed time: 0.446s, Critical Path: 0.05s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action

Actual

bazel run @cargo_raze//:raze fails when rules_rust is 0.8.0 or later.

❯ bazel run @cargo_raze//:raze -- --manifest-path=$PWD/Cargo.toml
ERROR: /private/var/tmp/_bazel_pddg/c055c30c6268cf8fffdaa4f0d3e6ae6b/external/cargo_raze/tools/BUILD.bazel:44:6: no such target '@rust_darwin_aarch64//:cargo': target 'cargo' not declared in package '' defined by /private/var/tmp/_bazel_pddg/c055c30c6268cf8fffdaa4f0d3e6ae6b/external/rust_darwin_aarch64/BUILD.bazel and referenced by '@cargo_raze//tools:cargo'
ERROR: Analysis of target '@cargo_raze//:raze' failed; build aborted:
INFO: Elapsed time: 0.081s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)

519 seems to be caused by this.

How to reproduce

I have created a very simple rust project and prepared a repository to check the combination with rules_rust from 0.5.0 to the latest 0.10.0. https://github.com/pddg/raze-rule-compatible-check/pulls

It is compatible from 0.5.0 to 0.7.0, but everything after 0.8.0 fails.