Skip to content

Commit f7424ce

Browse files
authored
Rollup merge of rust-lang#41011 - CleanCut:bootstrap-help, r=alexcrichton
Overhaul Bootstrap (x.py) Command-Line-Parsing & Help Output While working on rust-lang#40417, I got frustrated with the behavior of x.py and the bootstrap binary it wraps, so I decided to do something about it. This PR should improve documentation, make the command-line-parsing more flexible, and clean up some of the internals. No command that worked before should stop working. At least that's the theory. :-) This should resolve at least rust-lang#40920 and rust-lang#38373. Changes: - No more manual args manipulation -- getopts used everywhere except the one place it's not possible. As a result, options can be in any position, now, even before the subcommand. - The additional options for test, bench, and dist now appear in the help output. - No more single-letter variable bindings used internally for large scopes. - Don't output the time measurement when just invoking `x.py` or explicitly passing `-h` or `--help` - Logic is now much more linear. We build strings up, and then print them. - Refer to subcommands as subcommands everywhere (some places we were saying "command") - Other minor stuff. @alexcrichton This is my first PR. Do I need to do something specific to request reviewers or anything?
2 parents f88b44f + ea2bfae commit f7424ce

File tree

3 files changed

+165
-139
lines changed

3 files changed

+165
-139
lines changed

src/bootstrap/bootstrap.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,16 +591,19 @@ def bootstrap():
591591

592592
def main():
593593
start_time = time()
594+
help_triggered = ('-h' in sys.argv) or ('--help' in sys.argv) or (len(sys.argv) == 1)
594595
try:
595596
bootstrap()
596-
print("Build completed successfully in %s" % format_build_time(time() - start_time))
597+
if not help_triggered:
598+
print("Build completed successfully in %s" % format_build_time(time() - start_time))
597599
except (SystemExit, KeyboardInterrupt) as e:
598600
if hasattr(e, 'code') and isinstance(e.code, int):
599601
exit_code = e.code
600602
else:
601603
exit_code = 1
602604
print(e)
603-
print("Build completed unsuccessfully in %s" % format_build_time(time() - start_time))
605+
if not help_triggered:
606+
print("Build completed unsuccessfully in %s" % format_build_time(time() - start_time))
604607
sys.exit(exit_code)
605608

606609
if __name__ == '__main__':

0 commit comments

Comments
 (0)