3 # Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
4 # Copyright (C) 2009 Google Inc. All rights reserved.
5 # Copyright (C) 2010 moiji-mobile.com All rights reserved.
6 # Copyright (C) 2011 Research In Motion Limited. All rights reserved.
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
17 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
18 # its contributors may be used to endorse or promote products derived
19 # from this software without specific prior written permission.
21 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
22 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
25 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 # Build script wrapper for the WebKit Open Source Project.
39 use Getopt::Long qw(:config pass_through);
40 use lib $FindBin::Bin;
42 use webkitperl::features;
45 sub cMakeArgsFromFeatures();
46 sub checkForJavaSDK();
47 sub formatBuildTime($);
50 my $originalWorkingDirectory = getcwd();
63 my $onlyWebKitProject = 0;
65 my $startTime = time();
68 $requestAnimationFrameSupport,
70 $threeDRenderingSupport,
71 $accelerated2dCanvasSupport,
74 $channelMessagingSupport,
75 $clientBasedGeolocationSupport,
78 $cssGridLayoutSupport,
82 $dataTransferItemsSupport,
84 $deviceOrientationSupport,
85 $directoryUploadSupport,
88 $fullscreenAPISupport,
93 $indexedDatabaseSupport,
96 $inputTypeDateSupport,
97 $inputTypeDatetimeSupport,
98 $inputTypeDatetimelocalSupport,
99 $inputTypeMonthSupport,
100 $inputTypeTimeSupport,
101 $inputTypeWeekSupport,
102 $javaScriptDebuggerSupport,
103 $linkPrefetchSupport,
106 $mediaStatisticsSupport,
111 $mutationObserversSupport,
112 $netscapePluginSupport,
113 $notificationsSupport,
114 $orientationEventsSupport,
115 $pageVisibilityApiSupport,
118 $registerProtocolHandlerSupport,
119 $sharedWorkersSupport,
122 $svgDOMObjCBindingsSupport,
124 $systemMallocSupport,
125 $tiledBackingStoreSupport,
127 $touchIconLoadingSupport,
130 $webInspectorSupport,
138 { option => "request-animation-frame", desc => "Toggle requestAnimationFrame support",
139 define => "ENABLE_REQUEST_ANIMATION_FRAME", default => (isAppleMacWebKit()), value => \$requestAnimationFrameSupport },
141 { option => "3d-canvas", desc => "Toggle 3D canvas (WebGL) support",
142 define => "ENABLE_WEBGL", default => (isAppleMacWebKit() && !isLeopard()), value => \$threeDCanvasSupport },
144 { option => "3d-rendering", desc => "Toggle 3D rendering support",
145 define => "ENABLE_3D_RENDERING", default => (isAppleMacWebKit() || isQt()), value => \$threeDRenderingSupport },
147 { option => "accelerated-2d-canvas", desc => "Toggle accelerated 2D canvas support",
148 define => "ENABLE_ACCELERATED_2D_CANVAS", default => 0, value => \$accelerated2dCanvasSupport },
150 { option => "animation-api", desc => "Toggle animation API support",
151 define => "ENABLE_ANIMATION_API", default => isBlackBerry(), value => \$animationAPISupport },
153 { option => "blob", desc => "Toggle Blob support",
154 define => "ENABLE_BLOB", default => (isAppleMacWebKit() || isGtk() || isChromium()), value => \$blobSupport },
156 { option => "channel-messaging", desc => "Toggle MessageChannel and MessagePort support",
157 define => "ENABLE_CHANNEL_MESSAGING", default => 1, value => \$channelMessagingSupport },
159 { option => "client-based-geolocation", desc => "Toggle client-based Geolocation support",
160 define => "ENABLE_CLIENT_BASED_GEOLOCATION", default => (isAppleWebKit() || isGtk() || isBlackBerry()), value => \$clientBasedGeolocationSupport },
162 { option => "css-filters", desc => "Toggle CSS Filters support",
163 define => "ENABLE_CSS_FILTERS", default => isAppleWebKit(), value => \$cssFiltersSupport },
165 { option => "css-grid-layout", desc => "Toggle CSS Grid Layout support",
166 define => "ENABLE_CSS_GRID_LAYOUT", default => 0, value => \$cssGridLayoutSupport },
168 { option => "css-shaders", desc => "Toggle CSS Shaders (within CSS Filters) support",
169 define => "ENABLE_CSS_SHADERS", default => isAppleWebKit(), value => \$cssShadersSupport },
171 { option => "coverage", desc => "Toggle code coverage support",
172 define => "", default => 0, value => \$coverageSupport },
174 { option => "sql-database", desc => "Toggle SQL Database Support",
175 define => "ENABLE_SQL_DATABASE", default => 1, value => \$sqlDatabaseSupport },
177 { option => "datalist", desc => "Toggle HTML5 datalist support",
178 define => "ENABLE_DATALIST", default => 1, value => \$datalistSupport },
180 { option => "data-transfer-items", desc => "Toggle HTML5 data transfer items support",
181 define => "ENABLE_DATA_TRANSFER_ITEMS", default => 0, value => \$dataTransferItemsSupport },
183 { option => "details", desc => "Toggle HTML5 details support",
184 define => "ENABLE_DETAILS", default => 1, value => \$detailsSupport },
186 { option => "device-orientation", desc => "Toggle DeviceOrientation support",
187 define => "ENABLE_DEVICE_ORIENTATION", default => isBlackBerry(), value => \$deviceOrientationSupport },
189 { option => "directory-upload", desc => "Toogle Directory upload support",
190 define => "ENABLE_DIRECTORY_UPLOAD", default => 0, value => \$directoryUploadSupport },
192 { option => "mutation-observers", desc => "Toggle DOM mutation observer support",
193 define => "ENABLE_MUTATION_OBSERVERS", default => 0, value => \$mutationObserversSupport },
195 { option => "file-system", desc => "Toggle FileSystem support",
196 define => "ENABLE_FILE_SYSTEM", default => 0, value => \$fileSystemSupport },
198 { option => "filters", desc => "Toggle SVG Filters support",
199 define => "ENABLE_FILTERS", default => (isAppleWebKit() || isGtk() || isQt() || isEfl() || isBlackBerry()), value => \$filtersSupport },
201 { option => "fullscreen-api", desc => "Toggle Fullscreen API support",
202 define => "ENABLE_FULLSCREEN_API", default => (isAppleMacWebKit() || isGtk()), value => \$fullscreenAPISupport },
204 { option => "gamepad", desc => "Toggle Gamepad support",
205 define => "ENABLE_GAMEPAD", default => 0, value => \$gamepadSupport },
207 { option => "geolocation", desc => "Toggle Geolocation support",
208 define => "ENABLE_GEOLOCATION", default => (isAppleWebKit() || isGtk() || isBlackBerry()), value => \$geolocationSupport },
210 { option => "icon-database", desc => "Toggle Icon database support",
211 define => "ENABLE_ICONDATABASE", default => 1, value => \$iconDatabaseSupport },
213 { option => "indexed-database", desc => "Toggle Indexed Database API support",
214 define => "ENABLE_INDEXED_DATABASE", default => 0, value => \$indexedDatabaseSupport },
216 { option => "input-color", desc => "Color Input support",
217 define => "ENABLE_INPUT_COLOR", default => isBlackBerry(), value => \$inputColorSupport },
219 { option => "input-speech", desc => "Speech Input API support",
220 define => "ENABLE_INPUT_SPEECH", default => 0, value => \$inputSpeechSupport },
222 { option => "input-type-date", desc => "Toggle date type <input> support",
223 define => "ENABLE_INPUT_TYPE_DATE", default => 0, value => \$inputTypeDateSupport },
225 { option => "input-type-datetime", desc => "Toggle datetime type <input> support",
226 define => "ENABLE_INPUT_TYPE_DATETIME", default => 0, value => \$inputTypeDatetimeSupport },
228 { option => "input-type-datetimelocal", desc => "Toggle datetime-local type <input> support",
229 define => "ENABLE_INPUT_TYPE_DATETIMELOCAL", default => 0, value => \$inputTypeDatetimelocalSupport },
231 { option => "input-type-month", desc => "Toggle month type <input> support",
232 define => "ENABLE_INPUT_TYPE_MONTH", default => 0, value => \$inputTypeMonthSupport },
234 { option => "input-type-time", desc => "Toggle time type <input> support",
235 define => "ENABLE_INPUT_TYPE_TIME", default => 0, value => \$inputTypeTimeSupport },
237 { option => "input-type-week", desc => "Toggle week type <input> support",
238 define => "ENABLE_INPUT_TYPE_WEEK", default => 0, value => \$inputTypeWeekSupport },
240 { option => "inspector", desc => "Toggle Web Inspector support",
241 define => "ENABLE_INSPECTOR", default => 1, value => \$webInspectorSupport },
243 { option => "javascript-debugger", desc => "Toggle JavaScript Debugger/Profiler support",
244 define => "ENABLE_JAVASCRIPT_DEBUGGER", default => 1, value => \$javaScriptDebuggerSupport },
246 { option => "link-prefetch", desc => "Toggle pre fetching support",
247 define => "ENABLE_LINK_PREFETCH", default => 0, value => \$linkPrefetchSupport },
249 { option => "mathml", desc => "Toggle MathML support",
250 define => "ENABLE_MATHML", default => 1, value => \$mathmlSupport },
252 { option => "media-source", desc => "Toggle Media Source support",
253 define => "ENABLE_MEDIA_SOURCE", default => 0, value => \$mediaSourceSupport },
255 { option => "media-statistics", desc => "Toggle Media Statistics support",
256 define => "ENABLE_MEDIA_STATISTICS", default => 0, value => \$mediaStatisticsSupport },
258 { option => "media-stream", desc => "Toggle Media Stream API support (implies Blob support, currently Chromium and GTK only)",
259 define => "ENABLE_MEDIA_STREAM", default => (isChromium() || isGtk()), value => \$mediaStreamSupport },
261 { option => "meter-tag", desc => "Meter Tag support",
262 define => "ENABLE_METER_TAG", default => !isAppleWinWebKit(), value => \$meterTagSupport },
264 { option => "mhtml", desc => "Toggle MHTML support",
265 define => "ENABLE_MHTML", default => 0, value => \$mhtmlSupport },
267 { option => "microdata", desc => "Toggle Microdata support",
268 define => "ENABLE_MICRODATA", default => 0, value => \$microdataSupport },
270 { option => "netscape-plugin", desc => "Netscape Plugin support",
271 define => "ENABLE_NETSCAPE_PLUGIN_API", default => !isEfl(), value => \$netscapePluginSupport },
273 { option => "notifications", desc => "Toggle Desktop Notifications Support",
274 define => "ENABLE_NOTIFICATIONS", default => isEfl(), value => \$notificationsSupport },
276 { option => "orientation-events", desc => "Toggle Orientation Events support",
277 define => "ENABLE_ORIENTATION_EVENTS", default => isBlackBerry(), value => \$orientationEventsSupport },
279 { option => "page-visibility-api", desc => "Page Visibility API support",
280 define => "ENABLE_PAGE_VISIBILITY_API", default => 0, value => \$pageVisibilityApiSupport },
282 { option => "progress-tag", desc => "Progress Tag support",
283 define => "ENABLE_PROGRESS_TAG", default => 1, value => \$progressTagSupport },
285 { option => "quota", desc => "Toggle Quota support",
286 define => "ENABLE_QUOTA", default => 0, value => \$quotaSupport },
288 { option => "register-protocol-handler", desc => "Register Protocol Handler support",
289 define => "ENABLE_REGISTER_PROTOCOL_HANDLER", default => 0, value => \$registerProtocolHandlerSupport },
291 { option => "system-malloc", desc => "Toggle system allocator instead of TCmalloc",
292 define => "USE_SYSTEM_MALLOC", default => 0, value => \$systemMallocSupport },
294 { option => "shared-workers", desc => "Toggle SharedWorkers support",
295 define => "ENABLE_SHARED_WORKERS", default => (isAppleWebKit() || isGtk() || isBlackBerry()), value => \$sharedWorkersSupport },
297 { option => "style-scoped", desc => "Toggle <style scoped> support",
298 define => "ENABLE_STYLE_SCOPED", default => 0, value => \$styleScopedSupport },
300 { option => "svg", desc => "Toggle SVG support",
301 define => "ENABLE_SVG", default => 1, value => \$svgSupport },
303 { option => "svg-dom-objc-bindings", desc => "Toggle SVG DOM Objective-C bindings support (implies SVG support)",
304 define => "ENABLE_SVG_DOM_OBJC_BINDINGS", default => isAppleMacWebKit(), value => \$svgDOMObjCBindingsSupport },
306 { option => "svg-fonts", desc => "Toggle SVG fonts support (imples SVG support)",
307 define => "ENABLE_SVG_FONTS", default => 1, value => \$svgFontsSupport },
309 { option => "tiled-backing-store", desc => "Toggle Tiled Backing Store support",
310 define => "WTF_USE_TILED_BACKING_STORE", default => isQt(), value => \$tiledBackingStoreSupport },
312 { option => "touch-events", desc => "Toggle Touch Events support",
313 define => "ENABLE_TOUCH_EVENTS", default => (isQt() || isBlackBerry()), value => \$touchEventsSupport },
315 { option => "touch-icon-loading", desc => "Toggle Touch Icon Loading Support",
316 define => "ENABLE_TOUCH_ICON_LOADING", default => 0, value => \$touchIconLoadingSupport },
318 { option => "video", desc => "Toggle Video support",
319 define => "ENABLE_VIDEO", default => (isAppleWebKit() || isGtk() || isBlackBerry()), value => \$videoSupport },
321 { option => "web-audio", desc => "Toggle Web Audio support",
322 define => "ENABLE_WEB_AUDIO", default => 0, value=> \$webAudioSupport },
324 { option => "web-sockets", desc => "Toggle Web Sockets support",
325 define => "ENABLE_WEB_SOCKETS", default => 1, value=> \$webSocketsSupport },
327 { option => "web-timing", desc => "Toggle Web Timing support",
328 define => "ENABLE_WEB_TIMING", default => 0, value=> \$webTimingSupport },
330 { option => "workers", desc => "Toggle Web Workers support",
331 define => "ENABLE_WORKERS", default => (isAppleWebKit() || isGtk() || isBlackBerry()), value => \$workersSupport },
333 { option => "xslt", desc => "Toggle XSLT support",
334 define => "ENABLE_XSLT", default => 1, value => \$xsltSupport },
337 # Update defaults from Qt's project file
339 # Take a sneek peek at the arguments, since we will need the qmake binary early
340 # on to do profile parsing. We also need to know if we're showing the help-text.
342 if (/^--qmake=(.*)/) {
343 setQmakeBinaryPath($1);
344 } elsif (/^--help$/) {
351 %qtDefaults = qtFeatureDefaults();
354 foreach (@features) {
355 $_->{default} = (%qtDefaults ? $qtDefaults{$_->{define}} || 0 : -1);
359 # Additional environment parameters
360 push @ARGV, split(/ /, $ENV{'BUILD_WEBKIT_ARGS'}) if ($ENV{'BUILD_WEBKIT_ARGS'});
362 # Initialize values from defaults
364 if ($_ eq '--minimal') {
366 } elsif ($_ eq '--v8') {
371 # Initialize values from defaults
372 foreach (@features) {
373 ${$_->{value}} = ($minimal ? 0 : $_->{default});
376 $svgSupport = $svgSupport || $svgDOMObjCBindingsSupport || $svgFontsSupport;
378 $blobSupport = $blobSupport || $mediaStreamSupport;
380 my $programName = basename($0);
382 Usage: $programName [options] [options to pass to build system]
383 --help Show this help message
384 --clean Cleanup the build directory
385 --debug Compile in debug mode
386 --gyp Use GYP-generated project files
387 --dsym Change debugging format to dwarf-with-dsym (Mac only)
389 --blackberry Build the BlackBerry port on Mac/Linux
390 --chromium Build the Chromium port on Mac/Win/Linux
391 --chromium-android Build the Chromium port on Android
392 --efl Build the EFL port
393 --gtk Build the GTK+ port
394 --qt Build the Qt port
395 --wincairo Build using Cairo (rather than CoreGraphics) on Windows
396 --wince Build the WinCE port
398 --inspector-frontend Copy changes to the inspector front-end files to the build directory
400 --install-headers=<path> Set installation path for the headers (Qt only)
401 --install-libs=<path> Set installation path for the libraries (Qt only)
402 --v8 Use V8 as JavaScript engine (Qt only)
404 --prefix=<path> Set installation prefix to the given path (Gtk/Efl/BlackBerry only)
405 --makeargs=<arguments> Optional Makefile flags
406 --qmakearg=<arguments> Optional qmake flags (Qt only, e.g. --qmakearg="CONFIG+=webkit2" to build WebKit2)
407 --cmakearg=<arguments> Optional CMake flags (e.g. --cmakearg="-DFOO=bar -DCMAKE_PREFIX_PATH=/usr/local")
409 --minimal No optional features, unless explicitly enabled
411 --only-webkit Build only the WebKit project
412 --no-webkit2 Omit WebKit2 code from the build
417 'help' => \$showHelp,
420 'install-headers=s' => \$installHeaders,
421 'install-libs=s' => \$installLibs,
422 'prefix=s' => \$prefixPath,
423 'makeargs=s' => \$makeArgs,
424 'cmakeargs=s' => \$cmakeArgs,
425 'minimal' => \$minimal,
427 'only-webkit' => \$onlyWebKitProject,
428 'no-webkit2' => \$noWebKit2,
431 # Build usage text and options list from features
432 foreach (@features) {
433 my $opt = sprintf("%-35s", " --[no-]$_->{option}");
434 $usage .= "$opt $_->{desc} (default: $_->{default})\n";
435 $options{"$_->{option}!"} = $_->{value};
438 GetOptions(%options);
445 checkRequiredSystemConfig();
448 my $productDir = productDir();
450 # Remove 0 byte sized files from productDir after slave lost for Qt buildbots.
451 File::Find::find(\&unlinkZeroFiles, $productDir) if (isQt() && -e $productDir);
453 sub unlinkZeroFiles()
455 my $file = $File::Find::name;
456 # Remove 0 size files, except .d files used for dependency tracking
457 if (! -s $file && $file !~ m/\.d$/) {
459 print "0 byte sized file removed from build directory: $file\n";
463 # Check that all the project directories are there.
464 my @projects = ("Source/JavaScriptCore", "Source/WebCore", "Source/WebKit");
466 for my $dir (@projects) {
468 die "Error: No $dir directory found. Please do a fresh checkout.\n";
472 if (!isQt() && !-d "WebKitLibraries") {
473 die "Error: No WebKitLibraries directory found. Please do a fresh checkout.\n";
476 # Generate the generate project files from .gyp files
478 system("perl", "Tools/Scripts/generate-project-files") == 0 or die "Failed to run generate-project-files";
483 # enable autotool options accordingly
486 foreach (@features) {
487 push @options, autotoolsFlag(${$_->{value}}, $_->{option});
490 push @options, "--prefix=" . $prefixPath if defined($prefixPath);
491 push @options, "--makeargs=" . $makeArgs if $makeArgs;
492 } elsif (isAppleMacWebKit()) {
494 push @options, XcodeOptions();
498 my ($feature, $isEnabled, $defaultValue) = @_;
499 return "" if $defaultValue == $isEnabled;
500 return $feature . "=" . ($isEnabled ? $feature : "");
503 foreach (@features) {
504 if ($_->{option} ne "coverage") {
505 my $option = option($_->{define}, ${$_->{value}}, $_->{default});
506 push @options, $option unless $option eq "";
510 # Apple builds JavaScriptGlue, and only on the Mac.
511 splice @projects, 1, 0, "Source/JavaScriptGlue";
513 # ANGLE must come before WebCore
514 splice @projects, 0, 0, "Source/ThirdParty/ANGLE";
516 # WebKit2 is only supported in SnowLeopard and later at present.
517 push @projects, ("Source/WebKit2", "Tools/MiniBrowser") if osXVersion()->{"minor"} >= 6 and !$noWebKit2;
519 # Copy library and header from WebKitLibraries to a findable place in the product directory.
520 my @librariesToCopy = (
521 "libWebKitSystemInterfaceLeopard.a",
522 "libWebKitSystemInterfaceSnowLeopard.a",
523 "libWebKitSystemInterfaceLion.a",
524 "libWebCoreSQLite3.a",
526 foreach my $libName (@librariesToCopy) {
527 my $srcLib = "WebKitLibraries/" . $libName;
528 my $lib = "$productDir/" . $libName;
529 if (!-e $lib || -M $lib > -M $srcLib) {
530 print "Updating $lib\n";
531 system "ditto", $srcLib, $lib;
532 system "ranlib", $lib;
536 # FIXME: This code should be abstracted to not be copy/paste.
537 my $srcHeader = "WebKitLibraries/WebKitSystemInterface.h";
538 my $header = "$productDir/usr/local/include/WebKitSystemInterface.h";
539 if (!-e $header || -M $header > -M $srcHeader) {
540 print "Updating $header\n";
541 system "mkdir", "-p", "$productDir/usr/local/include";
542 system "ditto", $srcHeader, $header;
545 my $srcHeaderDir = "WebKitLibraries/WebCoreSQLite3";
546 my $headerDir = "$productDir/WebCoreSQLite3";
547 if (!-e $headerDir || -M $headerDir > -M $srcHeaderDir) {
548 print "Updating $headerDir\n";
549 system "ditto", $srcHeaderDir, $headerDir;
551 } elsif (isWinCairo()) {
552 (system("perl Tools/Scripts/update-webkit-wincairo-libs") == 0) or die;
553 } elsif (isAppleWinWebKit()) {
554 # Copy WebKitSupportLibrary to the correct location in WebKitLibraries so it can be found.
555 # Will fail if WebKitSupportLibrary.zip is not in source root.
556 (system("perl Tools/Scripts/update-webkit-support-libs") == 0) or die;
558 push @options, "--install-headers=" . $installHeaders if defined($installHeaders);
559 push @options, "--install-libs=" . $installLibs if defined($installLibs);
560 push @options, "--makeargs=" . $makeArgs if $makeArgs;
561 push @options, "--qmakearg=CONFIG+=no_webkit2" if $noWebKit2;
563 if (checkForArgumentAndRemoveFromARGV("-2")) {
564 print "Note: WebKit2 is now built by default, you don't need to passs -2. Disable using --no-webkit2\n";
567 @options = (@ARGV, @options);
569 foreach (@features) {
570 push @options, "DEFINES+=$_->{define}=${$_->{value}}" if $_->{define} && ${$_->{value}} != $_->{default};
574 push @options, "CONFIG+=minimal";
578 push @options, "CONFIG+=v8";
582 # If asked to build just the WebKit project, overwrite the projects
583 # list after all of the port specific tweaks have been made to
584 # build options, etc.
585 @projects = ("Source/WebKit") if $onlyWebKitProject;
587 # Force re-link of existing libraries if different than expected
588 removeLibraryDependingOnFeature("WebCore", "SVG", $svgSupport);
590 if (isInspectorFrontend()) {
591 exit exitStatus(copyInspectorFrontendFiles());
595 $makeArgs .= " --port=wx";
597 downloadWafIfNeeded();
598 @options = split(/ /, $makeArgs);
600 my $result = buildWafProject('.', $clean, @options);
601 exit exitStatus($result) if exitStatus($result);
605 # Currently chromium does not honour the features passed to build-webkit.
606 # Until this is solved, we issue a warning about that.
607 foreach (@features) {
608 if (${$_->{value}} ne $_->{default}) {
610 print "===========================================================\n";
611 print " Chromium does not honor the features passed to build-webkit.\n";
612 print " The preferred way is to set up your overrides in ~/.gyp/include.gypi.\n";
613 print " See https://trac.webkit.org/wiki/Chromium#Buildingwithfeaturedefines\n";
614 print " on how to do that.\n";
615 print "===========================================================\n";
621 # Chromium doesn't build by project directories.
623 push @options, "--makeargs=" . $makeArgs if $makeArgs;
624 my $result = buildChromium($clean, @options);
625 exit exitStatus($result) if exitStatus($result);
629 # By default we build using all of the available CPUs.
630 $makeArgs .= ($makeArgs ? " " : "") . "-j" . numberOfCPUs() if $makeArgs !~ /-j\s*\d+/;
631 buildCMakeProjectOrExit($clean, "Efl", $prefixPath, $makeArgs, cMakeArgsFromFeatures(), $cmakeArgs);
635 buildCMakeProjectOrExit($clean, "WinCE", $prefixPath, $makeArgs, ("-DCMAKE_WINCE_SDK=\"STANDARDSDK_500 (ARMV4I)\"", cMakeArgsFromFeatures()), $cmakeArgs);
638 if (isBlackBerry()) {
639 my %archInfo = blackberryTargetArchitecture();
640 my $arch = $archInfo{"arch"};
641 my $cpu = $archInfo{"cpu"};
642 my $cpuDir = $archInfo{"cpuDir"};
643 my $buSuffix = $archInfo{"buSuffix"};
645 my @cmakeExtraOptions;
647 $cpu = $arch . "v7le";
648 push @cmakeExtraOptions, '-DTARGETING_PLAYBOOK=1';
651 my $stageDir = $ENV{"STAGE_DIR"};
652 my $stageLib = File::Spec->catdir($stageDir, $cpuDir, "lib");
653 my $stageUsrLib = File::Spec->catdir($stageDir, $cpuDir, "usr", "lib");
654 my $stageInc = File::Spec->catdir($stageDir, "usr", "include");
656 my $qnxHost = $ENV{"QNX_HOST"};
660 if ($ENV{"USE_ICECC"}) {
661 chomp($ccCommand = `which icecc`);
662 $cxxCommand = $ccCommand;
663 $numberOfJobs = 50; # 50 is the number we choose for internal development
665 $ccCommand = File::Spec->catfile($qnxHost, "usr", "bin", "qcc");
666 $cxxCommand = $ccCommand;
667 $numberOfJobs = numberOfCPUs();
669 $makeArgs .= ($makeArgs ? " " : "") . "-j" . $numberOfJobs if $makeArgs !~ /-j\s*\d+/;
671 if ($ENV{"CCWRAP"}) {
672 $ccCommand = $ENV{"CCWRAP"};
673 push @cmakeExtraOptions, "-DCMAKE_C_COMPILER_ARG1=qcc";
674 push @cmakeExtraOptions, "-DCMAKE_CXX_COMPILER_ARG1=qcc";
677 push @cmakeExtraOptions, "-DCMAKE_SKIP_RPATH='ON'" if isDarwin();
678 push @cmakeExtraOptions, "-DENABLE_DRT=1" if $ENV{"ENABLE_DRT"};
680 my @includeSystemDirectories;
681 push @includeSystemDirectories, File::Spec->catdir($stageInc, "grskia", "skia");
682 push @includeSystemDirectories, File::Spec->catdir($stageInc, "grskia");
683 push @includeSystemDirectories, File::Spec->catdir($stageInc, "harfbuzz");
684 push @includeSystemDirectories, File::Spec->catdir($stageInc, "imf");
685 push @includeSystemDirectories, $stageInc;
686 push @includeSystemDirectories, File::Spec->catdir($stageInc, "browser", "platform");
687 push @includeSystemDirectories, File::Spec->catdir($stageInc, "browser", "qsk");
690 push @cxxFlags, "-Wl,-rpath-link,$stageLib";
691 push @cxxFlags, "-Wl,-rpath-link," . File::Spec->catfile($stageUsrLib, "torch-webkit");
692 push @cxxFlags, "-Wl,-rpath-link,$stageUsrLib";
693 push @cxxFlags, "-L$stageLib";
694 push @cxxFlags, "-L$stageUsrLib";
696 if ($ENV{"PROFILE"}) {
697 push @cmakeExtraOptions, "-DPROFILING=1";
698 push @cxxFlags, "-p";
702 push @cmakeArgs, "-DPUBLIC_BUILD=0";
703 push @cmakeArgs, '-DCMAKE_SYSTEM_NAME="QNX"';
704 push @cmakeArgs, "-DCMAKE_SYSTEM_PROCESSOR=\"$cpuDir\"";
705 push @cmakeArgs, '-DCMAKE_SYSTEM_VERSION="1"';
706 push @cmakeArgs, "-DCMAKE_C_COMPILER=\"$ccCommand\"";
707 push @cmakeArgs, "-DCMAKE_CXX_COMPILER=\"$cxxCommand\"";
708 push @cmakeArgs, "-DCMAKE_C_FLAGS=\"-Vgcc_nto${cpu} -g @cxxFlags\"";
709 push @cmakeArgs, "-DCMAKE_CXX_FLAGS=\"-Vgcc_nto${cpu}_cpp-ne -g -lang-c++ @cxxFlags\"";
711 # We cannot use CMAKE_INCLUDE_PATH since this describes the search path for header files in user directories.
712 # And the QNX system headers are in user directories on the host OS (i.e. they aren't installed in the host OS's
713 # system header search path). So, we need to inform g++ that these user directories (@includeSystemDirectories)
714 # are to be taken as the host OS's system header directories when building our port.
716 # Also, we cannot use CMAKE_SYSTEM_INCLUDE_PATH since that will override the entire system header path.
717 # So, we define the additional system include paths in ADDITIONAL_SYSTEM_INCLUDE_PATH. This list will
718 # be processed in OptionsBlackBerry.cmake.
719 push @cmakeArgs, '-DADDITIONAL_SYSTEM_INCLUDE_PATH="' . join(';', @includeSystemDirectories) . '"';
721 # FIXME: Make this more general purpose such that we can pass a list of directories and files.
722 push @cmakeArgs, '-DTHIRD_PARTY_ICU_DIR="' . File::Spec->catdir($stageInc, "unicode") . '"';
723 push @cmakeArgs, '-DTHIRD_PARTY_UNICODE_FILE="' . File::Spec->catfile($stageInc, "unicode.h") . '"';
725 push @cmakeArgs, "-DCMAKE_LIBRARY_PATH=\"$stageLib;$stageUsrLib\"";
726 push @cmakeArgs, '-DCMAKE_AR="' . File::Spec->catfile($qnxHost, "usr", "bin", "nto${buSuffix}-ar") . '"';
727 push @cmakeArgs, '-DCMAKE_RANLIB="' . File::Spec->catfile($qnxHost, "usr", "bin", "nto${buSuffix}-ranlib") . '"';
728 push @cmakeArgs, '-DCMAKE_LD="'. File::Spec->catfile($qnxHost, "usr", "bin", "nto${buSuffix}-ld") . '"';
729 push @cmakeArgs, '-DCMAKE_LINKER="' . File::Spec->catfile($qnxHost, "usr", "bin", "nto${buSuffix}-ld") . '"';
730 push @cmakeArgs, "-DECLIPSE_CDT4_GENERATE_SOURCE_PROJECT=TRUE";
731 push @cmakeArgs, '-G"Eclipse CDT4 - Unix Makefiles"';
732 push @cmakeArgs, @cmakeExtraOptions;
734 $prefixPath = $stageDir unless $prefixPath;
736 buildCMakeProjectOrExit($clean, "BlackBerry", $prefixPath, $makeArgs, (@cmakeArgs, cMakeArgsFromFeatures()));
739 # Build, and abort if the build fails.
740 for my $dir (@projects) {
744 # For Gtk and Qt the WebKit project builds all others
745 if ((isGtk() || isQt()) && $dir ne "Source/WebKit") {
750 my $project = basename($dir);
752 $result = buildGtkProject($project, $clean, !$noWebKit2, @options);
754 #FIXME: $dir should probably be $project.
755 $result = buildQMakeQtProject($dir, $clean, @options);
756 } elsif (isAppleMacWebKit()) {
757 my @local_options = @options;
758 push @local_options, XcodeCoverageSupportOptions() if $coverageSupport && $project ne "ANGLE";
759 my $useGYPProject = $useGYP && ($project =~ "WebCore|JavaScriptCore|JavaScriptGlue");
760 my $projectPath = $useGYPProject ? "gyp/$project" : $project;
761 $result = buildXCodeProject($projectPath, $clean, @local_options, @ARGV);
762 } elsif (isAppleWinWebKit()) {
763 if ($project eq "WebKit") {
764 $result = buildVisualStudioProject("win/WebKit.vcproj/WebKit.sln", $clean);
767 # Various build* calls above may change the CWD.
770 if (exitStatus($result)) {
771 my $scriptDir = relativeScriptsDir();
772 if (usingVisualStudioExpress()) {
773 # Visual Studio Express is so lame it can't stdout build failures.
774 # So we find its logs and dump them to the console ourselves.
775 system(File::Spec->catfile($scriptDir, "print-vse-failure-logs"));
777 if (isAppleWinWebKit()) {
778 print "\n\n===== BUILD FAILED ======\n\n";
779 print "Please ensure you have run $scriptDir/update-webkit to install dependencies.\n\n";
780 my $baseProductDir = baseProductDir();
781 print "You can view build errors by checking the BuildLog.htm files located at:\n$baseProductDir/obj/<project>/<config>.\n";
783 exit exitStatus($result);
787 # Don't report the "WebKit is now built" message after a clean operation.
790 # Write out congratulations message.
795 sub cMakeArgsFromFeatures()
798 foreach (@features) {
799 my $featureName = $_->{define};
801 my $featureEnabled = ${$_->{value}} ? "ON" : "OFF";
802 push @args, "-D$featureName=$featureEnabled";
808 sub checkForJavaSDK()
810 my $jniHeader = "/System/Library/Frameworks/JavaVM.framework/Headers/jni.h";
814 print "\nCan't find required $jniHeader, build will fail.\n\n";
815 print "After installing \"Java for Mac OS X 10.6 Update 3\", the Java Developer Package is required to build WebKit.\n";
816 print "Please install the package from http://connect.apple.com (found under Downloads > Java).\n\n";
817 print "For more information, see:\n";
818 print "https://lists.webkit.org/pipermail/webkit-dev/2010-October/014867.html\n";
819 print "https://webkit.org/building/tools.html\n\n";
823 sub formatBuildTime($)
825 my ($buildTime) = @_;
827 my $buildHours = int($buildTime / 3600);
828 my $buildMins = int(($buildTime - $buildHours * 3600) / 60);
829 my $buildSecs = $buildTime - $buildHours * 3600 - $buildMins * 60;
832 return sprintf("%dh:%02dm:%02ds", $buildHours, $buildMins, $buildSecs);
834 return sprintf("%02dm:%02ds", $buildMins, $buildSecs);
839 my $launcherPath = launcherPath();
840 my $launcherName = launcherName();
841 my $endTime = time();
842 my $buildTime = formatBuildTime($endTime - $startTime);
845 print "===========================================================\n";
846 print " WebKit is now built ($buildTime). \n";
848 print " To run $launcherName with this newly-built code, use the\n";
849 print " \"$launcherPath\" script.\n";
851 print "===========================================================\n";