Fix build.pl optimization error when Makefile doesn't exist.

This commit is contained in:
Brad Fitzpatrick 2011-05-12 19:11:28 -07:00
parent 0714e7ca1c
commit acd6227b31
1 changed files with 5 additions and 3 deletions

View File

@ -372,9 +372,11 @@ sub gen_target_makefile {
sub set_file_contents {
my ($fn, $new) = @_;
open(my $fh, $fn) or die;
my $cur = do { local $/; <$fh> };
return if $new eq $cur;
if (-e $fn) {
open(my $fh, $fn) or die "Failed to write to $fn: $!";
my $cur = do { local $/; <$fh> };
return if $new eq $cur;
}
open(my $fh, ">$fn") or die;
print $fh $new;
close($fh) or die;