Skip to content

Commit cd86a9b

Browse files
committed
bootstrap: Use common run() function to call cargo
This brings verbosity even to invocation of cargo itself
1 parent 604f716 commit cd86a9b

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

src/bootstrap/bootstrap.py

+12-18
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ def unpack(tarball, dst, verbose=False, match=None):
127127
shutil.move(tp, fp)
128128
shutil.rmtree(os.path.join(dst, fname))
129129

130-
def run(args, verbose=False, exception=False, cwd=None):
130+
def run(args, verbose=False, exception=False, cwd=None, env=None):
131131
if verbose:
132132
print("running: " + ' '.join(args))
133133
sys.stdout.flush()
134134
# Use Popen here instead of call() as it apparently allows powershell on
135135
# Windows to not lock up waiting for input presumably.
136-
ret = subprocess.Popen(args, cwd=cwd)
136+
ret = subprocess.Popen(args, cwd=cwd, env=env)
137137
code = ret.wait()
138138
if code != 0:
139139
err = "failed to run: " + ' '.join(args)
@@ -393,13 +393,7 @@ def build_bootstrap(self):
393393
args.append("--locked")
394394
if self.use_vendored_sources:
395395
args.append("--frozen")
396-
self.run(args, env)
397-
398-
def run(self, args, env=None, cwd=None):
399-
proc = subprocess.Popen(args, env=env, cwd=cwd)
400-
ret = proc.wait()
401-
if ret != 0:
402-
sys.exit(ret)
396+
run(args, env=env, verbose=self.verbose)
403397

404398
def output(self, args, env=None, cwd=None):
405399
default_encoding = sys.getdefaultencoding()
@@ -571,7 +565,7 @@ def update_submodules(self):
571565
path = line[1:].split(' ')[1]
572566
submodules.append([path, line[0]])
573567

574-
self.run(["git", "submodule", "sync"], cwd=self.rust_root)
568+
run(["git", "submodule", "sync"], cwd=self.rust_root)
575569

576570
for submod in submodules:
577571
path, status = submod
@@ -584,15 +578,15 @@ def update_submodules(self):
584578
submod_path = os.path.join(self.rust_root, path)
585579

586580
if status == ' ':
587-
self.run(["git", "reset", "--hard"], cwd=submod_path)
588-
self.run(["git", "clean", "-fdx"], cwd=submod_path)
581+
run(["git", "reset", "--hard"], cwd=submod_path)
582+
run(["git", "clean", "-fdx"], cwd=submod_path)
589583
elif status == '+':
590-
self.run(["git", "submodule", "update", path], cwd=self.rust_root)
591-
self.run(["git", "reset", "--hard"], cwd=submod_path)
592-
self.run(["git", "clean", "-fdx"], cwd=submod_path)
584+
run(["git", "submodule", "update", path], cwd=self.rust_root)
585+
run(["git", "reset", "--hard"], cwd=submod_path)
586+
run(["git", "clean", "-fdx"], cwd=submod_path)
593587
elif status == '-':
594-
self.run(["git", "submodule", "init", path], cwd=self.rust_root)
595-
self.run(["git", "submodule", "update", path], cwd=self.rust_root)
588+
run(["git", "submodule", "init", path], cwd=self.rust_root)
589+
run(["git", "submodule", "update", path], cwd=self.rust_root)
596590
else:
597591
raise ValueError('unknown submodule status: ' + status)
598592

@@ -685,7 +679,7 @@ def bootstrap():
685679
env["BUILD"] = rb.build
686680
env["SRC"] = rb.rust_root
687681
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
688-
rb.run(args, env)
682+
run(args, env=env, verbose=rb.verbose)
689683

690684
def main():
691685
start_time = time()

0 commit comments

Comments
 (0)