Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on lemmy.physfluids.fr
rust·Rustbyjapps13

Cargo env file?

Hello,

I have a project for which some machines have only a subset of features set. Currently, I write

cargo run --no-default-features --features "toto,titi" --bin my_bin

This is a bit cumbersome and I sometimes forget the --no-default-features --features part. I was wondering if there is a local config file that I could put in the directory to instruct cargo to use this particular subset of features. I guess this should be in the documentation, but I didn't find it.

View original on lemmy.physfluids.fr
11

7 replies

programming.dev

The way I can think of to do this is to make a program called cargo-build-env which reads a file of your choosing with the features and executes cargo, then place that binary in your ~/.cargo/bin directory. Then you can run cargo build-env to build your program

The program can be in any language as long as it's executable, including shell script

3

Yeah, a simple bash script should do. Such as:

#!/usr/bin/env bash

BUILD_FEATURES=${BUILD_FEATURES:=default}

cargo run --no-default-features --features "${BUILD_FEATURES}" --bin my_bin

Then just set a BUILD_FEATURES env var.

3
japps13reply
lemmy.physfluids.fr

This would look like it would be what I am looking for, but the documentation of the configuration file does not mention features.

2

You reached the end

Cargo env file? | Spyke