+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
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 = ();
%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 = ();
# 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 = ();
}
}