- Revision
- 106862
- Author
- [email protected]
- Date
- 2012-02-06 15:10:54 -0800 (Mon, 06 Feb 2012)
Log Message
In AppleWebKit, stop rebuilding IDLs that need not to be rebuilt
https://bugs.webkit.org/show_bug.cgi?id=77510
Reviewed by Adam Barth.
Currently, if any IDL file is updated, all IDL files are rebuilt.
This patch stops rebuilding IDL files which are not modified nor
whose supplemental dependencies are not changed.
The new build flow is as follows:
supplemental.dep : $(ALL_IDLS)
perl resolve-supplemental.pl ...
%.idl-needs-rebuild : %.idl supplemental.dep
perl update-idl-needs-rebuild.pl ...
JS%.cpp : %.idl-needs-rebuild
perl generate-bindings.pl ...
resolve-supplemental.pl generates the following supplemental.dep.
The number in () is the last access timestamp of the file.
A.idl(1200)
B.idl(1000) B-supplemental1.idl(800) B-supplemental2.idl(1200)
C.idl(1000)
update-idl-needs-rebuild.pl for X.idl touches X.idl-needs-rebuild,
if X.idl-needs-rebuild is older than X.idl or the IDL files which are
supplementing X.idl. For example, if the timestamps of A.idl-needs-rebuild,
B.idl-needs-rebuild and C.idl-needs-rebuild are all 1000, then A.idl-needs-rebuild
and B.idl-needs-rebuild will be touched.
Even if no IDL files are modified, update-idl-needs-rebuild.pl can run for all IDL files,
but generate-bindings.pl won't run. If any IDL file is updated, resolve-supplemental.pl
will run once, update-idl-needs-rebuild.pl will run for all IDL files, and
generate-bindings.pl will run for the IDL files which are modified or whose
dependencies are changed.
No tests. I manually confirmed the followings:
- Touch Element.idl, then only Element.idl is rebuilt
- Touch DOMWindow.idl, then only DOMWindow.idl is rebuilt
- Touch DOMWindowWebAudio.idl, then only DOMWindow.idl and DOMWindowWebAudio.idl are rebuilt
* DerivedSources.make: Modified the build flow as described above.
* bindings/scripts/generate-bindings.pl: Modified to read an IDL file path from .idl-needs-rebuild.
* bindings/scripts/update-idl-needs-rebuild.pl: Added. Touches X.idl-needs-rebuild if
the X.idl-needs-rebuild is older than X.idl or the IDL files which are supplementing X.idl.
(touch):
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (106861 => 106862)
--- trunk/Source/WebCore/ChangeLog 2012-02-06 23:10:17 UTC (rev 106861)
+++ trunk/Source/WebCore/ChangeLog 2012-02-06 23:10:54 UTC (rev 106862)
@@ -1,3 +1,55 @@
+2012-02-06 Kentaro Hara <[email protected]>
+
+ In AppleWebKit, stop rebuilding IDLs that need not to be rebuilt
+ https://bugs.webkit.org/show_bug.cgi?id=77510
+
+ Reviewed by Adam Barth.
+
+ Currently, if any IDL file is updated, all IDL files are rebuilt.
+ This patch stops rebuilding IDL files which are not modified nor
+ whose supplemental dependencies are not changed.
+
+ The new build flow is as follows:
+
+ supplemental.dep : $(ALL_IDLS)
+ perl resolve-supplemental.pl ...
+
+ %.idl-needs-rebuild : %.idl supplemental.dep
+ perl update-idl-needs-rebuild.pl ...
+
+ JS%.cpp : %.idl-needs-rebuild
+ perl generate-bindings.pl ...
+
+ resolve-supplemental.pl generates the following supplemental.dep.
+ The number in () is the last access timestamp of the file.
+
+ A.idl(1200)
+ B.idl(1000) B-supplemental1.idl(800) B-supplemental2.idl(1200)
+ C.idl(1000)
+
+ update-idl-needs-rebuild.pl for X.idl touches X.idl-needs-rebuild,
+ if X.idl-needs-rebuild is older than X.idl or the IDL files which are
+ supplementing X.idl. For example, if the timestamps of A.idl-needs-rebuild,
+ B.idl-needs-rebuild and C.idl-needs-rebuild are all 1000, then A.idl-needs-rebuild
+ and B.idl-needs-rebuild will be touched.
+
+ Even if no IDL files are modified, update-idl-needs-rebuild.pl can run for all IDL files,
+ but generate-bindings.pl won't run. If any IDL file is updated, resolve-supplemental.pl
+ will run once, update-idl-needs-rebuild.pl will run for all IDL files, and
+ generate-bindings.pl will run for the IDL files which are modified or whose
+ dependencies are changed.
+
+ No tests. I manually confirmed the followings:
+ - Touch Element.idl, then only Element.idl is rebuilt
+ - Touch DOMWindow.idl, then only DOMWindow.idl is rebuilt
+ - Touch DOMWindowWebAudio.idl, then only DOMWindow.idl and DOMWindowWebAudio.idl are rebuilt
+
+ * DerivedSources.make: Modified the build flow as described above.
+ * bindings/scripts/generate-bindings.pl: Modified to read an IDL file path from .idl-needs-rebuild.
+ * bindings/scripts/update-idl-needs-rebuild.pl: Added. Touches X.idl-needs-rebuild if
+ the X.idl-needs-rebuild is older than X.idl or the IDL files which are supplementing X.idl.
+ (touch):
+
2012-02-06 Wei James <[email protected]>
AudioBus need to support stereo->mono down mix in copyFrom sumFrom etc.
Modified: trunk/Source/WebCore/DerivedSources.make (106861 => 106862)
--- trunk/Source/WebCore/DerivedSources.make 2012-02-06 23:10:17 UTC (rev 106861)
+++ trunk/Source/WebCore/DerivedSources.make 2012-02-06 23:10:54 UTC (rev 106862)
@@ -584,15 +584,20 @@
DOM_CLASSES=$(basename $(notdir $(BINDING_IDLS)))
JS_DOM_HEADERS=$(filter-out JSMediaQueryListListener.h JSEventListener.h JSEventTarget.h, $(DOM_CLASSES:%=JS%.h))
+JS_IDL_NEEDS_REBUILDS=$(JS_DOM_HEADERS:JS%.h=%.idl-needs-rebuild) _javascript_CallFrame.idl-needs-rebuild
WEB_DOM_HEADERS :=
ifeq ($(findstring BUILDING_WX,$(FEATURE_DEFINES)), BUILDING_WX)
WEB_DOM_HEADERS := $(filter-out WebDOMXSLTProcessor.h WebDOMEventTarget.h, $(DOM_CLASSES:%=WebDOM%.h))
+CPP_IDL_NEEDS_REBUILDS=$(WEB_DOM_HEADERS:WebDOM%.h=%.idl-needs-rebuild)
endif # BUILDING_WX
all : \
$(JS_DOM_HEADERS) \
+ $(JS_IDL_NEEDS_REBUILDS) \
+ \
$(WEB_DOM_HEADERS) \
+ $(CPP_IDL_NEEDS_REBUILDS) \
\
JSJavaScriptCallFrame.h \
\
@@ -912,23 +917,24 @@
JS_BINDINGS_SCRIPTS = $(GENERATE_SCRIPTS) bindings/scripts/CodeGeneratorJS.pm
-SUPPLEMENTAL_DEPENDENCY_FILE = ./supplemental_dependency.tmp
+SUPPLEMENTAL_DEPENDENCY_FILE = ./supplemental.dep
IDL_FILES_TMP = ./idl_files.tmp
-ADDITIONAL_IDLS = $(WebCore)/inspector/_javascript_CallFrame.idl
# The following two lines get a space character stored in a variable.
# See <http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html>.
space :=
space +=
-$(SUPPLEMENTAL_DEPENDENCY_FILE) : $(RESOLVE_SUPPLEMENTAL_SCRIPTS) $(BINDING_IDLS) $(ADDITIONAL_IDLS)
- printf "$(subst $(space),,$(patsubst %,%\n,$(BINDING_IDLS) $(ADDITIONAL_IDLS)))" > $(IDL_FILES_TMP)
- $(call resolve_supplemental_script, $(RESOLVE_SUPPLEMENTAL_SCRIPTS)) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_JAVASCRIPT" --idlFilesList $(IDL_FILES_TMP) --supplementalDependencyFile $@
+$(SUPPLEMENTAL_DEPENDENCY_FILE) : $(RESOLVE_SUPPLEMENTAL_SCRIPTS) $(BINDING_IDLS) $(WebCore)/inspector/_javascript_CallFrame.idl
+ printf "$(subst $(space),,$(patsubst %,%\n,$(BINDING_IDLS) $(WebCore)/inspector/_javascript_CallFrame.idl))" > $(IDL_FILES_TMP)
+ $(call resolve_supplemental_script, $(RESOLVE_SUPPLEMENTAL_SCRIPTS)) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_JAVASCRIPT" --idlFilesList $(IDL_FILES_TMP) --supplementalDependencyFile $@ --newBuildFlow
rm -f $(IDL_FILES_TMP)
-JS%.h : %.idl $(JS_BINDINGS_SCRIPTS) $(SUPPLEMENTAL_DEPENDENCY_FILE)
- $(call generator_script, $(JS_BINDINGS_SCRIPTS)) $(IDL_COMMON_ARGS) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_JAVASCRIPT" --generator JS --supplementalDependencyFile $(SUPPLEMENTAL_DEPENDENCY_FILE) $<
+%.idl-needs-rebuild : %.idl $(SUPPLEMENTAL_DEPENDENCY_FILE) $(WebCore)/bindings/scripts/update-idl-needs-rebuild.pl
+ perl $(WebCore)/bindings/scripts/update-idl-needs-rebuild.pl --supplementalDependencyFile $(SUPPLEMENTAL_DEPENDENCY_FILE) --idlFile $<
+JS%.h : %.idl-needs-rebuild $(JS_BINDINGS_SCRIPTS)
+ $(call generator_script, $(JS_BINDINGS_SCRIPTS)) $(IDL_COMMON_ARGS) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_JAVASCRIPT" --generator JS --supplementalDependencyFile $(SUPPLEMENTAL_DEPENDENCY_FILE) --idlNeedsRebuildFile $< --newBuildFlow
# Inspector interfaces generator
@@ -954,8 +960,8 @@
ifeq ($(findstring BUILDING_WX,$(FEATURE_DEFINES)), BUILDING_WX)
CPP_BINDINGS_SCRIPTS = $(GENERATE_SCRIPTS) bindings/scripts/CodeGeneratorCPP.pm
-WebDOM%.h : %.idl $(CPP_BINDINGS_SCRIPTS) $(SUPPLEMENTAL_DEPENDENCY_FILE)
- $(call generator_script, $(CPP_BINDINGS_SCRIPTS)) $(IDL_COMMON_ARGS) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_CPP" --generator CPP --supplementalDependencyFile $(SUPPLEMENTAL_DEPENDENCY_FILE) $<
+WebDOM%.h : %.idl-needs-rebuild $(CPP_BINDINGS_SCRIPTS)
+ $(call generator_script, $(CPP_BINDINGS_SCRIPTS)) $(IDL_COMMON_ARGS) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_CPP" --generator CPP --supplementalDependencyFile $(SUPPLEMENTAL_DEPENDENCY_FILE) --idlNeedsRebuildFile $< --newBuildFlow
endif # BUILDING_WX
# ------------------------
@@ -965,8 +971,9 @@
ifeq ($(OS),MACOS)
OBJC_DOM_HEADERS=$(filter-out DOMDOMWindow.h DOMDOMMimeType.h DOMDOMPlugin.h,$(DOM_CLASSES:%=DOM%.h))
+OBJC_IDL_NEEDS_REBUILDS=$(OBJC_DOM_HEADERS:DOM%.h=%.idl-needs-rebuild)
-all : $(OBJC_DOM_HEADERS)
+all : $(OBJC_DOM_HEADERS) $(OBJC_IDL_NEEDS_REBUILDS)
all : CharsetData.cpp
@@ -997,8 +1004,8 @@
# Objective-C bindings
DOM_BINDINGS_SCRIPTS = $(GENERATE_BINDING_SCRIPTS) bindings/scripts/CodeGeneratorObjC.pm
-DOM%.h : %.idl $(DOM_BINDINGS_SCRIPTS) $(SUPPLEMENTAL_DEPENDENCY_FILE) bindings/objc/PublicDOMInterfaces.h
- $(call generator_script, $(DOM_BINDINGS_SCRIPTS)) $(IDL_COMMON_ARGS) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_OBJECTIVE_C" --generator ObjC --supplementalDependencyFile $(SUPPLEMENTAL_DEPENDENCY_FILE) $<
+DOM%.h : %.idl-needs-rebuild $(DOM_BINDINGS_SCRIPTS) bindings/objc/PublicDOMInterfaces.h
+ $(call generator_script, $(DOM_BINDINGS_SCRIPTS)) $(IDL_COMMON_ARGS) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_OBJECTIVE_C" --generator ObjC --supplementalDependencyFile $(SUPPLEMENTAL_DEPENDENCY_FILE) --idlNeedsRebuildFile $< --newBuildFlow
-include $(OBJC_DOM_HEADERS:.h=.dep)
Modified: trunk/Source/WebCore/bindings/scripts/generate-bindings.pl (106861 => 106862)
--- trunk/Source/WebCore/bindings/scripts/generate-bindings.pl 2012-02-06 23:10:17 UTC (rev 106861)
+++ trunk/Source/WebCore/bindings/scripts/generate-bindings.pl 2012-02-06 23:10:54 UTC (rev 106862)
@@ -50,6 +50,8 @@
my $verbose;
my $supplementalDependencyFile;
my $additionalIdlFilesList;
+my $idlNeedsRebuildFile;
+my $newBuildFlow;
GetOptions('include=s@' => \@idlDirectories,
'outputDir=s' => \$outputDirectory,
@@ -62,12 +64,28 @@
'verbose' => \$verbose,
'write-dependencies' => \$writeDependencies,
'supplementalDependencyFile=s' => \$supplementalDependencyFile,
- 'additionalIdlFilesList=s' => \$additionalIdlFilesList);
+ 'additionalIdlFilesList=s' => \$additionalIdlFilesList,
+ 'idlNeedsRebuildFile=s' => \$idlNeedsRebuildFile,
+ # FIXME: After supporting the new build flow in all build systems (bug 76970),
+ # we should remove the --newBuildFlow option.
+ 'newBuildFlow' => \$newBuildFlow);
my $targetIdlFile = $ARGV[0];
+if ($idlNeedsRebuildFile) {
+ open FH, "<", $idlNeedsRebuildFile or die "Couldn't open $idlNeedsRebuildFile: $!";
+ while (<FH>) {
+ chomp;
+ if (/^IDLFile=(.*)$/) {
+ $targetIdlFile = $1;
+ last;
+ }
+ }
+ close FH;
+}
+
die('Must specify input file.') unless defined($targetIdlFile);
-die('Must specify generator') unless defined($generator);
+die('Must specify generator.') unless defined($generator);
die('Must specify output directory.') unless defined($outputDirectory);
if (!$outputHeadersDirectory) {
@@ -82,25 +100,55 @@
my $idlFound = 0;
my @supplementedIdlFiles;
if ($supplementalDependencyFile) {
- # The format of a supplemental dependency file:
- #
- # DOMWindow.idl P.idl Q.idl R.idl
- # Document.idl S.idl
- # Event.idl
- # ...
- #
- # The above indicates that DOMWindow.idl is supplemented by P.idl, Q.idl and R.idl,
- # Document.idl is supplemented by S.idl, and Event.idl is supplemented by no IDLs.
- # The IDL that supplements another IDL (e.g. P.idl) never appears in the dependency file.
- open FH, "< $supplementalDependencyFile" or die "Cannot open $supplementalDependencyFile\n";
- while (my $line = <FH>) {
- my ($idlFile, @followingIdlFiles) = split(/\s+/, $line);
- if ($idlFile and basename($idlFile) eq basename($targetIdlFile)) {
- $idlFound = 1;
- @supplementedIdlFiles = @followingIdlFiles;
+ # FIXME: After supporting the new build flow in all build systems (bug 76970),
+ # we should remove this if statement.
+ if ($newBuildFlow) {
+ # The format of a supplemental dependency file:
+ #
+ # DOMWindow.idl(1000) P.idl(800) Q.idl(1200) R.idl(1000)
+ # Document.idl(1000) S.idl(800)
+ # Event.idl(1200)
+ # ...
+ #
+ # The above indicates that DOMWindow.idl is supplemented by P.idl, Q.idl and R.idl,
+ # Document.idl is supplemented by S.idl, and Event.idl is supplemented by no IDLs.
+ # The IDL that supplements another IDL (e.g. P.idl) never appears in the dependency file.
+ # The number in () is the last access timestamp of the file.
+ open FH, "<", $supplementalDependencyFile or die "Cannot open $supplementalDependencyFile\n";
+ while (my $line = <FH>) {
+ my ($idlFileEntry, @supplementalIdlFileEntries) = split(/\s+/, $line);
+ die "The format of supplemental.dep is wrong\n" unless $idlFileEntry =~ /^([^\(]*)\(\d+\)$/;
+ my $idlFile = $1;
+ if (basename($idlFile) eq basename($targetIdlFile)) {
+ $idlFound = 1;
+ for my $supplementalIdlFileEntry (@supplementalIdlFileEntries) {
+ die "The format of supplemental.dep is wrong\n" unless $supplementalIdlFileEntry =~ /^([^\(]*)\(\d+\)$/;
+ push @supplementedIdlFiles, $1;
+ }
+ }
}
+ close FH;
+ } else {
+ # The format of a supplemental dependency file:
+ #
+ # DOMWindow.idl P.idl Q.idl R.idl
+ # Document.idl S.idl
+ # Event.idl
+ # ...
+ #
+ # The above indicates that DOMWindow.idl is supplemented by P.idl, Q.idl and R.idl,
+ # Document.idl is supplemented by S.idl, and Event.idl is supplemented by no IDLs.
+ # The IDL that supplements another IDL (e.g. P.idl) never appears in the dependency file.
+ open FH, "<", $supplementalDependencyFile or die "Cannot open $supplementalDependencyFile\n";
+ while (my $line = <FH>) {
+ my ($idlFile, @followingIdlFiles) = split(/\s+/, $line);
+ if ($idlFile and basename($idlFile) eq basename($targetIdlFile)) {
+ $idlFound = 1;
+ @supplementedIdlFiles = @followingIdlFiles;
+ }
+ }
+ close FH;
}
- close FH;
# The file $additionalIdlFilesList contains one IDL file per line:
# P.idl
@@ -110,7 +158,7 @@
# (i.e. they are not described in the supplemental dependency file)
# but should generate .h and .cpp files.
if (!$idlFound and $additionalIdlFilesList) {
- open FH, "< $additionalIdlFilesList" or die "Cannot open $additionalIdlFilesList\n";
+ open FH, "<", $additionalIdlFilesList or die "Cannot open $additionalIdlFilesList\n";
my @idlFiles = <FH>;
chomp(@idlFiles);
$idlFound = grep { $_ and basename($_) eq basename($targetIdlFile) } @idlFiles;
@@ -207,11 +255,11 @@
$cppName at every build. This file must not be tried to compile.
*/
";
- open FH, "> ${outputHeadersDirectory}/${headerName}" or die "Cannot open $headerName\n";
+ open FH, ">", "${outputHeadersDirectory}/${headerName}" or die "Cannot open $headerName\n";
print FH $contents;
close FH;
- open FH, "> ${outputDirectory}/${cppName}" or die "Cannot open $cppName\n";
+ open FH, ">", "${outputDirectory}/${cppName}" or die "Cannot open $cppName\n";
print FH $contents;
close FH;
}
Modified: trunk/Source/WebCore/bindings/scripts/resolve-supplemental.pl (106861 => 106862)
--- trunk/Source/WebCore/bindings/scripts/resolve-supplemental.pl 2012-02-06 23:10:17 UTC (rev 106861)
+++ trunk/Source/WebCore/bindings/scripts/resolve-supplemental.pl 2012-02-06 23:10:54 UTC (rev 106862)
@@ -31,12 +31,16 @@
my $verbose;
my $idlFilesList;
my $supplementalDependencyFile;
+my $newBuildFlow;
GetOptions('defines=s' => \$defines,
'preprocessor=s' => \$preprocessor,
'verbose' => \$verbose,
'idlFilesList=s' => \$idlFilesList,
- 'supplementalDependencyFile=s' => \$supplementalDependencyFile);
+ 'supplementalDependencyFile=s' => \$supplementalDependencyFile,
+ # FIXME: After supporting the new build flow in all build systems (bug 76970),
+ # we should remove the --newBuildFlow option.
+ 'newBuildFlow' => \$newBuildFlow);
die('Must specify #define macros using --defines.') unless defined($defines);
die('Must specify an output file using --supplementalDependencyFile.') unless defined($supplementalDependencyFile);
@@ -46,7 +50,7 @@
print "Resolving [Supplemental=XXX] dependencies in all IDL files.\n";
}
-open FH, "< $idlFilesList" or die "Cannot open $idlFilesList\n";
+open FH, "<", $idlFilesList or die "Cannot open $idlFilesList\n";
my @idlFiles = <FH>;
chomp(@idlFiles);
close FH;
@@ -77,19 +81,50 @@
}
}
-# Outputs the dependency.
-# The format of a supplemental dependency file:
-#
-# DOMWindow.idl P.idl Q.idl R.idl
-# Document.idl S.idl
-# Event.idl
-# ...
-#
-# The above indicates that DOMWindow.idl is supplemented by P.idl, Q.idl and R.idl,
-# Document.idl is supplemented by S.idl, and Event.idl is supplemented by no IDLs.
-# The IDL that supplements another IDL (e.g. P.idl) never appears in the dependency file.
-open FH, "> $supplementalDependencyFile" or die "Cannot open $supplementalDependencyFile\n";
-foreach my $idlFile (sort keys %supplementals) {
- print FH $idlFile, " @{$supplementals{$idlFile}}\n";
+# FIXME: After supporting the new build flow in all build systems (bug 76970),
+# we should remove this if statement.
+if ($newBuildFlow) {
+ # The format of a supplemental dependency file:
+ #
+ # DOMWindow.idl(1000) P.idl(800) Q.idl(1200) R.idl(1000)
+ # Document.idl(1000) S.idl(800)
+ # Event.idl(1200)
+ # ...
+ #
+ # The above indicates that DOMWindow.idl is supplemented by P.idl, Q.idl and R.idl,
+ # Document.idl is supplemented by S.idl, and Event.idl is supplemented by no IDLs.
+ # The IDL that supplements another IDL (e.g. P.idl) never appears in the dependency file.
+ # The number in () is the last access timestamp of the file.
+ open FH, ">", $supplementalDependencyFile or die "Cannot open $supplementalDependencyFile\n";
+ foreach my $idlFile (sort keys %supplementals) {
+ print FH $idlFile . "(" . timestamp($idlFile) . ")";
+ for my $supplementalIdlFile (@{$supplementals{$idlFile}}) {
+ print FH " " . $supplementalIdlFile . "(" . timestamp($supplementalIdlFile) . ")";
+ }
+ print FH "\n";
+ }
+ close FH;
+} else {
+ # The format of a supplemental dependency file:
+ #
+ # DOMWindow.idl P.idl Q.idl R.idl
+ # Document.idl S.idl
+ # Event.idl
+ # ...
+ #
+ # The above indicates that DOMWindow.idl is supplemented by P.idl, Q.idl and R.idl,
+ # Document.idl is supplemented by S.idl, and Event.idl is supplemented by no IDLs.
+ # The IDL that supplements another IDL (e.g. P.idl) never appears in the dependency file.
+ open FH, ">", $supplementalDependencyFile or die "Cannot open $supplementalDependencyFile\n";
+ foreach my $idlFile (sort keys %supplementals) {
+ print FH $idlFile, " @{$supplementals{$idlFile}}\n";
+ }
+ close FH;
}
-close FH;
+
+sub timestamp
+{
+ my $file = shift;
+ return 0 if ! -e $file;
+ return (stat $file)[9];
+}
Added: trunk/Source/WebCore/bindings/scripts/update-idl-needs-rebuild.pl (0 => 106862)
--- trunk/Source/WebCore/bindings/scripts/update-idl-needs-rebuild.pl (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/update-idl-needs-rebuild.pl 2012-02-06 23:10:54 UTC (rev 106862)
@@ -0,0 +1,90 @@
+#!/usr/bin/perl -w
+#
+# Copyright (C) 2012 Google Inc. All rights reserved.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+#
+
+use strict;
+
+use File::Basename;
+use Getopt::Long;
+
+my $idlFile;
+my $supplementalDependencyFile;
+
+GetOptions('supplementalDependencyFile=s' => \$supplementalDependencyFile,
+ 'idlFile=s' => \$idlFile);
+
+die "Must specify an IDL file." unless $idlFile;
+die "Must specify a supplemental dependency file." unless $supplementalDependencyFile;
+
+# Touches .idl-needs-rebuild if .idl-needs-rebuild is older than this IDL file.
+my $idlNeedsRebuildFile = basename($idlFile) . "-needs-rebuild";
+my $timeStampOfIdlNeedsRebuildFile = timestamp($idlNeedsRebuildFile);
+if ($timeStampOfIdlNeedsRebuildFile < timestamp($idlFile)) {
+ touch($idlNeedsRebuildFile);
+ exit;
+}
+
+
+# The format of a supplemental dependency file:
+#
+# DOMWindow.idl(1000) P.idl(800) Q.idl(1200) R.idl(1000)
+# Document.idl(1000) S.idl(800)
+# Event.idl(1200)
+# ...
+#
+# The above indicates that DOMWindow.idl is supplemented by P.idl, Q.idl and R.idl,
+# Document.idl is supplemented by S.idl, and Event.idl is supplemented by no IDLs.
+# The IDL that supplements another IDL (e.g. P.idl) never appears in the dependency file.
+# The number in () is the last access timestamp of the file.
+open FH, "<", $supplementalDependencyFile or die "Couldn't open $supplementalDependencyFile: $!";
+while (my $line = <FH>) {
+ my ($idlFileEntry, @supplementalIdlFileEntries) = split(/\s+/, $line);
+ die "The format of supplemental.dep is wrong\n" unless $idlFileEntry =~ /^([^\(]*)\((\d+)\)$/;
+ next if (basename($1) ne basename($idlFile));
+ my $timeStampOfIdlFile = $2;
+ # Touches .idl-needs-rebuild if there is at least one supplemental IDL file which is newer than this IDL file.
+ for my $supplementalIdlFileEntry (@supplementalIdlFileEntries) {
+ die "The format of supplemental.dep is wrong\n" unless $supplementalIdlFileEntry =~ /^(?:[^\(]*)\((\d+)\)$/;
+ my $timeStampOfSupplementalIdlFile = $1;
+ if ($timeStampOfIdlNeedsRebuildFile < $timeStampOfSupplementalIdlFile) {
+ touch($idlNeedsRebuildFile);
+ last;
+ }
+ }
+ last;
+}
+close FH;
+
+sub touch
+{
+ my $file = shift;
+
+ open FH, ">", $file or die "Couldn't open $file: $!";
+ my $basename = basename($file);
+ print FH "This file is used by build scripts only. The timestamp of this file determines whether ${basename}.idl should be rebuilt or not.\n\n";
+ print FH "IDLFile=$idlFile\n";
+ close FH;
+}
+
+sub timestamp
+{
+ my $file = shift;
+ return 0 if ! -e $file;
+ return (stat $file)[9];
+}