Skip to content

Commit 34ae542

Browse files
committed
Passthrough cross environment variables by default.
1 parent dd760cf commit 34ae542

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

.changes/1073.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "added",
3+
"description": "passthrough cross environment variables by default"
4+
}

src/docker/shared.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ impl CargoVariant {
920920
}
921921

922922
pub(crate) trait DockerCommandExt {
923-
fn add_cargo_configuration_envvars(&mut self);
923+
fn add_configuration_envvars(&mut self);
924924
fn add_envvars(
925925
&mut self,
926926
options: &DockerOptions,
@@ -948,8 +948,8 @@ pub(crate) trait DockerCommandExt {
948948
}
949949

950950
impl DockerCommandExt for Command {
951-
fn add_cargo_configuration_envvars(&mut self) {
952-
let non_cargo_prefix = &[
951+
fn add_configuration_envvars(&mut self) {
952+
let other = &[
953953
"http_proxy",
954954
"TERM",
955955
"RUSTDOCFLAGS",
@@ -958,6 +958,7 @@ impl DockerCommandExt for Command {
958958
"HTTPS_PROXY",
959959
"HTTP_TIMEOUT",
960960
"https_proxy",
961+
"QEMU_STRACE",
961962
];
962963
let cargo_prefix_skip = &[
963964
"CARGO_HOME",
@@ -968,15 +969,22 @@ impl DockerCommandExt for Command {
968969
"CARGO_BUILD_RUSTC_WORKSPACE_WRAPPER",
969970
"CARGO_BUILD_RUSTDOC",
970971
];
971-
let is_cargo_passthrough = |key: &str| -> bool {
972-
non_cargo_prefix.contains(&key)
972+
let cross_prefix_skip = &[
973+
"CROSS_RUNNER",
974+
"CROSS_RUSTC_MAJOR_VERSION",
975+
"CROSS_RUSTC_MINOR_VERSION",
976+
"CROSS_RUSTC_PATCH_VERSION",
977+
];
978+
let is_passthrough = |key: &str| -> bool {
979+
other.contains(&key)
973980
|| key.starts_with("CARGO_") && !cargo_prefix_skip.contains(&key)
981+
|| key.starts_with("CROSS_") && !cross_prefix_skip.contains(&key)
974982
};
975983

976984
// also need to accept any additional flags used to configure
977-
// cargo, but only pass what's actually present.
985+
// cargo or cross, but only pass what's actually present.
978986
for (key, _) in env::vars() {
979-
if is_cargo_passthrough(&key) {
987+
if is_passthrough(&key) {
980988
self.args(["-e", &key]);
981989
}
982990
}
@@ -1018,20 +1026,12 @@ impl DockerCommandExt for Command {
10181026
// otherwise, zig has a permission error trying to create the cache
10191027
self.args(["-e", "XDG_CACHE_HOME=/target/.zig-cache"]);
10201028
}
1021-
self.add_cargo_configuration_envvars();
1029+
self.add_configuration_envvars();
10221030

10231031
if let Some(username) = id::username().wrap_err("could not get username")? {
10241032
self.args(["-e", &format!("USER={username}")]);
10251033
}
10261034

1027-
if let Ok(value) = env::var("QEMU_STRACE") {
1028-
self.args(["-e", &format!("QEMU_STRACE={value}")]);
1029-
}
1030-
1031-
if let Ok(value) = env::var("CROSS_DEBUG") {
1032-
self.args(["-e", &format!("CROSS_DEBUG={value}")]);
1033-
}
1034-
10351035
if let Ok(value) = env::var("CROSS_CONTAINER_OPTS") {
10361036
if env::var("DOCKER_OPTS").is_ok() {
10371037
msg_info.warn("using both `CROSS_CONTAINER_OPTS` and `DOCKER_OPTS`.")?;

0 commit comments

Comments
 (0)