volks73 / cargo-wix

A cargo subcommand to build Windows installers for rust projects using the WiX Toolset
https://volks73.github.io/cargo-wix
Apache License 2.0
306 stars 25 forks source link

Add `-B,--build-arg` option for the `cargo build` stage of the default subcommand #177

Open elpiel opened 1 year ago

elpiel commented 1 year ago

With cargo-deb you have the ability to set specific features that you want to use when building the package. It would be great to include such ability in cargo-wix as now you have to build manually with the given feature(s) and run cargo-wix with --no-build.

Our use case is that we distinguish between installed app and running with cargo run because of some binaries locations.

volks73 commented 1 year ago

My understanding was the features feature of cargo-deb was for defining a set of properties/flags/arguments like Profiles, but there are the -C and -L options that pass arguments to the candle.exe and light.exe applications for building the installer. To clarify, you would like something similar, like -B, to pass arguments to cargo for the cargo build "stage" of the cargo wix default subcommand?

To note, the -B option is already used for the init and print subcommands but not the cargo wix default command. I could see adding the -B,--build-arg option. Again, assuming this is what you are requesting.

elpiel commented 1 year ago

yes, build arguments (cli) or features (config) to build the binaries with. For the config, I really like the simple cargo-deb approach of specifying the features with a key.

For the CLI --build-args seems reasonable. cargo-deb uses --cargo-build but that overrides the whole cargo command, i.e. if you want to build with features (and I have to verify, though, if -- --features=... is actually used by cargo build):

cargo deb --cargo-build build -- --features=bundled

volks73 commented 1 year ago

Got it. I see cargo deb uses the -- syntax for passing additional arguments to the cargo build command. This appears to be the convention for various cargo subcommands that pass additional arguments to the underlying binary, such as passing arguments to rustc.

While this is the convention and I like to follow conventions as much as possible, I am leaning towards the -B,--build-arg option to be consistent with the -C and -L options. There are three binaries at work with the default cargo wix subcommand: (1) cargo build, (2) candle.exe, and (3) light.exe. I believe the cargo convention of using -- to pass additional arguments works well because there is only one underlying binary per subcommand/action. With three, it could be a little confusing and then having it work just for the cargo build binary but needing to use options for the Candle and Light binaries would be inconsistent and an exception that needed to be documented and heavily noted. A -B option is feels cleaner and more consistent at the moment.

volks73 commented 1 year ago

I have renamed the issue to be more descriptive and focused to the requested enhancement. I would also greatly appreciate and welcome any PR that implements this enhancement.

volks73 commented 1 year ago

@elpiel While the -B,--build-arg has not been added to the CLI, does #198 work for the configuration aspect?