From bb6f6eb66712f558f8637e4dee0eddb44e13bce8 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Fri, 11 Aug 2006 18:36:55 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29620 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/userloc.pl | 96 +++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 54 deletions(-) diff --git a/utils/userloc.pl b/utils/userloc.pl index 4a9fdd179fc..ab636e8a697 100755 --- a/utils/userloc.pl +++ b/utils/userloc.pl @@ -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... ... +# Syntax: userloc.pl [-recurse|-tag=tag|-html... ... # # 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] ..." +die "Usage userloc.pl [-recurse|-tag=tag|-html] ..." 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] ..." +die "Usage userloc.pl [-recurse|-tag=tag|-html] ..." 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 = ) ) { - 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 " Directory\n"; - foreach $user (sort keys %Stats) - { - print "",$user,"\n"; + if ($html) { + print " Directory\n"; + foreach $user (sort keys %Stats) + { + print "",$user,"\n"; + } + print "\n"; } - print "\n"; } $RowCount++; @@ -217,41 +207,39 @@ print "
LLVM LOC Based On CVS Annotation
\n"; print "

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.

\n"; -print "

The following directories were skipped:

\n"; -print "
    \n"; } +my @ignored_dirs; + for $Dir (@ALLDIRS) { - if ( -d "$Dir" && -d "$Dir/CVS" && ValidateDirectory($Dir) ) + if ( ValidateDirectory($Dir) ) { ScanDir($Dir); } elsif ($html) { - print "
  1. $Dir
  2. \n"; + push @ignored_dirs, $Dir; } } if ($html) { - print "
\n"; print "\n"; } -if ($details) -{ - foreach $dir (sort keys %StatsDetails) - { - printStats($dir,$StatsDetails{$dir}); - } -} - printStats("Total",\%Stats); - -if ($html) +if ($html) { - print "
\n"; + print ""; + if (scalar @ignored_dirs > 0) { + print "

The following directories were skipped:

\n"; + print "
    \n"; + foreach $index (0 .. $#ignored_dirs) { + print "
  1. ", $ignored_dirs[$index], "
  2. \n"; + } + print "
\n"; + } + print "\n"; } - -- 2.34.1