cargo-dist icon indicating copy to clipboard operation
cargo-dist copied to clipboard

Support bundling DLLs from $OUT_DIR

Open lukexor opened this issue 2 years ago • 7 comments

I'm building a binary distributable that relies on a library crate, which itself dynamically links to SDL2. For windows builds, the build.rs of that library sticks the correct x86_64 or i686 DLLs in the $OUT_DIR location for cargo so they will be present alongside the binary.

Currently the include feature would work for this, but I have no way of naming $OUT_DIR in Cargo.toml since it's not set until build time and globs are not supported. Also the specific list of files may change depending on the target platform.

I did see #194 but this request is a bit more limited in scope as these are build artifacts, not a generic random path outside $CARGO_MANIFEST_DIR and the dynamic file list makes this feel like a different feature request.

lukexor avatar Oct 31 '23 17:10 lukexor

makes perfect sense! I wonder if the linkage checker can detect this so we know to automatically include the dll 🤔

Gankra avatar Oct 31 '23 18:10 Gankra

That would be great! Currently, I'm not sure the best work-around.

I'm trying to learn the WIX toolset and I could modify the .wix file to include each file (or copy the dlls into my project instead of relying on $OUT_DIR and using Heat to collect the whole directory) - but then I lose out on the updating features of cargo dist init.

lukexor avatar Oct 31 '23 18:10 lukexor

Oh! Thanks for the additional context that you specifically interested in MSIs here -- some additional work may also be needed to teach MSIs to do additional includes: https://github.com/axodotdev/cargo-dist/issues/543

Gankra avatar Oct 31 '23 19:10 Gankra

I was able to get a decently working solution by just setting allow-dirty = ["msi"] and then modifying the main.wxs file to add the necessary DLL dependencies. This also allowed me to customize the installation images and have it launch the application after install.

The only downsides are having to manually manage any new wix features cargo dist releases, or migrating to wix 4 whenever that happens.

However, for now I'm not able to get the powershell to do a similar thing, as there seems to be no way to customize the dependencies for windows like there is for homebrew and apt.

lukexor avatar Nov 19 '23 21:11 lukexor

there seems to be no way to customize the dependencies for windows like there is for homebrew and apt.

It's possible to customize the dependencies that are installed during the build, but it's not currently possible to get the install script to install external packages alongside your software.

mistydemeo avatar Nov 20 '23 19:11 mistydemeo

there seems to be no way to customize the dependencies for windows like there is for homebrew and apt.

It's possible to customize the dependencies that are installed during the build, but it's not currently possible to get the install script to install external packages alongside your software.

Like being able to add dlls and customize the install dir? Currently powershell sticks the binary in .cargo/bin but stuffing dlls in there isn't ideal. The app I'm distributing requires SDL2 libraries which I have dlls for in my repository since they are generally bundled for windows instead of installed via a package manager

lukexor avatar Nov 20 '23 19:11 lukexor

Yeah including more than just the one file should require you to set a custom install-path, but we need a clear story for how to specify whether your custom install path is ok to dump More Files into.

(A new config for saying "yep it's fine" and changes to the ps1 and sh installers to detect that config and unpack more from the archive at install-time.)

Gankra avatar Nov 21 '23 18:11 Gankra