1 # Copyright (C) 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
2 # Copyright (C) 2009 Google Inc. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 # its contributors may be used to endorse or promote products derived
15 # from this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 # Module to share code to get to WebKit directories.
42 our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
45 @EXPORT = qw(&chdirWebKit &baseProductDir &productDir &XcodeOptions &XcodeOptionString &XcodeOptionStringNoConfig &passedConfiguration &setConfiguration &safariPath &checkFrameworks ¤tSVNRevision);
55 my @baseProductDirOption;
57 my $configurationForVisualStudio;
58 my $configurationProductDir;
60 my $currentSVNRevision;
64 my %qtFeatureDefaults;
70 my $isInspectorFrontend;
72 # Variables for Win32 support
77 my $willUseVCExpressWhenBuilding = 0;
79 # Defined in VCSUtils.
82 sub determineSourceDir
85 $sourceDir = $FindBin::Bin;
86 $sourceDir =~ s|/+$||; # Remove trailing '/' as we would die later
88 # walks up path checking each directory to see if it is the main WebKit project dir,
89 # defined by containing JavaScriptCore, WebCore, and WebKit
90 until ((-d "$sourceDir/JavaScriptCore" && -d "$sourceDir/WebCore" && -d "$sourceDir/WebKit") || (-d "$sourceDir/Internal" && -d "$sourceDir/OpenSource"))
92 if ($sourceDir !~ s|/[^/]+$||) {
93 die "Could not find top level webkit directory above source directory using FindBin.\n";
97 $sourceDir = "$sourceDir/OpenSource" if -d "$sourceDir/OpenSource";
100 sub currentPerlPath()
104 $thisPerl .= $Config{_exe} unless $thisPerl =~ m/$Config{_exe}$/i;
109 # used for scripts which are stored in a non-standard location
115 sub determineBaseProductDir
117 return if defined $baseProductDir;
118 determineSourceDir();
120 $baseProductDir = $ENV{"WEBKITOUTPUTDIR"};
122 if (!defined($baseProductDir) and isAppleMacWebKit()) {
123 # Silently remove ~/Library/Preferences/xcodebuild.plist which can
124 # cause build failure. The presence of
125 # ~/Library/Preferences/xcodebuild.plist can prevent xcodebuild from
126 # respecting global settings such as a custom build products directory
127 # (<rdar://problem/5585899>).
128 my $personalPlistFile = $ENV{HOME} . "/Library/Preferences/xcodebuild.plist";
129 if (-e $personalPlistFile) {
130 unlink($personalPlistFile) || die "Could not delete $personalPlistFile: $!";
133 open PRODUCT, "defaults read com.apple.Xcode PBXApplicationwideBuildSettings 2> " . File::Spec->devnull() . " |" or die;
134 $baseProductDir = join '', <PRODUCT>;
137 $baseProductDir = $1 if $baseProductDir =~ /SYMROOT\s*=\s*\"(.*?)\";/s;
138 undef $baseProductDir unless $baseProductDir =~ /^\//;
140 if (!defined($baseProductDir)) {
141 open PRODUCT, "defaults read com.apple.Xcode PBXProductDirectory 2> " . File::Spec->devnull() . " |" or die;
142 $baseProductDir = <PRODUCT>;
144 if ($baseProductDir) {
145 chomp $baseProductDir;
146 undef $baseProductDir unless $baseProductDir =~ /^\//;
149 } elsif (isSymbian()) {
150 # Shadow builds are not supported on Symbian
151 $baseProductDir = $sourceDir;
154 if (!defined($baseProductDir)) { # Port-spesific checks failed, use default
155 $baseProductDir = "$sourceDir/WebKitBuild";
158 if (isGit() && isGitBranchBuild()) {
159 my $branch = gitBranch();
160 $baseProductDir = "$baseProductDir/$branch";
163 if (isAppleMacWebKit()) {
164 $baseProductDir =~ s|^\Q$(SRCROOT)/..\E$|$sourceDir|;
165 $baseProductDir =~ s|^\Q$(SRCROOT)/../|$sourceDir/|;
166 $baseProductDir =~ s|^~/|$ENV{HOME}/|;
167 die "Can't handle Xcode product directory with a ~ in it.\n" if $baseProductDir =~ /~/;
168 die "Can't handle Xcode product directory with a variable in it.\n" if $baseProductDir =~ /\$/;
169 @baseProductDirOption = ("SYMROOT=$baseProductDir", "OBJROOT=$baseProductDir");
173 my $dosBuildPath = `cygpath --windows \"$baseProductDir\"`;
175 $ENV{"WEBKITOUTPUTDIR"} = $dosBuildPath;
178 if (isAppleWinWebKit()) {
179 my $unixBuildPath = `cygpath --unix \"$baseProductDir\"`;
180 chomp $unixBuildPath;
181 $baseProductDir = $unixBuildPath;
185 sub setBaseProductDir($)
187 ($baseProductDir) = @_;
190 sub determineConfiguration
192 return if defined $configuration;
193 determineBaseProductDir();
194 if (open CONFIGURATION, "$baseProductDir/Configuration") {
195 $configuration = <CONFIGURATION>;
198 if ($configuration) {
199 chomp $configuration;
200 # compatibility for people who have old Configuration files
201 $configuration = "Release" if $configuration eq "Deployment";
202 $configuration = "Debug" if $configuration eq "Development";
204 $configuration = "Release";
208 sub determineArchitecture
210 return if defined $architecture;
211 # make sure $architecture is defined for non-apple-mac builds
213 return unless isAppleMacWebKit();
215 determineBaseProductDir();
216 if (open ARCHITECTURE, "$baseProductDir/Architecture") {
217 $architecture = <ARCHITECTURE>;
223 if (isTiger() or isLeopard()) {
224 $architecture = `arch`;
226 my $supports64Bit = `sysctl -n hw.optional.x86_64`;
227 chomp $supports64Bit;
228 $architecture = $supports64Bit ? 'x86_64' : `arch`;
234 sub determineNumberOfCPUs
236 return if defined $numberOfCPUs;
238 # First try the nproc utility, if it exists. If we get no
239 # results fall back to just interpretting /proc directly.
240 chomp($numberOfCPUs = `nproc 2> /dev/null`);
241 if ($numberOfCPUs eq "") {
242 $numberOfCPUs = (grep /processor/, `cat /proc/cpuinfo`);
244 } elsif (isWindows() || isCygwin()) {
245 if (defined($ENV{NUMBER_OF_PROCESSORS})) {
246 $numberOfCPUs = $ENV{NUMBER_OF_PROCESSORS};
249 $numberOfCPUs = `ls /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor | wc -w`;
251 } elsif (isDarwin()) {
252 $numberOfCPUs = `sysctl -n hw.ncpu`;
258 my ($productDir) = @_;
260 $jscName .= "_debug" if (isCygwin() && ($configuration eq "Debug"));
261 $jscName .= ".exe" if (isWindows() || isCygwin());
262 return "$productDir/$jscName" if -e "$productDir/$jscName";
263 return "$productDir/JavaScriptCore.framework/Resources/$jscName";
266 sub argumentsForConfiguration()
268 determineConfiguration();
269 determineArchitecture();
272 push(@args, '--debug') if $configuration eq "Debug";
273 push(@args, '--release') if $configuration eq "Release";
274 push(@args, '--32-bit') if $architecture ne "x86_64";
275 push(@args, '--qt') if isQt();
276 push(@args, '--symbian') if isSymbian();
277 push(@args, '--gtk') if isGtk();
278 push(@args, '--efl') if isEfl();
279 push(@args, '--wx') if isWx();
280 push(@args, '--chromium') if isChromium();
281 push(@args, '--inspector-frontend') if isInspectorFrontend();
285 sub determineConfigurationForVisualStudio
287 return if defined $configurationForVisualStudio;
288 determineConfiguration();
289 $configurationForVisualStudio = $configuration;
290 return unless $configuration eq "Debug";
292 chomp(my $dir = `cygpath -ua '$ENV{WEBKITLIBRARIESDIR}'`);
293 $configurationForVisualStudio = "Debug_Internal" if -f "$dir/bin/CoreFoundation_debug.dll";
296 sub determineConfigurationProductDir
298 return if defined $configurationProductDir;
299 determineBaseProductDir();
300 determineConfiguration();
301 if (isAppleWinWebKit() && !isWx()) {
302 $configurationProductDir = "$baseProductDir/bin";
304 # [Gtk][Efl] We don't have Release/Debug configurations in straight
305 # autotool builds (non build-webkit). In this case and if
306 # WEBKITOUTPUTDIR exist, use that as our configuration dir. This will
307 # allows us to run run-webkit-tests without using build-webkit.
308 if ($ENV{"WEBKITOUTPUTDIR"} && (isGtk() || isEfl())) {
309 $configurationProductDir = "$baseProductDir";
311 $configurationProductDir = "$baseProductDir/$configuration";
316 sub setConfigurationProductDir($)
318 ($configurationProductDir) = @_;
321 sub determineCurrentSVNRevision
323 return if defined $currentSVNRevision;
324 determineSourceDir();
325 $currentSVNRevision = svnRevisionForDirectory($sourceDir);
326 return $currentSVNRevision;
332 determineSourceDir();
333 chdir $sourceDir or die;
338 determineBaseProductDir();
339 return $baseProductDir;
344 determineSourceDir();
350 determineConfigurationProductDir();
351 return $configurationProductDir;
356 my $productDir = productDir();
357 $productDir .= "/JavaScriptCore" if isQt();
358 $productDir .= "/$configuration" if (isQt() && isWindows());
359 $productDir .= "/Programs" if (isGtk() || isEfl());
366 determineConfiguration();
367 return $configuration;
370 sub configurationForVisualStudio()
372 determineConfigurationForVisualStudio();
373 return $configurationForVisualStudio;
376 sub currentSVNRevision
378 determineCurrentSVNRevision();
379 return $currentSVNRevision;
384 determineBaseProductDir();
385 determineConfiguration();
386 determineArchitecture();
387 return (@baseProductDirOption, "-configuration", $configuration, "ARCHS=$architecture");
390 sub XcodeOptionString
392 return join " ", XcodeOptions();
395 sub XcodeOptionStringNoConfig
397 return join " ", @baseProductDirOption;
400 sub XcodeCoverageSupportOptions()
402 my @coverageSupportOptions = ();
403 push @coverageSupportOptions, "GCC_GENERATE_TEST_COVERAGE_FILES=YES";
404 push @coverageSupportOptions, "GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES";
405 push @coverageSupportOptions, "EXTRA_LINK= \$(EXTRA_LINK) -ftest-coverage -fprofile-arcs";
406 push @coverageSupportOptions, "OTHER_CFLAGS= \$(OTHER_CFLAGS) -DCOVERAGE -MD";
407 push @coverageSupportOptions, "OTHER_LDFLAGS=\$(OTHER_LDFLAGS) -ftest-coverage -fprofile-arcs -lgcov";
408 return @coverageSupportOptions;
411 my $passedConfiguration;
412 my $searchedForPassedConfiguration;
413 sub determinePassedConfiguration
415 return if $searchedForPassedConfiguration;
416 $searchedForPassedConfiguration = 1;
418 my $isWinCairo = checkForArgumentAndRemoveFromARGV("--wincairo");
420 for my $i (0 .. $#ARGV) {
422 if ($opt =~ /^--debug$/i || $opt =~ /^--devel/i) {
423 splice(@ARGV, $i, 1);
424 $passedConfiguration = "Debug";
425 $passedConfiguration .= "_Cairo" if ($isWinCairo && isCygwin());
428 if ($opt =~ /^--release$/i || $opt =~ /^--deploy/i) {
429 splice(@ARGV, $i, 1);
430 $passedConfiguration = "Release";
431 $passedConfiguration .= "_Cairo" if ($isWinCairo && isCygwin());
434 if ($opt =~ /^--profil(e|ing)$/i) {
435 splice(@ARGV, $i, 1);
436 $passedConfiguration = "Profiling";
437 $passedConfiguration .= "_Cairo" if ($isWinCairo && isCygwin());
441 $passedConfiguration = undef;
444 sub passedConfiguration
446 determinePassedConfiguration();
447 return $passedConfiguration;
454 if (my $config = shift @_) {
455 $configuration = $config;
459 determinePassedConfiguration();
460 $configuration = $passedConfiguration if $passedConfiguration;
464 my $passedArchitecture;
465 my $searchedForPassedArchitecture;
466 sub determinePassedArchitecture
468 return if $searchedForPassedArchitecture;
469 $searchedForPassedArchitecture = 1;
471 for my $i (0 .. $#ARGV) {
473 if ($opt =~ /^--32-bit$/i) {
474 splice(@ARGV, $i, 1);
475 if (isAppleMacWebKit()) {
476 $passedArchitecture = `arch`;
477 chomp $passedArchitecture;
482 $passedArchitecture = undef;
485 sub passedArchitecture
487 determinePassedArchitecture();
488 return $passedArchitecture;
493 determineArchitecture();
494 return $architecture;
499 determineNumberOfCPUs();
500 return $numberOfCPUs;
505 if (my $arch = shift @_) {
506 $architecture = $arch;
510 determinePassedArchitecture();
511 $architecture = $passedArchitecture if $passedArchitecture;
515 sub safariPathFromSafariBundle
517 my ($safariBundle) = @_;
519 return "$safariBundle/Contents/MacOS/Safari" if isAppleMacWebKit();
520 return $safariBundle if isAppleWinWebKit();
523 sub installedSafariPath
527 if (isAppleMacWebKit()) {
528 $safariBundle = "/Applications/Safari.app";
529 } elsif (isAppleWinWebKit()) {
530 $safariBundle = `"$configurationProductDir/FindSafari.exe"`;
531 $safariBundle =~ s/[\r\n]+$//;
532 $safariBundle = `cygpath -u '$safariBundle'`;
533 $safariBundle =~ s/[\r\n]+$//;
534 $safariBundle .= "Safari.exe";
537 return safariPathFromSafariBundle($safariBundle);
543 # Use WEBKIT_SAFARI environment variable if present.
544 my $safariBundle = $ENV{WEBKIT_SAFARI};
545 if (!$safariBundle) {
546 determineConfigurationProductDir();
547 # Use Safari.app in product directory if present (good for Safari development team).
548 if (isAppleMacWebKit() && -d "$configurationProductDir/Safari.app") {
549 $safariBundle = "$configurationProductDir/Safari.app";
550 } elsif (isAppleWinWebKit()) {
551 my $path = "$configurationProductDir/Safari.exe";
552 my $debugPath = "$configurationProductDir/Safari_debug.exe";
554 if (configurationForVisualStudio() =~ /Debug/ && -x $debugPath) {
555 $safariBundle = $debugPath;
557 $safariBundle = $path;
560 if (!$safariBundle) {
561 return installedSafariPath();
564 my $safariPath = safariPathFromSafariBundle($safariBundle);
565 die "Can't find executable at $safariPath.\n" if isAppleMacWebKit() && !-x $safariPath;
569 sub builtDylibPathForName
571 my $libraryName = shift;
572 determineConfigurationProductDir();
574 return "$configurationProductDir/$libraryName";
577 $libraryName = "QtWebKit";
578 if (isDarwin() and -d "$configurationProductDir/lib/$libraryName.framework") {
579 return "$configurationProductDir/lib/$libraryName.framework/$libraryName";
580 } elsif (isWindows()) {
581 if (configuration() eq "Debug") {
582 # On Windows, there is a "d" suffix to the library name. See <http://trac.webkit.org/changeset/53924/>.
586 my $mkspec = `qmake -query QMAKE_MKSPECS`;
587 $mkspec =~ s/[\n|\r]$//g;
588 my $qtMajorVersion = retrieveQMakespecVar("$mkspec/qconfig.pri", "QT_MAJOR_VERSION");
589 if (not $qtMajorVersion) {
590 $qtMajorVersion = "";
592 return "$configurationProductDir/lib/$libraryName$qtMajorVersion.dll";
594 return "$configurationProductDir/lib/lib$libraryName.so";
598 return "$configurationProductDir/libwxwebkit.dylib";
601 my $libraryDir = "$configurationProductDir/$libraryName/../.libs/";
602 if (-e $libraryDir . "libwebkitgtk-3.0.so") {
603 return $libraryDir . "libwebkitgtk-3.0.so";
605 return $libraryDir . "libwebkitgtk-1.0.so";
608 return "$configurationProductDir/$libraryName/../.libs/libewebkit.so";
610 if (isAppleMacWebKit()) {
611 return "$configurationProductDir/$libraryName.framework/Versions/A/$libraryName";
613 if (isAppleWinWebKit()) {
614 if ($libraryName eq "JavaScriptCore") {
615 return "$baseProductDir/lib/$libraryName.lib";
617 return "$baseProductDir/$libraryName.intermediate/$configuration/$libraryName.intermediate/$libraryName.lib";
621 die "Unsupported platform, can't determine built library locations.\nTry `build-webkit --help` for more information.\n";
624 # Check to see that all the frameworks are built.
625 sub checkFrameworks # FIXME: This is a poor name since only the Mac calls built WebCore a Framework.
627 return if isCygwin();
628 my @frameworks = ("JavaScriptCore", "WebCore");
629 push(@frameworks, "WebKit") if isAppleMacWebKit(); # FIXME: This seems wrong, all ports should have a WebKit these days.
630 for my $framework (@frameworks) {
631 my $path = builtDylibPathForName($framework);
632 die "Can't find built framework at \"$path\".\n" unless -e $path;
636 sub isInspectorFrontend()
638 determineIsInspectorFrontend();
639 return $isInspectorFrontend;
642 sub determineIsInspectorFrontend()
644 return if defined($isInspectorFrontend);
645 $isInspectorFrontend = checkForArgumentAndRemoveFromARGV("--inspector-frontend");
656 determineIsSymbian();
660 sub qtFeatureDefaults()
662 determineQtFeatureDefaults();
663 return %qtFeatureDefaults;
669 my $devnull = File::Spec->devnull();
670 return `$command --version 2> $devnull`;
673 sub determineQtFeatureDefaults()
675 return if %qtFeatureDefaults;
676 die "ERROR: qmake missing but required to build WebKit.\n" if not commandExists("qmake");
677 my $originalCwd = getcwd();
678 chdir File::Spec->catfile(sourceDir(), "WebCore");
679 my $defaults = `qmake CONFIG+=compute_defaults 2>&1`;
682 while ($defaults =~ m/(\S+?)=(\S+?)/gi) {
683 $qtFeatureDefaults{$1}=$2;
687 sub checkForArgumentAndRemoveFromARGV
689 my $argToCheck = shift;
690 foreach my $opt (@ARGV) {
691 if ($opt =~ /^$argToCheck$/i ) {
692 @ARGV = grep(!/^$argToCheck$/i, @ARGV);
701 return if defined($isQt);
703 # Allow override in case QTDIR is not set.
704 if (checkForArgumentAndRemoveFromARGV("--qt")) {
709 # The presence of QTDIR only means Qt if --gtk or --wx or --efl are not on the command-line
710 if (isGtk() || isWx() || isEfl()) {
715 $isQt = defined($ENV{'QTDIR'});
718 sub determineIsSymbian()
720 return if defined($isSymbian);
722 if (checkForArgumentAndRemoveFromARGV("--symbian")) {
730 return if defined($isEfl);
731 $isEfl = checkForArgumentAndRemoveFromARGV("--efl");
748 return if defined($isGtk);
749 $isGtk = checkForArgumentAndRemoveFromARGV("--gtk");
760 return if defined($isWx);
761 $isWx = checkForArgumentAndRemoveFromARGV("--wx");
769 foreach my $opt (@ARGV) {
770 if ($opt =~ /^--wx-args/i ) {
771 @ARGV = grep(!/^--wx-args/i, @ARGV);
773 $rawWxArgs =~ s/--wx-args=//i;
776 @wxArgs = split(/,/, $rawWxArgs);
781 # Determine if this is debian, ubuntu, linspire, or something similar.
784 return -e "/etc/debian_version";
789 return -e "/etc/fedora-release";
794 determineIsChromium();
798 sub determineIsChromium()
800 return if defined($isChromium);
801 $isChromium = checkForArgumentAndRemoveFromARGV("--chromium");
806 return ($^O eq "cygwin") || 0;
809 sub determineWinVersion()
811 return if $winVersion;
818 my $versionString = `uname -s`;
819 $versionString =~ /(\d\.\d)/;
825 determineWinVersion();
831 return winVersion() eq "6.1";
836 return winVersion() eq "6.0";
841 return winVersion() eq "5.1";
846 return ($^O eq "darwin") || 0;
851 return ($^O eq "MSWin32") || 0;
856 return ($^O eq "msys") || 0;
861 return ($^O eq "linux") || 0;
866 return !(isQt() or isGtk() or isWx() or isChromium() or isEfl());
869 sub isAppleMacWebKit()
871 return isAppleWebKit() && isDarwin();
874 sub isAppleWinWebKit()
876 return isAppleWebKit() && isCygwin();
879 sub isPerianInstalled()
881 if (!isAppleWebKit()) {
885 if (-d "/Library/QuickTime/Perian.component") {
889 if (-d "$ENV{HOME}/Library/QuickTime/Perian.component") {
896 sub determineOSXVersion()
898 return if $osXVersion;
905 my $version = `sw_vers -productVersion`;
906 my @splitVersion = split(/\./, $version);
907 @splitVersion >= 2 or die "Invalid version $version";
909 "major" => $splitVersion[0],
910 "minor" => $splitVersion[1],
911 "subminor" => (defined($splitVersion[2]) ? $splitVersion[2] : 0),
917 determineOSXVersion();
923 return isDarwin() && osXVersion()->{"minor"} == 4;
928 return isDarwin() && osXVersion()->{"minor"} == 5;
933 return isDarwin() && osXVersion()->{"minor"} == 6;
938 return $ENV{'OS'} eq 'Windows_NT';
941 sub relativeScriptsDir()
943 my $scriptDir = File::Spec->catpath("", File::Spec->abs2rel(dirname($0), getcwd()), "");
944 if ($scriptDir eq "") {
952 my $relativeScriptsPath = relativeScriptsDir();
953 if (isGtk() || isQt() || isWx() || isEfl()) {
954 return "$relativeScriptsPath/run-launcher";
955 } elsif (isAppleWebKit()) {
956 return "$relativeScriptsPath/run-safari";
963 return "GtkLauncher";
965 return "QtTestBrowser";
968 } elsif (isAppleWebKit()) {
971 return "EWebLauncher";
975 sub checkRequiredSystemConfig
978 chomp(my $productVersion = `sw_vers -productVersion`);
979 if ($productVersion lt "10.4") {
980 print "*************************************************************\n";
981 print "Mac OS X Version 10.4.0 or later is required to build WebKit.\n";
982 print "You have " . $productVersion . ", thus the build will most likely fail.\n";
983 print "*************************************************************\n";
985 my $xcodeVersion = `xcodebuild -version`;
986 if ($xcodeVersion !~ /DevToolsCore-(\d+)/ || $1 < 747) {
987 print "*************************************************************\n";
988 print "Xcode Version 2.3 or later is required to build WebKit.\n";
989 print "You have an earlier version of Xcode, thus the build will\n";
990 print "most likely fail. The latest Xcode is available from the web:\n";
991 print "http://developer.apple.com/tools/xcode\n";
992 print "*************************************************************\n";
994 } elsif (isGtk() or isQt() or isWx() or isEfl()) {
995 my @cmds = qw(flex bison gperf);
997 foreach my $cmd (@cmds) {
998 push @missing, $cmd if not commandExists($cmd);
1002 my $list = join ", ", @missing;
1003 die "ERROR: $list missing but required to build WebKit.\n";
1006 # Win32 and other platforms may want to check for minimum config
1009 sub determineWindowsSourceDir()
1011 return if $windowsSourceDir;
1012 my $sourceDir = sourceDir();
1013 chomp($windowsSourceDir = `cygpath -w '$sourceDir'`);
1016 sub windowsSourceDir()
1018 determineWindowsSourceDir();
1019 return $windowsSourceDir;
1022 sub windowsLibrariesDir()
1024 return windowsSourceDir() . "\\WebKitLibraries\\win";
1027 sub windowsOutputDir()
1029 return windowsSourceDir() . "\\WebKitBuild";
1032 sub setupAppleWinEnv()
1034 return unless isAppleWinWebKit();
1036 if (isWindowsNT()) {
1037 my $restartNeeded = 0;
1038 my %variablesToSet = ();
1040 # Setting the environment variable 'CYGWIN' to 'tty' makes cygwin enable extra support (i.e., termios)
1041 # for UNIX-like ttys in the Windows console
1042 $variablesToSet{CYGWIN} = "tty" unless $ENV{CYGWIN};
1044 # Those environment variables must be set to be able to build inside Visual Studio.
1045 $variablesToSet{WEBKITLIBRARIESDIR} = windowsLibrariesDir() unless $ENV{WEBKITLIBRARIESDIR};
1046 $variablesToSet{WEBKITOUTPUTDIR} = windowsOutputDir() unless $ENV{WEBKITOUTPUTDIR};
1048 foreach my $variable (keys %variablesToSet) {
1049 print "Setting the Environment Variable '" . $variable . "' to '" . $variablesToSet{$variable} . "'\n\n";
1050 system qw(regtool -s set), '\\HKEY_CURRENT_USER\\Environment\\' . $variable, $variablesToSet{$variable};
1051 $restartNeeded ||= $variable eq "WEBKITLIBRARIESDIR" || $variable eq "WEBKITOUTPUTDIR";
1054 if ($restartNeeded) {
1055 print "Please restart your computer before attempting to build inside Visual Studio.\n\n";
1058 if (!$ENV{'WEBKITLIBRARIESDIR'}) {
1059 print "Warning: You must set the 'WebKitLibrariesDir' environment variable\n";
1060 print " to be able build WebKit from within Visual Studio.\n";
1061 print " Make sure that 'WebKitLibrariesDir' points to the\n";
1062 print " 'WebKitLibraries/win' directory, not the 'WebKitLibraries/' directory.\n\n";
1064 if (!$ENV{'WEBKITOUTPUTDIR'}) {
1065 print "Warning: You must set the 'WebKitOutputDir' environment variable\n";
1066 print " to be able build WebKit from within Visual Studio.\n\n";
1071 sub setupCygwinEnv()
1073 return if !isCygwin();
1074 return if $vcBuildPath;
1077 my $programFilesPath = $ENV{'PROGRAMFILES'} || "C:\\Program Files";
1078 if ($ENV{'VSINSTALLDIR'}) {
1079 $vsInstallDir = $ENV{'VSINSTALLDIR'};
1081 $vsInstallDir = "$programFilesPath/Microsoft Visual Studio 8";
1083 $vsInstallDir = `cygpath "$vsInstallDir"`;
1084 chomp $vsInstallDir;
1085 $vcBuildPath = "$vsInstallDir/Common7/IDE/devenv.com";
1086 if (-e $vcBuildPath) {
1087 # Visual Studio is installed; we can use pdevenv to build.
1088 $vcBuildPath = File::Spec->catfile(sourceDir(), qw(WebKitTools Scripts pdevenv));
1090 # Visual Studio not found, try VC++ Express
1091 $vcBuildPath = "$vsInstallDir/Common7/IDE/VCExpress.exe";
1092 if (! -e $vcBuildPath) {
1093 print "*************************************************************\n";
1094 print "Cannot find '$vcBuildPath'\n";
1095 print "Please execute the file 'vcvars32.bat' from\n";
1096 print "'$programFilesPath\\Microsoft Visual Studio 8\\VC\\bin\\'\n";
1097 print "to setup the necessary environment variables.\n";
1098 print "*************************************************************\n";
1101 $willUseVCExpressWhenBuilding = 1;
1104 my $qtSDKPath = "$programFilesPath/QuickTime SDK";
1105 if (0 && ! -e $qtSDKPath) {
1106 print "*************************************************************\n";
1107 print "Cannot find '$qtSDKPath'\n";
1108 print "Please download the QuickTime SDK for Windows from\n";
1109 print "http://developer.apple.com/quicktime/download/\n";
1110 print "*************************************************************\n";
1114 chomp($ENV{'WEBKITLIBRARIESDIR'} = `cygpath -wa "$sourceDir/WebKitLibraries/win"`) unless $ENV{'WEBKITLIBRARIESDIR'};
1116 $windowsTmpPath = `cygpath -w /tmp`;
1117 chomp $windowsTmpPath;
1118 print "Building results into: ", baseProductDir(), "\n";
1119 print "WEBKITOUTPUTDIR is set to: ", $ENV{"WEBKITOUTPUTDIR"}, "\n";
1120 print "WEBKITLIBRARIESDIR is set to: ", $ENV{"WEBKITLIBRARIESDIR"}, "\n";
1123 sub dieIfWindowsPlatformSDKNotInstalled
1125 my $registry32Path = "/proc/registry/";
1126 my $registry64Path = "/proc/registry64/";
1127 my $windowsPlatformSDKRegistryEntry = "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MicrosoftSDK/InstalledSDKs/D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1";
1129 # FIXME: It would be better to detect whether we are using 32- or 64-bit Windows
1130 # and only check the appropriate entry. But for now we just blindly check both.
1131 return if (-e $registry32Path . $windowsPlatformSDKRegistryEntry) || (-e $registry64Path . $windowsPlatformSDKRegistryEntry);
1133 print "*************************************************************\n";
1134 print "Cannot find registry entry '$windowsPlatformSDKRegistryEntry'.\n";
1135 print "Please download and install the Microsoft Windows Server 2003 R2\n";
1136 print "Platform SDK from <http://www.microsoft.com/downloads/details.aspx?\n";
1137 print "familyid=0baf2b35-c656-4969-ace8-e4c0c0716adb&displaylang=en>.\n\n";
1138 print "Then follow step 2 in the Windows section of the \"Installing Developer\n";
1139 print "Tools\" instructions at <http://www.webkit.org/building/tools.html>.\n";
1140 print "*************************************************************\n";
1144 sub copyInspectorFrontendFiles
1146 my $productDir = productDir();
1147 my $sourceInspectorPath = sourceDir() . "/WebCore/inspector/front-end/";
1148 my $inspectorResourcesDirPath = $ENV{"WEBKITINSPECTORRESOURCESDIR"};
1150 if (!defined($inspectorResourcesDirPath)) {
1151 $inspectorResourcesDirPath = "";
1154 if (isAppleMacWebKit()) {
1155 $inspectorResourcesDirPath = $productDir . "/WebCore.framework/Resources/inspector";
1156 } elsif (isAppleWinWebKit()) {
1157 $inspectorResourcesDirPath = $productDir . "/WebKit.resources/inspector";
1158 } elsif (isQt() || isGtk()) {
1159 my $prefix = $ENV{"WebKitInstallationPrefix"};
1160 $inspectorResourcesDirPath = (defined($prefix) ? $prefix : "/usr/share") . "/webkit-1.0/webinspector";
1162 my $prefix = $ENV{"WebKitInstallationPrefix"};
1163 $inspectorResourcesDirPath = (defined($prefix) ? $prefix : "/usr/share") . "/ewebkit/webinspector";
1166 if (! -d $inspectorResourcesDirPath) {
1167 print "*************************************************************\n";
1168 print "Cannot find '$inspectorResourcesDirPath'.\n" if (defined($inspectorResourcesDirPath));
1169 print "Make sure that you have built WebKit first.\n" if (! -d $productDir || defined($inspectorResourcesDirPath));
1170 print "Optionally, set the environment variable 'WebKitInspectorResourcesDir'\n";
1171 print "to point to the directory that contains the WebKit Inspector front-end\n";
1172 print "files for the built WebCore framework.\n";
1173 print "*************************************************************\n";
1176 return system "rsync", "-aut", "--exclude=/.DS_Store", "--exclude=*.re2js", "--exclude=.svn/", !isQt() ? "--exclude=/WebKit.qrc" : "", $sourceInspectorPath, $inspectorResourcesDirPath;
1179 sub buildXCodeProject($$@)
1181 my ($project, $clean, @extraOptions) = @_;
1184 push(@extraOptions, "-alltargets");
1185 push(@extraOptions, "clean");
1188 return system "xcodebuild", "-project", "$project.xcodeproj", @extraOptions;
1191 sub buildVisualStudioProject
1193 my ($project, $clean) = @_;
1196 my $config = configurationForVisualStudio();
1198 dieIfWindowsPlatformSDKNotInstalled() if $willUseVCExpressWhenBuilding;
1200 chomp(my $winProjectPath = `cygpath -w "$project"`);
1202 my $action = "/build";
1207 my @command = ($vcBuildPath, $winProjectPath, $action, $config);
1209 print join(" ", @command), "\n";
1210 return system @command;
1213 sub downloadWafIfNeeded
1215 # get / update waf if needed
1216 my $waf = "$sourceDir/WebKitTools/wx/waf";
1217 my $wafURL = 'http://wxwebkit.wxcommunity.com/downloads/deps/waf';
1219 my $result = system "curl -o $waf $wafURL";
1226 my ($project, $shouldClean, @options) = @_;
1228 # set the PYTHONPATH for waf
1229 my $pythonPath = $ENV{'PYTHONPATH'};
1230 if (!defined($pythonPath)) {
1233 my $sourceDir = sourceDir();
1234 my $newPythonPath = "$sourceDir/WebKitTools/wx/build:$pythonPath";
1236 $newPythonPath = `cygpath --mixed --path $newPythonPath`;
1238 $ENV{'PYTHONPATH'} = $newPythonPath;
1240 print "Building $project\n";
1242 my $wafCommand = "$sourceDir/WebKitTools/wx/waf";
1243 if ($ENV{'WXWEBKIT_WAF'}) {
1244 $wafCommand = $ENV{'WXWEBKIT_WAF'};
1247 $wafCommand = `cygpath --windows "$wafCommand"`;
1251 return system $wafCommand, "clean", "distclean";
1254 return system $wafCommand, 'configure', 'build', 'install', @options;
1257 sub retrieveQMakespecVar
1260 my $varname = $_[1];
1262 my $varvalue = undef;
1263 #print "retrieveMakespecVar " . $mkspec . ", " . $varname . "\n";
1266 open SPEC, "<$mkspec" or return $varvalue;
1268 if ($_ =~ /\s*include\((.+)\)/) {
1269 # open the included mkspec
1270 my $oldcwd = getcwd();
1271 (my $volume, my $directories, my $file) = File::Spec->splitpath($mkspec);
1272 my $newcwd = "$volume$directories";
1273 chdir $newcwd if $newcwd;
1274 $varvalue = retrieveQMakespecVar($1, $varname);
1276 } elsif ($_ =~ /$varname\s*=\s*([^\s]+)/) {
1285 sub qtMakeCommand($)
1287 my ($qmakebin) = @_;
1288 chomp(my $mkspec = `$qmakebin -query QMAKE_MKSPECS`);
1289 $mkspec .= "/default";
1290 my $compiler = retrieveQMakespecVar("$mkspec/qmake.conf", "QMAKE_CC");
1292 #print "default spec: " . $mkspec . "\n";
1293 #print "compiler found: " . $compiler . "\n";
1295 if ($compiler && $compiler eq "cl") {
1302 sub autotoolsFlag($$)
1304 my ($flag, $feature) = @_;
1305 my $prefix = $flag ? "--enable" : "--disable";
1307 return $prefix . '-' . $feature;
1310 sub autogenArgumentsHaveChanged($@)
1312 my ($filename, @currentArguments) = @_;
1314 if (! -e $filename) {
1318 open(AUTOTOOLS_ARGUMENTS, $filename);
1319 chomp(my $previousArguments = <AUTOTOOLS_ARGUMENTS>);
1320 close(AUTOTOOLS_ARGUMENTS);
1322 return $previousArguments ne join(" ", @currentArguments);
1325 sub buildAutotoolsProject($@)
1327 my ($clean, @buildParams) = @_;
1330 my $dir = productDir();
1331 my $config = passedConfiguration() || configuration();
1335 my $makeArgs = $ENV{"WebKitMakeArguments"} || "";
1336 for my $i (0 .. $#buildParams) {
1337 my $opt = $buildParams[$i];
1338 if ($opt =~ /^--makeargs=(.*)/i ) {
1339 $makeArgs = $makeArgs . " " . $1;
1340 } elsif ($opt =~ /^--prefix=(.*)/i ) {
1343 push @buildArgs, $opt;
1347 # Automatically determine the number of CPUs for make only
1348 # if make arguments haven't already been specified.
1349 if ($makeArgs eq "") {
1350 $makeArgs = "-j" . numberOfCPUs();
1353 $prefix = $ENV{"WebKitInstallationPrefix"} if !defined($prefix);
1354 push @buildArgs, "--prefix=" . $prefix if defined($prefix);
1356 # check if configuration is Debug
1357 if ($config =~ m/debug/i) {
1358 push @buildArgs, "--enable-debug";
1360 push @buildArgs, "--disable-debug";
1363 # Use rm to clean the build directory since distclean may miss files
1364 if ($clean && -d $dir) {
1365 system "rm", "-rf", "$dir";
1369 File::Path::mkpath($dir) or die "Failed to create build directory " . $dir
1371 chdir $dir or die "Failed to cd into " . $dir . "\n";
1377 # If GNUmakefile exists, don't run autogen.sh. The makefile should be
1378 # smart enough to track autotools dependencies and re-run autogen.sh
1379 # when build files change.
1380 my $autogenArgumentsFile = "previous-autogen-arguments.txt";
1382 if (!(-e "GNUmakefile") or autogenArgumentsHaveChanged($autogenArgumentsFile, @buildArgs)) {
1384 # Write autogen.sh arguments to a file so that we can detect
1385 # when they change and automatically re-run it.
1386 open(AUTOTOOLS_ARGUMENTS, ">$autogenArgumentsFile");
1387 print AUTOTOOLS_ARGUMENTS join(" ", @buildArgs);
1388 close(AUTOTOOLS_ARGUMENTS);
1390 print "Calling configure in " . $dir . "\n\n";
1391 print "Installation prefix directory: $prefix\n" if(defined($prefix));
1393 # Make the path relative since it will appear in all -I compiler flags.
1394 # Long argument lists cause bizarre slowdowns in libtool.
1395 my $relSourceDir = File::Spec->abs2rel($sourceDir) || ".";
1396 $result = system "$relSourceDir/autogen.sh", @buildArgs;
1398 die "Failed to setup build environment using 'autotools'!\n";
1402 $result = system "$make $makeArgs";
1404 die "\nFailed to build WebKit using '$make'!\n";
1411 sub buildCMakeProject($@)
1413 my ($port, $clean, @buildParams) = @_;
1414 my $dir = File::Spec->canonpath(baseProductDir());
1415 my $config = configuration();
1420 $makeArgs .= " -j" . numberOfCPUs() if ($makeArgs !~ m/-j\s*\d+/);
1423 print "Cleaning the build directory '$dir'\n";
1424 $dir = File::Spec->catfile($dir, $config);
1425 File::Path::remove_tree($dir, {keep_root => 1});
1428 my $cmakebin = "cmake";
1431 push @buildArgs, "-DPORT=$port";
1433 for my $i (0 .. $#buildParams) {
1434 my $opt = $buildParams[$i];
1435 if ($opt =~ /^--makeargs=(.*)/i ) {
1437 } elsif ($opt =~ /^--prefix=(.*)/i ) {
1438 push @buildArgs, "-DCMAKE_INSTALL_PREFIX=$1";
1440 push @buildArgs, $opt;
1444 if ($config =~ m/debug/i) {
1445 push @buildArgs, "-DCMAKE_BUILD_TYPE=Debug";
1446 } elsif ($config =~ m/release/i) {
1447 push @buildArgs, "-DCMAKE_BUILD_TYPE=Release";
1450 push @buildArgs, sourceDir();
1452 $dir = File::Spec->catfile($dir, $config);
1453 File::Path::mkpath($dir);
1454 chdir $dir or die "Failed to cd into " . $dir . "\n";
1456 print "Calling '$cmakebin @buildArgs' in " . $dir . "\n\n";
1457 my $result = system "$cmakebin @buildArgs";
1459 die "Failed while running $cmakebin to generate makefiles!\n";
1462 print "Calling '$make $makeArgs' in " . $dir . "\n\n";
1463 $result = system "$make $makeArgs";
1471 sub buildCMakeEflProject($@)
1473 my ($clean, @buildArgs) = @_;
1474 return buildCMakeProject("Efl", $clean, @buildArgs);
1477 sub buildQMakeProject($@)
1479 my ($clean, @buildParams) = @_;
1481 my @buildArgs = ("-r");
1483 my $qmakebin = "qmake"; # Allow override of the qmake binary from $PATH
1487 for my $i (0 .. $#buildParams) {
1488 my $opt = $buildParams[$i];
1489 if ($opt =~ /^--qmake=(.*)/i ) {
1491 } elsif ($opt =~ /^--qmakearg=(.*)/i ) {
1492 push @buildArgs, $1;
1493 } elsif ($opt =~ /^--makeargs=(.*)/i ) {
1495 } elsif ($opt =~ /^--install-headers=(.*)/i ) {
1496 $installHeaders = $1;
1497 } elsif ($opt =~ /^--install-libs=(.*)/i ) {
1500 push @buildArgs, $opt;
1504 my $make = qtMakeCommand($qmakebin);
1505 my $config = configuration();
1506 push @buildArgs, "INSTALL_HEADERS=" . $installHeaders if defined($installHeaders);
1507 push @buildArgs, "INSTALL_LIBS=" . $installLibs if defined($installLibs);
1508 my $dir = File::Spec->canonpath(baseProductDir());
1509 $dir = File::Spec->catfile($dir, $config) unless isSymbian();
1510 File::Path::mkpath($dir);
1511 chdir $dir or die "Failed to cd into " . $dir . "\n";
1513 print "Generating derived sources\n\n";
1515 push @buildArgs, "OUTPUT_DIR=" . baseProductDir() . "/$config";
1517 my @dsQmakeArgs = @buildArgs;
1518 push @dsQmakeArgs, "-r";
1519 push @dsQmakeArgs, sourceDir() . "/DerivedSources.pro";
1520 push @dsQmakeArgs, "-o Makefile.DerivedSources";
1521 print "Calling '$qmakebin @dsQmakeArgs' in " . $dir . "\n\n";
1522 my $result = system "$qmakebin @dsQmakeArgs";
1524 die "Failed while running $qmakebin to generate derived sources!\n";
1527 my $dsMakefile = "Makefile.DerivedSources";
1529 # Iterate over different source directories manually to workaround a problem with qmake+extraTargets+s60
1530 my @subdirs = ("JavaScriptCore", "WebCore", "WebKit/qt/Api");
1531 if (grep { $_ eq "CONFIG+=webkit2"} @buildArgs) {
1532 push @subdirs, "WebKit2";
1534 # Uncomment when WTR is ready upstream
1535 #push @subdirs, "WebKitTools/WebKitTestRunner";
1538 for my $subdir (@subdirs) {
1539 print "Calling '$make $makeargs -f $dsMakefile generated_files' in " . $dir . "/$subdir\n\n";
1540 if ($make eq "nmake") {
1541 my $subdirWindows = $subdir;
1542 $subdirWindows =~ s:/:\\:g;
1543 $result = system "pushd $subdirWindows && $make $makeargs -f $dsMakefile generated_files && popd";
1545 $result = system "$make $makeargs -C $subdir -f $dsMakefile generated_files";
1548 die "Failed to generate ${subdir}'s derived sources!\n";
1552 if ($config =~ m/debug/i) {
1553 push @buildArgs, "CONFIG-=release";
1554 push @buildArgs, "CONFIG+=debug";
1556 my $passedConfig = passedConfiguration() || "";
1557 if (!isDarwin() || $passedConfig =~ m/release/i) {
1558 push @buildArgs, "CONFIG+=release";
1559 push @buildArgs, "CONFIG-=debug";
1561 push @buildArgs, "CONFIG+=debug";
1562 push @buildArgs, "CONFIG+=debug_and_release";
1566 push @buildArgs, sourceDir() . "/WebKit.pro";
1568 print "Calling '$qmakebin @buildArgs' in " . $dir . "\n\n";
1569 print "Installation headers directory: $installHeaders\n" if(defined($installHeaders));
1570 print "Installation libraries directory: $installLibs\n" if(defined($installLibs));
1572 $result = system "$qmakebin @buildArgs";
1574 die "Failed to setup build environment using $qmakebin!\n";
1577 # Manually create makefiles for the examples so we don't build by default
1578 my $examplesDir = $dir . "/WebKit/qt/examples";
1579 File::Path::mkpath($examplesDir);
1580 $buildArgs[-1] = sourceDir() . "/WebKit/qt/examples/examples.pro";
1581 chdir $examplesDir or die;
1582 print "Calling '$qmakebin @buildArgs' in " . $examplesDir . "\n\n";
1583 $result = system "$qmakebin @buildArgs";
1584 die "Failed to create makefiles for the examples!\n" if $result ne 0;
1588 print "Calling '$make $makeargs distclean' in " . $dir . "\n\n";
1589 $result = system "$make $makeargs distclean";
1590 } elsif (isSymbian()) {
1591 print "\n\nWebKit is now configured for building, but you have to make\n";
1592 print "a choice about the target yourself. To start the build run:\n\n";
1593 print " make release-armv5|debug-winscw|etc.\n\n";
1595 print "Calling '$make $makeargs' in " . $dir . "\n\n";
1596 $result = system "$make $makeargs";
1603 sub buildQMakeQtProject($$@)
1605 my ($project, $clean, @buildArgs) = @_;
1607 return buildQMakeProject($clean, @buildArgs);
1610 sub buildGtkProject($$@)
1612 my ($project, $clean, @buildArgs) = @_;
1614 if ($project ne "WebKit") {
1615 die "The Gtk port builds JavaScriptCore, WebCore and WebKit in one shot! Only call it for 'WebKit'.\n";
1618 return buildAutotoolsProject($clean, @buildArgs);
1621 sub buildChromiumMakefile($$)
1623 my ($target, $clean) = @_;
1625 return system qw(rm -rf out);
1627 my $config = configuration();
1628 my $numCpus = numberOfCPUs();
1629 my @command = ("make", "-fMakefile.chromium", "-j$numCpus", "BUILDTYPE=$config", $target);
1630 print join(" ", @command) . "\n";
1631 return system @command;
1634 sub buildChromiumVisualStudioProject($$)
1636 my ($projectPath, $clean) = @_;
1638 my $config = configuration();
1639 my $action = "/build";
1640 $action = "/clean" if $clean;
1642 # Find Visual Studio installation.
1644 my $programFilesPath = $ENV{'PROGRAMFILES'} || "C:\\Program Files";
1645 if ($ENV{'VSINSTALLDIR'}) {
1646 $vsInstallDir = $ENV{'VSINSTALLDIR'};
1648 $vsInstallDir = "$programFilesPath/Microsoft Visual Studio 8";
1650 $vsInstallDir = `cygpath "$vsInstallDir"` if isCygwin();
1651 chomp $vsInstallDir;
1652 $vcBuildPath = "$vsInstallDir/Common7/IDE/devenv.com";
1653 if (! -e $vcBuildPath) {
1654 # Visual Studio not found, try VC++ Express
1655 $vcBuildPath = "$vsInstallDir/Common7/IDE/VCExpress.exe";
1656 if (! -e $vcBuildPath) {
1657 print "*************************************************************\n";
1658 print "Cannot find '$vcBuildPath'\n";
1659 print "Please execute the file 'vcvars32.bat' from\n";
1660 print "'$programFilesPath\\Microsoft Visual Studio 8\\VC\\bin\\'\n";
1661 print "to setup the necessary environment variables.\n";
1662 print "*************************************************************\n";
1667 # Create command line and execute it.
1668 my @command = ($vcBuildPath, $projectPath, $action, $config);
1669 print "Building results into: ", baseProductDir(), "\n";
1670 print join(" ", @command), "\n";
1671 return system @command;
1674 sub buildChromium($@)
1676 my ($clean, @options) = @_;
1678 # We might need to update DEPS or re-run GYP if things have changed.
1679 system("perl", "WebKitTools/Scripts/update-webkit-chromium") == 0 or die $!;
1683 # Mac build - builds the root xcode project.
1684 $result = buildXCodeProject("WebKit/chromium/WebKit", $clean, "-configuration", configuration(), @options);
1685 } elsif (isCygwin() || isWindows()) {
1686 # Windows build - builds the root visual studio solution.
1687 $result = buildChromiumVisualStudioProject("WebKit/chromium/WebKit.sln", $clean);
1688 } elsif (isLinux()) {
1689 # Linux build - build using make.
1690 $ result = buildChromiumMakefile("all", $clean);
1692 print STDERR "This platform is not supported by chromium.\n";
1697 sub appleApplicationSupportPath
1699 open INSTALL_DIR, "</proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Apple\ Inc./Apple\ Application\ Support/InstallDir";
1700 my $path = <INSTALL_DIR>;
1701 $path =~ s/[\r\n\x00].*//;
1704 my $unixPath = `cygpath -u '$path'`;
1709 sub setPathForRunningWebKitApp
1713 if (isAppleWinWebKit()) {
1714 $env->{PATH} = join(':', productDir(), dirname(installedSafariPath()), appleApplicationSupportPath(), $env->{PATH} || "");
1716 my $qtLibs = `qmake -query QT_INSTALL_LIBS`;
1717 $qtLibs =~ s/[\n|\r]$//g;
1718 $env->{PATH} = join(';', $qtLibs, productDir() . "/lib", $env->{PATH} || "");
1724 my ($debugger) = @_;
1726 if (isAppleMacWebKit()) {
1727 return system "$FindBin::Bin/gdb-safari", argumentsForConfiguration() if $debugger;
1729 my $productDir = productDir();
1730 print "Starting Safari with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n";
1731 $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
1732 $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
1733 if (!isTiger() && architecture()) {
1734 return system "arch", "-" . architecture(), safariPath(), @ARGV;
1736 return system safariPath(), @ARGV;
1740 if (isAppleWinWebKit()) {
1742 my $productDir = productDir();
1745 chomp($ENV{WEBKITNIGHTLY} = `cygpath -wa "$productDir"`);
1746 my $safariPath = safariPath();
1747 chomp($safariPath = `cygpath -wa "$safariPath"`);
1748 $result = system $vcBuildPath, "/debugexe", "\"$safariPath\"", @ARGV;
1750 $result = system File::Spec->catfile(productDir(), "WebKit.exe"), @ARGV;
1752 return $result if $result;
1760 if (isAppleMacWebKit()) {
1761 my $productDir = productDir();
1762 print "Starting MiniBrowser with DYLD_FRAMEWORK_PATH set to point to $productDir.\n";
1763 $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
1764 $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
1765 my $miniBrowserPath = "$productDir/MiniBrowser.app/Contents/MacOS/MiniBrowser";
1766 if (!isTiger() && architecture()) {
1767 return system "arch", "-" . architecture(), $miniBrowserPath, @ARGV;
1769 return system $miniBrowserPath, @ARGV;
1776 sub debugMiniBrowser
1778 if (isAppleMacWebKit()) {
1779 my $gdbPath = "/usr/bin/gdb";
1780 die "Can't find gdb executable. Is gdb installed?\n" unless -x $gdbPath;
1782 my $productDir = productDir();
1784 $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
1785 $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = 'YES';
1787 my $miniBrowserPath = "$productDir/MiniBrowser.app/Contents/MacOS/MiniBrowser";
1789 print "Starting MiniBrowser under gdb with DYLD_FRAMEWORK_PATH set to point to built WebKit2 in $productDir.\n";
1790 my @architectureFlags = ("-arch", architecture()) if !isTiger();
1791 exec $gdbPath, @architectureFlags, $miniBrowserPath or die;
1798 sub runWebKitTestRunner
1800 if (isAppleMacWebKit()) {
1801 my $productDir = productDir();
1802 print "Starting WebKitTestRunner with DYLD_FRAMEWORK_PATH set to point to $productDir.\n";
1803 $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
1804 $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
1805 my $webKitTestRunnerPath = "$productDir/WebKitTestRunner";
1806 if (!isTiger() && architecture()) {
1807 return system "arch", "-" . architecture(), $webKitTestRunnerPath, @ARGV;
1809 return system $webKitTestRunnerPath, @ARGV;
1816 sub debugWebKitTestRunner
1818 if (isAppleMacWebKit()) {
1819 my $gdbPath = "/usr/bin/gdb";
1820 die "Can't find gdb executable. Is gdb installed?\n" unless -x $gdbPath;
1822 my $productDir = productDir();
1823 $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
1824 $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = 'YES';
1826 my $webKitTestRunnerPath = "$productDir/WebKitTestRunner";
1828 print "Starting WebKitTestRunner under gdb with DYLD_FRAMEWORK_PATH set to point to $productDir.\n";
1829 my @architectureFlags = ("-arch", architecture()) if !isTiger();
1830 exec $gdbPath, @architectureFlags, $webKitTestRunnerPath or die;
1837 sub runTestWebKitAPI
1839 if (isAppleMacWebKit()) {
1840 my $productDir = productDir();
1841 print "Starting TestWebKitAPI with DYLD_FRAMEWORK_PATH set to point to $productDir.\n";
1842 $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
1843 $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
1844 my $testWebKitAPIPath = "$productDir/TestWebKitAPI";
1845 if (!isTiger() && architecture()) {
1846 return system "arch", "-" . architecture(), $testWebKitAPIPath, @ARGV;
1848 return system $testWebKitAPIPath, @ARGV;