Skip to content

Commit

Permalink
Rollup merge of rust-lang#41011 - CleanCut:bootstrap-help, r=alexcric…
Browse files Browse the repository at this point in the history
…hton

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?
  • Loading branch information
frewsxcv authored Apr 6, 2017
2 parents f88b44f + ea2bfae commit f7424ce
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 139 deletions.
7 changes: 5 additions & 2 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,16 +591,19 @@ def bootstrap():

def main():
start_time = time()
help_triggered = ('-h' in sys.argv) or ('--help' in sys.argv) or (len(sys.argv) == 1)
try:
bootstrap()
print("Build completed successfully in %s" % format_build_time(time() - start_time))
if not help_triggered:
print("Build completed successfully in %s" % format_build_time(time() - start_time))
except (SystemExit, KeyboardInterrupt) as e:
if hasattr(e, 'code') and isinstance(e.code, int):
exit_code = e.code
else:
exit_code = 1
print(e)
print("Build completed unsuccessfully in %s" % format_build_time(time() - start_time))
if not help_triggered:
print("Build completed unsuccessfully in %s" % format_build_time(time() - start_time))
sys.exit(exit_code)

if __name__ == '__main__':
Expand Down
Loading

0 comments on commit f7424ce

Please sign in to comment.