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();
43 my $svgExperimentalSupport = 0;
44 my $svgAnimationSupport = $svgExperimentalSupport;
45 my $svgFiltersSupport = $svgExperimentalSupport;
46 my $svgForeignObjectSupport = $svgExperimentalSupport;
47 my $svgUseSupport = 1;
48 my $svgFontsSupport = 1;
49 my $svgAsImageSupport = 1;
52 my $coverageSupport = 0;
53 my $videoSupport = isOSX() || isCygwin(); # Enable by default on OSX and Windows
57 my $programName = basename($0);
59 Usage: $programName [options] [options to pass to build system]
60 --help Show this help message
61 --[no-]svg Toggle SVG support (default: $svgSupport)
62 --[no-]svg-experimental Toggle SVG experimental features support (default: $svgExperimentalSupport,
64 --[no-]svg-animation Toggle SVG animation support (default: $svgAnimationSupport, implies SVG Support)
65 --[no-]svg-filters Toggle SVG filters support (default: $svgFiltersSupport, implies SVG Support)
66 --[no-]svg-foreign-object Toggle SVG forgeing object support (default: $svgForeignObjectSupport, implies SVG Support)
67 --[no-]svg-fonts Toggle SVG fonts support (default: $svgFontsSupport, implies SVG Support)
68 --[no-]svg-as-image Toggle SVG as Image support (default: $svgAsImageSupport, implies SVG Support)
69 --[no-]svg-use Toggle SVG use element support (default: $svgUseSupport, implies SVG Support)
70 --[no-]xpath Toggle XPath support (default: $xpathSupport)
71 --[no-]xslt Toggle XSLT support (default: $xsltSupport)
72 --[no-]video Toggle Video support (default: $videoSupport)
73 --[no-]coverage Toggle code coverage support (default: $coverageSupport)
76 GetOptions('svg!' => \$svgSupport,
77 'svg-experimental!' => \$svgExperimentalSupport,
78 'svg-animation!' => \$svgAnimationSupport,
79 'svg-filters!' => \$svgFiltersSupport,
80 'svg-foreign-object!' => \$svgForeignObjectSupport,
81 'svg-fonts!' => \$svgFontsSupport,
82 'svg-as-image!' => \$svgAsImageSupport,
83 'svg-use!' => \$svgUseSupport,
84 'xpath!' => \$xpathSupport,
85 'xslt!' => \$xsltSupport,
86 'video!' => \$videoSupport,
87 'coverage!' => \$coverageSupport,
96 $svgExperimentalSupport = 0 unless $svgSupport;
97 $svgAnimationSupport = 0 unless $svgSupport;
98 $svgFiltersSupport = 0 unless $svgSupport;
99 $svgForeignObjectSupport = 0 unless $svgSupport;
100 $svgFontsSupport = 0 unless $svgSupport;
101 $svgAsImageSupport = 0 unless $svgSupport;
102 $svgUseSupport = 0 unless $svgSupport;
104 if ($svgExperimentalSupport) {
105 $svgAnimationSupport = 1;
106 $svgFiltersSupport = 1;
107 $svgForeignObjectSupport = 1;
108 $svgFontsSupport = 1;
109 $svgAsImageSupport = 1;
113 checkRequiredSystemConfig();
117 # FIXME: Migrate build-wxwebkit commands into build-webkit.
120 $ENV{"WEBKITOUTPUTDIR"} = productDir();
122 if ($_ eq "wxgc" || $_ eq "wxpython") {
127 push(@opts, "clean");
129 system "WebKitTools/wx/build-wxwebkit @opts";
134 my $productDir = productDir();
135 my @options = XcodeOptions();
136 my @overrideFeatureDefinesOption = ();
139 push(@options, "-alltargets");
140 push(@options, "clean");
143 push @overrideFeatureDefinesOption, "ENABLE_DATABASE";
144 push @overrideFeatureDefinesOption, "ENABLE_ICONDATABASE";
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";
176 # Copy library and header from WebKitLibraries to a findable place in the product directory.
177 my $srcLib = "WebKitLibraries/libWebKitSystemInterfaceTiger.a";
178 my $lib = "$productDir/libWebKitSystemInterfaceTiger.a";
179 if (!-e $lib || -M $lib > -M $srcLib) {
180 print "Updating $lib\n";
181 system "ditto", $srcLib, $lib;
182 system "ranlib", $lib;
185 $srcLib = "WebKitLibraries/libWebKitSystemInterfaceLeopard.a";
186 $lib = "$productDir/libWebKitSystemInterfaceLeopard.a";
187 if (!-e $lib || -M $lib > -M $srcLib) {
188 print "Updating $lib\n";
189 system "ditto", $srcLib, $lib;
190 system "ranlib", $lib;
193 my $srcHeader = "WebKitLibraries/WebKitSystemInterface.h";
194 my $header = "$productDir/usr/local/include/WebKitSystemInterface.h";
195 if (!-e $header || -M $header > -M $srcHeader) {
196 print "Updating $header\n";
197 system "mkdir", "-p", "$productDir/usr/local/include";
198 system "ditto", $srcHeader, $header;
201 $srcLib = "WebKitLibraries/libWebCoreSQLite3.a";
202 $lib = "$productDir/libWebCoreSQLite3.a";
203 if (!-e $lib || -M $lib > -M $srcLib) {
204 print "Updating $lib\n";
205 system "ditto", $srcLib, $lib;
206 system "ranlib", $lib;
209 my $srcHeaderDir = "WebKitLibraries/WebCoreSQLite3";
210 my $headerDir = "$productDir/WebCoreSQLite3";
211 if (!-e $headerDir || -M $headerDir > -M $srcHeaderDir) {
212 print "Updating $headerDir\n";
213 system "ditto", $srcHeaderDir, $headerDir;
217 if (isGtk() && isDarwin() && !$ENV{QMAKESPEC}) {
218 # The qmake from Trolltech's binary "QT for Mac" distribution tries to
219 # create xcode projects, not Makefiles
220 $ENV{QMAKESPEC} = "macx-g++";
224 # Copy WebKitSupportLibrary to the correct location in WebKitLibraries so it can be found.
225 # Will fail if WebKitSupportLibrary.zip is not in source root.
226 (system("perl WebKitTools/Scripts/update-webkit-support-libs") == 0) or die;
229 # Force re-link of existing libraries if different than expected
230 removeLibraryDependingOnSVG("WebCore", $svgSupport);
232 # Build, and abort if the build fails.
233 for my $dir (@projects) {
237 if ($dir ne "WebKit") {
242 $result = buildQMakeGtkProject($dir, $clean);
244 if ($dir ne "WebKit") {
248 $result = buildQMakeQtProject($dir, $clean);
250 $result = system "xcodebuild", "-project", "$dir.xcodeproj", @options, $overrideFeatureDefinesString, @coverageSupportOption, @ARGV;
251 } elsif (isCygwin()) {
252 if ($dir eq "WebKit") {
253 $result = buildVisualStudioProject("win/WebKit.vcproj/WebKit.sln", $clean);
257 if (exitStatus($result)) {
259 print "\n\n===== BUILD FAILED ======\n\n";
260 my $scriptDir = relativeScriptsDir();
261 print "Please ensure you have run $scriptDir/update-webkit to install depenedencies.\n\n";
262 my $baseProductDir = baseProductDir();
263 print "You can view build errors by checking the BuildLog.htm files located at:\n$baseProductDir/obj/<project>/<config>.\n";
265 exit exitStatus($result);
270 # Don't report the "WebKit is now built" message after a clean operation.
273 # Write out congratulations message.
275 my $launcherPath = launcherPath();
276 my $launcherName = launcherName();
279 print "===========================================================\n";
280 print " WebKit is now built. To run $launcherName with this newly-built\n";
281 print " code, use the \"$launcherPath\" script.\n";
283 print "\n NOTE: WebKit has been built with SVG support enabled.\n";
284 print " $launcherName will have SVG viewing capabilities.\n";
286 if ($svgAnimationSupport or $svgFiltersSupport or $svgForeignObjectSupport or $svgFontsSupport or $svgAsImageSupport or $svgUseSupport) {
287 print "\n NOTE: WebKit has been built with experimental SVG features enabled.\n";
288 print " Your build supports: \n";
289 print " * Basic SVG animation.\n" if $svgAnimationSupport;
290 print " * SVG filters.\n" if $svgFiltersSupport;
291 print " * SVG foreign object.\n" if $svgForeignObjectSupport;
292 print " * SVG fonts.\n" if $svgFontsSupport;
293 print " * SVG as image.\n" if $svgAsImageSupport;
294 print " * SVG <use> support.\n" if $svgUseSupport;
296 print "===========================================================\n";