Skip to content

Commit 239e8cb

Browse files
Merge #772
772: Add `CROSS_CONTAINER_OPTS` environment variable. r=Emilgardis a=Alexhuszagh Rename `DOCKER_OPTS` to `CROSS_CONTAINER_OPTS`, and currently prefer `CROSS_CONTAINER_OPTS` to `DOCKER_OPTS`, although both are still valid. Closes #770. Co-authored-by: Alex Huszagh <[email protected]>
2 parents b282a83 + 5d6855b commit 239e8cb

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
88
### Added
99

1010
- #775 - forward Cargo exit code to host
11+
- #772 - added `CROSS_CONTAINER_OPTS` environment variable to replace `DOCKER_OPTS`.
1112
- #767 - added the `cross-util` and `cross-dev` commands.
1213
- #745 - added `thumbv7neon-*` targets.
1314
- #741 - added `armv7-unknown-linux-gnueabi` and `armv7-unknown-linux-musleabi` targets.

src/docker.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ fn validate_env_var(var: &str) -> Result<(&str, Option<&str>)> {
9494
Ok((key, value))
9595
}
9696

97+
fn parse_docker_opts(value: &str) -> Result<Vec<String>> {
98+
shell_words::split(value).wrap_err_with(|| format!("could not parse docker opts of {}", value))
99+
}
100+
97101
#[allow(unused_variables)]
98102
pub fn mount(cmd: &mut Command, val: &Path, verbose: bool) -> Result<PathBuf> {
99103
let host_path = file::canonicalize(&val)
@@ -291,11 +295,15 @@ pub fn run(
291295
docker.args(&["-e", &format!("CROSS_DEBUG={value}")]);
292296
}
293297

294-
if let Ok(value) = env::var("DOCKER_OPTS") {
295-
let opts = shell_words::split(&value)
296-
.wrap_err_with(|| format!("could not parse docker opts of {}", value))?;
297-
docker.args(&opts);
298-
}
298+
if let Ok(value) = env::var("CROSS_CONTAINER_OPTS") {
299+
if env::var("DOCKER_OPTS").is_ok() {
300+
eprintln!("Warning: using both `CROSS_CONTAINER_OPTS` and `DOCKER_OPTS`.");
301+
}
302+
docker.args(&parse_docker_opts(&value)?);
303+
} else if let Ok(value) = env::var("DOCKER_OPTS") {
304+
// FIXME: remove this when we deprecate DOCKER_OPTS.
305+
docker.args(&parse_docker_opts(&value)?);
306+
};
299307

300308
docker
301309
.args(&[

0 commit comments

Comments
 (0)