# 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
# -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;
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;
}
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);
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.*/);
return 1 if ($d =~ /.*projects\/sample.*/);
return 0 if ($d =~ /.*projects\/llvm-.*/);
return 0 if ($d =~ /.*win32.*/);
+ return 0 if ($d =~ /.*\/.libs\/.*/);
return 1;
}
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++;
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";
}
-