@@ -9,12 +9,15 @@ use crate::cargo::{cargo_metadata_with_args, CargoMetadata};
99use crate :: config:: { bool_from_envvar, Config } ;
1010use crate :: errors:: * ;
1111use crate :: extensions:: { CommandExt , SafeCommand } ;
12- use crate :: file:: { self , write_file, PathExt , ToUtf8 } ;
12+ use crate :: file:: { self , write_file, ToUtf8 } ;
1313use crate :: id;
1414use crate :: rustc:: { self , VersionMetaExt } ;
1515use crate :: shell:: { MessageInfo , Verbosity } ;
1616use crate :: Target ;
1717
18+ #[ cfg( target_os = "windows" ) ]
19+ use crate :: file:: PathExt ;
20+
1821pub use super :: custom:: CROSS_CUSTOM_DOCKERFILE_IMAGE_PREFIX ;
1922
2023pub const CROSS_IMAGE : & str = "ghcr.io/cross-rs" ;
@@ -496,20 +499,8 @@ pub(crate) fn docker_envvars(
496499 Ok ( ( ) )
497500}
498501
499- pub ( crate ) fn docker_cwd (
500- docker : & mut Command ,
501- paths : & DockerPaths ,
502- mount_volumes : bool ,
503- ) -> Result < ( ) > {
504- if mount_volumes {
505- docker. args ( & [ "-w" , paths. mount_cwd ( ) ] ) ;
506- } else if paths. mount_cwd ( ) == paths. workspace_root ( ) . to_utf8 ( ) ? {
507- docker. args ( & [ "-w" , "/project" ] ) ;
508- } else {
509- // We do this to avoid clashes with path separators. Windows uses `\` as a path separator on Path::join
510- let working_dir = Path :: new ( "/project" ) . join ( paths. workspace_from_cwd ( ) ?) ;
511- docker. args ( & [ "-w" , & working_dir. as_posix ( ) ?] ) ;
512- }
502+ pub ( crate ) fn docker_cwd ( docker : & mut Command , paths : & DockerPaths ) -> Result < ( ) > {
503+ docker. args ( & [ "-w" , paths. mount_cwd ( ) ] ) ;
513504
514505 Ok ( ( ) )
515506}
@@ -520,14 +511,7 @@ pub(crate) fn docker_mount(
520511 paths : & DockerPaths ,
521512 mount_cb : impl Fn ( & mut Command , & Path ) -> Result < String > ,
522513 mut store_cb : impl FnMut ( ( String , String ) ) ,
523- ) -> Result < bool > {
524- let mut mount_volumes = false ;
525- // FIXME(emilgardis 2022-04-07): This is a fallback so that if it's hard for us to do mounting logic, make it simple(r)
526- // Preferably we would not have to do this.
527- if !paths. in_workspace ( ) {
528- mount_volumes = true ;
529- }
530-
514+ ) -> Result < ( ) > {
531515 for ref var in options
532516 . config
533517 . env_volumes ( & options. target ) ?
@@ -545,7 +529,6 @@ pub(crate) fn docker_mount(
545529 let mount_path = mount_cb ( docker, host_path. as_ref ( ) ) ?;
546530 docker. args ( & [ "-e" , & format ! ( "{}={}" , host_path, mount_path) ] ) ;
547531 store_cb ( ( val, mount_path) ) ;
548- mount_volumes = true ;
549532 }
550533 }
551534
@@ -554,10 +537,9 @@ pub(crate) fn docker_mount(
554537 let host_path = paths. mount_finder . find_path ( & canonical_path, true ) ?;
555538 let mount_path = mount_cb ( docker, host_path. as_ref ( ) ) ?;
556539 store_cb ( ( path. to_utf8 ( ) ?. to_owned ( ) , mount_path) ) ;
557- mount_volumes = true ;
558540 }
559541
560- Ok ( mount_volumes )
542+ Ok ( ( ) )
561543}
562544
563545pub ( crate ) fn canonicalize_mount_path ( path : & Path ) -> Result < String > {
@@ -806,6 +788,9 @@ mod tests {
806788 use super :: * ;
807789 use crate :: id;
808790
791+ #[ cfg( not( target_os = "windows" ) ) ]
792+ use crate :: file:: PathExt ;
793+
809794 #[ test]
810795 fn test_docker_user_id ( ) {
811796 let var = "CROSS_ROOTLESS_CONTAINER_ENGINE" ;
0 commit comments