[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Thu Apr 8 00:58:51 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit f6fecb42e6ffd5bcb14d1785dc150fd635ce930a
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 8 22:45:52 2010 +0000

    2010-01-08  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Eric Seidel.
    
            Optimize the number of CPUs used for building Qt and Gtk
            https://bugs.webkit.org/show_bug.cgi?id=33394
    
            Instead of hardcoding the number 8, we should read the number of CPUs
            from the environment.
    
            * Scripts/webkitpy/executive.py:
            * Scripts/webkitpy/webkitport.py:
            * Scripts/webkitpy/webkitport_unittest.py:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53011 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index c2417e1..f68f4a6 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,17 @@
+2010-01-08  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        Optimize the number of CPUs used for building Qt and Gtk
+        https://bugs.webkit.org/show_bug.cgi?id=33394
+
+        Instead of hardcoding the number 8, we should read the number of CPUs
+        from the environment.
+
+        * Scripts/webkitpy/executive.py:
+        * Scripts/webkitpy/webkitport.py:
+        * Scripts/webkitpy/webkitport_unittest.py:
+
 2010-01-08  Chris Fleizach  <cfleizach at apple.com>
 
         Reviewed by Eric Seidel.
diff --git a/WebKitTools/Scripts/webkitpy/executive.py b/WebKitTools/Scripts/webkitpy/executive.py
index dd21489..74a39a3 100644
--- a/WebKitTools/Scripts/webkitpy/executive.py
+++ b/WebKitTools/Scripts/webkitpy/executive.py
@@ -98,6 +98,15 @@ class Executive(object):
         if exit_code:
             raise ScriptError(script_args=args, exit_code=exit_code, output=child_output)
 
+    @staticmethod
+    def cpu_count():
+        # This API exists only in Python 2.6 and higher.  :(
+        try:
+            import multiprocessing
+            return multiprocessing.cpu_count()
+        except (ImportError,NotImplementedError):
+            return 2 # This quantity is a lie but probably a reasonable guess for modern machines.
+
     # Error handlers do not need to be static methods once all callers are updated to use an Executive object.
     @staticmethod
     def default_error_handler(error):
diff --git a/WebKitTools/Scripts/webkitpy/webkitport.py b/WebKitTools/Scripts/webkitpy/webkitport.py
index b468c9d..fcde460 100644
--- a/WebKitTools/Scripts/webkitpy/webkitport.py
+++ b/WebKitTools/Scripts/webkitpy/webkitport.py
@@ -31,6 +31,8 @@
 import os
 
 from optparse import make_option
+from webkitpy.executive import Executive
+
 
 class WebKitPort(object):
     # We might need to pass scm into this function for scm.checkout_root
@@ -110,6 +112,7 @@ class GtkPort(WebKitPort):
     def build_webkit_command(cls, build_style=None):
         command = WebKitPort.build_webkit_command(build_style=build_style)
         command.append("--gtk")
+        command.append('--makeargs="-j%s"' % Executive.cpu_count())
         return command
 
     @classmethod
@@ -132,8 +135,7 @@ class QtPort(WebKitPort):
     def build_webkit_command(cls, build_style=None):
         command = WebKitPort.build_webkit_command(build_style=build_style)
         command.append("--qt")
-        # FIXME: We should probably detect the number of cores.
-        command.append('--makeargs="-j8"')
+        command.append('--makeargs="-j%s"' % Executive.cpu_count())
         return command
 
 
diff --git a/WebKitTools/Scripts/webkitpy/webkitport_unittest.py b/WebKitTools/Scripts/webkitpy/webkitport_unittest.py
index b699038..202234f 100644
--- a/WebKitTools/Scripts/webkitpy/webkitport_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/webkitport_unittest.py
@@ -29,8 +29,10 @@
 
 import unittest
 
+from webkitpy.executive import Executive
 from webkitpy.webkitport import WebKitPort, MacPort, GtkPort, QtPort, ChromiumPort
 
+
 class WebKitPortTest(unittest.TestCase):
     def test_mac_port(self):
         self.assertEquals(MacPort.name(), "Mac")
@@ -44,15 +46,15 @@ class WebKitPortTest(unittest.TestCase):
         self.assertEquals(GtkPort.name(), "Gtk")
         self.assertEquals(GtkPort.flag(), "--port=gtk")
         self.assertEquals(GtkPort.run_webkit_tests_command(), [WebKitPort.script_path("run-webkit-tests"), "--gtk"])
-        self.assertEquals(GtkPort.build_webkit_command(), [WebKitPort.script_path("build-webkit"), "--gtk"])
-        self.assertEquals(GtkPort.build_webkit_command(build_style="debug"), [WebKitPort.script_path("build-webkit"), "--debug", "--gtk"])
+        self.assertEquals(GtkPort.build_webkit_command(), [WebKitPort.script_path("build-webkit"), "--gtk", '--makeargs="-j%s"' % Executive.cpu_count()])
+        self.assertEquals(GtkPort.build_webkit_command(build_style="debug"), [WebKitPort.script_path("build-webkit"), "--debug", "--gtk", '--makeargs="-j%s"' % Executive.cpu_count()])
 
     def test_qt_port(self):
         self.assertEquals(QtPort.name(), "Qt")
         self.assertEquals(QtPort.flag(), "--port=qt")
         self.assertEquals(QtPort.run_webkit_tests_command(), [WebKitPort.script_path("run-webkit-tests")])
-        self.assertEquals(QtPort.build_webkit_command(), [WebKitPort.script_path("build-webkit"), "--qt", '--makeargs="-j8"'])
-        self.assertEquals(QtPort.build_webkit_command(build_style="debug"), [WebKitPort.script_path("build-webkit"), "--debug", "--qt", '--makeargs="-j8"'])
+        self.assertEquals(QtPort.build_webkit_command(), [WebKitPort.script_path("build-webkit"), "--qt", '--makeargs="-j%s"' % Executive.cpu_count()])
+        self.assertEquals(QtPort.build_webkit_command(build_style="debug"), [WebKitPort.script_path("build-webkit"), "--debug", "--qt", '--makeargs="-j%s"' % Executive.cpu_count()])
 
     def test_chromium_port(self):
         self.assertEquals(ChromiumPort.name(), "Chromium")

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list