Skip to content

Commit ee81cbf

Browse files
Replace periods with underscores as well when parsing env variables (#1541)
1 parent 9b4389c commit ee81cbf

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@
114114
//! Each of these variables can also be supplied with certain prefixes and suffixes,
115115
//! in the following prioritized order:
116116
//!
117-
//! 1. `<var>_<target>` - for example, `CC_x86_64-unknown-linux-gnu`
118-
//! 2. `<var>_<target_with_underscores>` - for example, `CC_x86_64_unknown_linux_gnu`
117+
//! 1. `<var>_<target>` - for example, `CC_x86_64-unknown-linux-gnu` or `CC_thumbv8m.main-none-eabi`
118+
//! 2. `<var>_<target_with_underscores>` - for example, `CC_x86_64_unknown_linux_gnu` or `CC_thumbv8m_main_none_eabi` (both periods and underscores are replaced)
119119
//! 3. `<build-kind>_<var>` - for example, `HOST_CC` or `TARGET_CFLAGS`
120120
//! 4. `<var>` - a plain `CC`, `AR` as above.
121121
//!
@@ -3928,7 +3928,7 @@ impl Build {
39283928
} else {
39293929
"HOST"
39303930
};
3931-
let target_u = target.replace('-', "_");
3931+
let target_u = target.replace(['-', '.'], "_");
39323932

39333933
Ok([
39343934
format!("{env}_{target}"),

tests/cc_env.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,14 @@ fn env_var_alternatives_override() {
133133
let compiler2 = format!("clang2{}", env::consts::EXE_SUFFIX);
134134
let compiler3 = format!("clang3{}", env::consts::EXE_SUFFIX);
135135
let compiler4 = format!("clang4{}", env::consts::EXE_SUFFIX);
136+
let compiler5 = format!("clang5{}", env::consts::EXE_SUFFIX);
136137

137138
let test = Test::new();
138139
test.shim(&compiler1);
139140
test.shim(&compiler2);
140141
test.shim(&compiler3);
141142
test.shim(&compiler4);
143+
test.shim(&compiler5);
142144

143145
env::set_var("CC", &compiler1);
144146
let compiler = test.gcc().target("x86_64-unknown-none").get_compiler();
@@ -156,4 +158,8 @@ fn env_var_alternatives_override() {
156158
env::set_var("CC_x86_64-unknown-none", &compiler4);
157159
let compiler = test.gcc().target("x86_64-unknown-none").get_compiler();
158160
assert_eq!(compiler.path(), Path::new(&compiler4));
161+
162+
env::set_var("CC_thumbv8m_main_none_eabi", &compiler5);
163+
let compiler = test.gcc().target("thumbv8m.main-none-eabi").get_compiler();
164+
assert_eq!(compiler.path(), Path::new(&compiler5));
159165
}

0 commit comments

Comments
 (0)