@@ -112,7 +112,7 @@ use std::path::{Path, PathBuf};
112112///
113113/// See module docs for more information.
114114pub struct Layout {
115- artifact_dir : ArtifactDirLayout ,
115+ artifact_dir : Option < ArtifactDirLayout > ,
116116 build_dir : BuildDirLayout ,
117117}
118118
@@ -127,6 +127,7 @@ impl Layout {
127127 ws : & Workspace < ' _ > ,
128128 target : Option < CompileTarget > ,
129129 dest : & str ,
130+ must_take_artifact_dir_lock : bool ,
130131 ) -> CargoResult < Layout > {
131132 let is_new_layout = ws. gctx ( ) . cli_unstable ( ) . build_dir_new_layout ;
132133 let mut root = ws. target_dir ( ) ;
@@ -150,15 +151,6 @@ impl Layout {
150151 // actual destination (sub)subdirectory.
151152 paths:: create_dir_all ( dest. as_path_unlocked ( ) ) ?;
152153
153- // For now we don't do any more finer-grained locking on the artifact
154- // directory, so just lock the entire thing for the duration of this
155- // compile.
156- let artifact_dir_lock = if is_on_nfs_mount ( root. as_path_unlocked ( ) ) {
157- None
158- } else {
159- Some ( dest. open_rw_exclusive_create ( ".cargo-lock" , ws. gctx ( ) , "artifact directory" ) ?)
160- } ;
161-
162154 let build_dir_lock = if root == build_root || is_on_nfs_mount ( build_root. as_path_unlocked ( ) )
163155 {
164156 None
@@ -169,21 +161,38 @@ impl Layout {
169161 "build directory" ,
170162 ) ?)
171163 } ;
172- let root = root. into_path_unlocked ( ) ;
173164 let build_root = build_root. into_path_unlocked ( ) ;
174- let dest = dest. into_path_unlocked ( ) ;
175165 let build_dest = build_dest. as_path_unlocked ( ) ;
176166 let deps = build_dest. join ( "deps" ) ;
177167 let artifact = deps. join ( "artifact" ) ;
178168
179- Ok ( Layout {
180- artifact_dir : ArtifactDirLayout {
169+ let artifact_dir = if must_take_artifact_dir_lock {
170+ // For now we don't do any more finer-grained locking on the artifact
171+ // directory, so just lock the entire thing for the duration of this
172+ // compile.
173+ let artifact_dir_lock = if is_on_nfs_mount ( root. as_path_unlocked ( ) ) {
174+ None
175+ } else {
176+ Some ( dest. open_rw_exclusive_create (
177+ ".cargo-lock" ,
178+ ws. gctx ( ) ,
179+ "artifact directory" ,
180+ ) ?)
181+ } ;
182+ let root = root. into_path_unlocked ( ) ;
183+ let dest = dest. into_path_unlocked ( ) ;
184+ Some ( ArtifactDirLayout {
181185 dest : dest. clone ( ) ,
182186 examples : dest. join ( "examples" ) ,
183187 doc : root. join ( "doc" ) ,
184188 timings : root. join ( "cargo-timings" ) ,
185189 _lock : artifact_dir_lock,
186- } ,
190+ } )
191+ } else {
192+ None
193+ } ;
194+ Ok ( Layout {
195+ artifact_dir,
187196 build_dir : BuildDirLayout {
188197 root : build_root. clone ( ) ,
189198 deps,
@@ -201,14 +210,16 @@ impl Layout {
201210
202211 /// Makes sure all directories stored in the Layout exist on the filesystem.
203212 pub fn prepare ( & mut self ) -> CargoResult < ( ) > {
204- self . artifact_dir . prepare ( ) ?;
213+ if let Some ( ref mut artifact_dir) = self . artifact_dir {
214+ artifact_dir. prepare ( ) ?;
215+ }
205216 self . build_dir . prepare ( ) ?;
206217
207218 Ok ( ( ) )
208219 }
209220
210- pub fn artifact_dir ( & self ) -> & ArtifactDirLayout {
211- & self . artifact_dir
221+ pub fn artifact_dir ( & self ) -> Option < & ArtifactDirLayout > {
222+ self . artifact_dir . as_ref ( )
212223 }
213224
214225 pub fn build_dir ( & self ) -> & BuildDirLayout {
0 commit comments