diff --git a/modules/ksb/Application.pm b/modules/ksb/Application.pm index dc4f05b..5a73b19 100644 --- a/modules/ksb/Application.pm +++ b/modules/ksb/Application.pm @@ -1457,6 +1457,8 @@ EOF my $statusViewer = $ctx->statusViewer(); my $i = 1; + $statusViewer->numberModulesTotal(scalar @modules); + while (my $module = shift @modules) { my $moduleName = $module->name(); @@ -1470,18 +1472,15 @@ EOF $moduleSet = " from g[$moduleSet]" if $moduleSet; note ("Building g[$modOutput]$moduleSet ($i/$num_modules)"); - my $start_time; + my $start_time = time; my $failedPhase = _buildSingleModule($ipc, $ctx, $module, \$start_time); - my $numSeconds = time - $start_time; - my $elapsed = prettify_seconds($numSeconds); + my $elapsed = prettify_seconds(time - $start_time); if ($failedPhase) { # FAILURE $ctx->markModulePhaseFailed($failedPhase, $module); print STATUS_FILE "$module: Failed on $failedPhase after $elapsed.\n"; - info ("\tOverall time for r[$module] was g[$elapsed].") - if $numSeconds >= 10; if ($result == 0) { # No failures yet, mark this as resume point @@ -1495,14 +1494,16 @@ EOF note ("\n$module didn't build, stopping here."); return 1; # Error } + + $statusViewer->numberModulesFailed(1 + $statusViewer->numberModulesFailed); } else { # Success print STATUS_FILE "$module: Succeeded after $elapsed.\n"; - info ("\tOverall time for g[$module] was g[$elapsed].") - if $numSeconds >= 10; push @build_done, $moduleName; # Make it show up as a success + + $statusViewer->numberModulesSucceeded(1 + $statusViewer->numberModulesSucceeded); } $i++; diff --git a/modules/ksb/BuildSystem.pm b/modules/ksb/BuildSystem.pm index fefc35d..7532d3b 100644 --- a/modules/ksb/BuildSystem.pm +++ b/modules/ksb/BuildSystem.pm @@ -199,7 +199,7 @@ sub installInternal return $self->safe_make ({ target => 'install', - message => "Installing g[$module]", + message => 'Installing..', 'prefix-options' => [@cmdPrefix], subdirs => [ split(' ', $module->getOption("checkout-only")) ], }) == 0; @@ -437,6 +437,8 @@ sub _runBuildCommand return log_command($module, $filename, $argRef); } + my $time = time; + my $statusViewer = $ctx->statusViewer(); $statusViewer->setStatus("\t$message"); $statusViewer->update(); @@ -445,8 +447,6 @@ sub _runBuildCommand my $log_command_callback = sub { my $input = shift; if (not defined $input) { - # End of input, cleanup. - $statusViewer->releaseTTY("\t$message done\n"); return; } @@ -465,9 +465,16 @@ sub _runBuildCommand } }; - return log_command($module, $filename, $argRef, { + my $result = log_command($module, $filename, $argRef, { callback => $log_command_callback }); + + # Cleanup TTY output. + $time = prettify_seconds(time - $time); + my $status = $result == 0 ? "g[b[succeeded]" : "r[b[failed]"; + $statusViewer->releaseTTY("\t$message $status (after $time)\n"); + + return $result; } 1; diff --git a/modules/ksb/BuildSystem/KDE4.pm b/modules/ksb/BuildSystem/KDE4.pm index a44ab24..c139460 100644 --- a/modules/ksb/BuildSystem/KDE4.pm +++ b/modules/ksb/BuildSystem/KDE4.pm @@ -111,7 +111,7 @@ sub installInternal return $self->safe_make ({ target => $target, logfile => 'install', - message => "Installing g[$module]", + message => 'Installing..', 'prefix-options' => [@cmdPrefix], subdirs => [ split(' ', $module->getOption("checkout-only")) ], }) == 0; diff --git a/modules/ksb/Module.pm b/modules/ksb/Module.pm index bee12b6..8848cab 100644 --- a/modules/ksb/Module.pm +++ b/modules/ksb/Module.pm @@ -408,7 +408,6 @@ sub build my $moduleName = $self->name(); my %pathinfo = $self->getInstallPathComponents('build'); my $builddir = $pathinfo{'fullpath'}; - my $start_time = time; my $buildSystem = $self->buildSystem(); if ($buildSystem->name() eq 'generic' && !pretending()) { @@ -426,35 +425,23 @@ sub build if (!$buildSystem->buildInternal()) { - # Build failed + return 0; + } - my $elapsed = prettify_seconds (time - $start_time); + # TODO: This should be a simple phase to run. + if ($self->getOption('run-tests')) + { + $self->buildSystem()->runTestsuite(); + } - # Well we tried, but it isn't going to happen. - note ("\n\tUnable to build y[$self]!"); - info ("\tTook g[$elapsed]."); - return 0; + # TODO: Likewise this should be a phase to run. + if ($self->getOption('install-after-build')) + { + return 0 if !$self->install(); } else { - my $elapsed = prettify_seconds (time - $start_time); - info ("\tBuild succeeded after g[$elapsed]."); - - # TODO: This should be a simple phase to run. - if ($self->getOption('run-tests')) - { - $self->buildSystem()->runTestsuite(); - } - - # TODO: Likewise this should be a phase to run. - if ($self->getOption('install-after-build')) - { - return 0 if !$self->install(); - } - else - { - info ("\tSkipping install for y[$self]"); - } + info ("\tSkipping install for y[$self]"); } return 1; diff --git a/modules/ksb/StatusView.pm b/modules/ksb/StatusView.pm index 6f16cb9..b31b9c4 100644 --- a/modules/ksb/StatusView.pm +++ b/modules/ksb/StatusView.pm @@ -1,4 +1,4 @@ -package ksb::StatusView 0.10; +package ksb::StatusView 0.20; # Helper used to handle a generic 'progress update' status for the module # build, update, install, etc. processes. @@ -21,6 +21,11 @@ sub new cur_progress => -1, progress_total => -1, status => '', + + # Records number of modules built stats + mod_total => -1, + mod_failed => 0, + mod_success => 0, }; # Must bless a hash ref since subclasses expect it. @@ -31,7 +36,7 @@ sub new sub setStatus { my ($self, $newStatus) = @_; - $self->{status} = $newStatus; + $self->{status} = colorize($newStatus); } # Sets the amount of progress made vs. the total progress possible. @@ -52,24 +57,66 @@ sub setProgressTotal $self->{progress_total} = $newProgressTotal; } +# Gets (or sets, if arg provided) number of modules to be built. +sub numberModulesTotal +{ + my ($self, $newTotal) = @_; + $self->{mod_total} = $newTotal if $newTotal; + return $self->{mod_total}; +} + +# Gets (or sets, if arg provided) number of modules built successfully. +sub numberModulesSucceeded +{ + my ($self, $newTotal) = @_; + $self->{mod_success} = $newTotal if $newTotal; + return $self->{mod_success}; +} + +# Gets (or sets, if arg provided) number of modules not built successfully. +sub numberModulesFailed +{ + my ($self, $newTotal) = @_; + $self->{mod_failed} = $newTotal if $newTotal; + return $self->{mod_failed}; +} + # Sends out the I/O needed to ensure the latest status is displayed. # E.g. for TTY it clears the line and redisplays the current stats. sub update { my $self = shift; - my $total = $self->{progress_total}; + my $progress_total = $self->{progress_total}; my $msg; - my $spinner = '-\\|/'; - if ($total > 0) { - $msg = sprintf ("%s %0.1f%%", - $self->{status}, - $self->{cur_progress} * 100 / $total, - ); + my ($mod_total, $mod_success, $mod_failed) = + @{$self}{qw(mod_total mod_success mod_failed)}; + + my $fmt_spec = ($mod_total >= 100) ? "%03d" : "%02d"; + my $status_line = $self->{status}; + + if ($mod_total > 1) { + # Build up message in reverse order + $msg = "$mod_total modules"; + $msg = colorize("r[b[$mod_failed] failed, ") . $msg if $mod_failed; + $msg = colorize("g[b[$mod_success] built, ") . $msg if $mod_success; + + $status_line = $self->{status} . " ($msg)"; + } + + if ($progress_total > 0) { + $msg = sprintf ("%0.1f%%", + $self->{cur_progress} * 100 / $progress_total, + ) . $status_line; + } + elsif ($self->{cur_progress} < 0) { + $msg = $status_line; } else { - $msg = $self->{status} . ' ' . - substr($spinner, $self->{cur_progress} % length($spinner), 1); + my $spinner = '-\\|/'; + $msg = + substr($spinner, $self->{cur_progress} % length($spinner), 1) . + $status_line; } _clearLineAndUpdate($msg); @@ -82,15 +129,13 @@ sub releaseTTY my $self = shift; my $msg = shift // ''; - _clearLineAndUpdate($msg); + _clearLineAndUpdate(colorize($msg)); } sub _clearLineAndUpdate { my $msg = shift; - $msg = colorize($msg); - # Give escape sequence to return to column 1 and clear the entire line # Then print message and return to column 1 again in case somewhere else # uses the tty.