Commit 8675fa83 authored by haraken@chromium.org's avatar haraken@chromium.org

In CodeGeneratorObjC.pm, overwrite the output .h/.mm

only if the bytes differ
https://bugs.webkit.org/show_bug.cgi?id=76874

Reviewed by Adam Barth.

This is one of steps to stop rebuilding .h/.cpp/.mm files
generated by unchanged IDLs (bug 76836).
This patch makes a change on CodeGeneratorObjC.pm so that
it overwrites the output .h/.mm only if the bytes differ.

No tests. No change in behavior.
I manually confirmed that when I add a new attribute to Element.idl,
the time-stamps of unrelated DOM*.h and DOM*.mm do not change.

* bindings/scripts/CodeGenerator.pm:
(UpdateFileIfChanged): Added. This method writes data to a file
only if the data is different from the data in the current file.
* bindings/scripts/CodeGeneratorObjC.pm:
(WriteData): Used UpdateFileIfChanged().


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105697 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a5e058b5
2012-01-23 Kentaro Hara <haraken@chromium.org>
In CodeGeneratorObjC.pm, overwrite the output .h/.mm
only if the bytes differ
https://bugs.webkit.org/show_bug.cgi?id=76874
Reviewed by Adam Barth.
This is one of steps to stop rebuilding .h/.cpp/.mm files
generated by unchanged IDLs (bug 76836).
This patch makes a change on CodeGeneratorObjC.pm so that
it overwrites the output .h/.mm only if the bytes differ.
No tests. No change in behavior.
I manually confirmed that when I add a new attribute to Element.idl,
the time-stamps of unrelated DOM*.h and DOM*.mm do not change.
* bindings/scripts/CodeGenerator.pm:
(UpdateFileIfChanged): Added. This method writes data to a file
only if the data is different from the data in the current file.
* bindings/scripts/CodeGeneratorObjC.pm:
(WriteData): Used UpdateFileIfChanged().
2012-01-23 Alexey Proskuryakov <ap@apple.com>
REGRESSION: Downloaded file name fallback encodings are not set correctly
......@@ -163,6 +163,30 @@ sub FileNamePrefix
return $codeGenerator->FileNamePrefix();
}
sub UpdateFileIfChanged
{
my $object = shift;
my $fileName = shift;
my $contents = shift;
my $shouldUpdate = 0;
if (open FH, $fileName) {
local $/ = undef;
my $oldContents = <FH>;
$shouldUpdate = 1 if $oldContents ne $contents;
close FH;
} else {
$shouldUpdate = 1;
}
if ($shouldUpdate) {
open FH, "> $fileName" or die "Couldn't open $fileName: $!\n";
print FH $contents;
close FH;
}
}
sub ForAllParents
{
my $object = shift;
......
......@@ -1776,25 +1776,15 @@ sub WriteData
my $internalHeaderFileName = "$outputDir/" . $name . "Internal.h";
my $depsFileName = "$outputDir/" . $name . ".dep";
# Remove old files.
unlink($headerFileName);
unlink($privateHeaderFileName);
unlink($implFileName);
unlink($internalHeaderFileName);
unlink($depsFileName);
# Write public header.
open(HEADER, ">$headerFileName") or die "Couldn't open file $headerFileName";
print HEADER @headerContentHeader;
print HEADER map { "\@class $_;\n" } sort keys(%headerForwardDeclarations);
print HEADER map { "\@protocol $_;\n" } sort keys(%headerForwardDeclarationsForProtocols);
my $contents = join "", @headerContentHeader;
map { $contents .= "\@class $_;\n" } sort keys(%headerForwardDeclarations);
map { $contents .= "\@protocol $_;\n" } sort keys(%headerForwardDeclarationsForProtocols);
my $hasForwardDeclarations = keys(%headerForwardDeclarations) + keys(%headerForwardDeclarationsForProtocols);
print HEADER "\n" if $hasForwardDeclarations;
print HEADER @headerContent;
close(HEADER);
$contents .= "\n" if $hasForwardDeclarations;
$contents .= join "", @headerContent;
$codeGenerator->UpdateFileIfChanged($headerFileName, $contents);
@headerContentHeader = ();
@headerContent = ();
......@@ -1802,17 +1792,14 @@ sub WriteData
%headerForwardDeclarationsForProtocols = ();
if (@privateHeaderContent > 0) {
open(PRIVATE_HEADER, ">$privateHeaderFileName") or die "Couldn't open file $privateHeaderFileName";
print PRIVATE_HEADER @privateHeaderContentHeader;
print PRIVATE_HEADER map { "\@class $_;\n" } sort keys(%privateHeaderForwardDeclarations);
print PRIVATE_HEADER map { "\@protocol $_;\n" } sort keys(%privateHeaderForwardDeclarationsForProtocols);
$contents = join "", @privateHeaderContentHeader;
map { $contents .= "\@class $_;\n" } sort keys(%privateHeaderForwardDeclarations);
map { $contents .= "\@protocol $_;\n" } sort keys(%privateHeaderForwardDeclarationsForProtocols);
$hasForwardDeclarations = keys(%privateHeaderForwardDeclarations) + keys(%privateHeaderForwardDeclarationsForProtocols);
print PRIVATE_HEADER "\n" if $hasForwardDeclarations;
print PRIVATE_HEADER @privateHeaderContent;
close(PRIVATE_HEADER);
$contents .= "\n" if $hasForwardDeclarations;
$contents .= join "", @privateHeaderContent;
$codeGenerator->UpdateFileIfChanged($privateHeaderFileName, $contents);
@privateHeaderContentHeader = ();
@privateHeaderContent = ();
......@@ -1822,34 +1809,28 @@ sub WriteData
# Write implementation file.
unless ($noImpl) {
open(IMPL, ">$implFileName") or die "Couldn't open file $implFileName";
print IMPL @implContentHeader;
print IMPL map { "#import \"$_\"\n" } sort keys(%implIncludes);
print IMPL @implContent;
close(IMPL);
$contents = join "", @implContentHeader;
map { $contents .= "#import \"$_\"\n" } sort keys(%implIncludes);
$contents .= join "", @implContent;
$codeGenerator->UpdateFileIfChanged($implFileName, $contents);
@implContentHeader = ();
@implContent = ();
%implIncludes = ();
}
if (@internalHeaderContent > 0) {
open(INTERNAL_HEADER, ">$internalHeaderFileName") or die "Couldn't open file $internalHeaderFileName";
print INTERNAL_HEADER @internalHeaderContent;
close(INTERNAL_HEADER);
if (@internalHeaderContent > 0) {
$contents = join "", @internalHeaderContent;
$codeGenerator->UpdateFileIfChanged($internalHeaderFileName, $contents);
@internalHeaderContent = ();
@internalHeaderContent = ();
}
# Write dependency file.
if (@depsContent) {
open(DEPS, ">$depsFileName") or die "Couldn't open file $depsFileName";
print DEPS @depsContent;
close(DEPS);
$contents = join "", @depsContent;
$codeGenerator->UpdateFileIfChanged($depsFileName, $contents);
@depsContent = ();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment