Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for library crates with multiple binaries #8

Closed
wants to merge 4 commits into from

Conversation

xNyaDev
Copy link

@xNyaDev xNyaDev commented Apr 10, 2023

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 mxre#32 with mxre saying there is nothing winres can do (at that moment). You can also not have a per-binary build script (rust-lang/cargo#1430), so something like this change is required to add metadata to library+binary combo crates.

@FabianLars
Copy link
Member

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
Copy link
Author

xNyaDev commented Apr 18, 2023

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

@FabianLars
Copy link
Member

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: [bug] failed to cross compile icons/icon.ico into a Windows Resource tauri-build 2.0.0-alpha.4 tauri#6746 / feat(build): Use embed-resource for windows resource compilation tauri#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
Copy link
Member

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 BenjaminRi/winresource#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! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants