WebKitTools/Scripts/build-webkit
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 #!/usr/bin/perl -w
       
     2 
       
     3 # Copyright (C) 2005, 2006 Apple Inc. All rights reserved.
       
     4 # Copyright (C) 2009 Google Inc. All rights reserved.
       
     5 #
       
     6 # Redistribution and use in source and binary forms, with or without
       
     7 # modification, are permitted provided that the following conditions
       
     8 # are met:
       
     9 #
       
    10 # 1.  Redistributions of source code must retain the above copyright
       
    11 #     notice, this list of conditions and the following disclaimer. 
       
    12 # 2.  Redistributions in binary form must reproduce the above copyright
       
    13 #     notice, this list of conditions and the following disclaimer in the
       
    14 #     documentation and/or other materials provided with the distribution. 
       
    15 # 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
       
    16 #     its contributors may be used to endorse or promote products derived
       
    17 #     from this software without specific prior written permission. 
       
    18 #
       
    19 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
       
    20 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
    21 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
       
    22 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
       
    23 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
       
    24 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
       
    25 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
       
    26 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
    27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
       
    28 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    29 
       
    30 # Build script wrapper for the WebKit Open Source Project.
       
    31 
       
    32 use strict;
       
    33 use File::Basename;
       
    34 use File::Find;
       
    35 use File::Spec;
       
    36 use FindBin;
       
    37 use Getopt::Long qw(:config pass_through);
       
    38 use lib $FindBin::Bin;
       
    39 use webkitdirs;
       
    40 use webkitperl::features;
       
    41 use POSIX;
       
    42 
       
    43 sub formatBuildTime($);
       
    44 sub writeCongrats();
       
    45 
       
    46 my $originalWorkingDirectory = getcwd();
       
    47 chdirWebKit();
       
    48 
       
    49 my $showHelp = 0;
       
    50 my $clean = 0;
       
    51 my $minimal = 0;
       
    52 my $installHeaders;
       
    53 my $installLibs;
       
    54 my $prefixPath;
       
    55 my $makeArgs;
       
    56 my $startTime = time();
       
    57 
       
    58 my ($linkPrefetchSupport, $threeDCanvasSupport, $threeDRenderingSupport, $channelMessagingSupport, $clientBasedGeolocationSupport, $databaseSupport, $datagridSupport, $datalistSupport,
       
    59     $domStorageSupport, $eventsourceSupport, $filtersSupport, $geolocationSupport, $iconDatabaseSupport, $imageResizerSupport, $indexedDatabaseSupport, $inputSpeechSupport,
       
    60     $javaScriptDebuggerSupport, $mathmlSupport, $offlineWebApplicationSupport, $rubySupport, $systemMallocSupport, $sandboxSupport, $sharedWorkersSupport,
       
    61     $svgSupport, $svgAnimationSupport, $svgAsImageSupport, $svgDOMObjCBindingsSupport, $svgFontsSupport,
       
    62     $svgForeignObjectSupport, $svgUseSupport, $videoSupport, $webSocketsSupport, $webTimingSupport, $wmlSupport, $wcssSupport, $xhtmlmpSupport, $workersSupport,
       
    63     $xpathSupport, $xsltSupport, $coverageSupport, $notificationsSupport, $blobSliceSupport, $tiledBackingStoreSupport,
       
    64     $fileReaderSupport, $fileWriterSupport, $directoryUploadSupport);
       
    65 
       
    66 my @features = (
       
    67     { option => "link-prefetch", desc => "Toggle pre fetching support",
       
    68       define => "ENABLE_LINK_PREFETCH", default => 0, value => \$linkPrefetchSupport },
       
    69 
       
    70     { option => "3d-canvas", desc => "Toggle 3D canvas support",
       
    71       define => "ENABLE_3D_CANVAS", default => (isAppleMacWebKit() && !isTiger() && !isLeopard()), value => \$threeDCanvasSupport },
       
    72 
       
    73     { option => "3d-rendering", desc => "Toggle 3D rendering support",
       
    74       define => "ENABLE_3D_RENDERING", default => (isAppleMacWebKit() && !isTiger()), value => \$threeDRenderingSupport },
       
    75 
       
    76     { option => "blob-slice", desc => "Toggle Blob.slice support",
       
    77       define => "ENABLE_BLOB_SLICE", default => (isAppleMacWebKit()), value => \$blobSliceSupport },
       
    78 
       
    79     { option => "channel-messaging", desc => "Toggle MessageChannel and MessagePort support",
       
    80       define => "ENABLE_CHANNEL_MESSAGING", default => 1, value => \$channelMessagingSupport },
       
    81 
       
    82     { option => "client-based-geolocation", desc => "Toggle client-based Geolocation support",
       
    83       define => "ENABLE_CLIENT_BASED_GEOLOCATION", default => isAppleWebKit(), value => \$clientBasedGeolocationSupport },
       
    84 
       
    85     { option => "coverage", desc => "Toggle code coverage support",
       
    86       define => "", default => 0, value => \$coverageSupport },
       
    87 
       
    88     { option => "database", desc => "Toggle Database Support",
       
    89       define => "ENABLE_DATABASE", default => 1, value => \$databaseSupport },
       
    90 
       
    91     { option => "datagrid", desc => "Toggle Datagrid Support",
       
    92       define => "ENABLE_DATAGRID", default => 0, value => \$datagridSupport },
       
    93       
       
    94     { option => "datalist", desc => "Toggle HTML5 datalist support",
       
    95       define => "ENABLE_DATALIST", default => 1, value => \$datalistSupport },
       
    96           
       
    97     { option => "directory-upload", desc => "Toogle Directory upload support",
       
    98       define => "ENABLE_DIRECTORY_UPLOAD", default => 0, value => \$directoryUploadSupport },
       
    99 
       
   100     { option => "dom-storage", desc => "Toggle DOM Storage Support",
       
   101       define => "ENABLE_DOM_STORAGE", default => 1, value => \$domStorageSupport },
       
   102 
       
   103     { option => "eventsource", desc => "Toggle server-sent events support",
       
   104       define => "ENABLE_EVENTSOURCE", default => 1, value => \$eventsourceSupport },
       
   105 
       
   106     { option => "filters", desc => "Toggle Filters support",
       
   107       define => "ENABLE_FILTERS", default => (isAppleWebKit() || isGtk() || isQt()), value => \$filtersSupport },
       
   108 
       
   109     { option => "geolocation", desc => "Toggle Geolocation support",
       
   110       define => "ENABLE_GEOLOCATION", default => (isAppleWebKit() || isGtk()), value => \$geolocationSupport },
       
   111 
       
   112     { option => "icon-database", desc => "Toggle Icon database support",
       
   113       define => "ENABLE_ICONDATABASE", default => 1, value => \$iconDatabaseSupport },
       
   114       
       
   115     { option => "image-resizer", desc => "Toggle Image Resizer API support",
       
   116       define => "ENABLE_IMAGE_RESIZER", default => 0, value => \$imageResizerSupport },
       
   117 
       
   118     { option => "indexed-database", desc => "Toggle Indexed Database API support",
       
   119       define => "ENABLE_INDEXED_DATABASE", default => 0, value => \$indexedDatabaseSupport },
       
   120 
       
   121     { option => "input-speech", desc => "Speech Input API support",
       
   122       define => "ENABLE_INPUT_SPEECH", default => 0, value => \$inputSpeechSupport },
       
   123 
       
   124     { option => "javascript-debugger", desc => "Toggle JavaScript Debugger/Profiler support",
       
   125       define => "ENABLE_JAVASCRIPT_DEBUGGER", default => 1, value => \$javaScriptDebuggerSupport },
       
   126 
       
   127     { option => "mathml", desc => "Toggle MathML support",
       
   128       define => "ENABLE_MATHML", default => 0, value => \$mathmlSupport },
       
   129 
       
   130     { option => "notifications", desc => "Toggle Desktop Notifications Support",
       
   131       define => "ENABLE_NOTIFICATIONS", default => 0, value => \$notificationsSupport },
       
   132 
       
   133     { option => "offline-web-applications", desc => "Toggle Offline Web Application Support",
       
   134       define => "ENABLE_OFFLINE_WEB_APPLICATIONS", default => 1, value => \$offlineWebApplicationSupport },
       
   135 
       
   136     { option => "ruby", desc => "Toggle HTML5 Ruby support",
       
   137       define => "ENABLE_RUBY", default => 1, value => \$rubySupport },
       
   138 
       
   139     { option => "system-malloc", desc => "Toggle system allocator instead of TCmalloc",
       
   140       define => "USE_SYSTEM_MALLOC", default => 0, value => \$systemMallocSupport },
       
   141 
       
   142     { option => "sandbox", desc => "Toggle HTML5 Sandboxed iframe support",
       
   143       define => "ENABLE_SANDBOX", default => 1, value => \$sandboxSupport },
       
   144 
       
   145     { option => "shared-workers", desc => "Toggle SharedWorkers support",
       
   146       define => "ENABLE_SHARED_WORKERS", default => (isAppleWebKit() || isGtk()), value => \$sharedWorkersSupport },
       
   147 
       
   148     { option => "svg", desc => "Toggle SVG support",
       
   149       define => "ENABLE_SVG", default => 1, value => \$svgSupport },
       
   150 
       
   151     { option => "svg-animation", desc => "Toggle SVG animation support (implies SVG support)",
       
   152       define => "ENABLE_SVG_ANIMATION", default => 1, value => \$svgAnimationSupport },
       
   153 
       
   154     { option => "svg-as-image", desc => "Toggle SVG as Image support (implies SVG support)",
       
   155       define => "ENABLE_SVG_AS_IMAGE", default => 1, value => \$svgAsImageSupport },
       
   156 
       
   157     { option => "svg-dom-objc-bindings", desc => "Toggle SVG DOM Objective-C bindings support (implies SVG support)",
       
   158       define => "ENABLE_SVG_DOM_OBJC_BINDINGS", default => isAppleMacWebKit(), value => \$svgDOMObjCBindingsSupport },
       
   159 
       
   160     { option => "svg-fonts", desc => "Toggle SVG fonts support (imples SVG support)",
       
   161       define => "ENABLE_SVG_FONTS", default => 1, value => \$svgFontsSupport },
       
   162 
       
   163     { option => "svg-foreign-object", desc => "Toggle SVG foreign object support (implies SVG support)",
       
   164       define => "ENABLE_SVG_FOREIGN_OBJECT", default => 1, value => \$svgForeignObjectSupport },
       
   165 
       
   166     { option => "svg-use", desc => "Toggle SVG use element support (implies SVG support)",
       
   167       define => "ENABLE_SVG_USE", default => 1, value => \$svgUseSupport },
       
   168 
       
   169     { option => "tiled-backing-store", desc => "Toggle Tiled Backing Store support",
       
   170       define => "ENABLE_TILED_BACKING_STORE", default => isQt(), value => \$tiledBackingStoreSupport },
       
   171 
       
   172     { option => "video", desc => "Toggle Video support",
       
   173       define => "ENABLE_VIDEO", default => (isAppleWebKit() || isGtk()), value => \$videoSupport },
       
   174 
       
   175     { option => "web-sockets", desc => "Toggle Web Sockets support",
       
   176       define => "ENABLE_WEB_SOCKETS", default => 1, value=> \$webSocketsSupport },
       
   177 
       
   178     { option => "web-timing", desc => "Toggle Web Timing support",
       
   179       define => "ENABLE_WEB_TIMING", default => 0, value=> \$webTimingSupport },
       
   180 
       
   181     { option => "wml", desc => "Toggle WML support",
       
   182       define => "ENABLE_WML", default => 0, value => \$wmlSupport },
       
   183 
       
   184     { option => "xhtmlmp", desc => "Toggle XHTML-MP support",
       
   185       define => "ENABLE_XHTMLMP", default => 0, value => \$xhtmlmpSupport },
       
   186 
       
   187     { option => "wcss", desc => "Toggle WCSS support",
       
   188       define => "ENABLE_WCSS", default => 0, value => \$wcssSupport },
       
   189 
       
   190     { option => "workers", desc => "Toggle Web Workers support",
       
   191       define => "ENABLE_WORKERS", default => (isAppleWebKit() || isGtk()), value => \$workersSupport },
       
   192 
       
   193     { option => "xpath", desc => "Toggle XPath support",
       
   194       define => "ENABLE_XPATH", default => 1, value => \$xpathSupport },
       
   195 
       
   196     { option => "xslt", desc => "Toggle XSLT support",
       
   197       define => "ENABLE_XSLT", default => 1, value => \$xsltSupport },
       
   198 
       
   199     { option => "file-reader", desc => "Toggle FileReader support",
       
   200       define => "ENABLE_FILE_READER", default => isAppleWebKit(), value => \$fileReaderSupport },
       
   201 
       
   202     { option => "file-writer", desc => "Toggle FileWriter support",
       
   203       define => "ENABLE_FILE_WRITER", default => 0, value => \$fileWriterSupport },
       
   204 );
       
   205 
       
   206 # Update defaults from Qt's project file
       
   207 if (isQt()) {
       
   208     my %qtDefaults = qtFeatureDefaults();
       
   209     foreach (@features) {
       
   210         $_->{default} = $qtDefaults{$_->{define}} || 0;
       
   211     }
       
   212 }
       
   213 
       
   214 # Additional environment parameters
       
   215 push @ARGV, split(/ /, $ENV{'BUILD_WEBKIT_ARGS'}) if ($ENV{'BUILD_WEBKIT_ARGS'});
       
   216 
       
   217 # Initialize values from defaults
       
   218 foreach (@ARGV) {
       
   219     if ($_ eq '--minimal') {
       
   220         $minimal = 1;
       
   221         last;
       
   222     }
       
   223 }
       
   224 
       
   225 # Initialize values from defaults
       
   226 foreach (@features) {
       
   227     ${$_->{value}} = ($_->{default} && !$minimal) || 0;
       
   228 }
       
   229 
       
   230 $svgSupport = $svgSupport || $svgAnimationSupport || $svgAsImageSupport
       
   231     || $svgDOMObjCBindingsSupport || $svgFontsSupport
       
   232     || $svgForeignObjectSupport || $svgUseSupport;
       
   233 
       
   234 
       
   235 my $programName = basename($0);
       
   236 my $usage = <<EOF;
       
   237 Usage: $programName [options] [options to pass to build system]
       
   238   --help                            Show this help message
       
   239   --clean                           Cleanup the build directory
       
   240   --debug                           Compile in debug mode
       
   241   --cairo-win32                     Build using Cairo (rather than CoreGraphics) on Windows
       
   242   --chromium                        Build the Chromium port on Mac/Win/Linux
       
   243   --gtk                             Build the GTK+ port
       
   244   --qt                              Build the Qt port
       
   245   --inspector-frontend              Copy changes to the inspector front-end files to the build directory
       
   246 
       
   247   --install-headers=<path>          Set installation path for the headers (Qt only)
       
   248   --install-libs=<path>             Set installation path for the libraries (Qt only)
       
   249 
       
   250   --prefix=<path>                   Set installation prefix to the given path (Gtk only)
       
   251   --makeargs=<arguments>            Optional Makefile flags
       
   252 
       
   253   --minimal                         No optional features, unless explicitly enabled.
       
   254 
       
   255 EOF
       
   256 
       
   257 my %options = (
       
   258     'help' => \$showHelp,
       
   259     'clean' => \$clean,
       
   260     'install-headers=s' => \$installHeaders,
       
   261     'install-libs=s' => \$installLibs,
       
   262     'prefix=s' => \$prefixPath,
       
   263     'makeargs=s' => \$makeArgs,
       
   264     'minimal' => \$minimal,
       
   265 );
       
   266 
       
   267 # Build usage text and options list from features
       
   268 foreach (@features) {
       
   269     my $opt = sprintf("%-35s", "  --[no-]$_->{option}");
       
   270     $usage .= "$opt $_->{desc} (default: $_->{default})\n";
       
   271     $options{"$_->{option}!"} = $_->{value};
       
   272 }
       
   273 
       
   274 GetOptions(%options);
       
   275 
       
   276 if ($showHelp) {
       
   277    print STDERR $usage;
       
   278    exit 1;
       
   279 }
       
   280 
       
   281 checkRequiredSystemConfig();
       
   282 setConfiguration();
       
   283 
       
   284 my $productDir = productDir();
       
   285 
       
   286 # Remove 0 byte sized files from productDir after slave lost for Qt buildbots.
       
   287 File::Find::find(\&unlinkZeroFiles, $productDir) if isQt();
       
   288 
       
   289 sub unlinkZeroFiles ()
       
   290 {
       
   291     my $file = $File::Find::name;
       
   292     if (! -s $file) {
       
   293         unlink $file;
       
   294         print "0 byte sized file removed from build directory: $file\n";
       
   295     }
       
   296 }
       
   297 
       
   298 # Check that all the project directories are there.
       
   299 my @projects = ("JavaScriptCore", "WebCore", "WebKit");
       
   300 
       
   301 my @otherDirs = ("WebKitLibraries");
       
   302 for my $dir (@projects, @otherDirs) {
       
   303     if (! -d $dir) {
       
   304         die "Error: No $dir directory found. Please do a fresh checkout.\n";
       
   305     }
       
   306 }
       
   307 
       
   308 my @options = ();
       
   309 
       
   310 # enable autotool options accordingly
       
   311 if (isGtk()) {
       
   312     @options = @ARGV;
       
   313     foreach (@features) {
       
   314         push @options, autotoolsFlag(${$_->{value}}, $_->{option});
       
   315     }
       
   316 
       
   317     push @options, "--prefix=" . $prefixPath if defined($prefixPath);
       
   318     push @options, "--makeargs=" . $makeArgs if defined($makeArgs);
       
   319 } elsif (isAppleMacWebKit()) {
       
   320     push @options, XcodeOptions();
       
   321 
       
   322     sub option($$$)
       
   323     {
       
   324         my ($feature, $isEnabled, $defaultValue) = @_;
       
   325         return "" if $defaultValue == $isEnabled;
       
   326         return $feature . "=" . ($isEnabled ? $feature : " ");
       
   327     }
       
   328 
       
   329     foreach (@features) {
       
   330         if ($_->{option} eq "coverage") {
       
   331             push @options, XcodeCoverageSupportOptions() if $coverageSupport;
       
   332         } else {
       
   333             my $option = option($_->{define}, ${$_->{value}}, $_->{default});
       
   334             push @options, $option unless $option eq "";
       
   335         }
       
   336     }
       
   337 
       
   338     # Apple builds JavaScriptGlue, and only on the Mac.
       
   339     splice @projects, 1, 0, "JavaScriptGlue";
       
   340 
       
   341     # WebKit2 is only supported in SnowLeopard and later at present.
       
   342     push @projects, ("WebKit2", "WebKitTools/MiniBrowser") if osXVersion()->{"minor"} >= 6;
       
   343 
       
   344     # Copy library and header from WebKitLibraries to a findable place in the product directory.
       
   345     my @librariesToCopy = (
       
   346         "libWebKitSystemInterfaceTiger.a",
       
   347         "libWebKitSystemInterfaceLeopard.a",
       
   348         "libWebKitSystemInterfaceSnowLeopard.a",
       
   349         "libWebCoreSQLite3.a",
       
   350     );
       
   351     foreach my $libName (@librariesToCopy) {
       
   352         my $srcLib = "WebKitLibraries/" . $libName;
       
   353         my $lib = "$productDir/" . $libName;
       
   354         if (!-e $lib || -M $lib > -M $srcLib) {
       
   355             print "Updating $lib\n";
       
   356             system "ditto", $srcLib, $lib;
       
   357             system "ranlib", $lib;
       
   358         }
       
   359     }
       
   360 
       
   361     # FIXME: This code should be abstracted to not be copy/paste.
       
   362     my $srcHeader = "WebKitLibraries/WebKitSystemInterface.h";
       
   363     my $header = "$productDir/usr/local/include/WebKitSystemInterface.h";
       
   364     if (!-e $header || -M $header > -M $srcHeader) {
       
   365         print "Updating $header\n";
       
   366         system "mkdir", "-p", "$productDir/usr/local/include";
       
   367         system "ditto", $srcHeader, $header;
       
   368     }
       
   369 
       
   370     my $srcHeaderDir = "WebKitLibraries/WebCoreSQLite3";
       
   371     my $headerDir = "$productDir/WebCoreSQLite3";
       
   372     if (!-e $headerDir || -M $headerDir > -M $srcHeaderDir) {
       
   373         print "Updating $headerDir\n";
       
   374         system "ditto", $srcHeaderDir, $headerDir;
       
   375     }
       
   376 } elsif (isAppleWinWebKit()) {
       
   377     # Copy WebKitSupportLibrary to the correct location in WebKitLibraries so it can be found.
       
   378     # Will fail if WebKitSupportLibrary.zip is not in source root.
       
   379     (system("perl WebKitTools/Scripts/update-webkit-support-libs") == 0) or die;
       
   380 } elsif (isQt()) {
       
   381     @options = @ARGV;
       
   382     push @options, "--install-headers=" . $installHeaders if defined($installHeaders);
       
   383     push @options, "--install-libs=" . $installLibs if defined($installLibs);
       
   384     push @options, "--makeargs=" . $makeArgs if defined($makeArgs);
       
   385 
       
   386     foreach (@features) {
       
   387         push @options, "DEFINES+=$_->{define}=${$_->{value}}" if ${$_->{value}} != $_->{default};
       
   388     }
       
   389 
       
   390     if ($minimal) {
       
   391         push @options, "CONFIG+=minimal";
       
   392     }
       
   393 }
       
   394 
       
   395 # Force re-link of existing libraries if different than expected
       
   396 removeLibraryDependingOnFeature("WebCore", "SVG", $svgSupport);
       
   397 
       
   398 if (isInspectorFrontend()) {
       
   399     exit exitStatus(copyInspectorFrontendFiles());
       
   400 }
       
   401 
       
   402 if (isWx()) {
       
   403     downloadWafIfNeeded();
       
   404     push @projects, 'WebKitTools/DumpRenderTree';
       
   405     push @projects, 'WebKitTools/wx/browser';
       
   406     push @projects, 'WebKit/wx/bindings/python';
       
   407 }
       
   408 
       
   409 if (isChromium()) {
       
   410     @options = @ARGV;
       
   411     # Chromium doesn't build by project directories.
       
   412     @projects = ();
       
   413     my $result = buildChromium($clean, @options);
       
   414     exit exitStatus($result) if exitStatus($result);
       
   415 }
       
   416 
       
   417 # Build, and abort if the build fails.
       
   418 for my $dir (@projects) {
       
   419     chdir $dir or die;
       
   420     my $result = 0;
       
   421 
       
   422     # For Gtk and Qt the WebKit project builds all others
       
   423     if ((isGtk() || isQt()) && $dir ne "WebKit") {
       
   424         chdir ".." or die;
       
   425         next;
       
   426     }
       
   427 
       
   428     if (isGtk()) {
       
   429         $result = buildGtkProject($dir, $clean,  @options);
       
   430     } elsif (isQt()) {
       
   431         $result = buildQMakeQtProject($dir, $clean, @options);
       
   432     } elsif (isAppleMacWebKit()) {
       
   433         $dir = "MiniBrowser" if $dir eq "WebKitTools/MiniBrowser";
       
   434         $result = buildXCodeProject($dir, $clean, @options, @ARGV);
       
   435     } elsif (isAppleWinWebKit()) {
       
   436         if ($dir eq "WebKit") {
       
   437             $result = buildVisualStudioProject("win/WebKit.vcproj/WebKit.sln", $clean);
       
   438         }
       
   439     } elsif (isWx()) {
       
   440         @options = ();
       
   441         if (defined($makeArgs)) {
       
   442             @options = split(/ /, $makeArgs);
       
   443         }
       
   444         if ($dir eq "WebKit" && isWx()) {
       
   445             chdir 'wx' or die;
       
   446         }
       
   447             
       
   448         $result = buildWafProject($dir, $clean, @options);
       
   449     }
       
   450 
       
   451     if (exitStatus($result)) {
       
   452         if (isAppleWinWebKit()) {
       
   453             print "\n\n===== BUILD FAILED ======\n\n";
       
   454             my $scriptDir = relativeScriptsDir();
       
   455             print "Please ensure you have run $scriptDir/update-webkit to install dependencies.\n\n";
       
   456             my $baseProductDir = baseProductDir();
       
   457             print "You can view build errors by checking the BuildLog.htm files located at:\n$baseProductDir/obj/<project>/<config>.\n";
       
   458         }
       
   459         exit exitStatus($result);
       
   460     }
       
   461     chdirWebKit();
       
   462 }
       
   463 
       
   464 # Don't report the "WebKit is now built" message after a clean operation.
       
   465 exit if $clean;
       
   466 
       
   467 # Write out congratulations message.
       
   468 writeCongrats();
       
   469 
       
   470 exit 0;
       
   471 
       
   472 sub formatBuildTime($)
       
   473 {
       
   474     my ($buildTime) = @_;
       
   475 
       
   476     my $buildHours = int($buildTime / 3600);
       
   477     my $buildMins = int(($buildTime - $buildHours * 3600) / 60);
       
   478     my $buildSecs = $buildTime - $buildHours * 3600 - $buildMins * 60;
       
   479 
       
   480     if ($buildHours) {
       
   481         return sprintf("%dh:%02dm:%02ds", $buildHours, $buildMins, $buildSecs);
       
   482     }
       
   483     return sprintf("%02dm:%02ds", $buildMins, $buildSecs);
       
   484 }
       
   485 
       
   486 sub writeCongrats()
       
   487 {
       
   488     my $launcherPath = launcherPath();
       
   489     my $launcherName = launcherName();
       
   490     my $endTime = time();
       
   491     my $buildTime = formatBuildTime($endTime - $startTime);
       
   492 
       
   493     print "\n";
       
   494     print "===========================================================\n";
       
   495     print " WebKit is now built ($buildTime). \n";
       
   496     if (!isChromium()) {
       
   497         print " To run $launcherName with this newly-built code, use the\n";
       
   498         print " \"$launcherPath\" script.\n";
       
   499     }
       
   500     print "===========================================================\n";
       
   501 }