The source code of the ./tools command that runs build steps is found in "build-tools/src/main.rs". There are two variables, release and force_color, which are set at the beginning of the script. They are used to set the color output and release mode flags for all invocations to cargo that the build script performs. But repeating each of these arguments each time cargo is called is verbose and error-prone.
There's already a function that is called to generate arguments to be passed on to cargo, cargo_args_for_crate, which is used right now to load features options from the Configuration.toml file. If the logic for adding the "--release" flag and the "--color=always" flag were added to the vector of arguments cargo_args_for_crate returns, then there can be just one set of arguments injected into each cargo call in the script, and the variables release and force_color (and all the places where they are used) can be deleted.
|
let mut args = ::std::env::args().collect::<Vec<_>>(); |
|
|
|
// Extract the --release flag from the args list. We'll reuse the --release |
|
// flag by injecting it into argumets for cargo. |
|
let release = args.iter().find(|x| *x == "--release").is_some(); |
|
args = args.into_iter().filter(|x| *x != "--release").collect(); |
|
|
|
// Respect the CLICOLOR env variable. |
|
let force_color = ::std::env::var("CLICOLOR") |
|
.map(|x| x == "1") |
|
.unwrap_or(false); |
|
let force_color_flag = if force_color { |
|
Some("--color=always") |
|
} else { |
|
None |
|
}; |
The source code of the
./toolscommand that runs build steps is found in "build-tools/src/main.rs". There are two variables,releaseandforce_color, which are set at the beginning of the script. They are used to set the color output and release mode flags for all invocations tocargothat the build script performs. But repeating each of these arguments each time cargo is called is verbose and error-prone.There's already a function that is called to generate arguments to be passed on to cargo,
cargo_args_for_crate, which is used right now to load features options from the Configuration.toml file. If the logic for adding the "--release" flag and the "--color=always" flag were added to the vector of argumentscargo_args_for_cratereturns, then there can be just one set of arguments injected into each cargo call in the script, and the variablesreleaseandforce_color(and all the places where they are used) can be deleted.edit-text/build-tools/src/main.rs
Lines 321 to 336 in 4156a85