4 use File
::Temp qw
/ tempdir /;
7 die "$prog <code file> <error string> [optional command]\n" if ($#ARGV < 0);
8 my $file = shift @ARGV;
9 die "$prog: [error] cannot read file $file\n" if (! -r
$file);
11 my $magic = shift @ARGV;
12 die "$prog: [error] no error string specified\n" if (! defined $magic);
14 # Create a backup of the file.
15 my $dir = tempdir
( CLEANUP
=> 1 );
16 print "$prog: created temporary directory '$dir'\n";
17 my $srcFile = "$dir/$file";
21 my $scriptFile = "$dir/script";
22 open(OUT
, ">$scriptFile") or die "$prog: cannot create '$scriptFile'\n";
23 my $reduceOut = "$dir/reduceOut";
26 if (scalar(@ARGV) > 0) { $command = \
@ARGV; }
28 my $compiler = "clang";
29 $command = [$compiler, "-fsyntax-only", "-Wfatal-errors", "-Wno-deprecated-declarations", "-Wimplicit-function-declaration"];
31 push @
$command, $srcFile;
32 my $commandStr = "@$command";
41 my \$command = "$commandStr > $reduceOut 2>&1";
43 open(IN, "$reduceOut") or exit(\$BAD);
46 if (/$magic/) { exit \$GOOD; }
51 `chmod +x $scriptFile`;
53 print "$prog: starting reduction\n";
56 system("multidelta -level=$level $scriptFile $srcFile");
59 for (my $i = 1 ; $i <= 5; $i++) {
60 foreach my $level (0,0,1,1,2,2,10) {
65 # Copy the final file.
66 `cp $srcFile $file.reduced`;
67 print "$prog: generated '$file.reduced";