3 # Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15 # its contributors may be used to endorse or promote products derived
16 # from this software without specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 # Build script wrapper for the WebKit Open Source Project.
35 use Getopt::Long qw(:config pass_through);
36 use lib $FindBin::Bin;
40 my $originalWorkingDirectory = getcwd();
42 my $channelMessagingSupport = 0;
43 my $databaseSupport = 1;
44 my $domStorageSupport = 1;
45 my $gnomeKeyringSupport = 0;
46 my $iconDatabaseSupport = 1;
47 my $offlineWebApplicationSupport = 1;
49 my $svgAnimationSupport = 1;
50 my $svgFiltersSupport = 0;
51 my $svgForeignObjectSupport = 1;
52 my $svgUseSupport = 1;
53 my $svgFontsSupport = 1;
54 my $svgAsImageSupport = 1;
58 my $coverageSupport = 0;
59 my $videoSupport = isAppleWebKit(); # Enable by default for Apple's builds
60 my $workersSupport = (isAppleWebKit() || isGtk()); # Enable by default for Apple's builds (mac/win) and Gtk+
61 my $geolocationSupport = (isAppleMacWebKit() && !isTiger() && !isLeopard());
64 my $buildUniversal = 0;
65 my $buildSixtyFourBit = 0;
66 my $threeDTransformsSupport = 0;
68 my $programName = basename($0);
70 Usage: $programName [options] [options to pass to build system]
71 --help Show this help message
72 --cairo-win32 Build using Cairo (rather than CoreGraphics) on Windows
73 --chromium Build the Chromium port on Mac/Win/Linux
74 --clean Cleanup the build directory
75 --gtk Build the GTK+ port
76 --universal Build 2-way universal (PPC and Intel 32-bit)
77 --64-bit Build 64-bit, combine with --universal to build 4-way universal
78 --[no-]3d-transforms Toggle 3D Transforms support (default: $threeDTransformsSupport)
79 --[no-]channel-messaging Toggle MessageChannel and MessagePort support (default: $channelMessagingSupport)
80 --[no-]offline-web-applications Toggle Offline Web Application Support (default : $offlineWebApplicationSupport)
81 --[no-]database Toggle Database Support (default: $databaseSupport)
82 --[no-]dom-storage Toggle DOM Storage Support (default: $domStorageSupport)
83 --[no-]gnomekeyring Toggle GNOME Keyring Support (GTK+ port only) (default: $gnomeKeyringSupport)
84 --[no-]icon-database Toggle Icon database support (default: $iconDatabaseSupport)
85 --[no-]svg Toggle SVG support (default: $svgSupport)
86 --[no-]svg-animation Toggle SVG animation support (default: $svgAnimationSupport, implies SVG Support)
87 --[no-]svg-filters Toggle SVG filters support (default: $svgFiltersSupport, implies SVG Support)
88 --[no-]svg-foreign-object Toggle SVG foreign object support (default: $svgForeignObjectSupport, implies SVG Support)
89 --[no-]svg-fonts Toggle SVG fonts support (default: $svgFontsSupport, implies SVG Support)
90 --[no-]svg-as-image Toggle SVG as Image support (default: $svgAsImageSupport, implies SVG Support)
91 --[no-]svg-use Toggle SVG use element support (default: $svgUseSupport, implies SVG Support)
92 --[no-]xpath Toggle XPath support (default: $xpathSupport)
93 --[no-]xslt Toggle XSLT support (default: $xsltSupport)
94 --[no-]wml Toggle WML support (default: $wmlSupport)
95 --[no-]video Toggle Video support (default: $videoSupport)
96 --[no-]workers Toggle Web Workers support (default: $workersSupport)
97 --[no-]geolocation Toggle Geolocation support (default: $geolocationSupport)
98 --[no-]coverage Toggle code coverage support (default: $coverageSupport)
102 '3d-transforms!' => \$threeDTransformsSupport,
103 'channel-messaging!' => \$channelMessagingSupport,
104 'database!' => \$databaseSupport,
105 'dom-storage!' => \$domStorageSupport,
106 'gnomekeyring!' => \$gnomeKeyringSupport,
107 'icon-database!' => \$iconDatabaseSupport,
108 'offline-web-applications!' => \$offlineWebApplicationSupport,
109 'svg!' => \$svgSupport,
110 'svg-animation!' => \$svgAnimationSupport,
111 'svg-filters!' => \$svgFiltersSupport,
112 'svg-foreign-object!' => \$svgForeignObjectSupport,
113 'svg-fonts!' => \$svgFontsSupport,
114 'svg-as-image!' => \$svgAsImageSupport,
115 'svg-use!' => \$svgUseSupport,
116 'xpath!' => \$xpathSupport,
117 'xslt!' => \$xsltSupport,
118 'wml!' => \$wmlSupport,
119 'video!' => \$videoSupport,
120 'workers!' => \$workersSupport,
121 'geolocation!' => \$geolocationSupport,
122 'coverage!' => \$coverageSupport,
123 'help' => \$showHelp,
124 'universal' => \$buildUniversal,
125 '64-bit' => \$buildSixtyFourBit,
133 checkRequiredSystemConfig();
138 $ENV{"WEBKITOUTPUTDIR"} = productDir();
140 my @opts = getWxArgs();
143 push(@opts, "clean");
145 system "WebKitTools/wx/build-wxwebkit @opts";
150 my $productDir = productDir();
151 my @overrideFeatureDefinesOption = ();
153 push @overrideFeatureDefinesOption, "ENABLE_3D_TRANSFORMS" if $threeDTransformsSupport;
154 push @overrideFeatureDefinesOption, "ENABLE_CHANNEL_MESSAGING" if $channelMessagingSupport;
155 push @overrideFeatureDefinesOption, "ENABLE_DATABASE" if $databaseSupport;
156 push @overrideFeatureDefinesOption, "ENABLE_DOM_STORAGE" if $domStorageSupport;
157 push @overrideFeatureDefinesOption, "ENABLE_ICONDATABASE" if $iconDatabaseSupport;
158 push @overrideFeatureDefinesOption, "ENABLE_OFFLINE_WEB_APPLICATIONS" if $offlineWebApplicationSupport;
159 push @overrideFeatureDefinesOption, "ENABLE_SVG" if $svgSupport;
160 push @overrideFeatureDefinesOption, "ENABLE_SVG_ANIMATION" if $svgAnimationSupport;
161 push @overrideFeatureDefinesOption, "ENABLE_SVG_AS_IMAGE" if $svgAsImageSupport;
162 push @overrideFeatureDefinesOption, "ENABLE_SVG_FILTERS" if $svgFiltersSupport;
163 push @overrideFeatureDefinesOption, "ENABLE_SVG_FONTS" if $svgFontsSupport;
164 push @overrideFeatureDefinesOption, "ENABLE_SVG_FOREIGN_OBJECT" if $svgForeignObjectSupport;
165 push @overrideFeatureDefinesOption, "ENABLE_SVG_USE" if $svgUseSupport;
166 push @overrideFeatureDefinesOption, "ENABLE_VIDEO" if $videoSupport;
167 push @overrideFeatureDefinesOption, "ENABLE_WORKERS" if $workersSupport;
168 push @overrideFeatureDefinesOption, "ENABLE_XPATH" if $xpathSupport;
169 push @overrideFeatureDefinesOption, "ENABLE_XSLT" if $xsltSupport;
170 push @overrideFeatureDefinesOption, "ENABLE_WML" if $wmlSupport;
171 push @overrideFeatureDefinesOption, "ENABLE_GEOLOCATION" if $geolocationSupport;
172 my $overrideFeatureDefinesString = "FEATURE_DEFINES=" . join(" ", @overrideFeatureDefinesOption);
174 my @coverageSupportOption = ($coverageSupport) ? XcodeCoverageSupportOptions() : ();
176 # Check that all the project directories are there.
177 my @projects = ("JavaScriptCore", "WebCore", "WebKit");
178 # Only Apple builds JavaScriptGlue, and only on the Mac
179 push @projects, "JavaScriptGlue" if isAppleMacWebKit();
181 my @otherDirs = ("WebKitLibraries");
182 for my $dir (@projects, @otherDirs) {
184 die "Error: No $dir directory found. Please do a fresh checkout.\n";
190 if ($buildSixtyFourBit && isAppleMacWebKit()) {
191 my $cpuVendor = `sysctl -n machdep.cpu.vendor`;
194 if ($buildUniversal) {
195 push(@options, "ARCHS=ppc ppc64 i386 x86_64");
196 } elsif ($cpuVendor eq "GenuineIntel") {
197 push(@options, "ARCHS=i386 x86_64");
199 push(@options, "ARCHS=ppc ppc64");
201 } elsif ($buildUniversal && isAppleMacWebKit()) {
202 push(@options, "ARCHS=ppc i386");
205 # enable autotool options accordingly
207 push @options, autotoolsFlag($databaseSupport, "database");
208 push @options, autotoolsFlag($domStorageSupport, "dom-storage");
209 push @options, autotoolsFlag($gnomeKeyringSupport, "gnomekeyring");
210 push @options, autotoolsFlag($iconDatabaseSupport, "icon-database");
211 push @options, autotoolsFlag($offlineWebApplicationSupport, "offline-web-applications");
212 push @options, autotoolsFlag($threeDTransformsSupport, "3D-transforms");
213 push @options, autotoolsFlag($channelMessagingSupport, "channel-messaging");
214 push @options, autotoolsFlag($svgSupport, "svg");
215 push @options, autotoolsFlag($svgAnimationSupport, "svg-animation");
216 push @options, autotoolsFlag($svgFiltersSupport, "svg-filters");
217 push @options, autotoolsFlag($svgForeignObjectSupport, "svg-foreign-object");
218 push @options, autotoolsFlag($svgFontsSupport, "svg-fonts");
219 push @options, autotoolsFlag($svgAsImageSupport, "svg-as-image");
220 push @options, autotoolsFlag($svgUseSupport, "svg-use-element");
221 push @options, autotoolsFlag($xpathSupport, "xpath");
222 push @options, autotoolsFlag($xsltSupport, "xslt");
223 push @options, autotoolsFlag($wmlSupport, "wml");
224 push @options, autotoolsFlag($videoSupport, "video");
225 push @options, autotoolsFlag($workersSupport, "web-workers");
226 push @options, autotoolsFlag($coverageSupport, "coverage");
229 if (isAppleMacWebKit()) {
231 push(@options, XcodeOptions());
233 # Copy library and header from WebKitLibraries to a findable place in the product directory.
234 my $srcLib = "WebKitLibraries/libWebKitSystemInterfaceTiger.a";
235 my $lib = "$productDir/libWebKitSystemInterfaceTiger.a";
236 if (!-e $lib || -M $lib > -M $srcLib) {
237 print "Updating $lib\n";
238 system "ditto", $srcLib, $lib;
239 system "ranlib", $lib;
242 $srcLib = "WebKitLibraries/libWebKitSystemInterfaceLeopard.a";
243 $lib = "$productDir/libWebKitSystemInterfaceLeopard.a";
244 if (!-e $lib || -M $lib > -M $srcLib) {
245 print "Updating $lib\n";
246 system "ditto", $srcLib, $lib;
247 system "ranlib", $lib;
250 my $srcHeader = "WebKitLibraries/WebKitSystemInterface.h";
251 my $header = "$productDir/usr/local/include/WebKitSystemInterface.h";
252 if (!-e $header || -M $header > -M $srcHeader) {
253 print "Updating $header\n";
254 system "mkdir", "-p", "$productDir/usr/local/include";
255 system "ditto", $srcHeader, $header;
258 $srcLib = "WebKitLibraries/libWebCoreSQLite3.a";
259 $lib = "$productDir/libWebCoreSQLite3.a";
260 if (!-e $lib || -M $lib > -M $srcLib) {
261 print "Updating $lib\n";
262 system "ditto", $srcLib, $lib;
263 system "ranlib", $lib;
266 my $srcHeaderDir = "WebKitLibraries/WebCoreSQLite3";
267 my $headerDir = "$productDir/WebCoreSQLite3";
268 if (!-e $headerDir || -M $headerDir > -M $srcHeaderDir) {
269 print "Updating $headerDir\n";
270 system "ditto", $srcHeaderDir, $headerDir;
274 if (isAppleWinWebKit()) {
275 # Copy WebKitSupportLibrary to the correct location in WebKitLibraries so it can be found.
276 # Will fail if WebKitSupportLibrary.zip is not in source root.
277 (system("perl WebKitTools/Scripts/update-webkit-support-libs") == 0) or die;
280 # Force re-link of existing libraries if different than expected
281 removeLibraryDependingOnSVG("WebCore", $svgSupport);
283 # Build, and abort if the build fails.
284 for my $dir (@projects) {
288 # For Gtk and Qt the WebKit project builds all others
289 if ((isGtk() || isQt()) && $dir ne "WebKit") {
295 $result = buildGtkProject($dir, $clean, @options);
297 $result = buildQMakeQtProject($dir, $clean, @ARGV);
298 } elsif (isAppleMacWebKit()) {
299 my @xcodeOptions = ();
300 push(@xcodeOptions, @options);
301 push(@xcodeOptions, $overrideFeatureDefinesString);
302 push(@xcodeOptions, @coverageSupportOption);
303 push(@xcodeOptions, @ARGV);
304 $result = buildXCodeProject($dir, $clean, @xcodeOptions);
305 } elsif (isAppleWinWebKit()) {
306 if ($dir eq "WebKit") {
307 $result = buildVisualStudioProject("win/WebKit.vcproj/WebKit.sln", $clean);
309 } elsif (isChromium()) {
310 $result = buildSconsProject($dir, $clean);
313 if (exitStatus($result)) {
314 if (isAppleWinWebKit()) {
315 print "\n\n===== BUILD FAILED ======\n\n";
316 my $scriptDir = relativeScriptsDir();
317 print "Please ensure you have run $scriptDir/update-webkit to install depenedencies.\n\n";
318 my $baseProductDir = baseProductDir();
319 print "You can view build errors by checking the BuildLog.htm files located at:\n$baseProductDir/obj/<project>/<config>.\n";
321 exit exitStatus($result);
326 # Don't report the "WebKit is now built" message after a clean operation.
329 # Write out congratulations message.
331 my $launcherPath = launcherPath();
332 my $launcherName = launcherName();
335 print "===========================================================\n";
336 print " WebKit is now built. To run $launcherName with this newly-built\n";
337 print " code, use the \"$launcherPath\" script.\n";
339 print "\n NOTE: WebKit has been built with SVG support enabled.\n";
340 print " $launcherName will have SVG viewing capabilities.\n";
342 if ($svgAnimationSupport or $svgFiltersSupport or $svgForeignObjectSupport or $svgFontsSupport or $svgAsImageSupport or $svgUseSupport) {
343 print " Your build supports the following (optional) SVG features: \n";
344 print " * Basic SVG animation.\n" if $svgAnimationSupport;
345 print " * SVG filters.\n" if $svgFiltersSupport;
346 print " * SVG foreign object.\n" if $svgForeignObjectSupport;
347 print " * SVG fonts.\n" if $svgFontsSupport;
348 print " * SVG as image.\n" if $svgAsImageSupport;
349 print " * SVG <use> support.\n" if $svgUseSupport;
351 print "===========================================================\n";