facebookincubator / reindeer

Reindeer is a tool to transform Rust Cargo dependencies into generated Buck build rules
MIT License
184 stars 30 forks source link

bracket-terminal crate ends up depending on two version of winit and can't be compiled #20

Closed photex closed 1 year ago

photex commented 1 year ago

Howdy!

When attempting to buckify a build that uses bracket-lib I've slowly but steadily managed to get it's components to build. But for bracket-terminal I'm actually stumped and haven't found an example of how to properly handle it:

error[E0464]: multiple candidates for `rmeta` dependency `winit` found
 --> third_party/vendor/bracket-terminal-0.8.7/src/hal/crossterm_be/scancode_helper.rs:1:5
  |
1 | use winit::event::VirtualKeyCode;
  |     ^^^^^
  |
  = note: candidate #1: /home/chip/workspaces/rlt/buck-out/v2/gen/root/524f8da68ea2a374/third_party/__winit-0.26.1__/rlib-static-static-metadata/libwinit-38f23547.rmeta
  = note: candidate #2: /home/chip/workspaces/rlt/buck-out/v2/gen/root/524f8da68ea2a374/third_party/__winit-0.27.5__/rlib-static-static-metadata/libwinit-38f23182.rmeta

The problem is that it specifies a non-optional dependency on two different versions of winit, 0.26 for wasm targets, and 0.27 for all others: https://github.com/amethyst/bracket-lib/blob/master/bracket-terminal/Cargo.toml

I don't have any intention to target wasm at the moment. I'm using the default platforms which I didn't think included wasm.

The resulting BUCK deps for brack-terminal are using both version of winit:

platform = {
        "linux-arm64": dict(
            deps = [
                ":winit-0.26.1",
                ":winit-0.27.5",
            ],
        ),
        "linux-x86_64": dict(
            deps = [
                ":winit-0.26.1",
                ":winit-0.27.5",
            ],
        ),
        "macos-arm64": dict(
            deps = [
                ":winit-0.26.1",
                ":winit-0.27.5",
            ],
        ),
....

EDIT: This happens when you use the 'cross_term' feature specifically. The default opengl feature appears to generally work out.

zertosh commented 1 year ago

I found the problem. I just put up a fix internally, but I am not feeling super confident in the approach. Just commenting this for now so you know that I am looking at this