Skip to content

Commit ec49234

Browse files
comexNicholas Allegra
authored and
Nicholas Allegra
committed
Support extra-verbose builds:
- The bootstrap crate currently passes -v to Cargo if itself invoked with -vv. But Cargo supports -vv (to show build script output), so make bootstrap pass that if itself invoked with -vvv. (More specifically, pass N '-v's to Cargo if invoked with N+1 of them.) - bootstrap.py currently tries to pass on up to two '-v's to cargo when building bootstrap, but incorrectly ('-v' is marked as 'store_true', so argparse stores either False or True, ignoring multiple '-v's). Fix this, allow passing any number of '-v's, and make it consistent with bootstrap's invocation of Cargo (i.e. subtract one from the number of '-v's). - Also improve bootstrap.py's config.toml 'parsing' to support arbitrary verbosity levels, + allow command line to override it.
1 parent 178becd commit ec49234

File tree

4 files changed

+7
-14
lines changed

4 files changed

+7
-14
lines changed

src/bootstrap/bootstrap.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,8 @@ def build_bootstrap(self):
597597
self.cargo()))
598598
args = [self.cargo(), "build", "--manifest-path",
599599
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")]
600-
if self.verbose:
600+
for _ in range(1, self.verbose):
601601
args.append("--verbose")
602-
if self.verbose > 1:
603-
args.append("--verbose")
604602
if self.use_locked_deps:
605603
args.append("--locked")
606604
if self.use_vendored_sources:
@@ -675,7 +673,7 @@ def bootstrap(help_triggered):
675673
parser.add_argument('--config')
676674
parser.add_argument('--build')
677675
parser.add_argument('--clean', action='store_true')
678-
parser.add_argument('-v', '--verbose', action='store_true')
676+
parser.add_argument('-v', '--verbose', action='count', default=0)
679677

680678
args = [a for a in sys.argv if a != '-h' and a != '--help']
681679
args, _ = parser.parse_known_args(args)
@@ -691,10 +689,9 @@ def bootstrap(help_triggered):
691689
except (OSError, IOError):
692690
pass
693691

694-
if '\nverbose = 2' in build.config_toml:
695-
build.verbose = 2
696-
elif '\nverbose = 1' in build.config_toml:
697-
build.verbose = 1
692+
match = re.search(r'\nverbose = (\d+)', build.config_toml)
693+
if match is not None:
694+
build.verbose = max(build.verbose, int(match.group(1)))
698695

699696
build.use_vendored_sources = '\nvendor = true' in build.config_toml
700697

src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ impl<'a> Builder<'a> {
763763
cargo.env("WINAPI_NO_BUNDLED_LIBRARIES", "1");
764764
}
765765

766-
if self.is_very_verbose() {
766+
for _ in 1..self.verbosity {
767767
cargo.arg("-v");
768768
}
769769

src/bootstrap/flags.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use cache::{Interned, INTERNER};
2929

3030
/// Deserialized version of all flags for this compile.
3131
pub struct Flags {
32-
pub verbose: usize, // verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
32+
pub verbose: usize, // number of -v args; each extra -v after the first is passed to Cargo
3333
pub on_fail: Option<String>,
3434
pub stage: Option<u32>,
3535
pub keep_stage: Option<u32>,

src/bootstrap/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,6 @@ impl Build {
605605
self.verbosity > 0
606606
}
607607

608-
pub fn is_very_verbose(&self) -> bool {
609-
self.verbosity > 1
610-
}
611-
612608
/// Prints a message if this build is configured in verbose mode.
613609
fn verbose(&self, msg: &str) {
614610
if self.is_verbose() {

0 commit comments

Comments
 (0)