mirror of
git://git.openwrt.org/openwrt/openwrt.git
synced 2024-12-23 15:12:50 +00:00
340df72e07
Having the build time written on stderr make it appear with V=w although it is not an error or warning. Just write the time on stdout to have it part of the build log like all the rest, but not clutter the output when only warnings and errors should be shown. Signed-off-by: Alban Bedel <albeu@free.fr>
66 lines
1.1 KiB
Perl
Executable File
66 lines
1.1 KiB
Perl
Executable File
#!/usr/bin/env perl
|
|
|
|
use strict;
|
|
use warnings;
|
|
use Config;
|
|
|
|
if (@ARGV < 2) {
|
|
die "Usage: $0 <prefix> <command...>\n";
|
|
}
|
|
|
|
sub gettime {
|
|
my ($sec, $usec);
|
|
|
|
eval {
|
|
require Time::HiRes;
|
|
($sec, $usec) = Time::HiRes::gettimeofday();
|
|
};
|
|
|
|
unless (defined($sec) && defined($usec)) {
|
|
my $tv_t = ($Config{'longsize'} == 8) ? 'qq' : 'll';
|
|
my $tv = pack $tv_t, 0, 0;
|
|
|
|
eval {
|
|
require 'syscall.ph';
|
|
syscall(SYS_gettimeofday(), $tv, 0);
|
|
};
|
|
|
|
($sec, $usec) = unpack $tv_t, $tv;
|
|
}
|
|
|
|
return ($sec, $usec);
|
|
}
|
|
|
|
my ($prefix, @cmd) = @ARGV;
|
|
my ($sec, $usec) = gettime();
|
|
my $pid = fork();
|
|
|
|
if (!defined($pid)) {
|
|
die "$0: Failure to fork(): $!\n";
|
|
}
|
|
elsif ($pid == 0) {
|
|
exec(@cmd);
|
|
die "$0: Failure to exec(): $!\n";
|
|
}
|
|
else {
|
|
$SIG{'INT'} = 'IGNORE';
|
|
$SIG{'QUIT'} = 'IGNORE';
|
|
|
|
if (waitpid($pid, 0) == -1) {
|
|
die "$0: Failure to waitpid(): $!\n";
|
|
}
|
|
|
|
my $exitcode = $? >> 8;
|
|
my ($sec2, $usec2) = gettime();
|
|
my (undef, undef, $cuser, $csystem) = times();
|
|
|
|
printf STDOUT "%s#%.2f#%.2f#%.2f\n",
|
|
$prefix, $cuser, $csystem,
|
|
($sec2 - $sec) + ($usec2 - $usec) / 1000000;
|
|
|
|
$SIG{'INT'} = 'DEFAULT';
|
|
$SIG{'QUIT'} = 'DEFAULT';
|
|
|
|
exit $exitcode;
|
|
}
|