From: Ted Kremenek Date: Wed, 2 Apr 2008 18:03:36 +0000 (+0000) Subject: Initial support for generating index.html file. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5744dc294e2d658a904e6bb258c0875fbac0d4a1;p=clang Initial support for generating index.html file. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49104 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/scan-build b/utils/scan-build index 357cfccb69..1f8aefbd88 100755 --- a/utils/scan-build +++ b/utils/scan-build @@ -114,6 +114,34 @@ sub SetHtmlEnv { $ENV{'CCC_ANALYZER_HTML'} = $Dir; } +##----------------------------------------------------------------------------## +# ScanFile - Scan a report file for various identifying attributes. +##----------------------------------------------------------------------------## + +sub ScanFile { + + my $Index = shift; + my $Dir = shift; + my $FName = shift; + + open(IN, "$Dir/$FName") or die "$Prog: Cannot open '$Dir/$FName'\n"; + + my $BugDesc = ""; + + while () { + + if (/$/) { + $BugDesc = $1; + last; + } + + } + + close(IN); + + push @$Index,[ $FName, $BugDesc ]; +} + ##----------------------------------------------------------------------------## # Postprocess - Postprocess the results of an analysis scan. ##----------------------------------------------------------------------------## @@ -137,8 +165,45 @@ sub Postprocess { `rm -fR $Dir`; return; } + + # Scan each report file and build an index. + + my @Index; + + foreach my $file (@files) { ScanFile(\@Index, $Dir, $file); } + + # Generate an index.html file. + + my $FName = "$Dir/index.html"; + + open(OUT, ">$FName") or die "$Prog: Cannot create file '$FName'\n"; + +print OUT < + +\n + +ENDTEXT + for my $row ( sort { $a->[1] cmp $b->[1] } @Index ) { + + print OUT "\n"; + + my $ReportFile = $row->[0]; + print OUT " \n"; + + for my $j ( 2 .. $#{$row} ) { + print OUT "\n" + } + +# print OUT "\n"; + print OUT "\n"; + print OUT "\n"; + } + + print OUT "
$row->[1]$row->[$j]View
\n\n"; + close(OUT); } ##----------------------------------------------------------------------------## @@ -173,7 +238,7 @@ sub RunBuildCommand { sub DisplayHelp { -print < [build options] OPTIONS: @@ -198,9 +263,9 @@ BUILD OPTIONS You can specify any build option acceptable to the build command. - For example: +EXAMPLE - $Prog -o /tmp/myhtmldir make -j4 + $Prog -o /tmp/myhtmldir make -j4 The above example causes analysis reports to be deposited into a subdirectory of "/tmp/myhtmldir" and to run "make" with the "-j4" option.