File tree 2 files changed +12
-4
lines changed
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,11 @@ pub struct InstallArgs {
71
71
#[ clap( long, action) ]
72
72
pub auto_install_rust_toolchain : bool ,
73
73
74
+ /// Clear target dir of `rustc_codegen_spirv` build after a successful build, saves about
75
+ /// 200MiB of disk space.
76
+ #[ clap( long = "no-clear-target" , default_value = "true" , action = clap:: ArgAction :: SetFalse ) ]
77
+ pub clear_target : bool ,
78
+
74
79
/// There is a tricky situation where a shader crate that depends on workspace config can have
75
80
/// a different `Cargo.lock` lockfile version from the the workspace's `Cargo.lock`. This can
76
81
/// prevent builds when an old Rust toolchain doesn't recognise the newer lockfile version.
Original file line number Diff line number Diff line change @@ -188,15 +188,18 @@ package = "rustc_codegen_spirv"
188
188
} )
189
189
. context ( "running build command" ) ?;
190
190
191
- let dylib_path = checkout
192
- . join ( "target" )
193
- . join ( "release" )
194
- . join ( & dylib_filename) ;
191
+ let target = checkout. join ( "target" ) ;
192
+ let dylib_path = target. join ( "release" ) . join ( & dylib_filename) ;
195
193
if dylib_path. is_file ( ) {
196
194
log:: info!( "successfully built {}" , dylib_path. display( ) ) ;
197
195
if !source_is_path {
198
196
std:: fs:: rename ( & dylib_path, & dest_dylib_path)
199
197
. context ( "renaming dylib path" ) ?;
198
+
199
+ if self . spirv_install . clear_target {
200
+ log:: warn!( "clearing target dir {}" , target. display( ) ) ;
201
+ std:: fs:: remove_dir_all ( & target) . context ( "clearing target dir" ) ?;
202
+ }
200
203
}
201
204
} else {
202
205
log:: error!( "could not find {}" , dylib_path. display( ) ) ;
You can’t perform that action at this time.
0 commit comments