Improve error handling of dbdExpand.pl

This commit is contained in:
Andrew Johnson
2014-09-23 15:11:40 -05:00
parent 32ca04dda8
commit 82f24149d9
+12 -4
View File
@@ -28,28 +28,34 @@ my $dbd = DBD->new();
# Calculate filename for the dependency warning message below
my $dep = $opt_o;
my $dot_d = '';
if ($opt_D) {
$dep =~ s{\.\./O\.Common/(.*)}{\1\$\(DEP\)};
$dot_d = '.d';
} else {
$dep = "\$(COMMON_DIR)/$dep";
}
die "dbdExpand.pl: No input files for $opt_o\n" if !@ARGV;
my $errors = 0;
while (@ARGV) {
my $file = shift @ARGV;
eval {
&ParseDBD($dbd, &Readfile($file, $macros, \@opt_I));
};
if ($@) {
warn "dbdExpand: $@";
warn " Your Makefile may need this dependency rule:\n" .
warn "dbdExpand.pl: $@";
warn " while reading '$file' to create '$opt_o$dot_d'\n";
warn " Your Makefile may need this dependency rule:\n",
" $dep: \$(COMMON_DIR)/$file\n"
if $@ =~ m/Can't find file/;
if $@ =~ m/Can't find file '$file'/;
++$errors;
}
}
if ($opt_D) { # Output dependencies only
if ($opt_D) { # Output dependencies only, ignore errors
my %filecount;
my @uniqfiles = grep { not $filecount{$_}++ } @inputfiles;
print "$opt_o: ", join(" \\\n ", @uniqfiles), "\n\n";
@@ -57,6 +63,8 @@ if ($opt_D) { # Output dependencies only
exit 0;
}
die "dbdExpand.pl: Exiting due to errors\n" if $errors;
my $out;
if ($opt_o) {
open $out, '>', $opt_o or die "Can't create $opt_o: $!\n";