Skip to content

Commit

Permalink
Prefer target.env values over build.env config.
Browse files Browse the repository at this point in the history
We currently use `build.env` over `target.$(...).env`, which means we
cannot set a default value and then override it for a specific target.
Given the following config file:

```toml
[build.env]
xargo = true

[target.aarch64-unknown-linux-gnu.env]
xargo = false
```

We currently would use `xargo` even on `aarch64-unknown-linux-gnu`, when
we should not, and only use `xargo` for every other target.

Closes #773.
  • Loading branch information
Alexhuszagh committed Jun 11, 2022
1 parent 7b2c645 commit 8993e71
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ impl Config {
(None, None)
};

match (env_build, toml_build) {
match (env_target, toml_target) {
(Some(value), _) => return Some(value),
(None, Some(value)) => return Some(value),
(None, None) => {}
};

match (env_target, toml_target) {
match (env_build, toml_build) {
(Some(value), _) => return Some(value),
(None, Some(value)) => return Some(value),
(None, None) => {}
Expand Down Expand Up @@ -360,7 +360,7 @@ mod tests {
map.insert("CROSS_TARGET_AARCH64_UNKNOWN_LINUX_GNU_XARGO", "true");
let env = Environment::new(Some(map));
let config = Config::new_with(Some(toml(TOML_BUILD_XARGO_FALSE)?), env);
assert!(matches!(config.xargo(&target()), Some(false)));
assert!(matches!(config.xargo(&target()), Some(true)));

Ok(())
}
Expand Down

0 comments on commit 8993e71

Please sign in to comment.