[chromium] Add support for building standalone webkit/chromium checkouts with ninja.
authorthakis@chromium.org <thakis@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Jan 2012 23:43:30 +0000 (23:43 +0000)
committerthakis@chromium.org <thakis@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Jan 2012 23:43:30 +0000 (23:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77243

Reviewed by Adam Barth.

Source/WebKit/chromium:

* gyp_webkit:

Tools:

* Scripts/update-webkit:
* Scripts/webkitdirs.pm:
(isChromiumNinja):
(determineIsChromiumNinja):
(buildChromiumNinja):
(buildChromium):

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

Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/gyp_webkit
Tools/ChangeLog
Tools/Scripts/update-webkit
Tools/Scripts/webkitdirs.pm

index 85e3fd1..8e53eec 100644 (file)
@@ -1,3 +1,12 @@
+2012-01-28  Nico Weber  <thakis@chromium.org>
+
+        [chromium] Add support for building standalone webkit/chromium checkouts with ninja.
+        https://bugs.webkit.org/show_bug.cgi?id=77243
+
+        Reviewed by Adam Barth.
+
+        * gyp_webkit:
+
 2012-01-27  Jeff Timanus  <twiz@chromium.org>
 
         [chromium] Increase the size of the Ganesh texture cache to prevent performance problems on advanced Canvas2D pages.
index 59071a3..2e73f4e 100755 (executable)
@@ -102,11 +102,12 @@ if __name__ == '__main__':
   if sys.platform not in ('darwin',):
     args.append('--no-circular-check')
 
-  # On linux, we want gyp to output a makefile (default is scons).
-  if (sys.platform.startswith('linux') or
+  generators = os.environ.get('GYP_GENERATORS', '')
+  if 'ninja' in generators:
+    args.extend([ '--toplevel-dir=../../..' ])
+  elif (sys.platform.startswith('linux') or
       'WEBKIT_ANDROID_BUILD' in os.environ or
-      (sys.platform == 'darwin' and
-          os.environ.get('GYP_GENERATORS', '').find('make') != -1)):
+      (sys.platform == 'darwin' and 'make' in generators)):
     args.extend(['-fmake',
                  '--suffix=.chromium',
                  '--toplevel-dir=../../..',
index 8bb61a9..959b14a 100644 (file)
@@ -1,3 +1,17 @@
+2012-01-28  Nico Weber  <thakis@chromium.org>
+
+        [chromium] Add support for building standalone webkit/chromium checkouts with ninja.
+        https://bugs.webkit.org/show_bug.cgi?id=77243
+
+        Reviewed by Adam Barth.
+
+        * Scripts/update-webkit:
+        * Scripts/webkitdirs.pm:
+        (isChromiumNinja):
+        (determineIsChromiumNinja):
+        (buildChromiumNinja):
+        (buildChromium):
+
 2012-01-27  Kentaro Hara  <haraken@chromium.org>
 
         The cpp parser of prepare-ChangeLog treats if(...) {} as a method
index 7ec88bb..eb94f16 100755 (executable)
@@ -48,6 +48,7 @@ my $quiet = '';
 my $showHelp;
 my $useGYP = 0;
 my $useMake = 0;
+my $useNinja = 0;
 
 determineIsChromium();
 determineIsChromiumAndroid();
@@ -61,6 +62,7 @@ my $getOptionsResult = GetOptions(
     'q|quiet' => \$quiet,
     'gyp' => \$useGYP,
     'make' => \$useMake,
+    'ninja' => \$useNinja,
 ); 
 
 if (!$getOptionsResult || $showHelp) {
@@ -68,6 +70,7 @@ if (!$getOptionsResult || $showHelp) {
 Usage: @{[ basename($0) ]} [options]
   --chromium          also update dependencies of the chromium port
   --make              generate the Makefile-based build system (Chromium only)
+  --ninja             generate the ninja-based build system (Chromium only)
   --chromium-android  also update dependencies of the chromium port for Android
   -h|--help           show the help message
   -q|--quiet          pass -q to svn update for quiet updates
@@ -80,6 +83,9 @@ __END__
 if ($useMake) {
     $ENV{"GYP_GENERATORS"} = "make";
 }
+if ($useNinja) {
+    $ENV{"GYP_GENERATORS"} = "ninja";
+}
 
 my $startTime = time();
 
index 431baaf..e8fe3d2 100755 (executable)
@@ -95,6 +95,7 @@ my $isBlackBerry;
 my $isChromium;
 my $isChromiumAndroid;
 my $isChromiumMacMake;
+my $isChromiumNinja;
 my $forceChromiumUpdate;
 my $isInspectorFrontend;
 my $isWK2;
@@ -1139,6 +1140,37 @@ sub determineIsChromiumMacMake()
     $isChromiumMacMake = isDarwin() && $hasUpToDateMakefile;
 }
 
+sub isChromiumNinja()
+{
+    determineIsChromiumNinja();
+    return $isChromiumNinja;
+}
+
+sub determineIsChromiumNinja()
+{
+    return if defined($isChromiumNinja);
+
+    my $config = configuration();
+
+    my $hasUpToDateNinjabuild = 0;
+    if (-e "out/$config/build.ninja") {
+        my $statNinja = stat("out/$config/build.ninja");
+
+        my $statXcode = 0;
+        if (-e 'Source/WebKit/chromium/WebKit.xcodeproj') {
+          $statXcode = stat('Source/WebKit/chromium/WebKit.xcodeproj')->mtime;
+        }
+
+        my $statMake = 0;
+        if (-e 'Makefile.chromium') {
+          $statXcode = stat('Makefile.chromium')->mtime;
+        }
+
+        $hasUpToDateNinjabuild = $statNinja > $statXcode && $statNinja > $statMake;
+    }
+    $isChromiumNinja = $hasUpToDateNinjabuild;
+}
+
 sub forceChromiumUpdate()
 {
     determineIsChromium();
@@ -2266,6 +2298,19 @@ sub buildChromiumMakefile($$@)
     return system $command;
 }
 
+sub buildChromiumNinja($$@)
+{
+    # rm -rf out requires rerunning gyp, so don't support --clean for now.
+    my ($target, @options) = @_;
+    my $config = configuration();
+    my $command = "";
+
+    $command .= "ninja -C out/$config $target";
+
+    print "$command\n";
+    return system $command;
+}
+
 sub buildChromiumVisualStudioProject($$)
 {
     my ($projectPath, $clean) = @_;
@@ -2316,12 +2361,14 @@ sub buildChromium($@)
     }
 
     my $result = 1;
-    if (isDarwin() && !isChromiumAndroid() && !isChromiumMacMake()) {
+    if (isDarwin() && !isChromiumAndroid() && !isChromiumMacMake() && !isChromiumNinja()) {
         # Mac build - builds the root xcode project.
         $result = buildXCodeProject("Source/WebKit/chromium/All", $clean, "-configuration", configuration(), @options);
     } elsif (isCygwin() || isWindows()) {
         # Windows build - builds the root visual studio solution.
         $result = buildChromiumVisualStudioProject("Source/WebKit/chromium/All.sln", $clean);
+    } elsif (isChromiumNinja()) {
+        $result = buildChromiumNinja("all", $clean, @options);
     } elsif (isLinux() || isChromiumAndroid() || isChromiumMacMake()) {
         # Linux build - build using make.
         $result = buildChromiumMakefile("all", $clean, @options);