@@ -263,7 +263,7 @@ pub struct ToolchainDirectories {
263
263
}
264
264
265
265
impl ToolchainDirectories {
266
- pub fn assemble ( mount_finder : & MountFinder , mut toolchain : QualifiedToolchain ) -> Result < Self > {
266
+ pub fn assemble ( mount_finder : & MountFinder , toolchain : QualifiedToolchain ) -> Result < Self > {
267
267
let home_dir =
268
268
home:: home_dir ( ) . ok_or_else ( || eyre:: eyre!( "could not find home directory" ) ) ?;
269
269
let cargo = home:: cargo_home ( ) ?;
@@ -311,8 +311,6 @@ impl ToolchainDirectories {
311
311
let cargo = mount_finder. find_mount_path ( cargo) ;
312
312
let xargo = mount_finder. find_mount_path ( xargo) ;
313
313
314
- toolchain. set_sysroot ( |p| mount_finder. find_mount_path ( p) ) ;
315
-
316
314
// canonicalize these once to avoid syscalls
317
315
let sysroot_mount_path = toolchain. get_sysroot ( ) . as_posix_absolute ( ) ?;
318
316
@@ -413,30 +411,29 @@ pub struct PackageDirectories {
413
411
impl PackageDirectories {
414
412
pub fn assemble (
415
413
mount_finder : & MountFinder ,
416
- mut metadata : CargoMetadata ,
414
+ metadata : CargoMetadata ,
417
415
cwd : & Path ,
418
416
) -> Result < ( Self , CargoMetadata ) > {
419
417
let target = & metadata. target_directory ;
420
418
// see ToolchainDirectories::assemble for creating directories
421
419
create_target_dir ( target) ?;
422
420
423
- metadata. target_directory = mount_finder. find_mount_path ( target) ;
424
-
425
421
// root is either workspace_root, or, if we're outside the workspace root, the current directory
426
- let host_root = mount_finder . find_mount_path ( if metadata. workspace_root . starts_with ( cwd) {
422
+ let host_root = if metadata. workspace_root . starts_with ( cwd) {
427
423
cwd
428
424
} else {
429
425
& metadata. workspace_root
430
- } ) ;
426
+ }
427
+ . to_path_buf ( ) ;
431
428
432
429
// on Windows, we can not mount the directory name directly. Instead, we use wslpath to convert the path to a linux compatible path.
433
430
// NOTE: on unix, host root has already found the mount path
434
431
let mount_root = host_root. as_posix_absolute ( ) ?;
435
- let mount_cwd = mount_finder . find_path ( cwd , false ) ?;
432
+ let mount_cwd = cwd . as_posix_absolute ( ) ?;
436
433
437
434
Ok ( (
438
435
PackageDirectories {
439
- target : metadata . target_directory . clone ( ) ,
436
+ target : mount_finder . find_mount_path ( target ) ,
440
437
host_root,
441
438
mount_root,
442
439
mount_cwd,
@@ -1193,10 +1190,7 @@ impl DockerCommandExt for Command {
1193
1190
if let Ok ( val) = value {
1194
1191
let canonical_path = file:: canonicalize ( & val) ?;
1195
1192
let host_path = paths. mount_finder . find_path ( & canonical_path, true ) ?;
1196
- let absolute_path = Path :: new ( & val) . as_posix_absolute ( ) ?;
1197
- let mount_path = paths
1198
- . mount_finder
1199
- . find_path ( Path :: new ( & absolute_path) , true ) ?;
1193
+ let mount_path = Path :: new ( & val) . as_posix_absolute ( ) ?;
1200
1194
mount_cb ( self , host_path. as_ref ( ) , mount_path. as_ref ( ) ) ?;
1201
1195
self . args ( [ "-e" , & format ! ( "{}={}" , var, mount_path) ] ) ;
1202
1196
store_cb ( ( val, mount_path) ) ;
@@ -1209,10 +1203,7 @@ impl DockerCommandExt for Command {
1209
1203
// to the mounted project directory.
1210
1204
let canonical_path = file:: canonicalize ( path) ?;
1211
1205
let host_path = paths. mount_finder . find_path ( & canonical_path, true ) ?;
1212
- let absolute_path = Path :: new ( path) . as_posix_absolute ( ) ?;
1213
- let mount_path = paths
1214
- . mount_finder
1215
- . find_path ( Path :: new ( & absolute_path) , true ) ?;
1206
+ let mount_path = path. as_posix_absolute ( ) ?;
1216
1207
mount_cb ( self , host_path. as_ref ( ) , mount_path. as_ref ( ) ) ?;
1217
1208
store_cb ( ( path. to_utf8 ( ) ?. to_owned ( ) , mount_path) ) ;
1218
1209
}
@@ -1716,15 +1707,9 @@ mod tests {
1716
1707
1717
1708
paths_equal ( toolchain_dirs. cargo ( ) , & mount_path ( home ( ) ?. join ( ".cargo" ) ) ) ?;
1718
1709
paths_equal ( toolchain_dirs. xargo ( ) , & mount_path ( home ( ) ?. join ( ".xargo" ) ) ) ?;
1719
- paths_equal ( package_dirs. host_root ( ) , & mount_path ( get_cwd ( ) ?) ) ?;
1720
- assert_eq ! (
1721
- package_dirs. mount_root( ) ,
1722
- & mount_path( get_cwd( ) ?) . as_posix_absolute( ) ?
1723
- ) ;
1724
- assert_eq ! (
1725
- package_dirs. mount_cwd( ) ,
1726
- & mount_path( get_cwd( ) ?) . as_posix_absolute( ) ?
1727
- ) ;
1710
+ paths_equal ( package_dirs. host_root ( ) , & get_cwd ( ) ?) ?;
1711
+ assert_eq ! ( package_dirs. mount_root( ) , & get_cwd( ) ?. as_posix_absolute( ) ?) ;
1712
+ assert_eq ! ( package_dirs. mount_cwd( ) , & get_cwd( ) ?. as_posix_absolute( ) ?) ;
1728
1713
1729
1714
reset_env ( vars) ;
1730
1715
Ok ( ( ) )
0 commit comments