tauri-apps / winres

Create and set windows icons and metadata for executables with a rust build script
MIT License
7 stars 6 forks source link

Add support for library crates with multiple binaries #8

Closed xNyaDev closed 1 year ago

xNyaDev commented 1 year ago

When users have a library crate with multiple binary files, they are not able to specify metadata for a single binary, only (I believe) for all of them at once. This PR adds an optional argument binary: Option<&str> to compile() which can be used to select the binary by its' name.

An example project showing how to use it has been added in multi_binary_example and it produces the following result:

image

This would require a minor version bump, as it changes how the .compile() function is called.

I have only tested my changes with MSVC on Windows, GNU compiler will require additional testing.

This has been discussed in https://github.com/mxre/winres/issues/32 with mxre saying there is nothing winres can do (at that moment). You can also not have a per-binary build script (https://github.com/rust-lang/cargo/issues/1430), so something like this change is required to add metadata to library+binary combo crates.

FabianLars commented 1 year ago

Thanks for contributing!

I didn't have time to really look at the PR (and the repo wasn't on my watchlist so i didn't get a notification), but what do you think about adding a new method like compile_for() so we don't have to make it a breaking change? This way we could also remove the Option from the public api if we wanted to.

xNyaDev commented 1 year ago

Sure, compile_for() sounds good, I'll do that.

FabianLars commented 1 year ago

Sorry for the long delay! Writing this so you don't think we're ghosting you, there are 2 small things i wanna note already:

  1. The gnu part does indeed not work, it just fails to compile. I meant to look into it (which is why i didn't straight up post the error :/ ) but had to postpone it to focus on some Tauri 1.3 stuff.
  2. We're thinking about dropping this fork again, ref: https://github.com/tauri-apps/tauri/issues/6746 / https://github.com/tauri-apps/tauri/pull/6760 but not sure yet and it may take a while and we're not 100% sure yet anyway.

Anywayyy, i'll try to get back to you about the gnu stuff this week, sorry again.

FabianLars commented 1 year ago

Okay soooo, I ended up replacing the resource compiler with the embed-resource crate since it has gnu/msvc and cross-platform handling, and to push it to Tauri users without a new Tauri release asap (because we released NSIS support in 1.3 and this made the experimental cross-platform compilation guide a tiny bit nicer).

This change also added support for multi-binary handling, but as far as i understand it, embed-resource is not that good at handling .dll files and focuses on .exe binaries, which again is perfect for Tauri, but may not be that nice for more general uses. Therefore i'd suggest reaching out to the winresource sister-fork and see if they are interest, though judging by https://github.com/BenjaminRi/winresource/issues/8 it looks like they are. I'd also be interested to help you figure out the gnu toolchain issues along the way if i find the time :)


Sorry for making conflicting changes "behind your back" but it was really a last-minute thing we wanted to tackle :/ Thank you so much for contributing though! ❤️