@@ -127,13 +127,13 @@ def unpack(tarball, dst, verbose=False, match=None):
127
127
shutil .move (tp , fp )
128
128
shutil .rmtree (os .path .join (dst , fname ))
129
129
130
- def run (args , verbose = False , exception = False , cwd = None ):
130
+ def run (args , verbose = False , exception = False ):
131
131
if verbose :
132
132
print ("running: " + ' ' .join (args ))
133
133
sys .stdout .flush ()
134
134
# Use Popen here instead of call() as it apparently allows powershell on
135
135
# Windows to not lock up waiting for input presumably.
136
- ret = subprocess .Popen (args , cwd = cwd )
136
+ ret = subprocess .Popen (args )
137
137
code = ret .wait ()
138
138
if code != 0 :
139
139
err = "failed to run: " + ' ' .join (args )
@@ -389,24 +389,14 @@ def build_bootstrap(self):
389
389
args .append ("--locked" )
390
390
if self .use_vendored_sources :
391
391
args .append ("--frozen" )
392
- self .run (args , env )
392
+ self .run (args , env = env )
393
393
394
- def run (self , args , env = None , cwd = None ):
395
- proc = subprocess .Popen (args , env = env , cwd = cwd )
394
+ def run (self , args , ** kwargs ):
395
+ proc = subprocess .Popen (args , ** kwargs )
396
396
ret = proc .wait ()
397
397
if ret != 0 :
398
398
sys .exit (ret )
399
399
400
- def output (self , args , env = None , cwd = None ):
401
- default_encoding = sys .getdefaultencoding ()
402
- proc = subprocess .Popen (args , stdout = subprocess .PIPE , env = env , cwd = cwd )
403
- (out , err ) = proc .communicate ()
404
- ret = proc .wait ()
405
- if ret != 0 :
406
- print (out )
407
- sys .exit (ret )
408
- return out .decode (default_encoding )
409
-
410
400
def build_triple (self ):
411
401
default_encoding = sys .getdefaultencoding ()
412
402
config = self .get_toml ('build' )
@@ -551,46 +541,26 @@ def update_submodules(self):
551
541
return
552
542
553
543
print ('Updating submodules' )
554
- output = self .output (["git" , "submodule" , "status" ], cwd = self .rust_root )
555
- submodules = []
556
- for line in output .splitlines ():
557
- # NOTE `git submodule status` output looks like this:
558
- #
559
- # -5066b7dcab7e700844b0e2ba71b8af9dc627a59b src/liblibc
560
- # +b37ef24aa82d2be3a3cc0fe89bf82292f4ca181c src/compiler-rt (remotes/origin/..)
561
- # e058ca661692a8d01f8cf9d35939dfe3105ce968 src/jemalloc (3.6.0-533-ge058ca6)
562
- #
563
- # The first character can be '-', '+' or ' ' and denotes the
564
- # `State` of the submodule Right next to this character is the
565
- # SHA-1 of the submodule HEAD And after that comes the path to the
566
- # submodule
567
- path = line [1 :].split (' ' )[1 ]
568
- submodules .append ([path , line [0 ]])
569
-
570
- self .run (["git" , "submodule" , "sync" ], cwd = self .rust_root )
571
-
572
- for submod in submodules :
573
- path , status = submod
574
- if path .endswith ('llvm' ) and \
544
+ self .run (["git" , "submodule" , "-q" , "sync" ], cwd = self .rust_root )
545
+ # FIXME: nobody does, but this won't work well with whitespace in
546
+ # submodule path
547
+ submodules = [s .split ()[1 ] for s in subprocess .check_output (
548
+ ["git" , "config" , "--file" , os .path .join (
549
+ self .rust_root , ".gitmodules" ), "--get-regexp" , "path" ]).splitlines ()]
550
+ for module in submodules :
551
+ if module .endswith (b"llvm" ) and \
575
552
(self .get_toml ('llvm-config' ) or self .get_mk ('CFG_LLVM_ROOT' )):
576
553
continue
577
- if path .endswith (' jemalloc' ) and \
554
+ if module .endswith (b" jemalloc" ) and \
578
555
(self .get_toml ('jemalloc' ) or self .get_mk ('CFG_JEMALLOC_ROOT' )):
579
556
continue
580
- submod_path = os .path .join (self .rust_root , path )
581
-
582
- if status == ' ' :
583
- self .run (["git" , "reset" , "--hard" ], cwd = submod_path )
584
- self .run (["git" , "clean" , "-fdx" ], cwd = submod_path )
585
- elif status == '+' :
586
- self .run (["git" , "submodule" , "update" , path ], cwd = self .rust_root )
587
- self .run (["git" , "reset" , "--hard" ], cwd = submod_path )
588
- self .run (["git" , "clean" , "-fdx" ], cwd = submod_path )
589
- elif status == '-' :
590
- self .run (["git" , "submodule" , "init" , path ], cwd = self .rust_root )
591
- self .run (["git" , "submodule" , "update" , path ], cwd = self .rust_root )
592
- else :
593
- raise ValueError ('unknown submodule status: ' + status )
557
+ self .run (["git" , "submodule" , "update" ,
558
+ "--init" , module ], cwd = self .rust_root )
559
+ self .run (["git" , "submodule" , "-q" , "foreach" , "git" ,
560
+ "reset" , "-q" , "--hard" ], cwd = self .rust_root )
561
+ self .run (["git" , "submodule" , "-q" , "foreach" , "git" ,
562
+ "clean" , "-qdfx" ], cwd = self .rust_root )
563
+
594
564
595
565
def bootstrap ():
596
566
parser = argparse .ArgumentParser (description = 'Build rust' )
@@ -676,7 +646,7 @@ def bootstrap():
676
646
env ["BUILD" ] = rb .build
677
647
env ["SRC" ] = rb .rust_root
678
648
env ["BOOTSTRAP_PARENT_ID" ] = str (os .getpid ())
679
- rb .run (args , env )
649
+ rb .run (args , env = env )
680
650
681
651
def main ():
682
652
start_time = time ()
0 commit comments