google / cargo-raze

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

cargo-raze generates duplicated `aliases` for rustix@0.37.19 #552

Open k1nkreet opened 1 year ago

k1nkreet commented 1 year ago

with rustix@0.37.19 cargo-raze creates rust_library with duplicated value in aliases field which fails to compile:

aliases = {
    "@raze__errno__0_3_1//:errno": "libc_errno",
    "@raze__errno__0_3_1//:errno": "libc_errno",
},

I've created a repository to reproduce: https://github.com/k1nkreet/cargo-raze-duplicated-alias

dayfine commented 1 year ago

Seeing this too. My Cargo.toml looks like:

[package]
edition = "2021"
name = "compile_with_bazel"
version = "0.0.0"

[lib]
path = "fake_lib.rs"

[dependencies]
approx = "0.5.1"
chrono = "0.4.26"
clap = {version = "=4.3.12", features = ["derive"]}
exitfailure = "0.5.1"
rayon = "1.7.0"
reqwest = {version = "0.11.0", features = ["blocking", "json"]}
serde = "1.0.119"
serde_derive = "1.0.119"
serde_json = "1.0.61"
structopt = "0.3.21"
tokio = {version = "1.0.2", features = ["full"]}

[package.metadata.raze]
genmode = "Remote"
package_aliases_dir = "."
rust_rules_workspace_name = "rules_rust"
workspace_path = "//cargo"

[package.metadata.raze.crates.clap.'4.3.12']
data_attr = '[":README.md", ":examples/demo.md"]'

[package.metadata.raze.crates.clap_builder.'4.3.12']
data_attr = '[":README.md"]'

[package.metadata.raze.crates.clap_derive.'4.3.12']
data_attr = '[":README.md"]'

The rustix version is 0.38.4

dayfine commented 1 year ago

Looking at this template:

https://github.com/google/cargo-raze/blob/afe9b483b0449eb043f3fa8aa08f62afffcfa2ed/impl/src/rendering/templates/partials/common_attrs.template#L4-L11

There doesn't seem to be any check that crate.default_deps.aliased_dependencies and crate.targeted_deps[].deps.aliased_dependencies does not contain duplicate.

hxndg commented 1 year ago

I just remove the duplicated line in generate build file to force compile proceed...,