mcgoo / cargo-vcpkg

Get external dependencies in one step by specifying vcpkg details in Cargo.toml
Apache License 2.0
39 stars 6 forks source link

Why is SDL2 being installed when I dont depend on it? #23

Open jonatino opened 5 months ago

jonatino commented 5 months ago

I'm just trying to get the opencv4 vcpkg.

[package.metadata.vcpkg]
git = "https://github.com/microsoft/vcpkg"
rev = "94a50e8"
dependencies = ["opencv4[contrib,nonfree]"]

[package.metadata.vcpkg.target]
x86_64-pc-windows-msvc = { triplet = "x64-windows-static-md" }

But for some reason when running cargo vcpkg build, it always trys to install sdl2?

> cargo vcpkg build
     Cloning https://github.com/microsoft/vcpkg
    Checkout rev 94a50e8
   Compiling vcpkg
  Installing sdl2 opencv4[contrib,nonfree]
jonatino commented 5 months ago

Did some more debugging and enabled some previously commented out dbg! statements. Initially, I used the example from the README.md and I ran the cargo vcpkg build command then after a few seconds Ctrl+C to cancel it. Then I switched the dependencies to the ones I want, but for some reason it seemed like my first example with the sdl2 from the README is still cached somehow in metadata? I've tried to delete Cargo.lock file but it does not fix the issue.

Here is the print statement from https://github.com/mcgoo/cargo-vcpkg/blob/master/src/main.rs#L344

[src\main.rs:339:5] &metadata.workspace_metadata = Null
[src\main.rs:344:13] &v = Metadata {
    vcpkg: Vcpkg {
        target: {
            "x86_64-pc-windows-msvc": Target {
                triplet: Some(
                    "x64-windows-static-md",
                ),
                dependencies: None,
                dev_dependencies: None,
            },
        },
        branch: None,
        rev: Some(
            "261c458af6e3eed5d099144aff95d2b5035f656b",
        ),
        git: Some(
            "https://github.com/microsoft/vcpkg",
        ),
        tag: None,
        dependencies: Some(
            [
                "sdl2",
            ],
        ),
        dev_dependencies: Some(
            [
                "sdl2",
                "sdl2-image[libjpeg-turbo,tiff,libwebp]",
                "sdl2-ttf",
                "sdl2-gfx",
                "sdl2-mixer",
            ],
        ),
        overlay_triplets_path: None,
        build_type: None,
    },
}
[src\main.rs:344:13] &v = Metadata {
    vcpkg: Vcpkg {
        target: {
            "x86_64-pc-windows-msvc": Target {
                triplet: Some(
                    "x64-windows-static",
                ),
                dependencies: Some(
                    [
                        "opencv4[contrib,nonfree]",
                    ],
                ),
                dev_dependencies: None,
            },
        },
        branch: None,
        rev: Some(
            "94a50e8",
        ),
        git: Some(
            "https://github.com/microsoft/vcpkg",
        ),
        tag: None,
        dependencies: None,
        dev_dependencies: None,
        overlay_triplets_path: None,
        build_type: None,
    },
}

The first print was the example I copied and I Ctrl+C'ed mid run and the second is the actual metadata from my project.

Hopefully that helps.