Skip to content

Commit

Permalink
Add support for complete config options locally.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexhuszagh committed Jul 13, 2022
1 parent 12a6e13 commit c91878e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/docker/local.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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() {
Expand Down
8 changes: 8 additions & 0 deletions src/docker/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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")),
Expand Down

0 comments on commit c91878e

Please sign in to comment.