@@ -181,13 +181,13 @@ def cargo_stamp(self):
181181 return os .path .join (self .bin_root (), '.cargo-stamp' )
182182
183183 def rustc_out_of_date (self ):
184- if not os .path .exists (self .rustc_stamp ()):
184+ if not os .path .exists (self .rustc_stamp ()) or self . clean :
185185 return True
186186 with open (self .rustc_stamp (), 'r' ) as f :
187187 return self .stage0_rustc_date () != f .read ()
188188
189189 def cargo_out_of_date (self ):
190- if not os .path .exists (self .cargo_stamp ()):
190+ if not os .path .exists (self .cargo_stamp ()) or self . clean :
191191 return True
192192 with open (self .cargo_stamp (), 'r' ) as f :
193193 return self .stage0_cargo_date () != f .read ()
@@ -234,8 +234,11 @@ def exe_suffix(self):
234234 return ''
235235
236236 def build_bootstrap (self ):
237+ build_dir = os .path .join (self .build_dir , "bootstrap" )
238+ if self .clean and os .path .exists (build_dir ):
239+ shutil .rmtree (build_dir )
237240 env = os .environ .copy ()
238- env ["CARGO_TARGET_DIR" ] = os . path . join ( self . build_dir , "bootstrap" )
241+ env ["CARGO_TARGET_DIR" ] = build_dir
239242 env ["RUSTC" ] = self .rustc ()
240243 env ["LD_LIBRARY_PATH" ] = os .path .join (self .bin_root (), "lib" )
241244 env ["DYLD_LIBRARY_PATH" ] = os .path .join (self .bin_root (), "lib" )
@@ -340,6 +343,7 @@ def build_triple(self):
340343def main ():
341344 parser = argparse .ArgumentParser (description = 'Build rust' )
342345 parser .add_argument ('--config' )
346+ parser .add_argument ('--clean' , action = 'store_true' )
343347 parser .add_argument ('-v' , '--verbose' , action = 'store_true' )
344348
345349 args = [a for a in sys .argv if a != '-h' ]
@@ -352,6 +356,7 @@ def main():
352356 rb .rust_root = os .path .abspath (os .path .join (__file__ , '../../..' ))
353357 rb .build_dir = os .path .join (os .getcwd (), "build" )
354358 rb .verbose = args .verbose
359+ rb .clean = args .clean
355360
356361 try :
357362 with open (args .config or 'config.toml' ) as config :
0 commit comments