-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathjavac-progress
executable file
·82 lines (72 loc) · 1.74 KB
/
javac-progress
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env perl
# Run javac, but process its STDERR to give progress indications.
# Example usage: To use with Daikon, put
# JAVAC = javac-progress --javac="javac-xlint -p '\./jtb/' javac"
# JAVAC_XLINT =
# in java/Makefile.user
use 5.006;
use strict;
use warnings;
$| = 1;
my $javac = "javac";
my $chars = 0;
my @remain;
for my $arg (@ARGV) {
if ($arg eq "--chars") {
$chars = 1;
} elsif ($arg =~ /^--javac=(.*)$/s) {
$javac = $1;
} else {
push @remain, $arg;
}
}
@ARGV = @remain;
my $width = ($ENV{COLUMNS} || 80);
sub abbrev {
my($line) = @_;
if ($line =~ /total/) {
return $line;
} elsif ($line =~ /parsing started/) {
return "p";
} elsif ($line =~ /parsing completed/) {
return "\bP";
} elsif ($line =~ /loading/) {
if ($line =~ /rt\.jar/) {
return "l";
} else {
return "L";
}
} elsif ($line =~ /wrote/) {
return "w";
} elsif ($line =~ /checking/) {
return "c";
} elsif ($line =~ /search path/) {
return "S";
} else {
return $line;
}
}
# XXX This quoting isn't quite right.
# Better to fork and avoid the shell.
my $javac_args = join(" ", map("'$_'", @ARGV));
open(JAVAC, "$javac -verbose $javac_args 2>&1 |") or die "$!\n";
while (<JAVAC>) {
if (/^\[/) {
s/total (\d+)(\d\d\d)ms/total $1.$2sec/;
if ($chars) {
print abbrev($_);
} else {
chomp;
my $len = length($_);
if ($len > $width) {
$_ = substr($_, 0, $width);
} else {
$_ .= " " x ($width - $len);
}
print "$_\r";
}
} else {
print;
}
}
close JAVAC;