Skip to content

Commit c91878e

Browse files
committed
Add support for complete config options locally.
1 parent 12a6e13 commit c91878e

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/docker/local.rs

+21
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use std::io;
2+
use std::path::Path;
23
use std::process::ExitStatus;
34

45
use super::shared::*;
6+
use crate::cross_toml::CargoConfigBehavior;
57
use crate::errors::Result;
68
use crate::extensions::CommandExt;
79
use crate::file::{PathExt, ToUtf8};
@@ -66,6 +68,25 @@ pub(crate) fn run(
6668
]);
6769
}
6870

71+
// If we're using all config settings, we need to mount all `.cargo` dirs.
72+
// We've already mounted the CWD, so start at the parents.
73+
let mut host_cwd = paths.cwd.parent();
74+
let mut mount_cwd = Path::new(&paths.directories.mount_cwd).parent();
75+
if let CargoConfigBehavior::Complete = options.cargo_config_behavior {
76+
while let (Some(host), Some(mount)) = (host_cwd, mount_cwd) {
77+
let host_cargo = host.join(".cargo");
78+
let mount_cargo = mount.join(".cargo");
79+
if host_cargo.exists() {
80+
docker.args(&[
81+
"-v",
82+
&format!("{}:{}:Z", host_cargo.to_utf8()?, mount_cargo.as_posix()?),
83+
]);
84+
}
85+
host_cwd = host.parent();
86+
mount_cwd = mount.parent();
87+
}
88+
}
89+
6990
if io::Stdin::is_atty() {
7091
docker.arg("-i");
7192
if io::Stdout::is_atty() && io::Stderr::is_atty() {

src/docker/remote.rs

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use super::engine::Engine;
1111
use super::shared::*;
1212
use crate::cargo::CargoMetadata;
1313
use crate::config::bool_from_envvar;
14+
use crate::cross_toml::CargoConfigBehavior;
1415
use crate::errors::Result;
1516
use crate::extensions::CommandExt;
1617
use crate::file::{self, PathExt, ToUtf8};
@@ -1046,6 +1047,13 @@ pub(crate) fn run(
10461047
)
10471048
.wrap_err("when copying project")?;
10481049

1050+
// If we're using all config settings, write the combined
1051+
// config file to a fixed location (to avoid it becoming stale).
1052+
if let CargoConfigBehavior::Complete = options.cargo_config_behavior {
1053+
// TODO(ahuszagh) Need to write the file out.
1054+
todo!();
1055+
}
1056+
10491057
let mut copied = vec![
10501058
(&dirs.xargo, mount_prefix_path.join("xargo")),
10511059
(&dirs.cargo, mount_prefix_path.join("cargo")),

0 commit comments

Comments
 (0)