@@ -181,13 +181,13 @@ def cargo_stamp(self):
181
181
return os .path .join (self .bin_root (), '.cargo-stamp' )
182
182
183
183
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 :
185
185
return True
186
186
with open (self .rustc_stamp (), 'r' ) as f :
187
187
return self .stage0_rustc_date () != f .read ()
188
188
189
189
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 :
191
191
return True
192
192
with open (self .cargo_stamp (), 'r' ) as f :
193
193
return self .stage0_cargo_date () != f .read ()
@@ -234,8 +234,11 @@ def exe_suffix(self):
234
234
return ''
235
235
236
236
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 )
237
240
env = os .environ .copy ()
238
- env ["CARGO_TARGET_DIR" ] = os . path . join ( self . build_dir , "bootstrap" )
241
+ env ["CARGO_TARGET_DIR" ] = build_dir
239
242
env ["RUSTC" ] = self .rustc ()
240
243
env ["LD_LIBRARY_PATH" ] = os .path .join (self .bin_root (), "lib" )
241
244
env ["DYLD_LIBRARY_PATH" ] = os .path .join (self .bin_root (), "lib" )
@@ -340,6 +343,7 @@ def build_triple(self):
340
343
def main ():
341
344
parser = argparse .ArgumentParser (description = 'Build rust' )
342
345
parser .add_argument ('--config' )
346
+ parser .add_argument ('--clean' , action = 'store_true' )
343
347
parser .add_argument ('-v' , '--verbose' , action = 'store_true' )
344
348
345
349
args = [a for a in sys .argv if a != '-h' ]
@@ -352,6 +356,7 @@ def main():
352
356
rb .rust_root = os .path .abspath (os .path .join (__file__ , '../../..' ))
353
357
rb .build_dir = os .path .join (os .getcwd (), "build" )
354
358
rb .verbose = args .verbose
359
+ rb .clean = args .clean
355
360
356
361
try :
357
362
with open (args .config or 'config.toml' ) as config :
0 commit comments