rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.35k stars 1.62k forks source link

Runnable env per build configuration (debug, release) #12300

Open IceTDrinker opened 2 years ago

IceTDrinker commented 2 years ago

Hello!

First I would like to say a big thank you for this wonderful extension, really makes working with Rust in VSCode a breeze once a bit of configuration is done ๐Ÿ™‚

I'm currently facing a case where we use different RUSTFLAGS between our debug and release builds. rust-analyzer seems to be using mostly the debug build, I tried setting some RUSTFLAGS (the ones for the release profile) through the runnableEnv config, this invalidated the build cache as there was a mismatch between the standard debug flags I use to build stuff in my terminal and the ones (for release) that rust-analyzer used as I set them in the configuration.

So the question is: how hard would it be to have runnableEnvs on a per config basis (debug, release) and more (?) (test, bench) not sure if it makes sense to have additional envs for test and benches, but I guess it could be useful.

Maybe it's already doable and I don't see it!

Otherwise maybe you can point to the relevant code in here and I might be able to contribute something if it's not a high priority feature!

Cheers

Veykril commented 2 years ago

you wanna set the RUSTFLAGS in server.extraEnv instead of runnableEnv, that way all the cargo processes r-a spawns will spawn with that env flag. Otherwise there is currently no way to set different things here for debug vs release builds

IceTDrinker commented 2 years ago

I think it worked with runnableEnv (I'm not sure now ๐Ÿ˜… ) but ok noted that there is no per profile setting!

Veykril commented 2 years ago

it might, but if you have RUSTFLAGS set you want to mirror them for the server usually as otherwise cargo will do a bunch of rebuilds usually.

IceTDrinker commented 2 years ago

it might, but if you have RUSTFLAGS set you want to mirror them for the server usually as otherwise cargo will do a bunch of rebuilds usually.

Yep sounds right!