1 # Copyright (C) 2009, Google Inc. All rights reserved. 2 # 3 # Redistribution and use in source and binary forms, with or without 4 # modification, are permitted provided that the following conditions are 5 # met: 6 # 7 # * Redistributions of source code must retain the above copyright 8 # notice, this list of conditions and the following disclaimer. 9 # * Redistributions in binary form must reproduce the above 10 # copyright notice, this list of conditions and the following disclaimer 11 # in the documentation and/or other materials provided with the 12 # distribution. 13 # * Neither the name of Google Inc. nor the names of its 14 # contributors may be used to endorse or promote products derived from 15 # this software without specific prior written permission. 16 # 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 # 29 # WebKit's Python module for understanding the various ports 30 31 import os 32 33 from optparse import make_option 34 from webkitpy.executive import Executive 35 36 37 class WebKitPort(object): 38 39 # We might need to pass scm into this function for scm.checkout_root 40 @classmethod 41 def script_path(cls, script_name): 42 return os.path.join("WebKitTools", "Scripts", script_name) 43 44 @staticmethod 45 def port(port_name): 46 ports = { 47 "chromium": ChromiumPort, 48 "gtk": GtkPort, 49 "mac": MacPort, 50 "qt": QtPort, 51 } 52 # FIXME: We should default to WinPort on Windows. 53 return ports.get(port_name, MacPort) 54 55 @classmethod 56 def name(cls): 57 raise NotImplementedError("subclasses must implement") 58 59 @classmethod 60 def flag(cls): 61 raise NotImplementedError("subclasses must implement") 62 63 @classmethod 64 def update_webkit_command(cls): 65 return [cls.script_path("update-webkit")] 66 67 @classmethod 68 def build_webkit_command(cls, build_style=None): 69 command = [cls.script_path("build-webkit")] 70 if build_style == "debug": 71 command.append("--debug") 72 if build_style == "release": 73 command.append("--release") 74 return command 75 76 @classmethod 77 def run_javascriptcore_tests_command(cls): 78 return [cls.script_path("run-javascriptcore-tests")] 79 80 @classmethod 81 def run_webkit_tests_command(cls): 82 return [cls.script_path("run-webkit-tests")] 83 84 @classmethod 85 def run_python_unittests_command(cls): 86 return [cls.script_path("test-webkitpy")] 87 88 @classmethod 89 def run_perl_unittests_command(cls): 90 return [cls.script_path("test-webkitperl")] 91 92 93 class MacPort(WebKitPort): 94 95 @classmethod 96 def name(cls): 97 return "Mac" 98 99 @classmethod 100 def flag(cls): 101 return "--port=mac" 102 103 104 class GtkPort(WebKitPort): 105 106 @classmethod 107 def name(cls): 108 return "Gtk" 109 110 @classmethod 111 def flag(cls): 112 return "--port=gtk" 113 114 @classmethod 115 def build_webkit_command(cls, build_style=None): 116 command = WebKitPort.build_webkit_command(build_style=build_style) 117 command.append("--gtk") 118 command.append('--makeargs="-j%s"' % Executive.cpu_count()) 119 return command 120 121 @classmethod 122 def run_webkit_tests_command(cls): 123 command = WebKitPort.run_webkit_tests_command() 124 command.append("--gtk") 125 return command 126 127 128 class QtPort(WebKitPort): 129 130 @classmethod 131 def name(cls): 132 return "Qt" 133 134 @classmethod 135 def flag(cls): 136 return "--port=qt" 137 138 @classmethod 139 def build_webkit_command(cls, build_style=None): 140 command = WebKitPort.build_webkit_command(build_style=build_style) 141 command.append("--qt") 142 command.append('--makeargs="-j%s"' % Executive.cpu_count()) 143 return command 144 145 146 class ChromiumPort(WebKitPort): 147 148 @classmethod 149 def name(cls): 150 return "Chromium" 151 152 @classmethod 153 def flag(cls): 154 return "--port=chromium" 155 156 @classmethod 157 def update_webkit_command(cls): 158 command = WebKitPort.update_webkit_command() 159 command.append("--chromium") 160 return command 161 162 @classmethod 163 def build_webkit_command(cls, build_style=None): 164 command = WebKitPort.build_webkit_command(build_style=build_style) 165 command.append("--chromium") 166 return command 167