blob: 99262e4e1ea8bcce94e776fe39870e0b0fd88e6e [file] [log] [blame]
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001#!/usr/bin/env perl
2#
3# The LLVM Compiler Infrastructure
4#
5# This file is distributed under the University of Illinois Open Source
6# License. See LICENSE.TXT for details.
7#
8##===----------------------------------------------------------------------===##
9#
10# A script designed to wrap a build so that all calls to gcc are intercepted
11# and piped to the static analyzer.
12#
13##===----------------------------------------------------------------------===##
14
15use strict;
16use warnings;
17use File::Temp qw/ :mktemp /;
Ted Kremenek22d6a632008-04-02 20:43:36 +000018use FindBin qw($RealBin);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +000019
20my $Verbose = 0; # Verbose output from this script.
21my $Prog = "scan-build";
22
23##----------------------------------------------------------------------------##
24# GetHTMLRunDir - Construct an HTML directory name for the current run.
25##----------------------------------------------------------------------------##
26
Sam Bishopa0e22662008-04-02 03:35:43 +000027sub GetHTMLRunDir {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +000028
29 die "Not enough arguments." if (@_ == 0);
30
31 my $Dir = shift @_;
32
33 # Get current date and time.
34
35 my @CurrentTime = localtime();
36
37 my $year = $CurrentTime[5] + 1900;
38 my $day = $CurrentTime[3];
39 my $month = $CurrentTime[4] + 1;
40
41 my $DateString = "$year-$month-$day";
42
43 # Determine the run number.
44
45 my $RunNumber;
46
47 if (-d $Dir) {
48
49 if (! -r $Dir) {
Sam Bishopa0e22662008-04-02 03:35:43 +000050 die "error: '$Dir' exists but is not readable.\n";
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +000051 }
52
53 # Iterate over all files in the specified directory.
54
55 my $max = 0;
56
57 opendir(DIR, $Dir);
58 my @FILES= readdir(DIR);
59 closedir(DIR);
60
61 foreach my $f (@FILES) {
62
63 my @x = split/-/, $f;
64
65 next if (scalar(@x) != 4);
66 next if ($x[0] != $year);
67 next if ($x[1] != $month);
68 next if ($x[2] != $day);
69
70 if ($x[3] > $max) {
71 $max = $x[3];
72 }
73 }
74
75 $RunNumber = $max + 1;
76 }
77 else {
78
79 if (-x $Dir) {
Sam Bishopa0e22662008-04-02 03:35:43 +000080 die "error: '$Dir' exists but is not a directory.\n";
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +000081 }
82
83 # $Dir does not exist. It will be automatically created by the
84 # clang driver. Set the run number to 1.
85
86 $RunNumber = 1;
87 }
88
89 die "RunNumber must be defined!" if (!defined($RunNumber));
90
91 # Append the run number.
92
93 return "$Dir/$DateString-$RunNumber";
94}
95
Sam Bishopa0e22662008-04-02 03:35:43 +000096sub SetHtmlEnv {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +000097
98 die "Wrong number of arguments." if (scalar(@_) != 2);
99
100 my $Args = shift;
101 my $Dir = shift;
102
103 die "No build command." if (scalar(@$Args) == 0);
104
105 my $Cmd = $$Args[0];
106
107 if ($Cmd =~ /configure/) {
108 return;
109 }
110
111 if ($Verbose) {
112 print "$Prog: Emitting reports for this run to '$Dir'.\n";
113 }
114
115 $ENV{'CCC_ANALYZER_HTML'} = $Dir;
116}
117
118##----------------------------------------------------------------------------##
Ted Kremenek57cf4462008-04-18 15:09:30 +0000119# ComputeDigest - Compute a digest of the specified file.
120##----------------------------------------------------------------------------##
121
122sub ComputeDigest {
123 my $FName = shift;
124 die "Cannot read $FName" if (! -r $FName);
125 my $Result = `sha1sum -b $FName`;
126 my @Output = split /\s+/,$Result;
127 die "Bad output from sha1sum" if (scalar(@Output) != 2);
128 return $Output[0];
129}
130
131##----------------------------------------------------------------------------##
Ted Kremenek5744dc22008-04-02 18:03:36 +0000132# ScanFile - Scan a report file for various identifying attributes.
133##----------------------------------------------------------------------------##
134
Ted Kremenek57cf4462008-04-18 15:09:30 +0000135# Sometimes a source file is scanned more than once, and thus produces
136# multiple error reports. We use a cache to solve this problem.
137
138my %AlreadyScanned;
139
Ted Kremenek5744dc22008-04-02 18:03:36 +0000140sub ScanFile {
141
142 my $Index = shift;
143 my $Dir = shift;
144 my $FName = shift;
145
Ted Kremenek57cf4462008-04-18 15:09:30 +0000146 # Compute a digest for the report file. Determine if we have already
147 # scanned a file that looks just like it.
148
149 my $digest = ComputeDigest("$Dir/$FName");
150
151 if (defined($AlreadyScanned{$digest})) {
152 # Redundant file. Remove it.
153 `rm -f $Dir/$FName`;
154 return;
155 }
156
157 $AlreadyScanned{$digest} = 1;
158
Ted Kremenek809709f2008-04-18 16:58:34 +0000159 # At this point the report file is not world readable. Make it happen.
Ted Kremenek684bb092008-04-18 15:18:20 +0000160 `chmod 644 $Dir/$FName`;
161
162 # Scan the report file for tags.
Ted Kremenek5744dc22008-04-02 18:03:36 +0000163 open(IN, "$Dir/$FName") or die "$Prog: Cannot open '$Dir/$FName'\n";
164
165 my $BugDesc = "";
Ted Kremenek22d6a632008-04-02 20:43:36 +0000166 my $BugFile = "";
167 my $BugPathLength = 1;
168 my $BugLine = 0;
Ted Kremenek5744dc22008-04-02 18:03:36 +0000169
170 while (<IN>) {
171
172 if (/<!-- BUGDESC (.*) -->$/) {
173 $BugDesc = $1;
Ted Kremenek5744dc22008-04-02 18:03:36 +0000174 }
Ted Kremenek22d6a632008-04-02 20:43:36 +0000175 elsif (/<!-- BUGFILE (.*) -->$/) {
176 $BugFile = $1;
177 }
178 elsif (/<!-- BUGPATHLENGTH (.*) -->$/) {
179 $BugPathLength = $1;
180 }
181 elsif (/<!-- BUGLINE (.*) -->$/) {
182 $BugLine = $1;
183 }
Ted Kremenek5744dc22008-04-02 18:03:36 +0000184 }
185
186 close(IN);
187
Ted Kremenek22d6a632008-04-02 20:43:36 +0000188 push @$Index,[ $FName, $BugDesc, $BugFile, $BugLine, $BugPathLength ];
189}
190
191##----------------------------------------------------------------------------##
192# CopyJS - Copy JavaScript code to target directory.
193##----------------------------------------------------------------------------##
194
195sub CopyJS {
196
197 my $Dir = shift;
198
199 die "$Prog: Cannot find 'sorttable.js'.\n"
200 if (! -r "$RealBin/sorttable.js");
201
202 `cp $RealBin/sorttable.js $Dir`;
203
204 die "$Prog: Could not copy 'sorttable.js' to '$Dir'."
205 if (! -r "$Dir/sorttable.js");
Ted Kremenek5744dc22008-04-02 18:03:36 +0000206}
207
208##----------------------------------------------------------------------------##
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000209# Postprocess - Postprocess the results of an analysis scan.
210##----------------------------------------------------------------------------##
211
Sam Bishopa0e22662008-04-02 03:35:43 +0000212sub Postprocess {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000213
214 my $Dir = shift;
Ted Kremenek684bb092008-04-18 15:18:20 +0000215 my $BaseDir = shift;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000216
217 die "No directory specified." if (!defined($Dir));
Ted Kremenek684bb092008-04-18 15:18:20 +0000218 die "No base directory specified." if (!defined($BaseDir));
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000219
220 if (! -d $Dir) {
221 return;
222 }
223
224 opendir(DIR, $Dir);
225 my @files = grep(/^report-.*\.html$/,readdir(DIR));
226 closedir(DIR);
227
228 if (scalar(@files) == 0) {
Ted Kremenek02493782008-04-02 07:05:07 +0000229 print "$Prog: Removing directory '$Dir' because it contains no reports.\n";
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000230 `rm -fR $Dir`;
231 return;
232 }
Ted Kremenek5744dc22008-04-02 18:03:36 +0000233
234 # Scan each report file and build an index.
235
236 my @Index;
237
238 foreach my $file (@files) { ScanFile(\@Index, $Dir, $file); }
239
240 # Generate an index.html file.
241
242 my $FName = "$Dir/index.html";
243
244 open(OUT, ">$FName") or die "$Prog: Cannot create file '$FName'\n";
245
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000246 # Print out the header.
247
Ted Kremenek5744dc22008-04-02 18:03:36 +0000248print OUT <<ENDTEXT;
249<html>
250<head>
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000251<style type="text/css">
252 body { color:#000000; background-color:#ffffff }
Ted Kremenek22d6a632008-04-02 20:43:36 +0000253 body { font-family: Helvetica, sans-serif; font-size:9pt }
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000254 h1 { font-size:12pt }
Ted Kremenek22d6a632008-04-02 20:43:36 +0000255 table.sortable thead {
256 background-color:#eee; color:#666666;
257 font-weight: bold; cursor: default;
Ted Kremenekbba1cf52008-04-03 05:50:51 +0000258 text-align:center;
259 border-top: 2px solid #000000;
260 border-bottom: 2px solid #000000;
261 font-weight: bold; font-family: Verdana
262 }
Ted Kremenek22d6a632008-04-02 20:43:36 +0000263 table.sortable { border: 1px #000000 solid }
264 table.sortable { border-collapse: collapse; border-spacing: 0px }
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000265 td { border-bottom: 1px #000000 dotted }
Ted Kremenek22d6a632008-04-02 20:43:36 +0000266 td { padding:5px; padding-left:8px; padding-right:8px }
Ted Kremenekd8c6d0c2008-04-07 23:50:07 +0000267 td { text-align:left; font-size:9pt }
Ted Kremenek22d6a632008-04-02 20:43:36 +0000268 td.View { padding-left: 10px }
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000269</style>
Ted Kremenek22d6a632008-04-02 20:43:36 +0000270<script src="sorttable.js"></script>
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000271<script language='javascript' type="text/javascript">
272function SetDisplay(RowClass, DisplayVal)
273{
274 var Rows = document.getElementsByTagName("tr");
275 for ( var i = 0 ; i < Rows.length; ++i ) {
276 if (Rows[i].className == RowClass) {
277 Rows[i].style.display = DisplayVal;
278 }
279 }
280}
281
282function ToggleDisplay(CheckButton, ClassName) {
283 window.console.log("writing");
284 if (CheckButton.checked) {
285 SetDisplay(ClassName, "");
286 }
287 else {
288 SetDisplay(ClassName, "none");
289 }
290}
291</script>
292</head>
293<body>
294ENDTEXT
295
296 # Print out the summary table.
297
298 my %Totals;
299
300 for my $row ( @Index ) {
301
302 my $bug_type = lc($row->[1]);
303
304 if (!defined($Totals{$bug_type})) {
305 $Totals{$bug_type} = 1;
306 }
307 else {
308 $Totals{$bug_type}++;
309 }
310 }
311
312print OUT <<ENDTEXT;
313<h3>Summary</h3>
314<table class="sortable">
315<tr>
316 <td>Bug Type</td>
317 <td>Quantity</td>
318 <td "sorttable_nosort">Display?</td>
319</tr>
320ENDTEXT
321
322 for my $key ( sort { $a cmp $b } keys %Totals ) {
323 my $x = $key;
324 $x =~ s/\s/_/g;
325 print OUT "<tr><td>$key</td><td>$Totals{$key}</td><td><input type=\"checkbox\" onClick=\"ToggleDisplay(this,'bt_$x');\" checked/></td></tr>\n";
326 }
327
328 # Print out the table of errors.
329
330print OUT <<ENDTEXT;
331</table>
332<h3>Reports</h3>
Ted Kremenek22d6a632008-04-02 20:43:36 +0000333<table class="sortable">
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000334<tr>
Ted Kremenekbba1cf52008-04-03 05:50:51 +0000335 <td>Bug Type</td>
336 <td>File</td>
337 <td>Line</td>
338 <td>Path Length</td>
339 <td "sorttable_nosort"></td>
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000340</tr>
Ted Kremenek5744dc22008-04-02 18:03:36 +0000341ENDTEXT
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000342
Ted Kremenek5744dc22008-04-02 18:03:36 +0000343 for my $row ( sort { $a->[1] cmp $b->[1] } @Index ) {
344
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000345 my $x = lc($row->[1]);
346 $x =~ s/\s/_/g;
347
348 print OUT "<tr class=\"bt_$x\">\n";
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000349
Ted Kremenek5744dc22008-04-02 18:03:36 +0000350 my $ReportFile = $row->[0];
351
Ted Kremenek22d6a632008-04-02 20:43:36 +0000352 print OUT " <td class=\"DESC\">";
353 print OUT lc($row->[1]);
354 print OUT "</td>\n";
Ted Kremenek5744dc22008-04-02 18:03:36 +0000355
356 for my $j ( 2 .. $#{$row} ) {
357 print OUT "<td>$row->[$j]</td>\n"
358 }
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000359
360 # Emit the "View" link.
Ted Kremenek5744dc22008-04-02 18:03:36 +0000361
Ted Kremenek22d6a632008-04-02 20:43:36 +0000362 print OUT " <td class=\"View\"><a href=\"$ReportFile#EndPath\">View</a></td>\n";
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000363
364 # End the row.
Ted Kremenek5744dc22008-04-02 18:03:36 +0000365 print OUT "</tr>\n";
366 }
367
368 print OUT "</table>\n</body></html>\n";
369 close(OUT);
Ted Kremenek22d6a632008-04-02 20:43:36 +0000370
Ted Kremenek22d6a632008-04-02 20:43:36 +0000371 CopyJS($Dir);
Ted Kremenek684bb092008-04-18 15:18:20 +0000372
373 # Make sure $Dir and $BaseDir is world readable/executable.
374 `chmod 755 $Dir`;
375 `chmod 755 $BaseDir`;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000376}
377
378##----------------------------------------------------------------------------##
Ted Kremenekdab11102008-04-02 04:43:42 +0000379# RunBuildCommand - Run the build command.
380##----------------------------------------------------------------------------##
381
382sub RunBuildCommand {
383
384 my $Args = shift;
Ted Kremenek7442ca62008-04-02 16:04:51 +0000385 my $IgnoreErrors = shift;
Ted Kremenekdab11102008-04-02 04:43:42 +0000386 my $Cmd = $Args->[0];
387
Ted Kremenek6a43ba92008-04-02 15:34:12 +0000388 if ($Cmd eq "gcc" or $Cmd eq "cc" or $Cmd eq "llvm-gcc") {
Ted Kremenekdab11102008-04-02 04:43:42 +0000389 shift @$Args;
390 unshift @$Args, "ccc-analyzer"
391 }
Ted Kremenek7442ca62008-04-02 16:04:51 +0000392 elsif ($IgnoreErrors) {
393 if ($Cmd eq "make" or $Cmd eq "gmake") {
394 push @$Args, "-k";
395 }
396 elsif ($Cmd eq "xcodebuild") {
397 push @$Args, "-PBXBuildsContinueAfterErrors=YES";
398 }
Ted Kremenek22d6a632008-04-02 20:43:36 +0000399 }
Ted Kremenekdab11102008-04-02 04:43:42 +0000400
401 system(@$Args);
402}
403
Ted Kremenekdab11102008-04-02 04:43:42 +0000404##----------------------------------------------------------------------------##
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000405# DisplayHelp - Utility function to display all help options.
406##----------------------------------------------------------------------------##
407
Sam Bishopa0e22662008-04-02 03:35:43 +0000408sub DisplayHelp {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000409
Ted Kremenek5744dc22008-04-02 18:03:36 +0000410print <<ENDTEXT;
Sam Bishopa0e22662008-04-02 03:35:43 +0000411USAGE: $Prog [options] <build command> [build options]
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000412
413OPTIONS:
414
415 -o - Target directory for HTML report files. Subdirectories
Sam Bishopa0e22662008-04-02 03:35:43 +0000416 will be created as needed to represent separate "runs" of
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000417 the analyzer. If this option is not specified, a directory
418 is created in /tmp to store the reports.
419
Ted Kremenek10f883f2008-04-03 07:11:44 +0000420 -h - Display this message.
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000421 --help
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000422
Ted Kremenekaf08f642008-04-02 16:31:58 +0000423 -k - Add a "keep on going" option to the specified build command.
Ted Kremenekf02e8db2008-04-02 16:41:25 +0000424 --keep-going This option currently supports make and xcodebuild.
425 This is a convenience option; one can specify this
426 behavior directly using build options.
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000427
Ted Kremenekdab11102008-04-02 04:43:42 +0000428 -v - Verbose output from $Prog and the analyzer.
429 A second "-v" increases verbosity.
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000430
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000431 -V - View analysis results in a web browser when the build
432 --view completes.
433
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000434BUILD OPTIONS
435
Ted Kremenek39eefde2008-04-02 16:47:27 +0000436 You can specify any build option acceptable to the build command.
437
Ted Kremenek5744dc22008-04-02 18:03:36 +0000438EXAMPLE
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000439
Ted Kremenek5744dc22008-04-02 18:03:36 +0000440 $Prog -o /tmp/myhtmldir make -j4
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000441
Ted Kremenek39eefde2008-04-02 16:47:27 +0000442 The above example causes analysis reports to be deposited into
443 a subdirectory of "/tmp/myhtmldir" and to run "make" with the "-j4" option.
444 A different subdirectory is created each time $Prog analyzes a project.
445 The analyzer should support most parallel builds, but not distributed builds.
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000446
447ENDTEXT
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000448}
449
450##----------------------------------------------------------------------------##
451# Process command-line arguments.
452##----------------------------------------------------------------------------##
453
454my $HtmlDir; # Parent directory to store HTML files.
455my $IgnoreErrors = 0; # Ignore build errors.
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000456my $ViewResults = 0; # View results when the build terminates.
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000457
458if (!@ARGV) {
459 DisplayHelp();
Sam Bishopa0e22662008-04-02 03:35:43 +0000460 exit 1;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000461}
462
463while (@ARGV) {
464
465 # Scan for options we recognize.
466
467 my $arg = $ARGV[0];
468
Sam Bishop2f2418e2008-04-03 14:29:47 +0000469 if ($arg eq "-h" or $arg eq "--help") {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000470 DisplayHelp();
Sam Bishopa0e22662008-04-02 03:35:43 +0000471 exit 0;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000472 }
473
474 if ($arg eq "-o") {
475 shift @ARGV;
476
477 if (!@ARGV) {
Ted Kremenek0062ad42008-04-02 16:35:01 +0000478 die "$Prog: '-o' option requires a target directory name.\n";
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000479 }
480
481 $HtmlDir = shift @ARGV;
482 next;
483 }
484
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000485 if ($arg eq "-k" or $arg eq "--keep-going") {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000486 shift @ARGV;
487 $IgnoreErrors = 1;
488 next;
489 }
490
491 if ($arg eq "-v") {
492 shift @ARGV;
493 $Verbose++;
494 next;
495 }
496
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000497 if ($arg eq "-V" or $arg eq "--view") {
498 shift @ARGV;
499 $ViewResults = 1;
500 next;
501 }
502
Ted Kremenek0062ad42008-04-02 16:35:01 +0000503 die "$Prog: unrecognized option '$arg'\n" if ($arg =~ /^-/);
504
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000505 last;
506}
507
508if (!@ARGV) {
509 print STDERR "$Prog: No build command specified.\n\n";
510 DisplayHelp();
Sam Bishopa0e22662008-04-02 03:35:43 +0000511 exit 1;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000512}
513
514# Determine the output directory for the HTML reports.
515
516if (!defined($HtmlDir)) {
517
Sam Bishopa0e22662008-04-02 03:35:43 +0000518 $HtmlDir = mkdtemp("/tmp/$Prog-XXXXXX");
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000519
520 if (!defined($HtmlDir)) {
Sam Bishopa0e22662008-04-02 03:35:43 +0000521 die "error: Cannot create HTML directory in /tmp.\n";
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000522 }
523
524 if (!$Verbose) {
525 print "$Prog: Using '$HtmlDir' as base HTML report directory.\n";
526 }
527}
528
Ted Kremenek684bb092008-04-18 15:18:20 +0000529my $BaseDir = $HtmlDir;
Sam Bishopa0e22662008-04-02 03:35:43 +0000530$HtmlDir = GetHTMLRunDir($HtmlDir);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000531
532# Set the appropriate environment variables.
533
Sam Bishopa0e22662008-04-02 03:35:43 +0000534SetHtmlEnv(\@ARGV, $HtmlDir);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000535
Ted Kremenek0b6c1532008-04-08 20:22:12 +0000536my $Cmd = "$RealBin/ccc-analyzer";
537
538die "$Prog: Executable 'ccc-analyzer' does not exist at '$Cmd'\n"
539 if (! -x $Cmd);
Ted Kremenekf22eacb2008-04-18 22:00:56 +0000540
541my $Clang = "$RealBin/clang";
542
543if (! -x $Clang) {
544 print "$Prog: 'clang' executable not found in '$RealBin'. Using 'clang' from path.\n";
545 $Clang = "clang";
546}
Ted Kremenek0b6c1532008-04-08 20:22:12 +0000547
Ted Kremenek4f4b17d2008-04-03 20:08:18 +0000548$ENV{'CC'} = $Cmd;
Ted Kremenekf22eacb2008-04-18 22:00:56 +0000549$ENV{'CLANG'} = $Clang;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000550
551if ($Verbose >= 2) {
552 $ENV{'CCC_ANALYZER_VERBOSE'} = 1;
553}
554
555# Run the build.
556
Ted Kremenek7442ca62008-04-02 16:04:51 +0000557RunBuildCommand(\@ARGV, $IgnoreErrors);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000558
559# Postprocess the HTML directory.
560
Ted Kremenek684bb092008-04-18 15:18:20 +0000561Postprocess($HtmlDir, $BaseDir);
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000562
563if ($ViewResults and -r "$HtmlDir/index.html") {
564 # Only works on Mac OS X (for now).
565 print "Viewing analysis results: '$HtmlDir/index.html'\n";
566 `open $HtmlDir/index.html`
567}