diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-04-02 18:03:36 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-04-02 18:03:36 +0000 |
commit | 5744dc294e2d658a904e6bb258c0875fbac0d4a1 (patch) | |
tree | 09d29afa3e6d4e4da4ee7772156e31e404f1349f | |
parent | 86b4381356dc9ab668cc831ff2f252674d28a91a (diff) |
Initial support for generating index.html file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49104 91177308-0d34-0410-b5e6-96231b3b80d8
-rwxr-xr-x | utils/scan-build | 71 |
1 files changed, 68 insertions, 3 deletions
diff --git a/utils/scan-build b/utils/scan-build index 357cfccb69..1f8aefbd88 100755 --- a/utils/scan-build +++ b/utils/scan-build @@ -115,6 +115,34 @@ sub SetHtmlEnv { } ##----------------------------------------------------------------------------## +# 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 (<IN>) { + + if (/<!-- BUGDESC (.*) -->$/) { + $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 <<ENDTEXT; +<html> +<head> +</head>\n<body> +<table class="reports"> +ENDTEXT + for my $row ( sort { $a->[1] cmp $b->[1] } @Index ) { + + print OUT "<tr>\n"; + + my $ReportFile = $row->[0]; + print OUT " <td class=\"DESC\">$row->[1]</td>\n"; + + for my $j ( 2 .. $#{$row} ) { + print OUT "<td>$row->[$j]</td>\n" + } + +# print OUT "<td><input type=\"button\" value=\"View\"></td>\n"; + print OUT "<td><a href=\"$ReportFile#EndPath\">View</a></td>\n"; + print OUT "</tr>\n"; + } + + print OUT "</table>\n</body></html>\n"; + close(OUT); } ##----------------------------------------------------------------------------## @@ -173,7 +238,7 @@ sub RunBuildCommand { sub DisplayHelp { -print <<ENDTEXT +print <<ENDTEXT; USAGE: $Prog [options] <build command> [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. |