-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Add --quiet flag to x.py and bootstrap to suppress output
#154616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,7 @@ def eprint(*args, **kwargs): | |
| print(*args, **kwargs) | ||
|
|
||
|
|
||
| def get(base, url, path, checksums, verbose=False): | ||
| def get(base, url, path, checksums, verbose=0): | ||
| with tempfile.NamedTemporaryFile(delete=False) as temp_file: | ||
| temp_path = temp_file.name | ||
|
|
||
|
|
@@ -66,11 +66,11 @@ def get(base, url, path, checksums, verbose=False): | |
| sha256 = checksums[url] | ||
| if os.path.exists(path): | ||
| if verify(path, sha256, False): | ||
| if verbose: | ||
| if verbose > 0: | ||
| eprint("using already-download file", path) | ||
| return | ||
| else: | ||
| if verbose: | ||
| if verbose > 0: | ||
| eprint( | ||
| "ignoring already-download file", | ||
| path, | ||
|
|
@@ -80,12 +80,12 @@ def get(base, url, path, checksums, verbose=False): | |
| download(temp_path, "{}/{}".format(base, url), True, verbose) | ||
| if not verify(temp_path, sha256, verbose): | ||
| raise RuntimeError("failed verification") | ||
| if verbose: | ||
| if verbose > 0: | ||
| eprint("moving {} to {}".format(temp_path, path)) | ||
| shutil.move(temp_path, path) | ||
| finally: | ||
| if os.path.isfile(temp_path): | ||
| if verbose: | ||
| if verbose > 0: | ||
| eprint("removing", temp_path) | ||
| os.unlink(temp_path) | ||
|
|
||
|
|
@@ -113,11 +113,11 @@ def _download(path, url, probably_big, verbose, exception): | |
| # If an error occurs: | ||
| # - If we are on win32 fallback to powershell | ||
| # - Otherwise raise the error if appropriate | ||
| if probably_big or verbose: | ||
| if probably_big or verbose > 0: | ||
| eprint("downloading {}".format(url)) | ||
|
|
||
| try: | ||
| if (probably_big or verbose) and "GITHUB_ACTIONS" not in os.environ: | ||
| if (probably_big or verbose > 0) and "GITHUB_ACTIONS" not in os.environ: | ||
| option = "--progress-bar" | ||
| else: | ||
| option = "--silent" | ||
|
|
@@ -180,7 +180,7 @@ def _download(path, url, probably_big, verbose, exception): | |
|
|
||
| def verify(path, expected, verbose): | ||
| """Check if the sha256 sum of the given path is valid""" | ||
| if verbose: | ||
| if verbose > 0: | ||
| eprint("verifying", path) | ||
| with open(path, "rb") as source: | ||
| found = hashlib.sha256(source.read()).hexdigest() | ||
|
|
@@ -194,7 +194,7 @@ def verify(path, expected, verbose): | |
| return verified | ||
|
|
||
|
|
||
| def unpack(tarball, tarball_suffix, dst, verbose=False, match=None): | ||
| def unpack(tarball, tarball_suffix, dst, verbose=0, match=None): | ||
| """Unpack the given tarball file""" | ||
| eprint("extracting", tarball) | ||
| fname = os.path.basename(tarball).replace(tarball_suffix, "") | ||
|
|
@@ -208,7 +208,7 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None): | |
| name = name[len(match) + 1 :] | ||
|
|
||
| dst_path = os.path.join(dst, name) | ||
| if verbose: | ||
| if verbose > 0: | ||
| eprint(" extracting", member) | ||
| tar.extract(member, dst) | ||
| src_path = os.path.join(dst, member) | ||
|
|
@@ -218,9 +218,9 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None): | |
| shutil.rmtree(os.path.join(dst, fname)) | ||
|
|
||
|
|
||
| def run(args, verbose=False, exception=False, is_bootstrap=False, **kwargs): | ||
| def run(args, verbose=0, exception=False, is_bootstrap=False, **kwargs): | ||
| """Run a child program in a new process""" | ||
| if verbose: | ||
| if verbose > 0: | ||
| eprint("running: " + " ".join(args)) | ||
| sys.stdout.flush() | ||
| # Ensure that the .exe is used on Windows just in case a Linux ELF has been | ||
|
|
@@ -233,7 +233,7 @@ def run(args, verbose=False, exception=False, is_bootstrap=False, **kwargs): | |
| code = ret.wait() | ||
| if code != 0: | ||
| err = "failed to run: " + " ".join(args) | ||
| if verbose or exception: | ||
| if verbose > 0 or exception: | ||
| raise RuntimeError(err) | ||
| # For most failures, we definitely do want to print this error, or the user will have no | ||
| # idea what went wrong. But when we've successfully built bootstrap and it failed, it will | ||
|
|
@@ -293,13 +293,13 @@ def default_build_triple(verbose): | |
| version = version.decode(default_encoding) | ||
| host = next(x for x in version.split("\n") if x.startswith("host: ")) | ||
| triple = host.split("host: ")[1] | ||
| if verbose: | ||
| if verbose > 0: | ||
| eprint( | ||
| "detected default triple {} from pre-installed rustc".format(triple) | ||
| ) | ||
| return triple | ||
| except Exception as e: | ||
| if verbose: | ||
| if verbose > 0: | ||
| eprint("pre-installed rustc not detected: {}".format(e)) | ||
| eprint("falling back to auto-detect") | ||
|
|
||
|
|
@@ -699,7 +699,7 @@ def download_toolchain(self): | |
| # Unpack the tarballs in parallel. | ||
| # In Python 2.7, Pool cannot be used as a context manager. | ||
| pool_size = min(len(tarballs_download_info), get_cpus()) | ||
| if self.verbose: | ||
| if self.verbose > 0: | ||
| print( | ||
| "Choosing a pool size of", | ||
| pool_size, | ||
|
|
@@ -1126,6 +1126,8 @@ def build_bootstrap_cmd(self, env): | |
| ] | ||
| # verbose cargo output is very noisy, so only enable it with -vv | ||
| args.extend("--verbose" for _ in range(self.verbose - 1)) | ||
| if self.verbose < 0: | ||
| args.append("--quiet") | ||
|
|
||
| target_features = [] | ||
| if self.get_toml("crt-static", build_section) == "true": | ||
|
|
@@ -1276,6 +1278,7 @@ def parse_args(args): | |
| "--warnings", choices=["deny", "warn", "default"], default="default" | ||
| ) | ||
| parser.add_argument("-v", "--verbose", action="count", default=0) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion [MUTEX 2/2]: Looks like Python's |
||
| parser.add_argument("-q", "--quiet", action="store_const", const=-1, dest="verbose") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussion: hm, I thought about this a bit, I was wondering why this was using I'm slightly conflicted, because now "verbose" is more like but then again, it's not really the end of the world. We may want to leave a comment here re. the intention / recycling of |
||
|
|
||
| return parser.parse_known_args(args)[0] | ||
|
|
||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: the general idea of a I ask because some of the warnings can indicate real, genuine problems. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question [MUTEX 1/2]: hm, this combination is somewhat interesting. Does cargo support
--quiet --verbose?EDIT: no, you cannot:
$ cargo check --quiet --verbose error: cannot set both --verbose and --quietCan we also:
--verbose/-vvet al. with--quietduring arg parsing?I kinda don't want to have to wait until we reach cargo to know that this is not a valid combo.