Skip to content

Commit f0fb2a6

Browse files
committed
skip target dir
1 parent 728c98c commit f0fb2a6

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

src/bin/commands/install.rs

+19-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use eyre::Context;
66
pub struct Install {
77
#[clap(long)]
88
target: Option<String>,
9+
#[clap(long)]
10+
root: String,
911
/// Provide verbose diagnostic output.
1012
#[clap(short, long)]
1113
pub verbose: bool,
@@ -50,6 +52,8 @@ impl Install {
5052
if let Some(target) = self.target {
5153
command.push(format!("--target={target}"));
5254
}
55+
command.push(format!("--root={}", self.root));
56+
5357
if let Some(engine) = self.engine {
5458
std::env::set_var(docker::CROSS_CONTAINER_ENGINE_VAR, engine);
5559
}
@@ -101,9 +105,19 @@ impl Install {
101105

102106
let cwd = std::env::current_dir()?;
103107

104-
let paths =
105-
docker::DockerPaths::create(&engine, todo!(), cwd, toolchain.clone(), msg_info)?;
106-
let options = docker::DockerOptions::new(
108+
let paths = docker::DockerPaths::create(
109+
&engine,
110+
cross::CargoMetadata {
111+
workspace_root: cwd.clone(),
112+
target_directory: cross::file::absolute_path(self.root)?,
113+
packages: vec![],
114+
workspace_members: vec![],
115+
},
116+
cwd,
117+
toolchain.clone(),
118+
msg_info,
119+
)?;
120+
let mut options = docker::DockerOptions::new(
107121
engine,
108122
target.clone(),
109123
config,
@@ -112,6 +126,8 @@ impl Install {
112126
rustc_version,
113127
);
114128

129+
options.skip_target_dir = true;
130+
115131
cross::install_interpreter_if_needed(
116132
&args,
117133
host_version_meta,
@@ -122,7 +138,6 @@ impl Install {
122138

123139
let status = docker::run(options, paths, &filtered_args, msg_info)
124140
.wrap_err("could not run container")?;
125-
let needs_host = args.subcommand.map_or(false, |sc| sc.needs_host(is_remote));
126141
if !status.success() {
127142
cross::warn_on_failure(&target, &toolchain, msg_info)?;
128143
}

src/docker/local.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,20 @@ pub(crate) fn run(
8787
package_dirs.mount_root()
8888
),
8989
]);
90-
docker
91-
.args([
92-
"-v",
93-
&format!(
94-
"{}:{}:z,ro",
95-
toolchain_dirs.get_sysroot().to_utf8()?,
96-
toolchain_dirs.sysroot_mount_path()
97-
),
98-
])
99-
.args([
90+
docker.args([
91+
"-v",
92+
&format!(
93+
"{}:{}:z,ro",
94+
toolchain_dirs.get_sysroot().to_utf8()?,
95+
toolchain_dirs.sysroot_mount_path()
96+
),
97+
]);
98+
if !options.skip_target_dir {
99+
docker.args([
100100
"-v",
101101
&format!("{}:/target:z", package_dirs.target().to_utf8()?),
102102
]);
103+
}
103104
docker.add_cwd(&paths)?;
104105

105106
// When running inside NixOS or using Nix packaging we need to add the Nix

src/docker/shared.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub struct DockerOptions {
3333
pub target: Target,
3434
pub config: Config,
3535
pub image: Image,
36+
pub skip_target_dir: bool,
3637
pub cargo_variant: CargoVariant,
3738
// not all toolchains will provide this
3839
pub rustc_version: Option<RustcVersion>,
@@ -52,6 +53,7 @@ impl DockerOptions {
5253
target,
5354
config,
5455
image,
56+
skip_target_dir: false,
5557
cargo_variant,
5658
rustc_version,
5759
}
@@ -1034,8 +1036,11 @@ impl DockerCommandExt for Command {
10341036
"-e",
10351037
&format!("CROSS_RUST_SYSROOT={}", dirs.sysroot_mount_path()),
10361038
])
1037-
.args(["-e", "CARGO_TARGET_DIR=/target"])
10381039
.args(["-e", &cross_runner]);
1040+
1041+
if !options.skip_target_dir {
1042+
self.args(["-e", "CARGO_TARGET_DIR=/target"]);
1043+
}
10391044
if options.cargo_variant.uses_zig() {
10401045
// otherwise, zig has a permission error trying to create the cache
10411046
self.args(["-e", "XDG_CACHE_HOME=/target/.zig-cache"]);

0 commit comments

Comments
 (0)