Title: [105805] trunk/Source/WebCore
Revision
105805
Author
[email protected]
Date
2012-01-24 14:09:45 -0800 (Tue, 24 Jan 2012)

Log Message

CodeGeneratorCPP.pm should overwrite the output .h/.cpp
only if the bytes differ
https://bugs.webkit.org/show_bug.cgi?id=76926

Reviewed by Adam Barth.

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

No tests. No change in behavior.
Manually confirm that when you add a new attribute to Element.idl,
the time-stamps of unrelated WebDOM*.h and WebDOM*.cpp do not change.

* bindings/scripts/CodeGeneratorCPP.pm:
(WriteData): Used UpdateFileIfChanged().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (105804 => 105805)


--- trunk/Source/WebCore/ChangeLog	2012-01-24 22:04:14 UTC (rev 105804)
+++ trunk/Source/WebCore/ChangeLog	2012-01-24 22:09:45 UTC (rev 105805)
@@ -1,3 +1,23 @@
+2012-01-24  Kentaro Hara  <[email protected]>
+
+        CodeGeneratorCPP.pm should overwrite the output .h/.cpp
+        only if the bytes differ
+        https://bugs.webkit.org/show_bug.cgi?id=76926
+
+        Reviewed by Adam Barth.
+
+        This is one of steps to stop rebuilding .h/.cpp files
+        generated by unchanged IDLs (bug 76836).
+        This patch makes a change on CodeGeneratorCPP.pm so that
+        it overwrites the output .h/.cpp only if the bytes differ.
+
+        No tests. No change in behavior.
+        Manually confirm that when you add a new attribute to Element.idl,
+        the time-stamps of unrelated WebDOM*.h and WebDOM*.cpp do not change.
+
+        * bindings/scripts/CodeGeneratorCPP.pm:
+        (WriteData): Used UpdateFileIfChanged().
+
 2012-01-24  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r105238.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm (105804 => 105805)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm	2012-01-24 22:04:14 UTC (rev 105804)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm	2012-01-24 22:09:45 UTC (rev 105805)
@@ -932,15 +932,9 @@
     my $headerFileName = "$outputDir/" . $name . ".h";
     my $implFileName = "$outputDir/" . $name . ".cpp";
 
-    # Remove old files.
-    unlink($headerFileName);
-    unlink($implFileName);
-
-    # Write public header.
-    open(HEADER, ">$headerFileName") or die "Couldn't open file $headerFileName";
-    
-    print HEADER @headerContentHeader;
-    print HEADER "\n";
+    # Update a .h file if the contents are changed.
+    my $contents = join "", @headerContentHeader;
+    $contents .= "\n";
     foreach my $class (sort keys(%headerForwardDeclarations)) {
         if ($class =~ /::/) {
             my $namespacePart = $class;
@@ -949,34 +943,32 @@
             my $classPart = $class;
             $classPart =~ s/${namespacePart}:://;
 
-            print HEADER "namespace $namespacePart {\nclass $classPart;\n};\n\n";
+            $contents .= "namespace $namespacePart {\nclass $classPart;\n};\n\n";
         } else {
-            print HEADER "class $class;\n"
+            $contents .= "class $class;\n"
         }
     }
 
     my $hasForwardDeclarations = keys(%headerForwardDeclarations);
-    print HEADER "\n" if $hasForwardDeclarations;
-    print HEADER @headerContent;
-    close(HEADER);
+    $contents .= "\n" if $hasForwardDeclarations;
+    $contents .= join "", @headerContent;
+    $codeGenerator->UpdateFileIfChanged($headerFileName, $contents);
 
     @headerContentHeader = ();
     @headerContent = ();
     %headerForwardDeclarations = ();
 
-    # Write implementation file.
-    open(IMPL, ">$implFileName") or die "Couldn't open file $implFileName";
+    # Update a .cpp file if the contents are changed.
+    $contents = join "", @implContentHeader;
 
-    print IMPL @implContentHeader;
-
     foreach my $include (sort keys(%implIncludes)) {
         # "className.h" is already included right after config.h, silence check-webkit-style
         next if $include eq "$name.h";
-        print IMPL "#include \"$include\"\n";
+        $contents .= "#include \"$include\"\n";
     }
 
-    print IMPL @implContent;
-    close(IMPL);
+    $contents .= join "", @implContent;
+    $codeGenerator->UpdateFileIfChanged($implFileName, $contents);
 
     @implContentHeader = ();
     @implContent = ();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to