From c91878ee7c091ecde4a3b08527f4054a25755e1f Mon Sep 17 00:00:00 2001 From: Alex Huszagh Date: Wed, 13 Jul 2022 00:11:40 -0500 Subject: [PATCH] Add support for complete config options locally. --- src/docker/local.rs | 21 +++++++++++++++++++++ src/docker/remote.rs | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/src/docker/local.rs b/src/docker/local.rs index 134961908..88c968035 100644 --- a/src/docker/local.rs +++ b/src/docker/local.rs @@ -1,7 +1,9 @@ use std::io; +use std::path::Path; use std::process::ExitStatus; use super::shared::*; +use crate::cross_toml::CargoConfigBehavior; use crate::errors::Result; use crate::extensions::CommandExt; use crate::file::{PathExt, ToUtf8}; @@ -66,6 +68,25 @@ pub(crate) fn run( ]); } + // If we're using all config settings, we need to mount all `.cargo` dirs. + // We've already mounted the CWD, so start at the parents. + let mut host_cwd = paths.cwd.parent(); + let mut mount_cwd = Path::new(&paths.directories.mount_cwd).parent(); + if let CargoConfigBehavior::Complete = options.cargo_config_behavior { + while let (Some(host), Some(mount)) = (host_cwd, mount_cwd) { + let host_cargo = host.join(".cargo"); + let mount_cargo = mount.join(".cargo"); + if host_cargo.exists() { + docker.args(&[ + "-v", + &format!("{}:{}:Z", host_cargo.to_utf8()?, mount_cargo.as_posix()?), + ]); + } + host_cwd = host.parent(); + mount_cwd = mount.parent(); + } + } + if io::Stdin::is_atty() { docker.arg("-i"); if io::Stdout::is_atty() && io::Stderr::is_atty() { diff --git a/src/docker/remote.rs b/src/docker/remote.rs index b77d504b3..516cab4bb 100644 --- a/src/docker/remote.rs +++ b/src/docker/remote.rs @@ -11,6 +11,7 @@ use super::engine::Engine; use super::shared::*; use crate::cargo::CargoMetadata; use crate::config::bool_from_envvar; +use crate::cross_toml::CargoConfigBehavior; use crate::errors::Result; use crate::extensions::CommandExt; use crate::file::{self, PathExt, ToUtf8}; @@ -1046,6 +1047,13 @@ pub(crate) fn run( ) .wrap_err("when copying project")?; + // If we're using all config settings, write the combined + // config file to a fixed location (to avoid it becoming stale). + if let CargoConfigBehavior::Complete = options.cargo_config_behavior { + // TODO(ahuszagh) Need to write the file out. + todo!(); + } + let mut copied = vec![ (&dirs.xargo, mount_prefix_path.join("xargo")), (&dirs.cargo, mount_prefix_path.join("cargo")),