Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve symlinks for cargo and xargo home. #947

Merged
merged 1 commit into from
Jul 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changes/947.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"type": "internal",
"description": "resolve symlinks to cargo and xargo home before mounting",
"issues": [373]
},
{
"type": "fixed",
"description": "mount cargo, xargo, and the sysroot at the same path as on the host to avoid unnecessary recompilation.",
Emilgardis marked this conversation as resolved.
Show resolved Hide resolved
"issues": [551]
}
]
7 changes: 3 additions & 4 deletions src/bin/commands/containers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,23 +451,22 @@ pub fn create_persistent_volume(
docker::remote::copy_volume_container_xargo(
engine,
&container,
&dirs.xargo,
&toolchain_host,
&dirs,
mount_prefix.as_ref(),
msg_info,
)?;
docker::remote::copy_volume_container_cargo(
engine,
&container,
&dirs.cargo,
&dirs,
mount_prefix.as_ref(),
copy_registry,
msg_info,
)?;
docker::remote::copy_volume_container_rust(
engine,
&container,
&toolchain,
&dirs,
None,
mount_prefix.as_ref(),
msg_info,
Expand Down
6 changes: 6 additions & 0 deletions src/docker/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ impl ImagePlatform {
}
}

impl Default for ImagePlatform {
fn default() -> ImagePlatform {
ImagePlatform::DEFAULT
}
}

impl TryFrom<&str> for ImagePlatform {
type Error = <Self as std::str::FromStr>::Err;

Expand Down
28 changes: 22 additions & 6 deletions src/docker/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ pub(crate) fn run(
.image
.platform
.specify_platform(&options.engine, &mut docker);
docker_envvars(&mut docker, &options.config, &options.target, msg_info)?;
docker_envvars(
&mut docker,
&options.config,
dirs,
&options.target,
msg_info,
)?;

docker_mount(
&mut docker,
Expand All @@ -44,18 +50,28 @@ pub(crate) fn run(
docker_user_id(&mut docker, engine.kind);

docker
.args(&["-v", &format!("{}:/xargo:Z", dirs.xargo.to_utf8()?)])
.args(&["-v", &format!("{}:/cargo:Z", dirs.cargo.to_utf8()?)])
.args(&[
"-v",
&format!("{}:{}:Z", dirs.xargo.to_utf8()?, dirs.xargo_mount_path()),
])
.args(&[
"-v",
&format!("{}:{}:Z", dirs.cargo.to_utf8()?, dirs.cargo_mount_path()),
])
// Prevent `bin` from being mounted inside the Docker container.
.args(&["-v", "/cargo/bin"]);
.args(&["-v", &format!("{}/bin", dirs.cargo_mount_path())]);
docker.args(&[
"-v",
&format!("{}:{}:Z", dirs.host_root.to_utf8()?, dirs.mount_root),
]);
docker
.args(&[
"-v",
&format!("{}:/rust:Z,ro", paths.get_sysroot().to_utf8()?),
&format!(
"{}:{}:Z,ro",
dirs.get_sysroot().to_utf8()?,
dirs.sysroot_mount_path()
),
])
.args(&["-v", &format!("{}:/target:Z", dirs.target.to_utf8()?)]);
docker_cwd(&mut docker, &paths)?;
Expand Down Expand Up @@ -84,7 +100,7 @@ pub(crate) fn run(

docker
.arg(&image_name)
.args(&["sh", "-c", &format!("PATH=$PATH:/rust/bin {:?}", cmd)])
.args(&["sh", "-c", &build_command(dirs, &cmd)])
.run_and_get_status(msg_info, false)
.map_err(Into::into)
}
Loading