axodotdev / cargo-dist

📦 shippable application packaging
https://axodotdev.github.io/cargo-dist/
Apache License 2.0
1.52k stars 72 forks source link

`RUSTFLAGS` via cargo config #513

Open aumetra opened 1 year ago

aumetra commented 1 year ago

I tried to integrate cargo-dist into my release workflow and hit a roadblock in form of my required rustflags.

In my cargo config I set a rustflag to compile the uuid crate with unstable features to be able to use UUIDv7.

cargo-dist's usage of the environment variable completely overwrites the cargo configuration though.

Right now I'm resorting to allowing a dirty CI state and adding the RUSTFLAGS env-var with the appropriate value, since cargo-dist preserves those.


I personally see two possible solutions to this:

  1. cargo-dist parses the cargo config and appends any rustflags to the environment variable it sets
  2. cargo-dist adds the ability to add arbitrary environment variables

Both of these would be nice features tbh

Gankra commented 1 year ago

The offending code, with comment giving some context:

https://github.com/axodotdev/cargo-dist/blob/1fe2cb9eef71bb6cb3c0fe1af92c7119b3fe2997/cargo-dist/src/tasks.rs#L1960-L1969

I hadn't considered straight up reading the flags out of Cargo's config, that's an interesting idea... (wonder if it's exposed in guppy/cargo-metadata already...)

Gankra commented 1 year ago

Adding arbitrary env vars is also probably just the more useful/general/simple feature tho

aumetra commented 1 year ago

I would take the issue for arbitrary env vars, if that's fine

Gankra commented 1 year ago

@aumetra absolutely!