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 # Simplified build script for Web Kit Open Source Project.
35 use Getopt::Long qw(:config pass_through);
36 use lib $FindBin::Bin;
40 my $originalWorkingDirectory = getcwd();
42 my $databaseSupport = 1;
43 my $icondatabaseSupport = 1;
45 my $svgExperimentalSupport = 0;
46 my $svgAnimationSupport = $svgExperimentalSupport;
47 my $svgFiltersSupport = $svgExperimentalSupport;
48 my $svgForeignObjectSupport = $svgExperimentalSupport;
49 my $svgUseSupport = 1;
50 my $svgFontsSupport = 1;
51 my $svgAsImageSupport = 1;
54 my $coverageSupport = 0;
55 my $videoSupport = isOSX() || isCygwin(); # Enable by default on OSX and Windows
59 my $programName = basename($0);
61 Usage: $programName [options] [options to pass to build system]
62 --help Show this help message
63 --[no-]database Toggle Database Support (default: $databaseSupport)
64 --[no-]icondatabase Toggle Icon database support (default: $icondatabaseSupport)
65 --[no-]svg Toggle SVG support (default: $svgSupport)
66 --[no-]svg-experimental Toggle SVG experimental features support (default: $svgExperimentalSupport,
68 --[no-]svg-animation Toggle SVG animation support (default: $svgAnimationSupport, implies SVG Support)
69 --[no-]svg-filters Toggle SVG filters support (default: $svgFiltersSupport, implies SVG Support)
70 --[no-]svg-foreign-object Toggle SVG forgeing object support (default: $svgForeignObjectSupport, implies SVG Support)
71 --[no-]svg-fonts Toggle SVG fonts support (default: $svgFontsSupport, implies SVG Support)
72 --[no-]svg-as-image Toggle SVG as Image support (default: $svgAsImageSupport, implies SVG Support)
73 --[no-]svg-use Toggle SVG use element support (default: $svgUseSupport, implies SVG Support)
74 --[no-]xpath Toggle XPath support (default: $xpathSupport)
75 --[no-]xslt Toggle XSLT support (default: $xsltSupport)
76 --[no-]video Toggle Video support (default: $videoSupport)
77 --[no-]coverage Toggle code coverage support (default: $coverageSupport)
80 GetOptions('database!' => \$databaseSupport,
81 'icondatabase!' => \$icondatabaseSupport,
82 'svg!' => \$svgSupport,
83 'svg-experimental!' => \$svgExperimentalSupport,
84 'svg-animation!' => \$svgAnimationSupport,
85 'svg-filters!' => \$svgFiltersSupport,
86 'svg-foreign-object!' => \$svgForeignObjectSupport,
87 'svg-fonts!' => \$svgFontsSupport,
88 'svg-as-image!' => \$svgAsImageSupport,
89 'svg-use!' => \$svgUseSupport,
90 'xpath!' => \$xpathSupport,
91 'xslt!' => \$xsltSupport,
92 'video!' => \$videoSupport,
93 'coverage!' => \$coverageSupport,
102 $svgExperimentalSupport = 0 unless $svgSupport;
103 $svgAnimationSupport = 0 unless $svgSupport;
104 $svgFiltersSupport = 0 unless $svgSupport;
105 $svgForeignObjectSupport = 0 unless $svgSupport;
106 $svgFontsSupport = 0 unless $svgSupport;
107 $svgAsImageSupport = 0 unless $svgSupport;
108 $svgUseSupport = 0 unless $svgSupport;
110 if ($svgExperimentalSupport) {
111 $svgAnimationSupport = 1;
112 $svgFiltersSupport = 1;
113 $svgForeignObjectSupport = 1;
114 $svgFontsSupport = 1;
115 $svgAsImageSupport = 1;
119 checkRequiredSystemConfig();
123 # FIXME: Migrate build-wxwebkit commands into build-webkit.
126 $ENV{"WEBKITOUTPUTDIR"} = productDir();
128 if ($_ eq "wxgc" || $_ eq "wxpython") {
133 push(@opts, "clean");
135 system "WebKitTools/wx/build-wxwebkit @opts";
140 my $productDir = productDir();
141 my @overrideFeatureDefinesOption = ();
143 push @overrideFeatureDefinesOption, "ENABLE_DATABASE" if $databaseSupport;
144 push @overrideFeatureDefinesOption, "ENABLE_ICONDATABASE" if $icondatabaseSupport;
145 push @overrideFeatureDefinesOption, "ENABLE_SVG" if $svgSupport;
146 push @overrideFeatureDefinesOption, "ENABLE_SVG_ANIMATION" if $svgAnimationSupport;
147 push @overrideFeatureDefinesOption, "ENABLE_SVG_FILTERS" if $svgFiltersSupport;
148 push @overrideFeatureDefinesOption, "ENABLE_SVG_FOREIGN_OBJECT" if $svgForeignObjectSupport;
149 push @overrideFeatureDefinesOption, "ENABLE_SVG_FONTS" if $svgFontsSupport;
150 push @overrideFeatureDefinesOption, "ENABLE_SVG_AS_IMAGE" if $svgAsImageSupport;
151 push @overrideFeatureDefinesOption, "ENABLE_SVG_USE" if $svgUseSupport;
152 push @overrideFeatureDefinesOption, "ENABLE_XPATH" if $xpathSupport;
153 push @overrideFeatureDefinesOption, "ENABLE_XSLT" if $xsltSupport;
154 push @overrideFeatureDefinesOption, "ENABLE_VIDEO" if $videoSupport;
155 my $overrideFeatureDefinesString = "FEATURE_DEFINES=" . join(" ", @overrideFeatureDefinesOption);
157 my @coverageSupportOption = ();
158 if ($coverageSupport) {
159 push @coverageSupportOption, "GCC_GENERATE_TEST_COVERAGE_FILES=YES";
160 push @coverageSupportOption, "GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES";
161 push @coverageSupportOption, "EXTRA_LINK= -ftest-coverage -fprofile-arcs";
162 push @coverageSupportOption, "OTHER_CFLAGS= -MD";
163 push @coverageSupportOption, "OTHER_LDFLAGS=\$(OTHER_LDFLAGS) -ftest-coverage -fprofile-arcs -framework AppKit";
166 # Check that all the project directories are there.
167 my @projects = ("JavaScriptCore", "JavaScriptGlue", "WebCore", "WebKit");
168 my @otherDirs = ("WebKitLibraries");
169 for my $dir (@projects, @otherDirs) {
171 die "Error: No $dir directory found. Please do a fresh checkout.\n";
177 if ($clean && isOSX()) {
178 push(@options, "-alltargets");
179 push(@options, "clean");
182 # enable autotool options accordingly
183 if ($ENV{WEBKITAUTOTOOLS}) {
184 push @options, autotoolsFlag($databaseSupport, "database");
185 push @options, autotoolsFlag($icondatabaseSupport, "icondatabase");
186 push @options, autotoolsFlag($svgSupport, "svg");
187 push @options, autotoolsFlag($svgAnimationSupport, "svg-animation");
188 push @options, autotoolsFlag($svgFiltersSupport, "svg-filters");
189 push @options, autotoolsFlag($svgForeignObjectSupport, "svg-foreign-object");
190 push @options, autotoolsFlag($svgFontsSupport, "svg-fonts");
191 push @options, autotoolsFlag($svgAsImageSupport, "svg-as-image");
192 push @options, autotoolsFlag($svgUseSupport, "svg-use-element");
193 push @options, autotoolsFlag($xpathSupport, "xpath");
194 push @options, autotoolsFlag($xsltSupport, "xslt");
195 push @options, autotoolsFlag($videoSupport, "video");
196 push @options, autotoolsFlag($coverageSupport, "coverage");
201 push(@options, XcodeOptions());
203 # Copy library and header from WebKitLibraries to a findable place in the product directory.
204 my $srcLib = "WebKitLibraries/libWebKitSystemInterfaceTiger.a";
205 my $lib = "$productDir/libWebKitSystemInterfaceTiger.a";
206 if (!-e $lib || -M $lib > -M $srcLib) {
207 print "Updating $lib\n";
208 system "ditto", $srcLib, $lib;
209 system "ranlib", $lib;
212 $srcLib = "WebKitLibraries/libWebKitSystemInterfaceLeopard.a";
213 $lib = "$productDir/libWebKitSystemInterfaceLeopard.a";
214 if (!-e $lib || -M $lib > -M $srcLib) {
215 print "Updating $lib\n";
216 system "ditto", $srcLib, $lib;
217 system "ranlib", $lib;
220 my $srcHeader = "WebKitLibraries/WebKitSystemInterface.h";
221 my $header = "$productDir/usr/local/include/WebKitSystemInterface.h";
222 if (!-e $header || -M $header > -M $srcHeader) {
223 print "Updating $header\n";
224 system "mkdir", "-p", "$productDir/usr/local/include";
225 system "ditto", $srcHeader, $header;
228 $srcLib = "WebKitLibraries/libWebCoreSQLite3.a";
229 $lib = "$productDir/libWebCoreSQLite3.a";
230 if (!-e $lib || -M $lib > -M $srcLib) {
231 print "Updating $lib\n";
232 system "ditto", $srcLib, $lib;
233 system "ranlib", $lib;
236 my $srcHeaderDir = "WebKitLibraries/WebCoreSQLite3";
237 my $headerDir = "$productDir/WebCoreSQLite3";
238 if (!-e $headerDir || -M $headerDir > -M $srcHeaderDir) {
239 print "Updating $headerDir\n";
240 system "ditto", $srcHeaderDir, $headerDir;
244 if (isGtk() && isDarwin() && !$ENV{WEBKITAUTOTOOLS} && !$ENV{QMAKESPEC}) {
245 # The qmake from Trolltech's binary "QT for Mac" distribution tries to
246 # create xcode projects, not Makefiles
247 $ENV{QMAKESPEC} = "macx-g++";
251 # Copy WebKitSupportLibrary to the correct location in WebKitLibraries so it can be found.
252 # Will fail if WebKitSupportLibrary.zip is not in source root.
253 (system("perl WebKitTools/Scripts/update-webkit-support-libs") == 0) or die;
256 # Force re-link of existing libraries if different than expected
257 removeLibraryDependingOnSVG("WebCore", $svgSupport);
259 # Build, and abort if the build fails.
260 for my $dir (@projects) {
265 if ($dir ne "WebKit") {
270 $result = buildGtkProject($dir, $clean, @options);
272 if ($dir ne "WebKit") {
276 $result = buildQMakeQtProject($dir, $clean);
278 $result = system "xcodebuild", "-project", "$dir.xcodeproj", @options, $overrideFeatureDefinesString, @coverageSupportOption, @ARGV;
279 } elsif (isCygwin()) {
280 if ($dir eq "WebKit") {
281 $result = buildVisualStudioProject("win/WebKit.vcproj/WebKit.sln", $clean);
285 if (exitStatus($result)) {
287 print "\n\n===== BUILD FAILED ======\n\n";
288 my $scriptDir = relativeScriptsDir();
289 print "Please ensure you have run $scriptDir/update-webkit to install depenedencies.\n\n";
290 my $baseProductDir = baseProductDir();
291 print "You can view build errors by checking the BuildLog.htm files located at:\n$baseProductDir/obj/<project>/<config>.\n";
293 exit exitStatus($result);
298 # Don't report the "WebKit is now built" message after a clean operation.
301 # Write out congratulations message.
303 my $launcherPath = launcherPath();
304 my $launcherName = launcherName();
307 print "===========================================================\n";
308 print " WebKit is now built. To run $launcherName with this newly-built\n";
309 print " code, use the \"$launcherPath\" script.\n";
311 print "\n NOTE: WebKit has been built with SVG support enabled.\n";
312 print " $launcherName will have SVG viewing capabilities.\n";
314 if ($svgAnimationSupport or $svgFiltersSupport or $svgForeignObjectSupport or $svgFontsSupport or $svgAsImageSupport or $svgUseSupport) {
315 print "\n NOTE: WebKit has been built with experimental SVG features enabled.\n";
316 print " Your build supports: \n";
317 print " * Basic SVG animation.\n" if $svgAnimationSupport;
318 print " * SVG filters.\n" if $svgFiltersSupport;
319 print " * SVG foreign object.\n" if $svgForeignObjectSupport;
320 print " * SVG fonts.\n" if $svgFontsSupport;
321 print " * SVG as image.\n" if $svgAsImageSupport;
322 print " * SVG <use> support.\n" if $svgUseSupport;
324 print "===========================================================\n";