Skip to content

Commit

Permalink
lxapigen.pl: Don't overwrite files that didn't change.
Browse files Browse the repository at this point in the history
This prevents a full rebuild every time you add an API.
  • Loading branch information
icculus committed Jun 6, 2018
1 parent b1217b7 commit 8b69564
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lxapigen.pl
Expand Up @@ -87,7 +87,8 @@ sub typesize {

# Here we go...

my $outfname = "$dirname/$module-lx.h";
my $finalfname = "$dirname/$module-lx.h";
my $outfname = "$finalfname-new";
open(OUT, '>', $outfname) or die("Failed to open '$outfname' for writing: $!\n");

print OUT <<EOF
Expand Down Expand Up @@ -227,6 +228,12 @@ sub typesize {
;

close(OUT);

if ((system("diff --brief '$finalfname' '$outfname'") == -1) || ($? != 0)) {
rename($outfname, $finalfname) or die("Failed to rename '$outfname' to '$finalfname': $!\n");
} else {
unlink($outfname); # they match, just delete the new copy so build system doesn't rebuild everything.
}
}

closedir(DIRH);
Expand Down

0 comments on commit 8b69564

Please sign in to comment.