Drop the -details option, it was broken. If you want to know about a

particular directory, just pass that directory to the script. Also, clean
up the HTML output, put list of skipped dirs at the end, and make a few
other minor improvements.

llvm-svn: 29620
This commit is contained in:
Reid Spencer 2006-08-11 18:36:55 +00:00
parent 962752dcea
commit 092ae90eab
1 changed files with 42 additions and 54 deletions

View File

@ -8,11 +8,9 @@
# then the cwd is used. The directory must be an LLVM tree checked out
# from cvs.
#
# Syntax: userloc.pl [-details|-recurse|-tag=tag|-html... <directory>...
# Syntax: userloc.pl [-recurse|-tag=tag|-html... <directory>...
#
# Options:
# -details
# Print detailed per-directory information.
# -recurse
# Recurse through sub directories. Without this, only the
# specified directory is examined
@ -21,40 +19,31 @@
# -html
# Generate HTML output instead of text output
die "Usage userloc.pl [-details|-recurse|-tag=tag|-html] <directories>..."
die "Usage userloc.pl [-recurse|-tag=tag|-html] <directories>..."
if ($#ARGV < 0);
my $tag = "";
my $details = 0;
my $recurse = 0;
my $html = 0;
my $debug = 0;
while ( substr($ARGV[0],0,1) eq '-' )
{
if ($ARGV[0] eq "-details")
{
$details = 1 ;
}
elsif ($ARGV[0] eq "-recurse")
{
if ($ARGV[0] eq "-recurse") {
$recurse = 1;
}
elsif ($ARGV[0] =~ /-tag=.*/)
{
} elsif ($ARGV[0] =~ /-tag=.*/) {
$tag = $ARGV[0];
$tag =~ s#-tag=(.*)#$1#;
}
elsif ($ARGV[0] eq "-html")
{
} elsif ($ARGV[0] eq "-html") {
$html = 1;
}
else
{
} elsif ($ARGV[0] eq "-debug") {
$debug = 1;
} else {
die "Invalid option: $ARGV[0]";
}
shift;
}
die "Usage userloc.pl [-details|-recurse|-tag=tag|-html] <directories>..."
die "Usage userloc.pl [-recurse|-tag=tag|-html] <directories>..."
if ($#ARGV < 0);
my %Stats;
@ -65,14 +54,15 @@ sub ValidateFile
my $f = $_[0];
my $d = $_[1];
return 0 if ( "$f" eq "configure");
if ( $d =~ ".*autoconf.*")
{
return 1 if ($f eq "configure.ac");
return 1 if ($f eq "AutoRegen.sh");
return 0;
}
return 0 if ( "$f" eq "configure");
return 0 if ( "$f" eq 'PPCPerfectShuffle.h' );
return 0 if ( $f =~ /.*\.cvs/);
return 1;
}
@ -95,13 +85,13 @@ sub GetCVSFiles
return $files;
}
my $annotate = "cvs annotate -lf ";
my $annotate = "cvs -z6 annotate -lf ";
if (length($tag) > 0)
{
$annotate = $annotate . " -r " . $tag;
$annotate = $annotate . " -r" . $tag;
}
sub ScanDir
sub ScanDir
{
my $Dir = $_[0];
my $files = GetCVSFiles($Dir);
@ -109,26 +99,23 @@ sub ScanDir
open (DATA,"$annotate $files 2>/dev/null |")
|| die "Can't read cvs annotation data";
my %st;
while ( defined($line = <DATA>) )
{
if ($line =~ /^[0-9.]*[ \t]*\(/)
if ($line =~ /^[0-9.]*[ \t]*\([^)]*\):/)
{
$line =~ s#^[0-9.]*[ \t]*\(([a-zA-Z0-9_.-]*).*#$1#;
chomp($line);
$st{$line}++;
$line =~ s#^[0-9.]*[ \t]*\(([a-zA-Z0-9_.-]*) [^)]*\):.*#$1#;
$Stats{$line}++;
}
}
$StatsDetails{$Dir} = { %st };
close DATA;
}
sub ValidateDirectory
{
my $d = $_[0];
return 0 if (! -d "$d" || ! -d "$d/CVS");
return 0 if ($d =~ /.*CVS.*/);
return 0 if ($d =~ /.*Debug.*/);
return 0 if ($d =~ /.*Release.*/);
@ -144,6 +131,7 @@ sub ValidateDirectory
return 1 if ($d =~ /.*projects\/sample.*/);
return 0 if ($d =~ /.*projects\/llvm-.*/);
return 0 if ($d =~ /.*win32.*/);
return 0 if ($d =~ /.*\/.libs\/.*/);
return 1;
}
@ -157,12 +145,14 @@ sub printStats
if ($RowCount % 10 == 0)
{
print " <tr><th style=\"text-align:left\">Directory</th>\n";
foreach $user (sort keys %Stats)
{
print "<th style=\"text-align:right\">",$user,"</th>\n";
if ($html) {
print " <tr><th style=\"text-align:left\">Directory</th>\n";
foreach $user (sort keys %Stats)
{
print "<th style=\"text-align:right\">",$user,"</th>\n";
}
print "</tr>\n";
}
print "</tr>\n";
}
$RowCount++;
@ -217,41 +207,39 @@ print "<body><div class=\"doc_title\">LLVM LOC Based On CVS Annotation</div>\n";
print "<p>This document shows the total lines of code per user in each\n";
print "LLVM directory. Lines of code are attributed by the user that last\n";
print "committed the line. This does not necessarily reflect authorship.</p>\n";
print "<p>The following directories were skipped:</p>\n";
print "<ol>\n";
}
my @ignored_dirs;
for $Dir (@ALLDIRS)
{
if ( -d "$Dir" && -d "$Dir/CVS" && ValidateDirectory($Dir) )
if ( ValidateDirectory($Dir) )
{
ScanDir($Dir);
}
elsif ($html)
{
print "<li>$Dir</li>\n";
push @ignored_dirs, $Dir;
}
}
if ($html)
{
print "</ol>\n";
print "<table>\n";
}
if ($details)
{
foreach $dir (sort keys %StatsDetails)
{
printStats($dir,$StatsDetails{$dir});
}
}
printStats("Total",\%Stats);
if ($html)
if ($html)
{
print "</table></body></html>\n";
print "</table>";
if (scalar @ignored_dirs > 0) {
print "<p>The following directories were skipped:</p>\n";
print "<ol>\n";
foreach $index (0 .. $#ignored_dirs) {
print " <li>", $ignored_dirs[$index], "</li>\n";
}
print "</ol>\n";
}
print "</body></html>\n";
}