[Qt] Change how build-webkit decides when to do full incremental builds
authorvestbo@webkit.org <vestbo@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jan 2012 10:14:48 +0000 (10:14 +0000)
committervestbo@webkit.org <vestbo@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jan 2012 10:14:48 +0000 (10:14 +0000)
Instead of relying on update-webkit (which isn't run on the bots) to
decide when to do a full incremental build (make qmake), we let the
build-webkit script itself check the current SVN revision against the
previous build (by storing it in .webkit.config).

If the two differ we assume a full incremental build is needed, since
the new revisions might have introduced problematic things like new
Q_OBJECT macros. If not, we assume the developer is doing changes
locally, and revert to doing a plain 'make'.

In addition, when the build fails in the latter case, we inform the
developer of possible pitfalls and how to manually run 'make qmake'.

Reviewed by Ossy.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105603 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/update-webkit
Tools/Scripts/webkitdirs.pm

index dfd39b6..017a36f 100644 (file)
@@ -1,3 +1,26 @@
+2012-01-20  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
+
+        [Qt] Change how build-webkit decides when to do full incremental builds
+
+        Instead of relying on update-webkit (which isn't run on the bots) to
+        decide when to do a full incremental build (make qmake), we let the
+        build-webkit script itself check the current SVN revision against the
+        previous build (by storing it in .webkit.config).
+
+        If the two differ we assume a full incremental build is needed, since
+        the new revisions might have introduced problematic things like new
+        Q_OBJECT macros. If not, we assume the developer is doing changes
+        locally, and revert to doing a plain 'make'.
+
+        In addition, when the build fails in the latter case, we inform the
+        developer of possible pitfalls and how to manually run 'make qmake'.
+
+        Reviewed by Ossy.
+
+        * Scripts/update-webkit:
+        * Scripts/webkitdirs.pm:
+        (buildQMakeProjects):
+
 2012-01-23  Mario Sanchez Prada  <msanchez@igalia.com>
 
         [GTK] run-gtk-tests randomly fails while running the xprop comand
index b529feb..7ec88bb 100755 (executable)
@@ -83,8 +83,6 @@ if ($useMake) {
 
 my $startTime = time();
 
-my $initialRevision = currentSVNRevision();
-
 my @svnOptions = ();
 push @svnOptions, '-q' if $quiet;
 
@@ -95,9 +93,6 @@ print "Updating OpenSource\n" unless $quiet;
 runSvnUpdate() if isSVN();
 runGitUpdate() if isGit();
 
-# The update might have given us a new revision
-determineCurrentSVNRevision();
-
 if (-d "../Internal") {
     chdir("../Internal");
     print "Updating Internal\n" unless $quiet;
@@ -121,13 +116,6 @@ if (-d "../Internal") {
         # WinCairo shares the auxiliary libs from the Apple port.
         system("perl", "Tools/Scripts/update-webkit-wincairo-libs") == 0 or die;
     }
-} elsif (isQt()) {
-    if (currentSVNRevision() ne $initialRevision) {
-        my $hintFile = File::Spec->catfile(sourceDir(), "Tools", "qmake", ".build-hint");
-        open(HINTFILE, ">$hintFile") || die("Could not open $hintFile for writing!\n");
-        print HINTFILE "incremental\n";
-        close(HINTFILE);
-    }
 }
 
 setupAppleWinEnv() if isAppleWinWebKit();
index ccaa410..8ab60d9 100755 (executable)
@@ -2070,14 +2070,9 @@ sub buildQMakeProjects
 
     my %defines = qtFeatureDefaults(\@buildArgs);
 
-    my $pathToBuildHint = File::Spec->catfile(sourceDir(), "Tools", "qmake", ".build-hint");
-    my $buildHint = "";
-    if (-e $pathToBuildHint && open(BUILDHINT, $pathToBuildHint)) {
-        chomp($buildHint = <BUILDHINT>);
-        close(BUILDHINT);
-    }
+    my $svnRevision = currentSVNRevision();
 
-    my $needsCleanBuild = 0;
+    my $buildHint = "";
 
     my $pathToDefinesCache = File::Spec->catfile($dir, ".webkit.config");
     my $pathToOldDefinesFile = File::Spec->catfile($dir, "defaults.txt");
@@ -2085,39 +2080,55 @@ sub buildQMakeProjects
     # Ease transition to new build layout
     if (-e $pathToOldDefinesFile) {
         print "Old build layout detected";
-        $needsCleanBuild = 1;
+        $buildHint = "clean";
     } elsif (-e $pathToDefinesCache && open(DEFAULTS, $pathToDefinesCache)) {
         my %previousDefines;
         while (<DEFAULTS>) {
-            if ($_ =~ m/(\S+?)=(\S+?)/gi) {
+            if ($_ =~ m/(\S+)=(\S+)/gi) {
                 $previousDefines{$1} = $2;
             }
         }
         close (DEFAULTS);
 
+        $previousDefines{"SVN_REVISION"} = "unknown" if not exists $previousDefines{"SVN_REVISION"};
+
+        if ($svnRevision ne $previousDefines{"SVN_REVISION"}) {
+            print "Last built revision was " . $previousDefines{"SVN_REVISION"} .
+                ", now at revision $svnRevision. Full incremental build needed.\n";
+
+            $buildHint = "incremental";
+        }
+
+        # Don't confuse the should-we-clean heuristics below
+        delete($previousDefines{"SVN_REVISION"});
+
         my @uniqueDefineNames = keys %{ +{ map { $_, 1 } (keys %defines, keys %previousDefines) } };
         foreach my $define (@uniqueDefineNames) {
             if (! exists $previousDefines{$define}) {
                 print "Feature $define added";
-                $needsCleanBuild = 1;
+                $buildHint = "clean";
                 last;
             }
 
             if (! exists $defines{$define}) {
                 print "Feature $define removed";
-                $needsCleanBuild = 1;
+                $buildHint = "clean";
                 last;
             }
 
             if ($defines{$define} != $previousDefines{$define}) {
                 print "Feature $define changed ($previousDefines{$define} -> $defines{$define})";
-                $needsCleanBuild = 1;
+                $buildHint = "clean";
                 last;
             }
         }
+    } else {
+        # Missing build cache suggests we had a broken build after a clean,
+        # so we assume we have to do an incremental build just in case.
+        $buildHint = "incremental";
     }
 
-    if ($needsCleanBuild) {
+    if ($buildHint eq "clean") {
         print ", clean build needed!\n";
         # FIXME: This STDIN/STDOUT check does not work on the bots. Disable until it does.
         # if (! -t STDIN || ( &promptUser("Would you like to clean the build directory?", "yes") eq "yes")) {
@@ -2132,13 +2143,6 @@ sub buildQMakeProjects
         #}
     }
 
-    open(DEFAULTS, ">$pathToDefinesCache");
-    print DEFAULTS "# These defines were set when building WebKit last time\n";
-    foreach my $key (sort keys %defines) {
-        print DEFAULTS "$key=$defines{$key}\n";
-    }
-    close(DEFAULTS);
-
     my $result = 0;
 
     my $makefile = File::Spec->catfile($dir, "Makefile");
@@ -2160,13 +2164,9 @@ sub buildQMakeProjects
     my $command = "$make $makeargs";
     $command =~ s/\s+$//;
 
-    # FIXME: Until the bots use update-webkit instead of raw SVN, we
-    # need to force the build-hint to 'incremental' :(
-    $buildHint = "incremental";
-
     if ($clean) {
         $command = "$command distclean";
-    } elsif ($buildHint =~ /^incremental$/) {
+    } elsif ($buildHint eq "incremental") {
         $command = "$command incremental";
     }
 
@@ -2175,7 +2175,38 @@ sub buildQMakeProjects
 
     chdir ".." or die;
 
-    unlink($pathToBuildHint) || die "Could not delete $pathToBuildHint: $!" if -e $pathToBuildHint && $result eq 0;
+    if ($result eq 0) {
+        $defines{"SVN_REVISION"} = $svnRevision;
+        open(DEFAULTS, ">$pathToDefinesCache");
+        print DEFAULTS "# These defines were set when building WebKit last time\n";
+        foreach my $key (sort keys %defines) {
+            print DEFAULTS "$key=$defines{$key}\n";
+        }
+        close(DEFAULTS);
+    } elsif ($buildHint eq "" && exitStatus($result)) {
+        my $exitCode = exitStatus($result);
+        my $failMessage = <<EOF;
+
+===== BUILD FAILED ======
+
+The build failed with exit code $exitCode. This may have been because you
+
+  - added an #include to a source/header
+  - added a Q_OBJECT macro to a class
+  - added a new resource to a qrc file
+
+as dependencies are not automatically re-computed for local developer builds.
+You may try computing dependencies manually by running 'make qmake' in:
+
+  $dir
+
+or passing --makeargs="qmake" to build-webkit.
+
+=========================
+
+EOF
+        print "$failMessage";
+    }
 
     return $result;
 }