15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# Copyright (C) 2005, 2006, 2007, 2010, 2011, 2012 Apple Inc. All rights reserved. 25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# Copyright (C) 2009 Google Inc. All rights reserved. 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# Copyright (C) 2011 Research In Motion Limited. All rights reserved. 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# Redistribution and use in source and binary forms, with or without 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# modification, are permitted provided that the following conditions 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# are met: 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# 1. Redistributions of source code must retain the above copyright 10fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch# notice, this list of conditions and the following disclaimer. 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# 2. Redistributions in binary form must reproduce the above copyright 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# notice, this list of conditions and the following disclaimer in the 13fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch# documentation and/or other materials provided with the distribution. 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# its contributors may be used to endorse or promote products derived 16fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch# from this software without specific prior written permission. 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# Module to share code to get to WebKit directories. 305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)use strict; 325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)use version; 335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)use warnings; 345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)use Config; 355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)use Digest::MD5 qw(md5_hex); 365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)use FindBin; 375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)use File::Basename; 385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)use File::Path qw(mkpath rmtree); 395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)use File::Spec; 405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)use File::stat; 415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)use POSIX; 425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)use VCSUtils; 435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)BEGIN { 455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) use Exporter (); 465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); 475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $VERSION = 1.00; 485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) @ISA = qw(Exporter); 495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) @EXPORT = qw( 505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &XcodeOptionString 515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &XcodeOptionStringNoConfig 525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &XcodeOptions 535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &baseProductDir 545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &chdirWebKit 555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &checkFrameworks 565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &cmakeBasedPortArguments 575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &cmakeBasedPortName 585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ¤tSVNRevision 595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &debugSafari 605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &nmPath 615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &passedConfiguration 625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &printHelpAndExitForRunAndDebugWebKitAppIfNeeded 635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &productDir 645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &runMacWebKitApp 655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &safariPath 665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) &setConfiguration 675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) USE_OPEN_COMMAND 685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ); 695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) %EXPORT_TAGS = ( ); 705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) @EXPORT_OK = (); 715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)use constant USE_OPEN_COMMAND => 1; # Used in runMacWebKitApp(). 745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)use constant INCLUDE_OPTIONS_FOR_DEBUGGING => 1; 755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)our @EXPORT_OK; 775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $architecture; 795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $numberOfCPUs; 805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $baseProductDir; 815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my @baseProductDirOption; 825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $configuration; 83926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)my $xcodeSDK; 845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $configurationForVisualStudio; 855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $configurationProductDir; 865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $sourceDir; 875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $currentSVNRevision; 885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $debugger; 895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $nmPath; 905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $osXVersion; 915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $generateDsym; 925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $isQt; 935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $qmakebin = "qmake"; # Allow override of the qmake binary from $PATH 945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $isGtk; 955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $isWinCE; 965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $isWinCairo; 975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $isWx; 985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $isEfl; 995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my @wxArgs; 1005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $isBlackBerry; 1015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $isChromium; 1025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $isChromiumAndroid; 1035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $isChromiumMacMake; 1045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $isChromiumNinja; 1055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $forceChromiumUpdate; 1065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $isInspectorFrontend; 1075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $isWK2; 1085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $shouldTargetWebProcess; 1095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $shouldUseXPCServiceForWebProcess; 1105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $shouldUseGuardMalloc; 1115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $xcodeVersion; 1125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# Variables for Win32 support 1145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $vcBuildPath; 1155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $windowsSourceDir; 1165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $winVersion; 1175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $willUseVCExpressWhenBuilding = 0; 1185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# Defined in VCSUtils. 1205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub exitStatus($); 1215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineSourceDir 1235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 1245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if $sourceDir; 1255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $sourceDir = $FindBin::Bin; 12623e46e0f045bc1935a09565578b448d36cfc5b8cBen Murdoch $sourceDir =~ s|/Tools/Scripts/?$||; # Remove trailing '/' as we would die later 1275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12823e46e0f045bc1935a09565578b448d36cfc5b8cBen Murdoch die "Could not find top level Blink directory using FindBin.\n" unless -d "$sourceDir/Tools"; 1295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 1305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub currentPerlPath() 1325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 1335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $thisPerl = $^X; 1345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($^O ne 'VMS') { 1355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $thisPerl .= $Config{_exe} unless $thisPerl =~ m/$Config{_exe}$/i; 1365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $thisPerl; 1385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 1395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub setQmakeBinaryPath($) 1415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 1425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ($qmakebin) = @_; 1435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 1445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# used for scripts which are stored in a non-standard location 1465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub setSourceDir($) 1475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 1485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ($sourceDir) = @_; 1495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 1505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineXcodeVersion 1525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 1535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined $xcodeVersion; 1545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $xcodebuildVersionOutput = `xcodebuild -version`; 1555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $xcodeVersion = ($xcodebuildVersionOutput =~ /Xcode ([0-9](\.[0-9]+)*)/) ? $1 : "3.0"; 1565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 1575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub readXcodeUserDefault($) 1595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 1605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($unprefixedKey) = @_; 1615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineXcodeVersion(); 1635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $xcodeDefaultsDomain = (eval "v$xcodeVersion" lt v4) ? "com.apple.Xcode" : "com.apple.dt.Xcode"; 1655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $xcodeDefaultsPrefix = (eval "v$xcodeVersion" lt v4) ? "PBX" : "IDE"; 1665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $devnull = File::Spec->devnull(); 1675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $value = `defaults read $xcodeDefaultsDomain ${xcodeDefaultsPrefix}${unprefixedKey} 2> ${devnull}`; 1695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if $?; 1705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp $value; 1725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $value; 1735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 1745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineBaseProductDir 1765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 1775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined $baseProductDir; 1785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineSourceDir(); 1795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $setSharedPrecompsDir; 181926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $baseProductDir = $ENV{"WEBKITOUTPUTDIR"}; # FIXME: Switch to WEBKIT_OUTPUTDIR as part of https://bugs.webkit.org/show_bug.cgi?id=109472 1825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!defined($baseProductDir) and isAppleMacWebKit()) { 1845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Silently remove ~/Library/Preferences/xcodebuild.plist which can 1855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # cause build failure. The presence of 1865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # ~/Library/Preferences/xcodebuild.plist can prevent xcodebuild from 1875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # respecting global settings such as a custom build products directory 1885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # (<rdar://problem/5585899>). 1895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $personalPlistFile = $ENV{HOME} . "/Library/Preferences/xcodebuild.plist"; 1905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (-e $personalPlistFile) { 1915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) unlink($personalPlistFile) || die "Could not delete $personalPlistFile: $!"; 1925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineXcodeVersion(); 1955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (eval "v$xcodeVersion" ge v4) { 1975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $buildLocationStyle = join '', readXcodeUserDefault("BuildLocationStyle"); 1985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($buildLocationStyle eq "Custom") { 1995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $buildLocationType = join '', readXcodeUserDefault("CustomBuildLocationType"); 2005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # FIXME: Read CustomBuildIntermediatesPath and set OBJROOT accordingly. 2015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $baseProductDir = readXcodeUserDefault("CustomBuildProductsPath") if $buildLocationType eq "Absolute"; 2025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # DeterminedByTargets corresponds to a setting of "Legacy" in Xcode. 2055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # It is the only build location style for which SHARED_PRECOMPS_DIR is not 2065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # overridden when building from within Xcode. 2075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $setSharedPrecompsDir = 1 if $buildLocationStyle ne "DeterminedByTargets"; 2085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!defined($baseProductDir)) { 2115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $baseProductDir = join '', readXcodeUserDefault("ApplicationwideBuildSettings"); 2125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $baseProductDir = $1 if $baseProductDir =~ /SYMROOT\s*=\s*\"(.*?)\";/s; 2135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) undef $baseProductDir unless $baseProductDir =~ /^\//; 2165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isChromium()) { 217926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (isLinux() || isChromiumAndroid() || isChromiumMacMake() || isChromiumNinja()) { 2185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $baseProductDir = "$sourceDir/out"; 2195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isDarwin()) { 2205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $baseProductDir = "$sourceDir/Source/WebKit/chromium/xcodebuild"; 2215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isWindows() || isCygwin()) { 2225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $baseProductDir = "$sourceDir/Source/WebKit/chromium/build"; 2235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!defined($baseProductDir)) { # Port-specific checks failed, use default 2275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $baseProductDir = "$sourceDir/WebKitBuild"; 2285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isBlackBerry()) { 2315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my %archInfo = blackberryTargetArchitecture(); 2325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $baseProductDir = "$baseProductDir/" . $archInfo{"cpuDir"}; 2335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isGit() && isGitBranchBuild() && !isChromium()) { 2365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $branch = gitBranch(); 2375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $baseProductDir = "$baseProductDir/$branch"; 2385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleMacWebKit()) { 2415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $baseProductDir =~ s|^\Q$(SRCROOT)/..\E$|$sourceDir|; 2425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $baseProductDir =~ s|^\Q$(SRCROOT)/../|$sourceDir/|; 2435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $baseProductDir =~ s|^~/|$ENV{HOME}/|; 2445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "Can't handle Xcode product directory with a ~ in it.\n" if $baseProductDir =~ /~/; 2455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "Can't handle Xcode product directory with a variable in it.\n" if $baseProductDir =~ /\$/; 2465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) @baseProductDirOption = ("SYMROOT=$baseProductDir", "OBJROOT=$baseProductDir"); 2475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@baseProductDirOption, "SHARED_PRECOMPS_DIR=${baseProductDir}/PrecompiledHeaders") if $setSharedPrecompsDir; 2485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isCygwin()) { 2515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $dosBuildPath = `cygpath --windows \"$baseProductDir\"`; 2525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp $dosBuildPath; 2535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{"WEBKITOUTPUTDIR"} = $dosBuildPath; 254926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $ENV{"WEBKIT_OUTPUTDIR"} = $dosBuildPath; 2555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $unixBuildPath = `cygpath --unix \"$baseProductDir\"`; 2565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp $unixBuildPath; 2575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $baseProductDir = $unixBuildPath; 2585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub setBaseProductDir($) 2625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 2635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ($baseProductDir) = @_; 2645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineConfiguration 2675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 2685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined $configuration; 2695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineBaseProductDir(); 2705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (open CONFIGURATION, "$baseProductDir/Configuration") { 2715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $configuration = <CONFIGURATION>; 2725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) close CONFIGURATION; 2735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($configuration) { 2755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp $configuration; 2765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # compatibility for people who have old Configuration files 2775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $configuration = "Release" if $configuration eq "Deployment"; 2785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $configuration = "Debug" if $configuration eq "Development"; 2795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 2805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $configuration = "Release"; 2815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($configuration && isWinCairo()) { 2845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) unless ($configuration =~ /_Cairo_CFLite$/) { 2855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $configuration .= "_Cairo_CFLite"; 2865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineArchitecture 2915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 2925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined $architecture; 2935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # make sure $architecture is defined in all cases 2945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $architecture = ""; 2955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineBaseProductDir(); 297926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) determineXcodeSDK(); 2985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isGtk()) { 3005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineConfigurationProductDir(); 3015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $host_triple = `grep -E '^host = ' $configurationProductDir/GNUmakefile`; 3025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($host_triple =~ m/^host = ([^-]+)-/) { 3035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # We have a configured build tree; use it. 3045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $architecture = $1; 3055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 3065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isAppleMacWebKit()) { 3075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (open ARCHITECTURE, "$baseProductDir/Architecture") { 3085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $architecture = <ARCHITECTURE>; 3095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) close ARCHITECTURE; 3105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 3115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($architecture) { 3125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp $architecture; 3135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 314926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (not defined $xcodeSDK or $xcodeSDK =~ /^(\/$|macosx)/) { 315926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my $supports64Bit = `sysctl -n hw.optional.x86_64`; 316926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) chomp $supports64Bit; 317926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $architecture = 'x86_64' if $supports64Bit; 318926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } elsif ($xcodeSDK =~ /^iphonesimulator/) { 319926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $architecture = 'i386'; 320926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } elsif ($xcodeSDK =~ /^iphoneos/) { 321926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $architecture = 'armv7'; 322926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 3235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 3245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isEfl()) { 3255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $host_processor = ""; 3265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $host_processor = `cmake --system-information | grep CMAKE_SYSTEM_PROCESSOR`; 3275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($host_processor =~ m/^CMAKE_SYSTEM_PROCESSOR \"([^"]+)\"/) { 3285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # We have a configured build tree; use it. 3295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $architecture = $1; 3305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $architecture = 'x86_64' if $architecture eq 'amd64'; 3315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 3325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 3335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!$architecture && (isGtk() || isAppleMacWebKit() || isEfl())) { 3355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Fall back to output of `arch', if it is present. 3365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $architecture = `arch`; 3375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp $architecture; 3385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 3395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!$architecture && (isGtk() || isAppleMacWebKit() || isEfl())) { 3415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Fall back to output of `uname -m', if it is present. 3425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $architecture = `uname -m`; 3435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp $architecture; 3445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 3455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineNumberOfCPUs 3485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 3495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined $numberOfCPUs; 3505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (defined($ENV{NUMBER_OF_PROCESSORS})) { 3515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $numberOfCPUs = $ENV{NUMBER_OF_PROCESSORS}; 3525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isLinux()) { 3535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # First try the nproc utility, if it exists. If we get no 3545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # results fall back to just interpretting /proc directly. 3555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp($numberOfCPUs = `nproc --all 2> /dev/null`); 3565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($numberOfCPUs eq "") { 3575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $numberOfCPUs = (grep /processor/, `cat /proc/cpuinfo`); 3585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 3595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isWindows() || isCygwin()) { 3605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Assumes cygwin 3615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $numberOfCPUs = `ls /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor | wc -w`; 3625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isDarwin() || isFreeBSD()) { 3635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp($numberOfCPUs = `sysctl -n hw.ncpu`); 3645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 3655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub jscPath($) 3685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 3695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($productDir) = @_; 3705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $jscName = "jsc"; 3715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $jscName .= "_debug" if configurationForVisualStudio() eq "Debug_All"; 3725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $jscName .= ".exe" if (isWindows() || isCygwin()); 3735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "$productDir/$jscName" if -e "$productDir/$jscName"; 3745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "$productDir/JavaScriptCore.framework/Resources/$jscName"; 3755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub argumentsForConfiguration() 3785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 3795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineConfiguration(); 3805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineArchitecture(); 3815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @args = (); 3835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@args, '--debug') if $configuration eq "Debug"; 3845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@args, '--release') if $configuration eq "Release"; 3855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@args, '--32-bit') if $architecture ne "x86_64"; 3865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@args, '--qt') if isQt(); 3875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@args, '--gtk') if isGtk(); 3885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@args, '--efl') if isEfl(); 3895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@args, '--wincairo') if isWinCairo(); 3905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@args, '--wince') if isWinCE(); 3915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@args, '--wx') if isWx(); 3925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@args, '--blackberry') if isBlackBerry(); 3935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@args, '--chromium') if isChromium() && !isChromiumAndroid(); 3945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@args, '--chromium-android') if isChromiumAndroid(); 3955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@args, '--inspector-frontend') if isInspectorFrontend(); 3965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return @args; 3975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 399926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)sub determineXcodeSDK 400926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){ 401926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return if defined $xcodeSDK; 402926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) for (my $i = 0; $i <= $#ARGV; $i++) { 403926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my $opt = $ARGV[$i]; 404926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if ($opt =~ /^--sdk$/i) { 405926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) splice(@ARGV, $i, 1); 406926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $xcodeSDK = splice(@ARGV, $i, 1); 407926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } elsif ($opt =~ /^--device$/i) { 408926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) splice(@ARGV, $i, 1); 409926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $xcodeSDK = 'iphoneos.internal'; 410926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } elsif ($opt =~ /^--sim(ulator)?/i) { 411926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) splice(@ARGV, $i, 1); 412926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $xcodeSDK = 'iphonesimulator'; 413926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 414926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 415926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)} 416926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 417926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)sub xcodeSDK 418926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){ 419926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) determineXcodeSDK(); 420926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return $xcodeSDK; 421926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)} 422926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 4235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineConfigurationForVisualStudio 4245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 4255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined $configurationForVisualStudio; 4265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineConfiguration(); 4275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # FIXME: We should detect when Debug_All or Production has been chosen. 4285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $configurationForVisualStudio = $configuration; 4295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub usesPerConfigurationBuildDirectory 4325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 4335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # [Gtk] We don't have Release/Debug configurations in straight 4345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # autotool builds (non build-webkit). In this case and if 4355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # WEBKITOUTPUTDIR exist, use that as our configuration dir. This will 4365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # allows us to run run-webkit-tests without using build-webkit. 4375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return ($ENV{"WEBKITOUTPUTDIR"} && isGtk()) || isAppleWinWebKit(); 4385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineConfigurationProductDir 4415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 4425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined $configurationProductDir; 4435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineBaseProductDir(); 4445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineConfiguration(); 4455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleWinWebKit() && !isWx()) { 4465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $configurationProductDir = File::Spec->catdir($baseProductDir, configurationForVisualStudio(), "bin"); 4475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 4485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (usesPerConfigurationBuildDirectory()) { 4495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $configurationProductDir = "$baseProductDir"; 4505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 4515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $configurationProductDir = "$baseProductDir/$configuration"; 4525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 4535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 4545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub setConfigurationProductDir($) 4575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 4585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ($configurationProductDir) = @_; 4595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineCurrentSVNRevision 4625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 4635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # We always update the current SVN revision here, and leave the caching 4645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # to currentSVNRevision(), so that changes to the SVN revision while the 4655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # script is running can be picked up by calling this function again. 4665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineSourceDir(); 4675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $currentSVNRevision = svnRevisionForDirectory($sourceDir); 4685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $currentSVNRevision; 4695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub chdirWebKit 4735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 4745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineSourceDir(); 4755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chdir $sourceDir or die; 4765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub baseProductDir 4795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 4805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineBaseProductDir(); 4815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $baseProductDir; 4825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub sourceDir 4855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 4865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineSourceDir(); 4875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $sourceDir; 4885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub productDir 4915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 4925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineConfigurationProductDir(); 4935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $configurationProductDir; 4945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub jscProductDir 4975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 4985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $productDir = productDir(); 4995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $productDir .= "/bin" if (isQt() || isEfl()); 5005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $productDir .= "/Programs" if isGtk(); 5015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $productDir; 5035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 5045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub configuration() 5065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 5075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineConfiguration(); 5085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $configuration; 5095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 5105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub configurationForVisualStudio() 5125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 5135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineConfigurationForVisualStudio(); 5145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $configurationForVisualStudio; 5155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 5165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub currentSVNRevision 5185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 5195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineCurrentSVNRevision() if not defined $currentSVNRevision; 5205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $currentSVNRevision; 5215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 5225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub generateDsym() 5245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 5255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineGenerateDsym(); 5265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $generateDsym; 5275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 5285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineGenerateDsym() 5305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 5315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($generateDsym); 5325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $generateDsym = checkForArgumentAndRemoveFromARGV("--dsym"); 5335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 5345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub argumentsForXcode() 5365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 5375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @args = (); 5385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @args, "DEBUG_INFORMATION_FORMAT=dwarf-with-dsym" if generateDsym(); 5395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return @args; 5405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 5415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub XcodeOptions 5435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 5445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineBaseProductDir(); 5455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineConfiguration(); 5465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineArchitecture(); 547926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) determineXcodeSDK(); 548926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 549926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my @sdkOption = ($xcodeSDK ? "SDKROOT=$xcodeSDK" : ()); 550926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my @architectureOption = ($architecture ? "ARCHS=$architecture" : ()); 551926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 552926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return (@baseProductDirOption, "-configuration", $configuration, @architectureOption, @sdkOption, argumentsForXcode()); 5535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 5545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub XcodeOptionString 5565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 5575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return join " ", XcodeOptions(); 5585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 5595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub XcodeOptionStringNoConfig 5615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 5625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return join " ", @baseProductDirOption; 5635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 5645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub XcodeCoverageSupportOptions() 5665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 5675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @coverageSupportOptions = (); 5685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @coverageSupportOptions, "GCC_GENERATE_TEST_COVERAGE_FILES=YES"; 5695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @coverageSupportOptions, "GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES"; 5705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @coverageSupportOptions, "EXTRA_LINK= \$(EXTRA_LINK) -ftest-coverage -fprofile-arcs"; 5715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @coverageSupportOptions, "OTHER_CFLAGS= \$(OTHER_CFLAGS) -DCOVERAGE -MD"; 5725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @coverageSupportOptions, "OTHER_LDFLAGS=\$(OTHER_LDFLAGS) -ftest-coverage -fprofile-arcs -lgcov"; 5735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return @coverageSupportOptions; 5745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 5755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $passedConfiguration; 5775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $searchedForPassedConfiguration; 5785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determinePassedConfiguration 5795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 5805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if $searchedForPassedConfiguration; 5815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $searchedForPassedConfiguration = 1; 5825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for my $i (0 .. $#ARGV) { 5845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $opt = $ARGV[$i]; 585926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if ($opt =~ /^--debug$/i) { 5865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) splice(@ARGV, $i, 1); 5875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $passedConfiguration = "Debug"; 5885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $passedConfiguration .= "_Cairo_CFLite" if (isWinCairo() && isCygwin()); 5895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 5905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 591926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if ($opt =~ /^--release$/i) { 5925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) splice(@ARGV, $i, 1); 5935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $passedConfiguration = "Release"; 5945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $passedConfiguration .= "_Cairo_CFLite" if (isWinCairo() && isCygwin()); 5955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 5965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 5975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($opt =~ /^--profil(e|ing)$/i) { 5985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) splice(@ARGV, $i, 1); 5995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $passedConfiguration = "Profiling"; 6005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $passedConfiguration .= "_Cairo_CFLite" if (isWinCairo() && isCygwin()); 6015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 6025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 6035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 6045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $passedConfiguration = undef; 6055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 6065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub passedConfiguration 6085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 6095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determinePassedConfiguration(); 6105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $passedConfiguration; 6115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 6125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub setConfiguration 6145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 6155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setArchitecture(); 6165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (my $config = shift @_) { 6185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $configuration = $config; 6195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 6205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 6215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determinePassedConfiguration(); 6235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $configuration = $passedConfiguration if $passedConfiguration; 6245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 6255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $passedArchitecture; 6285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)my $searchedForPassedArchitecture; 6295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determinePassedArchitecture 6305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 6315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if $searchedForPassedArchitecture; 6325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $searchedForPassedArchitecture = 1; 6335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for my $i (0 .. $#ARGV) { 6355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $opt = $ARGV[$i]; 6365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($opt =~ /^--32-bit$/i) { 6375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) splice(@ARGV, $i, 1); 6385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleMacWebKit() || isWx()) { 6395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $passedArchitecture = `arch`; 6405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp $passedArchitecture; 6415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 6425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 6435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 6445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 6455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $passedArchitecture = undef; 6465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 6475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub passedArchitecture 6495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 6505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determinePassedArchitecture(); 6515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $passedArchitecture; 6525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 6535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub architecture() 6555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 6565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineArchitecture(); 6575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $architecture; 6585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 6595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub numberOfCPUs() 6615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 6625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineNumberOfCPUs(); 6635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $numberOfCPUs; 6645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 6655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub setArchitecture 6675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 6685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (my $arch = shift @_) { 6695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $architecture = $arch; 6705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 6715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 6725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determinePassedArchitecture(); 6745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $architecture = $passedArchitecture if $passedArchitecture; 6755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 6765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub executableHasEntitlements 6785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 6795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $executablePath = shift; 6805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return (`codesign -d --entitlements - $executablePath 2>&1` =~ /<key>/); 6815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 6825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub safariPathFromSafariBundle 6845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 6855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($safariBundle) = @_; 6865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleMacWebKit()) { 6885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $safariPath = "$safariBundle/Contents/MacOS/Safari"; 6895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $safariForWebKitDevelopmentPath = "$safariBundle/Contents/MacOS/SafariForWebKitDevelopment"; 6905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $safariForWebKitDevelopmentPath if -f $safariForWebKitDevelopmentPath && executableHasEntitlements($safariPath); 6915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $safariPath; 6925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 6935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $safariBundle if isAppleWinWebKit(); 6945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 6955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub installedSafariPath 6975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 6985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $safariBundle; 6995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 7005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleMacWebKit()) { 7015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $safariBundle = "/Applications/Safari.app"; 7025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isAppleWinWebKit()) { 7035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $safariBundle = readRegistryString("/HKLM/SOFTWARE/Apple Computer, Inc./Safari/InstallDir"); 7045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $safariBundle =~ s/[\r\n]+$//; 7055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $safariBundle = `cygpath -u '$safariBundle'` if isCygwin(); 7065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $safariBundle =~ s/[\r\n]+$//; 7075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $safariBundle .= "Safari.exe"; 7085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 7095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 7105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return safariPathFromSafariBundle($safariBundle); 7115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 7125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 7135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# Locate Safari. 7145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub safariPath 7155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 7165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Use WEBKIT_SAFARI environment variable if present. 7175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $safariBundle = $ENV{WEBKIT_SAFARI}; 7185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!$safariBundle) { 7195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineConfigurationProductDir(); 7205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Use Safari.app in product directory if present (good for Safari development team). 7215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleMacWebKit() && -d "$configurationProductDir/Safari.app") { 7225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $safariBundle = "$configurationProductDir/Safari.app"; 7235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isAppleWinWebKit()) { 7245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $path = "$configurationProductDir/Safari.exe"; 7255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $debugPath = "$configurationProductDir/Safari_debug.exe"; 7265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 7275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (configurationForVisualStudio() eq "Debug_All" && -x $debugPath) { 7285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $safariBundle = $debugPath; 7295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (-x $path) { 7305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $safariBundle = $path; 7315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 7325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 7335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!$safariBundle) { 7345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return installedSafariPath(); 7355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 7365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 7375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $safariPath = safariPathFromSafariBundle($safariBundle); 7385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "Can't find executable at $safariPath.\n" if isAppleMacWebKit() && !-x $safariPath; 7395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $safariPath; 7405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 7415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 7425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub builtDylibPathForName 7435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 7445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $libraryName = shift; 7455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineConfigurationProductDir(); 7465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isChromium()) { 7475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "$configurationProductDir/$libraryName"; 7485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 7495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isBlackBerry()) { 7505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $libraryExtension = $libraryName =~ /^WebKit$/i ? ".so" : ".a"; 7515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "$configurationProductDir/$libraryName/lib" . lc($libraryName) . $libraryExtension; 7525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 7535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isQt()) { 7545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $isSearchingForWebCore = $libraryName =~ "WebCore"; 755926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (isDarwin()) { 756926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $libraryName = "QtWebKitWidgets"; 757926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } else { 758926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $libraryName = "Qt5WebKitWidgets"; 759926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 7605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $result; 7615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isDarwin() and -d "$configurationProductDir/lib/$libraryName.framework") { 7625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $result = "$configurationProductDir/lib/$libraryName.framework/$libraryName"; 7635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isDarwin() and -d "$configurationProductDir/lib") { 7645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $result = "$configurationProductDir/lib/lib$libraryName.dylib"; 7655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isWindows()) { 7665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (configuration() eq "Debug") { 7675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # On Windows, there is a "d" suffix to the library name. See <http://trac.webkit.org/changeset/53924/>. 7685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $libraryName .= "d"; 7695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 7705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 7715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp(my $mkspec = `$qmakebin -query QT_HOST_DATA`); 7725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $mkspec .= "/mkspecs"; 7735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $qtMajorVersion = retrieveQMakespecVar("$mkspec/qconfig.pri", "QT_MAJOR_VERSION"); 7745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (not $qtMajorVersion) { 7755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $qtMajorVersion = ""; 7765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 7775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 7785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $result = "$configurationProductDir/lib/$libraryName$qtMajorVersion.dll"; 7795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 7805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $result = "$configurationProductDir/lib/lib$libraryName.so"; 7815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 7825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 7835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($isSearchingForWebCore) { 7845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # With CONFIG+=force_static_libs_as_shared we have a shared library for each subdir. 7855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # For feature detection to work it is necessary to return the path of the WebCore library here. 7865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $replacedWithWebCore = $result; 7875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $replacedWithWebCore =~ s/$libraryName/WebCore/g; 7885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (-e $replacedWithWebCore) { 7895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $replacedWithWebCore; 7905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 7915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 7925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 7935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $result; 7945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 7955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isWx()) { 7965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "$configurationProductDir/libwxwebkit.dylib"; 7975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 7985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isGtk()) { 7995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # WebKitGTK+ for GTK2, WebKitGTK+ for GTK3, and WebKit2 respectively. 80053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) my @libraries = ("libwebkitgtk-1.0", "libwebkitgtk-3.0", "libwebkit2gtk-3.0"); 8015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $extension = isDarwin() ? ".dylib" : ".so"; 8025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 8035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) foreach $libraryName (@libraries) { 8045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $libraryPath = "$configurationProductDir/.libs/" . $libraryName . $extension; 8055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $libraryPath if -e $libraryPath; 8065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 8075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "NotFound"; 8085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 8095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isEfl()) { 810926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (isWK2()) { 811926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return "$configurationProductDir/lib/libewebkit2.so"; 812926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 8135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "$configurationProductDir/lib/libewebkit.so"; 8145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 8155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isWinCE()) { 8165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "$configurationProductDir/$libraryName"; 8175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 8185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleMacWebKit()) { 8195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "$configurationProductDir/$libraryName.framework/Versions/A/$libraryName"; 8205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 8215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleWinWebKit()) { 8225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($libraryName eq "JavaScriptCore") { 8235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "$baseProductDir/lib/$libraryName.lib"; 8245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 8255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "$baseProductDir/$libraryName.intermediate/$configuration/$libraryName.intermediate/$libraryName.lib"; 8265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 8275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 8285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 8295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "Unsupported platform, can't determine built library locations.\nTry `build-webkit --help` for more information.\n"; 8305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 8315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 8325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# Check to see that all the frameworks are built. 8335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub checkFrameworks # FIXME: This is a poor name since only the Mac calls built WebCore a Framework. 8345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 8355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if isCygwin() || isWindows(); 8365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @frameworks = ("JavaScriptCore", "WebCore"); 8375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@frameworks, "WebKit") if isAppleMacWebKit(); # FIXME: This seems wrong, all ports should have a WebKit these days. 8385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for my $framework (@frameworks) { 8395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $path = builtDylibPathForName($framework); 8405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "Can't find built framework at \"$path\".\n" unless -e $path; 8415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 8425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 8435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 8445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isInspectorFrontend() 8455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 8465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineIsInspectorFrontend(); 8475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $isInspectorFrontend; 8485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 8495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 8505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineIsInspectorFrontend() 8515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 8525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($isInspectorFrontend); 8535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isInspectorFrontend = checkForArgumentAndRemoveFromARGV("--inspector-frontend"); 8545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 8555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 8565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isQt() 8575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 8585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineIsQt(); 8595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $isQt; 8605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 8615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 8625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub getQtVersion() 8635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 8645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $qtVersion = `$qmakebin --version`; 8655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $qtVersion =~ s/^(.*)Qt version (\d\.\d)(.*)/$2/s ; 8665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $qtVersion; 8675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 8685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 8695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub qtFeatureDefaults 8705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 8715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "ERROR: qmake missing but required to build WebKit.\n" if not commandExists($qmakebin); 8725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 8735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $oldQmakeEval = $ENV{QMAKE_CACHE_EVAL}; 8745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{QMAKE_CACHE_EVAL} = "CONFIG+=print_defaults"; 8755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 8765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $originalCwd = getcwd(); 8775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $qmakepath = File::Spec->catfile(sourceDir(), "Tools", "qmake"); 8785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chdir $qmakepath or die "Failed to cd into " . $qmakepath . "\n"; 8795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 8805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $file = File::Spec->catfile(sourceDir(), "WebKit.pro"); 8815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 8825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @buildArgs; 8835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) @buildArgs = (@buildArgs, @{$_[0]}) if (@_); 8845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 8855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @defaults = `$qmakebin @buildArgs $file 2>&1`; 8865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 8875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my %qtFeatureDefaults; 8885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for (@defaults) { 8895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (/DEFINES: /) { 8905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) while (/(\S+?)=(\S+?)/gi) { 8915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $qtFeatureDefaults{$1}=$2; 8925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 8935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (/Done computing defaults/) { 8945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) last; 8955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (@_) { 8965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print $_; 8975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 8985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 8995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 9005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chdir $originalCwd; 9015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{QMAKE_CACHE_EVAL} = $oldQmakeEval; 9025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 9035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return %qtFeatureDefaults; 9045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 9055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 9065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub commandExists($) 9075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 9085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $command = shift; 9095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $devnull = File::Spec->devnull(); 9105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return `$command --version 2> $devnull`; 9115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 9125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 9135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub checkForArgumentAndRemoveFromARGV 9145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 9155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $argToCheck = shift; 9165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return checkForArgumentAndRemoveFromArrayRef($argToCheck, \@ARGV); 9175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 9185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 9195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub checkForArgumentAndRemoveFromArrayRef 9205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 9215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($argToCheck, $arrayRef) = @_; 9225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @indicesToRemove; 9235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) foreach my $index (0 .. $#$arrayRef) { 9245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $opt = $$arrayRef[$index]; 9255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($opt =~ /^$argToCheck$/i ) { 9265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@indicesToRemove, $index); 9275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 9285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 9295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) foreach my $index (@indicesToRemove) { 9305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) splice(@$arrayRef, $index, 1); 9315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 9325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $#indicesToRemove > -1; 9335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 9345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 9355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isWK2() 9365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 9375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (defined($isWK2)) { 9385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $isWK2; 9395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 9405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (checkForArgumentAndRemoveFromARGV("-2")) { 9415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isWK2 = 1; 9425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 9435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isWK2 = 0; 9445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 9455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $isWK2; 9465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 9475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 9485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineIsQt() 9495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 9505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($isQt); 9515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 9525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Allow override in case QTDIR is not set. 9535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (checkForArgumentAndRemoveFromARGV("--qt")) { 9545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isQt = 1; 9555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 9565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 9575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 9585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # The presence of QTDIR only means Qt if --gtk or --wx or --efl or --blackberry or --chromium or --wincairo are not on the command-line 9595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isGtk() || isWx() || isEfl() || isBlackBerry() || isChromium() || isWinCairo()) { 9605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isQt = 0; 9615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 9625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 9635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 9645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isQt = defined($ENV{'QTDIR'}); 9655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 9665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 9675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isBlackBerry() 9685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 9695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineIsBlackBerry(); 9705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $isBlackBerry; 9715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 9725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 9735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineIsBlackBerry() 9745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 9755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($isBlackBerry); 9765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isBlackBerry = checkForArgumentAndRemoveFromARGV("--blackberry"); 9775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 9785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 9795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub blackberryTargetArchitecture() 9805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 9815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $arch = $ENV{"BLACKBERRY_ARCH_TYPE"} ? $ENV{"BLACKBERRY_ARCH_TYPE"} : "arm"; 9825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $cpu = $ENV{"BLACKBERRY_ARCH_CPU"} ? $ENV{"BLACKBERRY_ARCH_CPU"} : ""; 9835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $cpuDir; 9845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $buSuffix; 9855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (($cpu eq "v7le") || ($cpu eq "a9")) { 9865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $cpuDir = $arch . "le-v7"; 9875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $buSuffix = $arch . "v7"; 9885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 9895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $cpu = $arch; 9905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $cpuDir = $arch; 9915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $buSuffix = $arch; 9925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 9935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return ("arch" => $arch, 9945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) "cpu" => $cpu, 9955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) "cpuDir" => $cpuDir, 9965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) "buSuffix" => $buSuffix); 9975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 9985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 9995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub blackberryCMakeArguments() 10005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 10015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my %archInfo = blackberryTargetArchitecture(); 10025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $arch = $archInfo{"arch"}; 10035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $cpu = $archInfo{"cpu"}; 10045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $cpuDir = $archInfo{"cpuDir"}; 10055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $buSuffix = $archInfo{"buSuffix"}; 10065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 10075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @cmakeExtraOptions; 10085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($cpu eq "a9") { 10095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $cpu = $arch . "v7le"; 10105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeExtraOptions, '-DTARGETING_PLAYBOOK=1'; 10115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 10125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 10135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $stageDir = $ENV{"STAGE_DIR"}; 10145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $stageLib = File::Spec->catdir($stageDir, $cpuDir, "lib"); 10155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $stageUsrLib = File::Spec->catdir($stageDir, $cpuDir, "usr", "lib"); 10165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $stageInc = File::Spec->catdir($stageDir, "usr", "include"); 10175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 10185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $qnxHost = $ENV{"QNX_HOST"}; 10195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $ccCommand; 10205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $cxxCommand; 10215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($ENV{"USE_ICECC"}) { 10225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp($ccCommand = `which icecc`); 10235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $cxxCommand = $ccCommand; 10245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 10255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ccCommand = File::Spec->catfile($qnxHost, "usr", "bin", "qcc"); 10265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $cxxCommand = $ccCommand; 10275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 10285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 10295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($ENV{"CCWRAP"}) { 10305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ccCommand = $ENV{"CCWRAP"}; 10315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeExtraOptions, "-DCMAKE_C_COMPILER_ARG1=qcc"; 10325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeExtraOptions, "-DCMAKE_CXX_COMPILER_ARG1=qcc"; 10335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 10345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 10355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeExtraOptions, "-DCMAKE_SKIP_RPATH='ON'" if isDarwin(); 10365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeExtraOptions, "-DPUBLIC_BUILD=1" if $ENV{"PUBLIC_BUILD"}; 10375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeExtraOptions, "-DENABLE_GLES2=1" unless $ENV{"DISABLE_GLES2"}; 10385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 10395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @includeSystemDirectories; 10405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @includeSystemDirectories, File::Spec->catdir($stageInc, "grskia", "skia"); 10415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @includeSystemDirectories, File::Spec->catdir($stageInc, "grskia"); 10425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @includeSystemDirectories, File::Spec->catdir($stageInc, "harfbuzz"); 10435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @includeSystemDirectories, File::Spec->catdir($stageInc, "imf"); 1044926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) # We only use jpeg-turbo for device build 1045926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) push @includeSystemDirectories, File::Spec->catdir($stageInc, "jpeg-turbo") if $arch=~/arm/; 10465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @includeSystemDirectories, $stageInc; 10475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @includeSystemDirectories, File::Spec->catdir($stageInc, "browser", "platform"); 1048926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) push @includeSystemDirectories, File::Spec->catdir($stageInc, "browser", "platform", "graphics"); 10495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @includeSystemDirectories, File::Spec->catdir($stageInc, "browser", "qsk"); 10505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @includeSystemDirectories, File::Spec->catdir($stageInc, "ots"); 10515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 10525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @cxxFlags; 10535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cxxFlags, "-Wl,-rpath-link,$stageLib"; 10545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cxxFlags, "-Wl,-rpath-link," . File::Spec->catfile($stageUsrLib, "torch-webkit"); 10555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cxxFlags, "-Wl,-rpath-link,$stageUsrLib"; 10565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cxxFlags, "-L$stageLib"; 10575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cxxFlags, "-L$stageUsrLib"; 10585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 10595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($ENV{"PROFILE"}) { 10605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeExtraOptions, "-DPROFILING=1"; 10615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cxxFlags, "-p"; 10625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 10635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 10645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @cmakeArgs; 10655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, '-DCMAKE_SYSTEM_NAME="QNX"'; 10665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, "-DCMAKE_SYSTEM_PROCESSOR=\"$cpuDir\""; 10675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, '-DCMAKE_SYSTEM_VERSION="1"'; 10685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, "-DCMAKE_C_COMPILER=\"$ccCommand\""; 10695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, "-DCMAKE_CXX_COMPILER=\"$cxxCommand\""; 10705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, "-DCMAKE_C_FLAGS=\"-Vgcc_nto${cpu} -g @cxxFlags\""; 10715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, "-DCMAKE_CXX_FLAGS=\"-Vgcc_nto${cpu}_cpp-ne -g -lang-c++ @cxxFlags\""; 10725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 10735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # We cannot use CMAKE_INCLUDE_PATH since this describes the search path for header files in user directories. 10745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # And the QNX system headers are in user directories on the host OS (i.e. they aren't installed in the host OS's 10755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # system header search path). So, we need to inform g++ that these user directories (@includeSystemDirectories) 10765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # are to be taken as the host OS's system header directories when building our port. 10775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # 10785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Also, we cannot use CMAKE_SYSTEM_INCLUDE_PATH since that will override the entire system header path. 10795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # So, we define the additional system include paths in ADDITIONAL_SYSTEM_INCLUDE_PATH. This list will 10805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # be processed in OptionsBlackBerry.cmake. 10815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, '-DADDITIONAL_SYSTEM_INCLUDE_PATH="' . join(';', @includeSystemDirectories) . '"'; 10825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 10835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # FIXME: Make this more general purpose such that we can pass a list of directories and files. 10845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, '-DTHIRD_PARTY_ICU_DIR="' . File::Spec->catdir($stageInc, "unicode") . '"'; 10855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, '-DTHIRD_PARTY_UNICODE_FILE="' . File::Spec->catfile($stageInc, "unicode.h") . '"'; 10865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 10875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, "-DCMAKE_LIBRARY_PATH=\"$stageLib;$stageUsrLib\""; 10885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, '-DCMAKE_AR="' . File::Spec->catfile($qnxHost, "usr", "bin", "nto${buSuffix}-ar") . '"'; 10895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, '-DCMAKE_RANLIB="' . File::Spec->catfile($qnxHost, "usr", "bin", "nto${buSuffix}-ranlib") . '"'; 10905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, '-DCMAKE_LD="'. File::Spec->catfile($qnxHost, "usr", "bin", "nto${buSuffix}-ld") . '"'; 10915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, '-DCMAKE_LINKER="' . File::Spec->catfile($qnxHost, "usr", "bin", "nto${buSuffix}-ld") . '"'; 10925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, "-DECLIPSE_CDT4_GENERATE_SOURCE_PROJECT=TRUE"; 10935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, '-G"Eclipse CDT4 - Unix Makefiles"'; 10945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmakeArgs, @cmakeExtraOptions; 10955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return @cmakeArgs; 10965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 10975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 10985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineIsEfl() 10995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 11005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($isEfl); 11015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isEfl = checkForArgumentAndRemoveFromARGV("--efl"); 11025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 11035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 11045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isEfl() 11055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 11065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineIsEfl(); 11075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $isEfl; 11085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 11095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 11105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isGtk() 11115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 11125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineIsGtk(); 11135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $isGtk; 11145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 11155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 11165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineIsGtk() 11175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 11185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($isGtk); 11195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isGtk = checkForArgumentAndRemoveFromARGV("--gtk"); 11205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 11215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 11225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isWinCE() 11235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 11245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineIsWinCE(); 11255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $isWinCE; 11265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 11275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 11285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineIsWinCE() 11295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 11305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($isWinCE); 11315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isWinCE = checkForArgumentAndRemoveFromARGV("--wince"); 11325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 11335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 11345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isWx() 11355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 11365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineIsWx(); 11375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $isWx; 11385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 11395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 11405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineIsWx() 11415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 11425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($isWx); 11435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isWx = checkForArgumentAndRemoveFromARGV("--wx"); 11445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 11455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 11465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub getWxArgs() 11475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 11485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!@wxArgs) { 11495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) @wxArgs = (""); 11505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $rawWxArgs = ""; 11515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) foreach my $opt (@ARGV) { 11525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($opt =~ /^--wx-args/i ) { 11535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) @ARGV = grep(!/^--wx-args/i, @ARGV); 11545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $rawWxArgs = $opt; 11555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $rawWxArgs =~ s/--wx-args=//i; 11565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 11575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 11585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) @wxArgs = split(/,/, $rawWxArgs); 11595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 11605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return @wxArgs; 11615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 11625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 11635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)# Determine if this is debian, ubuntu, linspire, or something similar. 11645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isDebianBased() 11655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 11665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return -e "/etc/debian_version"; 11675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 11685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 11695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isFedoraBased() 11705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 11715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return -e "/etc/fedora-release"; 11725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 11735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 11745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isChromium() 11755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 11765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineIsChromium(); 11775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineIsChromiumAndroid(); 11785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $isChromium || $isChromiumAndroid; 11795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 11805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 11815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineIsChromium() 11825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 11835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($isChromium); 11845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isChromium = checkForArgumentAndRemoveFromARGV("--chromium"); 11855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($isChromium) { 11865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $forceChromiumUpdate = checkForArgumentAndRemoveFromARGV("--force-update"); 11875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 11885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 11895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 11905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isChromiumAndroid() 11915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 11925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineIsChromiumAndroid(); 11935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $isChromiumAndroid; 11945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 11955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 11965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineIsChromiumAndroid() 11975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 11985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($isChromiumAndroid); 11995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isChromiumAndroid = checkForArgumentAndRemoveFromARGV("--chromium-android"); 12005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 12015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isChromiumMacMake() 12035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 12045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineIsChromiumMacMake(); 12055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $isChromiumMacMake; 12065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 12075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineIsChromiumMacMake() 12095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 12105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($isChromiumMacMake); 12115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $hasUpToDateMakefile = 0; 12135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (-e 'Makefile.chromium') { 12145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) unless (-e 'Source/WebKit/chromium/WebKit.xcodeproj') { 12155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $hasUpToDateMakefile = 1; 12165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 12175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $hasUpToDateMakefile = stat('Makefile.chromium')->mtime > stat('Source/WebKit/chromium/WebKit.xcodeproj')->mtime; 12185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 12195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 12205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isChromiumMacMake = isDarwin() && $hasUpToDateMakefile; 12215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 12225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isChromiumNinja() 12245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 12255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineIsChromiumNinja(); 12265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $isChromiumNinja; 12275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 12285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineIsChromiumNinja() 12305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 12315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($isChromiumNinja); 12325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1233926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) # This function can be called from baseProductDir(), which in turn is 1234926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) # called by configuration(). So calling configuration() here leads to 1235926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) # infinite recursion. Gyp writes both Debug and Release at the same time 1236926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) # by default, so just check the timestamp on the Release build.ninja file. 1237926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my $config = "Release"; 12385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $hasUpToDateNinjabuild = 0; 12405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (-e "out/$config/build.ninja") { 12415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $statNinja = stat("out/$config/build.ninja")->mtime; 12425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $statXcode = 0; 12445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (-e 'Source/WebKit/chromium/WebKit.xcodeproj') { 12455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $statXcode = stat('Source/WebKit/chromium/WebKit.xcodeproj')->mtime; 12465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 12475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $statMake = 0; 12495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (-e 'Makefile.chromium') { 12505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $statMake = stat('Makefile.chromium')->mtime; 12515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 12525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1253926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my $statVisualStudio = 0; 1254926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (-e 'Source/WebKit/chromium/webkit.vcxproj') { 1255926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $statVisualStudio = stat('Source/WebKit/chromium/webkit.vcxproj')->mtime; 1256926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 1257926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 1258926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $hasUpToDateNinjabuild = $statNinja > $statXcode && $statNinja > $statMake && $statNinja > $statVisualStudio; 12595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 12605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isChromiumNinja = $hasUpToDateNinjabuild; 12615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 12625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub forceChromiumUpdate() 12645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 12655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineIsChromium(); 12665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $forceChromiumUpdate; 12675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 12685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isWinCairo() 12705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 12715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineIsWinCairo(); 12725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $isWinCairo; 12735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 12745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineIsWinCairo() 12765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 12775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($isWinCairo); 12785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $isWinCairo = checkForArgumentAndRemoveFromARGV("--wincairo"); 12795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 12805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isCygwin() 12825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 12835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return ($^O eq "cygwin") || 0; 12845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 12855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isAnyWindows() 12875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 12885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return isWindows() || isCygwin(); 12895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 12905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineWinVersion() 12925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 12935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if $winVersion; 12945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 12955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!isAnyWindows()) { 12965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $winVersion = -1; 12975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 12985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 12995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $versionString = `cmd /c ver`; 13015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $versionString =~ /(\d)\.(\d)\.(\d+)/; 13025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $winVersion = { 13045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) major => $1, 13055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) minor => $2, 13065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) build => $3, 13075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) }; 13085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 13095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub winVersion() 13115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 13125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineWinVersion(); 13135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $winVersion; 13145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 13155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isWindows7SP0() 13175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 13185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return isAnyWindows() && winVersion()->{major} == 6 && winVersion()->{minor} == 1 && winVersion()->{build} == 7600; 13195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 13205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isWindowsVista() 13225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 13235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return isAnyWindows() && winVersion()->{major} == 6 && winVersion()->{minor} == 0; 13245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 13255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isWindowsXP() 13275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 13285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return isAnyWindows() && winVersion()->{major} == 5 && winVersion()->{minor} == 1; 13295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 13305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isDarwin() 13325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 13335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return ($^O eq "darwin") || 0; 13345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 13355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isWindows() 13375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 13385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return ($^O eq "MSWin32") || 0; 13395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 13405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isLinux() 13425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 13435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return ($^O eq "linux") || 0; 13445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 13455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isFreeBSD() 13475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 13485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return ($^O eq "freebsd") || 0; 13495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 13505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isARM() 13525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 1353926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return $Config{archname} =~ /^arm[v\-]/; 13545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 13555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isCrossCompilation() 13575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 13585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $compiler = ""; 13595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $compiler = $ENV{'CC'} if (defined($ENV{'CC'})); 13605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($compiler =~ /gcc/) { 13615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $compiler_options = `$compiler -v 2>&1`; 13625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @host = $compiler_options =~ m/--host=(.*?)\s/; 13635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @target = $compiler_options =~ m/--target=(.*?)\s/; 13645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return ($host[0] ne "" && $target[0] ne "" && $host[0] ne $target[0]); 13665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 13675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 0; 13685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 13695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isAppleWebKit() 13715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 13725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return !(isQt() or isGtk() or isWx() or isChromium() or isEfl() or isWinCE() or isBlackBerry()); 13735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 13745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isAppleMacWebKit() 13765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 13775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return isAppleWebKit() && isDarwin(); 13785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 13795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isAppleWinWebKit() 13815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 13825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return isAppleWebKit() && (isCygwin() || isWindows()); 13835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 13845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isPerianInstalled() 13865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 13875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!isAppleWebKit()) { 13885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 0; 13895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 13905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (-d "/Library/QuickTime/Perian.component") { 13925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 1; 13935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 13945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (-d "$ENV{HOME}/Library/QuickTime/Perian.component") { 13965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 1; 13975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 13985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 13995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 0; 14005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 14015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineNmPath() 14035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 14045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if $nmPath; 14055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleMacWebKit()) { 14075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $nmPath = `xcrun -find nm`; 14085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp $nmPath; 14095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 14105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $nmPath = "nm" if !$nmPath; 14115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 14125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub nmPath() 14145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 14155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineNmPath(); 14165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $nmPath; 14175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 14185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineOSXVersion() 14205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 14215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if $osXVersion; 14225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!isDarwin()) { 14245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $osXVersion = -1; 14255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 14265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 14275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $version = `sw_vers -productVersion`; 14295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @splitVersion = split(/\./, $version); 14305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) @splitVersion >= 2 or die "Invalid version $version"; 14315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $osXVersion = { 14325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) "major" => $splitVersion[0], 14335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) "minor" => $splitVersion[1], 14345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) "subminor" => (defined($splitVersion[2]) ? $splitVersion[2] : 0), 14355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) }; 14365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 14375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub osXVersion() 14395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 14405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineOSXVersion(); 14415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $osXVersion; 14425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 14435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isSnowLeopard() 14455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 14465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return isDarwin() && osXVersion()->{"minor"} == 6; 14475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 14485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isLion() 14505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 14515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return isDarwin() && osXVersion()->{"minor"} == 7; 14525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 14535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub isWindowsNT() 14555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 14565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $ENV{'OS'} eq 'Windows_NT'; 14575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 14585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub shouldTargetWebProcess 14605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 14615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineShouldTargetWebProcess(); 14625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $shouldTargetWebProcess; 14635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 14645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineShouldTargetWebProcess 14665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 14675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($shouldTargetWebProcess); 14685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $shouldTargetWebProcess = checkForArgumentAndRemoveFromARGV("--target-web-process"); 14695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 14705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub shouldUseXPCServiceForWebProcess 14725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 14735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineShouldUseXPCServiceForWebProcess(); 14745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $shouldUseXPCServiceForWebProcess; 14755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 14765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineShouldUseXPCServiceForWebProcess 14785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 14795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($shouldUseXPCServiceForWebProcess); 14805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $shouldUseXPCServiceForWebProcess = checkForArgumentAndRemoveFromARGV("--use-web-process-xpc-service"); 14815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 14825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub debugger 14845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 14855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineDebugger(); 14865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $debugger; 14875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 14885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineDebugger 14905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 14915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if defined($debugger); 14925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 14935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineXcodeVersion(); 14945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (eval "v$xcodeVersion" ge v4.5) { 14955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $debugger = "lldb"; 14965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 14975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $debugger = "gdb"; 14985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 14995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 15005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (checkForArgumentAndRemoveFromARGV("--use-lldb")) { 15015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $debugger = "lldb"; 15025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 15035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 15045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (checkForArgumentAndRemoveFromARGV("--use-gdb")) { 15055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $debugger = "gdb"; 15065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 15075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 15085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 15095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub appendToEnvironmentVariableList 15105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 15115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($environmentVariableName, $value) = @_; 15125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 15135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (defined($ENV{$environmentVariableName})) { 15145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{$environmentVariableName} .= ":" . $value; 15155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 15165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{$environmentVariableName} = $value; 15175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 15185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 15195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 15205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub setUpGuardMallocIfNeeded 15215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 15225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!isDarwin()) { 15235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 15245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 15255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 15265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!defined($shouldUseGuardMalloc)) { 15275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $shouldUseGuardMalloc = checkForArgumentAndRemoveFromARGV("--guard-malloc"); 15285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 15295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 15305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($shouldUseGuardMalloc) { 15315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) appendToEnvironmentVariableList("DYLD_INSERT_LIBRARIES", "/usr/lib/libgmalloc.dylib"); 15325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 15335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 15345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 15355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub relativeScriptsDir() 15365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 15375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $scriptDir = File::Spec->catpath("", File::Spec->abs2rel($FindBin::Bin, getcwd()), ""); 15385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($scriptDir eq "") { 15395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $scriptDir = "."; 15405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 15415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $scriptDir; 15425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 15435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 15445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub launcherPath() 15455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 15465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $relativeScriptsPath = relativeScriptsDir(); 15475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isGtk() || isQt() || isWx() || isEfl() || isWinCE()) { 15485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "$relativeScriptsPath/run-launcher"; 15495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isAppleWebKit()) { 15505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "$relativeScriptsPath/run-safari"; 15515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 15525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 15535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 15545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub launcherName() 15555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 15565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isGtk()) { 15575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "GtkLauncher"; 15585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isQt()) { 15595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "QtTestBrowser"; 15605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isWx()) { 15615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "wxBrowser"; 15625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isAppleWebKit()) { 15635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "Safari"; 15645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isEfl()) { 1565926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return "EWebLauncher/MiniBrowser"; 15665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isWinCE()) { 15675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "WinCELauncher"; 15685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 15695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 15705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 15715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub checkRequiredSystemConfig 15725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 15735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isDarwin()) { 15745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp(my $productVersion = `sw_vers -productVersion`); 15755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (eval "v$productVersion" lt v10.4) { 15765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "*************************************************************\n"; 15775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Mac OS X Version 10.4.0 or later is required to build WebKit.\n"; 15785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "You have " . $productVersion . ", thus the build will most likely fail.\n"; 15795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "*************************************************************\n"; 15805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 15815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $xcodebuildVersionOutput = `xcodebuild -version`; 15825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $devToolsCoreVersion = ($xcodebuildVersionOutput =~ /DevToolsCore-(\d+)/) ? $1 : undef; 15835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $xcodeVersion = ($xcodebuildVersionOutput =~ /Xcode ([0-9](\.[0-9]+)*)/) ? $1 : undef; 15845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!$devToolsCoreVersion && !$xcodeVersion 15855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) || $devToolsCoreVersion && $devToolsCoreVersion < 747 15865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) || $xcodeVersion && eval "v$xcodeVersion" lt v2.3) { 15875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "*************************************************************\n"; 15885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Xcode Version 2.3 or later is required to build WebKit.\n"; 15895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "You have an earlier version of Xcode, thus the build will\n"; 15905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "most likely fail. The latest Xcode is available from the web:\n"; 15915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "http://developer.apple.com/tools/xcode\n"; 15925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "*************************************************************\n"; 15935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 15945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isGtk() or isQt() or isWx() or isEfl()) { 15955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @cmds = qw(bison gperf); 15965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isQt() and isWindows()) { 15975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmds, "win_flex"; 15985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 15995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @cmds, "flex"; 16005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 16015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @missing = (); 16025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $oldPath = $ENV{PATH}; 16035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isQt() and isWindows()) { 16045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp(my $gnuWin32Dir = `$qmakebin -query QT_HOST_DATA`); 16055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $gnuWin32Dir = File::Spec->catfile($gnuWin32Dir, "..", "gnuwin32", "bin"); 16065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (-d "$gnuWin32Dir") { 16075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{PATH} = $gnuWin32Dir . ";" . $ENV{PATH}; 16085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 16095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 16105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) foreach my $cmd (@cmds) { 16115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @missing, $cmd if not commandExists($cmd); 16125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 16135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 16145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (@missing) { 16155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $list = join ", ", @missing; 16165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "ERROR: $list missing but required to build WebKit.\n"; 16175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 16185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isQt() and isWindows()) { 16195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{PATH} = $oldPath; 16205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 16215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 16225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Win32 and other platforms may want to check for minimum config 16235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 16245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 16255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub determineWindowsSourceDir() 16265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 16275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if $windowsSourceDir; 16285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $windowsSourceDir = sourceDir(); 16295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp($windowsSourceDir = `cygpath -w '$windowsSourceDir'`) if isCygwin(); 16305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 16315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 16325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub windowsSourceDir() 16335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 16345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineWindowsSourceDir(); 16355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $windowsSourceDir; 16365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 16375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1638926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)sub windowsSourceSourceDir() 1639926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){ 1640926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return windowsSourceDir() . "\\Source"; 1641926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)} 1642926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 16435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub windowsLibrariesDir() 16445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 16455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return windowsSourceDir() . "\\WebKitLibraries\\win"; 16465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 16475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 16485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub windowsOutputDir() 16495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 16505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return windowsSourceDir() . "\\WebKitBuild"; 16515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 16525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 16535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub setupAppleWinEnv() 16545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 16555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return unless isAppleWinWebKit(); 16565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 16575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isWindowsNT()) { 16585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $restartNeeded = 0; 16595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my %variablesToSet = (); 16605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1661fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch # FIXME: We should remove this explicit version check for cygwin once we stop supporting Cygwin 1.7.9 or older versions. 16625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # https://bugs.webkit.org/show_bug.cgi?id=85791 16635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $uname_version = (POSIX::uname())[2]; 16645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $uname_version =~ s/\(.*\)//; # Remove the trailing cygwin version, if any. 16655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (version->parse($uname_version) < version->parse("1.7.10")) { 16665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Setting the environment variable 'CYGWIN' to 'tty' makes cygwin enable extra support (i.e., termios) 16675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # for UNIX-like ttys in the Windows console 16685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $variablesToSet{CYGWIN} = "tty" unless $ENV{CYGWIN}; 16695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1670fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch 16715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Those environment variables must be set to be able to build inside Visual Studio. 16725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $variablesToSet{WEBKITLIBRARIESDIR} = windowsLibrariesDir() unless $ENV{WEBKITLIBRARIESDIR}; 1673926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $variablesToSet{WEBKIT_LIBRARIES} = windowsLibrariesDir() unless $ENV{WEBKIT_LIBRARIES}; 16745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $variablesToSet{WEBKITOUTPUTDIR} = windowsOutputDir() unless $ENV{WEBKITOUTPUTDIR}; 1675926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $variablesToSet{WEBKIT_OUTPUTDIR} = windowsOutputDir() unless $ENV{WEBKIT_OUTPUTDIR}; 1676926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $variablesToSet{WEBKIT_SOURCE} = windowsSourceSourceDir() unless $ENV{WEBKIT_SOURCE}; 16775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 16785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) foreach my $variable (keys %variablesToSet) { 16795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Setting the Environment Variable '" . $variable . "' to '" . $variablesToSet{$variable} . "'\n\n"; 16805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) system qw(regtool -s set), '\\HKEY_CURRENT_USER\\Environment\\' . $variable, $variablesToSet{$variable}; 1681926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $restartNeeded ||= $variable eq "WEBKITLIBRARIESDIR" || $variable eq "WEBKITOUTPUTDIR" || $variable eq "WEBKIT_LIBRARIES" || $variable eq "WEBKIT_OUTPUTDIR" || $variable eq "WEBKIT_SOURCE"; 16825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 16835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 16845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($restartNeeded) { 16855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Please restart your computer before attempting to build inside Visual Studio.\n\n"; 16865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 16875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 16885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!$ENV{'WEBKITLIBRARIESDIR'}) { 1689926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) # VS2005 version. This will be removed as part of https://bugs.webkit.org/show_bug.cgi?id=109472. 16905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Warning: You must set the 'WebKitLibrariesDir' environment variable\n"; 1691926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print " to be able build WebKit from within Visual Studio 2005.\n"; 16925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print " Make sure that 'WebKitLibrariesDir' points to the\n"; 16935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print " 'WebKitLibraries/win' directory, not the 'WebKitLibraries/' directory.\n\n"; 16945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1695926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (!$ENV{'WEBKIT_LIBRARIES'}) { 1696926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) # VS2010 (and newer) version. This will replace the VS2005 version as part of 1697fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch # https://bugs.webkit.org/show_bug.cgi?id=109472. 1698926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print "Warning: You must set the 'WebKit_Libraries' environment variable\n"; 1699926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print " to be able build WebKit from within Visual Studio 2010 and newer.\n"; 1700926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print " Make sure that 'WebKit_Libraries' points to the\n"; 1701926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print " 'WebKitLibraries/win' directory, not the 'WebKitLibraries/' directory.\n\n"; 1702926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 17035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!$ENV{'WEBKITOUTPUTDIR'}) { 1704926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) # VS2005 version. This will be removed as part of https://bugs.webkit.org/show_bug.cgi?id=109472. 17055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Warning: You must set the 'WebKitOutputDir' environment variable\n"; 1706926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print " to be able build WebKit from within Visual Studio 2005.\n\n"; 1707926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 1708926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (!$ENV{'WEBKIT_OUTPUTDIR'}) { 1709926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) # VS2010 (and newer) version. This will replace the VS2005 version as part of 1710fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch # https://bugs.webkit.org/show_bug.cgi?id=109472. 1711926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print "Warning: You must set the 'WebKit_OutputDir' environment variable\n"; 1712926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print " to be able build WebKit from within Visual Studio 2010 and newer.\n\n"; 1713926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 1714926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (!$ENV{'WEBKIT_SOURCE'}) { 1715926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print "Warning: You must set the 'WebKit_Source' environment variable\n"; 1716926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print " to be able build WebKit from within Visual Studio 2010 and newer.\n\n"; 17175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 17185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 17195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 17205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 17215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub setupCygwinEnv() 17225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 17235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if !isCygwin() && !isWindows(); 17245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if $vcBuildPath; 17255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 17265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $vsInstallDir; 17275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $programFilesPath = $ENV{'PROGRAMFILES(X86)'} || $ENV{'PROGRAMFILES'} || "C:\\Program Files"; 17285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($ENV{'VSINSTALLDIR'}) { 17295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $vsInstallDir = $ENV{'VSINSTALLDIR'}; 17305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 17315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $vsInstallDir = File::Spec->catdir($programFilesPath, "Microsoft Visual Studio 8"); 17325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 17335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp($vsInstallDir = `cygpath "$vsInstallDir"`) if isCygwin(); 17345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $vcBuildPath = File::Spec->catfile($vsInstallDir, qw(Common7 IDE devenv.com)); 17355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (-e $vcBuildPath) { 17365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Visual Studio is installed; we can use pdevenv to build. 17375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # FIXME: Make pdevenv work with non-Cygwin Perl. 17385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $vcBuildPath = File::Spec->catfile(sourceDir(), qw(Tools Scripts pdevenv)) if isCygwin(); 17395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 17405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Visual Studio not found, try VC++ Express 17415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $vcBuildPath = File::Spec->catfile($vsInstallDir, qw(Common7 IDE VCExpress.exe)); 17425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (! -e $vcBuildPath) { 17435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "*************************************************************\n"; 17445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Cannot find '$vcBuildPath'\n"; 17455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Please execute the file 'vcvars32.bat' from\n"; 17465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "'$programFilesPath\\Microsoft Visual Studio 8\\VC\\bin\\'\n"; 17475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "to setup the necessary environment variables.\n"; 17485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "*************************************************************\n"; 17495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die; 17505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 17515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $willUseVCExpressWhenBuilding = 1; 17525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 17535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 17545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $qtSDKPath = File::Spec->catdir($programFilesPath, "QuickTime SDK"); 17555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (0 && ! -e $qtSDKPath) { 17565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "*************************************************************\n"; 17575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Cannot find '$qtSDKPath'\n"; 17585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Please download the QuickTime SDK for Windows from\n"; 17595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "http://developer.apple.com/quicktime/download/\n"; 17605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "*************************************************************\n"; 17615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die; 17625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1763fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch 17645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) unless ($ENV{WEBKITLIBRARIESDIR}) { 17655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{'WEBKITLIBRARIESDIR'} = File::Spec->catdir($sourceDir, "WebKitLibraries", "win"); 17665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp($ENV{WEBKITLIBRARIESDIR} = `cygpath -wa '$ENV{WEBKITLIBRARIESDIR}'`) if isCygwin(); 17675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1768926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) unless ($ENV{WEBKIT_LIBRARIES}) { 1769926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $ENV{'WEBKIT_LIBRARIES'} = File::Spec->catdir($sourceDir, "WebKitLibraries", "win"); 1770926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) chomp($ENV{WEBKIT_LIBRARIES} = `cygpath -wa '$ENV{WEBKIT_LIBRARIES}'`) if isCygwin(); 1771926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 17725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 17735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Building results into: ", baseProductDir(), "\n"; 17745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "WEBKITOUTPUTDIR is set to: ", $ENV{"WEBKITOUTPUTDIR"}, "\n"; 1775926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print "WEBKIT_OUTPUTDIR is set to: ", $ENV{"WEBKIT_OUTPUTDIR"}, "\n"; 17765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "WEBKITLIBRARIESDIR is set to: ", $ENV{"WEBKITLIBRARIESDIR"}, "\n"; 1777926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print "WEBKIT_LIBRARIES is set to: ", $ENV{"WEBKIT_LIBRARIES"}, "\n"; 17785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 17795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 17805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub dieIfWindowsPlatformSDKNotInstalled 17815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 17825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $registry32Path = "/proc/registry/"; 17835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $registry64Path = "/proc/registry64/"; 17845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $windowsPlatformSDKRegistryEntry = "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MicrosoftSDK/InstalledSDKs/D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1"; 17855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 17865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # FIXME: It would be better to detect whether we are using 32- or 64-bit Windows 17875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # and only check the appropriate entry. But for now we just blindly check both. 17885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return if (-e $registry32Path . $windowsPlatformSDKRegistryEntry) || (-e $registry64Path . $windowsPlatformSDKRegistryEntry); 17895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 17905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "*************************************************************\n"; 17915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Cannot find registry entry '$windowsPlatformSDKRegistryEntry'.\n"; 17925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Please download and install the Microsoft Windows Server 2003 R2\n"; 17935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Platform SDK from <http://www.microsoft.com/downloads/details.aspx?\n"; 17945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "familyid=0baf2b35-c656-4969-ace8-e4c0c0716adb&displaylang=en>.\n\n"; 17955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Then follow step 2 in the Windows section of the \"Installing Developer\n"; 17965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Tools\" instructions at <http://www.webkit.org/building/tools.html>.\n"; 17975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "*************************************************************\n"; 17985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die; 17995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 18005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub copyInspectorFrontendFiles 18025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 18035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $productDir = productDir(); 18045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $sourceInspectorPath = sourceDir() . "/Source/WebCore/inspector/front-end/"; 18055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $inspectorResourcesDirPath = $ENV{"WEBKITINSPECTORRESOURCESDIR"}; 18065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!defined($inspectorResourcesDirPath)) { 18085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $inspectorResourcesDirPath = ""; 18095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 18105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleMacWebKit()) { 18125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $inspectorResourcesDirPath = $productDir . "/WebCore.framework/Resources/inspector"; 18135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isAppleWinWebKit()) { 18145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $inspectorResourcesDirPath = $productDir . "/WebKit.resources/inspector"; 18155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isQt() || isGtk()) { 18165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $prefix = $ENV{"WebKitInstallationPrefix"}; 18175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $inspectorResourcesDirPath = (defined($prefix) ? $prefix : "/usr/share") . "/webkit-1.0/webinspector"; 18185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isEfl()) { 18195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $prefix = $ENV{"WebKitInstallationPrefix"}; 18205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $inspectorResourcesDirPath = (defined($prefix) ? $prefix : "/usr/share") . "/ewebkit/webinspector"; 18215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 18225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (! -d $inspectorResourcesDirPath) { 18245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "*************************************************************\n"; 18255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Cannot find '$inspectorResourcesDirPath'.\n" if (defined($inspectorResourcesDirPath)); 18265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Make sure that you have built WebKit first.\n" if (! -d $productDir || defined($inspectorResourcesDirPath)); 18275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Optionally, set the environment variable 'WebKitInspectorResourcesDir'\n"; 18285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "to point to the directory that contains the WebKit Inspector front-end\n"; 18295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "files for the built WebCore framework.\n"; 18305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "*************************************************************\n"; 18315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die; 18325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 18335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleMacWebKit()) { 18355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $sourceLocalizedStrings = sourceDir() . "/Source/WebCore/English.lproj/localizedStrings.js"; 18365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $destinationLocalizedStrings = $productDir . "/WebCore.framework/Resources/English.lproj/localizedStrings.js"; 18375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) system "ditto", $sourceLocalizedStrings, $destinationLocalizedStrings; 18385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 18395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system "rsync", "-aut", "--exclude=/.DS_Store", "--exclude=*.re2js", "--exclude=.svn/", !isQt() ? "--exclude=/WebKit.qrc" : "", $sourceInspectorPath, $inspectorResourcesDirPath; 18415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 18425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub buildXCodeProject($$@) 18445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 18455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($project, $clean, @extraOptions) = @_; 18465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($clean) { 18485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@extraOptions, "-alltargets"); 18495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@extraOptions, "clean"); 18505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 18515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system "xcodebuild", "-project", "$project.xcodeproj", @extraOptions; 18535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 18545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub usingVisualStudioExpress() 18565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 18575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setupCygwinEnv(); 18585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $willUseVCExpressWhenBuilding; 18595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 18605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub buildVisualStudioProject 18625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 18635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($project, $clean) = @_; 18645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setupCygwinEnv(); 18655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $config = configurationForVisualStudio(); 18675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) dieIfWindowsPlatformSDKNotInstalled() if $willUseVCExpressWhenBuilding; 18695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp($project = `cygpath -w "$project"`) if isCygwin(); 1871fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch 18725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $action = "/build"; 18735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($clean) { 18745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $action = "/clean"; 18755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 18765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @command = ($vcBuildPath, $project, $action, $config); 18785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print join(" ", @command), "\n"; 18805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system @command; 18815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 18825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub downloadWafIfNeeded 18845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 18855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # get / update waf if needed 18865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $waf = "$sourceDir/Tools/waf/waf"; 18875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $wafURL = 'http://wxwebkit.kosoftworks.com/downloads/deps/waf'; 18885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!-f $waf) { 18895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $result = system "curl -o $waf $wafURL"; 18905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chmod 0755, $waf; 18915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 18925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 18935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 18945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub buildWafProject 18955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 18965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($project, $shouldClean, @options) = @_; 1897fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch 18985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # set the PYTHONPATH for waf 18995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $pythonPath = $ENV{'PYTHONPATH'}; 19005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!defined($pythonPath)) { 19015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $pythonPath = ''; 19025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 19035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $sourceDir = sourceDir(); 19045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $newPythonPath = "$sourceDir/Tools/waf/build:$pythonPath"; 19055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isCygwin()) { 19065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $newPythonPath = `cygpath --mixed --path $newPythonPath`; 19075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 19085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{'PYTHONPATH'} = $newPythonPath; 1909fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch 19105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Building $project\n"; 19115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 19125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $wafCommand = "$sourceDir/Tools/waf/waf"; 19135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($ENV{'WXWEBKIT_WAF'}) { 19145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $wafCommand = $ENV{'WXWEBKIT_WAF'}; 19155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 19165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isCygwin()) { 19175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $wafCommand = `cygpath --windows "$wafCommand"`; 19185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp($wafCommand); 19195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 19205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($shouldClean) { 19215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system $wafCommand, "uninstall", "clean", "distclean"; 19225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1923fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch 19245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system $wafCommand, 'configure', 'build', 'install', @options; 19255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 19265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 19275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub retrieveQMakespecVar 19285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 19295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $mkspec = $_[0]; 19305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $varname = $_[1]; 19315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 19325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $varvalue = undef; 19335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) #print "retrieveMakespecVar " . $mkspec . ", " . $varname . "\n"; 19345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 19355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) local *SPEC; 19365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) open SPEC, "<$mkspec" or return $varvalue; 19375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) while (<SPEC>) { 19385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($_ =~ /\s*include\((.+)\)/) { 19395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # open the included mkspec 19405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $oldcwd = getcwd(); 19415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) (my $volume, my $directories, my $file) = File::Spec->splitpath($mkspec); 19425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $newcwd = "$volume$directories"; 19435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chdir $newcwd if $newcwd; 19445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $varvalue = retrieveQMakespecVar($1, $varname); 19455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chdir $oldcwd; 19465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif ($_ =~ /$varname\s*=\s*([^\s]+)/) { 19475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $varvalue = $1; 19485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) last; 19495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 19505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 19515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) close SPEC; 19525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $varvalue; 19535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 19545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 19555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub qtMakeCommand($) 19565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 19575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($qmakebin) = @_; 19585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp(my $hostDataPath = `$qmakebin -query QT_HOST_DATA`); 19595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $mkspecPath = $hostDataPath . "/mkspecs/default/qmake.conf"; 19605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (! -e $mkspecPath) { 19615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp(my $mkspec= `$qmakebin -query QMAKE_XSPEC`); 19625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $mkspecPath = $hostDataPath . "/mkspecs/" . $mkspec . "/qmake.conf"; 19635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 19645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $compiler = retrieveQMakespecVar($mkspecPath, "QMAKE_CC"); 19655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 19665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) #print "default spec: " . $mkspec . "\n"; 19675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) #print "compiler found: " . $compiler . "\n"; 19685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 19695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($compiler && $compiler eq "cl") { 19705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "nmake"; 19715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 19725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 19735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "make"; 19745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 19755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 19765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub autotoolsFlag($$) 19775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 19785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($flag, $feature) = @_; 19795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $prefix = $flag ? "--enable" : "--disable"; 19805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 19815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $prefix . '-' . $feature; 19825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 19835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 19845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub runAutogenForAutotoolsProjectIfNecessary($@) 19855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 1986926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my ($dir, $prefix, $sourceDir, $project, $joinedOverridableFeatures, @buildArgs) = @_; 1987926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 1988926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my $joinedBuildArgs = join(" ", @buildArgs); 19895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 19905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (-e "GNUmakefile") { 19915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Just assume that build-jsc will never be used to reconfigure JSC. Later 19925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # we can go back and make this more complicated if the demand is there. 19935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($project ne "WebKit") { 19945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 19955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 19965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1997926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) # Run autogen.sh again if either the features overrided by build-webkit or build arguments have changed. 1998926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (!mustReRunAutogen($sourceDir, "WebKitFeatureOverrides.txt", $joinedOverridableFeatures) 1999926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) && !mustReRunAutogen($sourceDir, "previous-autogen-arguments.txt", $joinedBuildArgs)) { 20005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 20015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 20025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 20035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 20045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Calling autogen.sh in " . $dir . "\n\n"; 20055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Installation prefix directory: $prefix\n" if(defined($prefix)); 20065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 20075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Only for WebKit, write the autogen.sh arguments to a file so that we can detect 20085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # when they change and automatically re-run it. 20095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($project eq 'WebKit') { 2010926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) open(OVERRIDABLE_FEATURES, ">WebKitFeatureOverrides.txt"); 2011926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print OVERRIDABLE_FEATURES $joinedOverridableFeatures; 2012926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) close(OVERRIDABLE_FEATURES); 2013926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 2014926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) open(AUTOTOOLS_ARGUMENTS, ">previous-autogen-arguments.txt"); 2015926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print AUTOTOOLS_ARGUMENTS $joinedBuildArgs; 20165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) close(AUTOTOOLS_ARGUMENTS); 20175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 20185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 20195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Make the path relative since it will appear in all -I compiler flags. 20205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Long argument lists cause bizarre slowdowns in libtool. 20215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $relSourceDir = File::Spec->abs2rel($sourceDir) || "."; 20225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 20235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Compiler options to keep floating point values consistent 20245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # between 32-bit and 64-bit architectures. The options are also 20255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # used on Chromium build. 20265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineArchitecture(); 20275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($architecture ne "x86_64" && !isARM()) { 20285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{'CXXFLAGS'} = "-march=pentium4 -msse2 -mfpmath=sse " . ($ENV{'CXXFLAGS'} || ""); 20295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 20305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 20315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Prefix the command with jhbuild run. 20325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) unshift(@buildArgs, "$relSourceDir/autogen.sh"); 2033926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) unshift(@buildArgs, jhbuildWrapperPrefixIfNeeded()); 20345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (system(@buildArgs) ne 0) { 20355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "Calling autogen.sh failed!\n"; 20365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 20375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 20385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 20395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub getJhbuildPath() 20405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 20415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return join('/', baseProductDir(), "Dependencies"); 20425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 20435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 20445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub mustReRunAutogen($@) 20455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 2046926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my ($sourceDir, $filename, $currentContents) = @_; 20475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 20485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (! -e $filename) { 20495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 1; 20505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 20515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2052926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) open(CONTENTS_FILE, $filename); 2053926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) chomp(my $previousContents = <CONTENTS_FILE>); 2054926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) close(CONTENTS_FILE); 20555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 20565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # We only care about the WebKit2 argument when we are building WebKit itself. 20575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # build-jsc never passes --enable-webkit2, so if we didn't do this, autogen.sh 20585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # would run for every single build on the bots, since it runs both build-webkit 20595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # and build-jsc. 2060926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if ($previousContents ne $currentContents) { 2061926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print "Contents for file $filename have changed.\n"; 2062926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print "Previous contents were: $previousContents\n\n"; 2063926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print "New contents are: $currentContents\n"; 20645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 1; 20655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 20665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 20675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 0; 20685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 20695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 20705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub buildAutotoolsProject($@) 20715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 2072926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my ($project, $clean, $prefix, $makeArgs, $noWebKit1, $noWebKit2, @features) = @_; 20735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 20745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $make = 'make'; 20755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $dir = productDir(); 20765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $config = passedConfiguration() || configuration(); 20775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 20785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Use rm to clean the build directory since distclean may miss files 20795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($clean && -d $dir) { 20805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) system "rm", "-rf", "$dir"; 20815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 20825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 20835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (! -d $dir) { 20845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) File::Path::mkpath($dir) or die "Failed to create build directory " . $dir 20855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 20865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chdir $dir or die "Failed to cd into " . $dir . "\n"; 20875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 20885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($clean) { 20895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 0; 20905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 20915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2092926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my @buildArgs = @ARGV; 2093926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if ($noWebKit1) { 2094926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) unshift(@buildArgs, "--disable-webkit1"); 2095926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 2096926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if ($noWebKit2) { 2097926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) unshift(@buildArgs, "--disable-webkit2"); 2098926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 2099926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 2100926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) # Configurable features listed here should be kept in sync with the 2101926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) # features for which there exists a configuration option in configure.ac. 2102926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my %configurableFeatures = ( 2103926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) "gamepad" => 1, 2104926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) "geolocation" => 1, 2105926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) "media-stream" => 1, 2106926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) "svg" => 1, 2107926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) "svg-fonts" => 1, 2108926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) "video" => 1, 2109926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) "webgl" => 1, 2110926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) "web-audio" => 1, 2111926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) "xslt" => 1, 2112926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) ); 2113926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my @overridableFeatures = (); 2114926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) foreach (@features) { 2115926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if ($configurableFeatures{$_->{option}}) { 2116926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) push @buildArgs, autotoolsFlag(${$_->{value}}, $_->{option});; 21175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 2118926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) push @overridableFeatures, $_->{define} . "=" . (${$_->{value}} ? "1" : "0"); 21195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 21205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 21215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2122926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $makeArgs = $makeArgs || ""; 2123926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $makeArgs = $makeArgs . " " . $ENV{"WebKitMakeArguments"} if $ENV{"WebKitMakeArguments"}; 2124926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 21255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Automatically determine the number of CPUs for make only 21265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # if make arguments haven't already been specified. 21275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($makeArgs eq "") { 21285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $makeArgs = "-j" . numberOfCPUs(); 21295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 21305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 21315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # WebKit is the default target, so we don't need to specify anything. 21325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($project eq "JavaScriptCore") { 21335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $makeArgs .= " jsc"; 21345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif ($project eq "WTF") { 21355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $makeArgs .= " libWTF.la"; 21365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 21375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 21385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $prefix = $ENV{"WebKitInstallationPrefix"} if !defined($prefix); 21395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @buildArgs, "--prefix=" . $prefix if defined($prefix); 21405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 21415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Check if configuration is Debug. 21425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $debug = $config =~ m/debug/i; 21435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($debug) { 21445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @buildArgs, "--enable-debug"; 21455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 21465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @buildArgs, "--disable-debug"; 21475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 21485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 21495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (checkForArgumentAndRemoveFromArrayRef("--update-gtk", \@buildArgs)) { 21505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Force autogen to run, to catch the possibly updated libraries. 21515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) system("rm -f previous-autogen-arguments.txt"); 21525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 21535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) system("perl", "$sourceDir/Tools/Scripts/update-webkitgtk-libs") == 0 or die $!; 21545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 21555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 21565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # If GNUmakefile exists, don't run autogen.sh unless its arguments 21575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # have changed. The makefile should be smart enough to track autotools 21585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # dependencies and re-run autogen.sh when build files change. 2159926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my $joinedOverridableFeatures = join(" ", @overridableFeatures); 2160926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) runAutogenForAutotoolsProjectIfNecessary($dir, $prefix, $sourceDir, $project, $joinedOverridableFeatures, @buildArgs); 21615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2162926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my $runWithJhbuild = join(" ", jhbuildWrapperPrefixIfNeeded()); 21635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (system("$runWithJhbuild $make $makeArgs") ne 0) { 21645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "\nFailed to build WebKit using '$make'!\n"; 21655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 21665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 21675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chdir ".." or die; 21685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2169926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if ($project eq 'WebKit' && !isCrossCompilation() && !($noWebKit1 && $noWebKit2)) { 21705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @docGenerationOptions = ("$sourceDir/Tools/gtk/generate-gtkdoc", "--skip-html"); 21715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push(@docGenerationOptions, productDir()); 21725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2173926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) unshift(@docGenerationOptions, jhbuildWrapperPrefixIfNeeded()); 21745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 21755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (system(@docGenerationOptions)) { 21765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "\n gtkdoc did not build without warnings\n"; 21775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 21785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 21795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 21805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 0; 21815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 21825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 21835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub jhbuildWrapperPrefixIfNeeded() 21845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 21855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (-e getJhbuildPath()) { 2186926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my @prefix = (File::Spec->catfile(sourceDir(), "Tools", "jhbuild", "jhbuild-wrapper")); 21875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isEfl()) { 2188926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) push(@prefix, "--efl"); 21895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isGtk()) { 2190926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) push(@prefix, "--gtk"); 21915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2192926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) push(@prefix, "run"); 2193926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 2194926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return @prefix; 21955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 21965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2197926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return (); 21985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 21995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub removeCMakeCache() 22015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 22025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $cacheFilePath = File::Spec->catdir(baseProductDir(), configuration(), "CMakeCache.txt"); 22035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) unlink($cacheFilePath) if -e $cacheFilePath; 22045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 22055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub generateBuildSystemFromCMakeProject 22075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 22085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($port, $prefixPath, @cmakeArgs, $additionalCMakeArgs) = @_; 22095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $config = configuration(); 22105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $buildPath = File::Spec->catdir(baseProductDir(), $config); 22115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) File::Path::mkpath($buildPath) unless -d $buildPath; 22125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $originalWorkingDirectory = getcwd(); 22135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chdir($buildPath) or die; 22145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @args; 22165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @args, "-DPORT=\"$port\""; 22175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @args, "-DCMAKE_INSTALL_PREFIX=\"$prefixPath\"" if $prefixPath; 22185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @args, "-DSHARED_CORE=ON" if isEfl() && $ENV{"ENABLE_DRT"}; 22195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($config =~ /release/i) { 22205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @args, "-DCMAKE_BUILD_TYPE=Release"; 22215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif ($config =~ /debug/i) { 22225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @args, "-DCMAKE_BUILD_TYPE=Debug"; 22235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2224926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) # Don't warn variables which aren't used by cmake ports. 2225926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) push @args, "--no-warn-unused-cli"; 22265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @args, @cmakeArgs if @cmakeArgs; 22275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @args, $additionalCMakeArgs if $additionalCMakeArgs; 22285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @args, '"' . sourceDir() . '"'; 22305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Compiler options to keep floating point values consistent 22325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # between 32-bit and 64-bit architectures. 22335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) determineArchitecture(); 22345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($architecture ne "x86_64" && !isARM()) { 22355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{'CXXFLAGS'} = "-march=pentium4 -msse2 -mfpmath=sse " . ($ENV{'CXXFLAGS'} || ""); 22365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 22375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # We call system("cmake @args") instead of system("cmake", @args) so that @args is 22395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # parsed for shell metacharacters. 2240926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my $wrapper = join(" ", jhbuildWrapperPrefixIfNeeded()) . " "; 22415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $returnCode = system($wrapper . "cmake @args"); 22425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chdir($originalWorkingDirectory); 22445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $returnCode; 22455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 22465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub buildCMakeGeneratedProject($) 22485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 22495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($makeArgs) = @_; 22505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $config = configuration(); 22515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $buildPath = File::Spec->catdir(baseProductDir(), $config); 22525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (! -d $buildPath) { 22535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "Must call generateBuildSystemFromCMakeProject() before building CMake project."; 22545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 22555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @args = ("--build", $buildPath, "--config", $config); 22565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @args, ("--", $makeArgs) if $makeArgs; 22575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # We call system("cmake @args") instead of system("cmake", @args) so that @args is 22595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # parsed for shell metacharacters. In particular, $makeArgs may contain such metacharacters. 2260926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my $wrapper = join(" ", jhbuildWrapperPrefixIfNeeded()) . " "; 22615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system($wrapper . "cmake @args"); 22625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 22635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub cleanCMakeGeneratedProject() 22655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 22665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $config = configuration(); 22675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $buildPath = File::Spec->catdir(baseProductDir(), $config); 22685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (-d $buildPath) { 22695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system("cmake", "--build", $buildPath, "--config", $config, "--target", "clean"); 22705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 22715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 0; 22725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 22735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub buildCMakeProjectOrExit($$$$@) 22755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 22765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($clean, $port, $prefixPath, $makeArgs, @cmakeArgs) = @_; 22775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $returnCode; 22785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) exit(exitStatus(cleanCMakeGeneratedProject())) if $clean; 22805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isEfl() && checkForArgumentAndRemoveFromARGV("--update-efl")) { 22825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) system("perl", "$sourceDir/Tools/Scripts/update-webkitefl-libs") == 0 or die $!; 22835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 22845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $returnCode = exitStatus(generateBuildSystemFromCMakeProject($port, $prefixPath, @cmakeArgs)); 22875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) exit($returnCode) if $returnCode; 22885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isBlackBerry()) { 22895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 0 if (defined($ENV{"GENERATE_CMAKE_PROJECT_ONLY"}) eq '1'); 22905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 22915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $returnCode = exitStatus(buildCMakeGeneratedProject($makeArgs)); 22925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) exit($returnCode) if $returnCode; 22935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 0; 22945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 22955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 22965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub cmakeBasedPortArguments() 22975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 22985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return blackberryCMakeArguments() if isBlackBerry(); 2299926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return ('-G "Visual Studio 8 2005 STANDARDSDK_500 (ARMV4I)"') if isWinCE(); 23005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return (); 23015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 23025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 23035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub cmakeBasedPortName() 23045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 23055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "BlackBerry" if isBlackBerry(); 23065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "Efl" if isEfl(); 23075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return "WinCE" if isWinCE(); 23085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return ""; 23095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 23105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 23115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub promptUser 23125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 23135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($prompt, $default) = @_; 23145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $defaultValue = $default ? "[$default]" : ""; 23155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "$prompt $defaultValue: "; 23165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp(my $input = <STDIN>); 23175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $input ? $input : $default; 23185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 23195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 23205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub buildQMakeProjects 23215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 23225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($projects, $clean, @buildParams) = @_; 23235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 23245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @buildArgs = (); 23255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $qconfigs = ""; 23265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 23275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $make = qtMakeCommand($qmakebin); 23285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $makeargs = ""; 23295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $command; 23305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $installHeaders; 23315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $installLibs; 23325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for my $i (0 .. $#buildParams) { 23335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $opt = $buildParams[$i]; 23345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($opt =~ /^--qmake=(.*)/i ) { 23355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $qmakebin = $1; 23365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif ($opt =~ /^--qmakearg=(.*)/i ) { 23375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @buildArgs, $1; 23385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif ($opt =~ /^--makeargs=(.*)/i ) { 23395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $makeargs = $1; 23405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif ($opt =~ /^--install-headers=(.*)/i ) { 23415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $installHeaders = $1; 23425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif ($opt =~ /^--install-libs=(.*)/i ) { 23435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $installLibs = $1; 23445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 23455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @buildArgs, $opt; 23465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 23475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 23485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 23495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Automatically determine the number of CPUs for make only if this make argument haven't already been specified. 23505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($make eq "make" && $makeargs !~ /-j\s*\d+/i && (!defined $ENV{"MAKEFLAGS"} || ($ENV{"MAKEFLAGS"} !~ /-j\s*\d+/i ))) { 23515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $makeargs .= " -j" . numberOfCPUs(); 23525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 23535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 23545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $make = "$make $makeargs"; 23555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $make =~ s/\s+$//; 23565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 23575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $originalCwd = getcwd(); 23585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $dir = File::Spec->canonpath(productDir()); 23595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) File::Path::mkpath($dir); 23605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chdir $dir or die "Failed to cd into " . $dir . "\n"; 23615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 23625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($clean) { 23635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $command = "$make distclean"; 23645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "\nCalling '$command' in " . $dir . "\n\n"; 23655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system $command; 23665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 23675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 23685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $qmakepath = File::Spec->catfile(sourceDir(), "Tools", "qmake"); 23695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $qmakecommand = $qmakebin; 23705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 23715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $config = configuration(); 23725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @buildArgs, "INSTALL_HEADERS=" . $installHeaders if defined($installHeaders); 23735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @buildArgs, "INSTALL_LIBS=" . $installLibs if defined($installLibs); 23745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 23755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $passedConfig = passedConfiguration() || ""; 23765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($passedConfig =~ m/debug/i) { 23775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @buildArgs, "CONFIG-=release"; 23785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @buildArgs, "CONFIG+=debug"; 23795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif ($passedConfig =~ m/release/i) { 23805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @buildArgs, "CONFIG+=release"; 23815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @buildArgs, "CONFIG-=debug"; 23825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif ($passedConfig) { 23835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "Build type $passedConfig is not supported with --qt.\n"; 23845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 23855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 23865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Using build-webkit to build assumes you want a developer-build 23875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @buildArgs, "CONFIG-=production_build"; 23885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 23895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $svnRevision = currentSVNRevision(); 23905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $previousSvnRevision = "unknown"; 23915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 23925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $buildHint = ""; 23935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2394926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my $pathToBuiltRevisions = File::Spec->catfile($dir, ".builtRevisions.cache"); 2395926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (-e $pathToBuiltRevisions && open(BUILTREVISIONS, $pathToBuiltRevisions)) { 2396926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) while (<BUILTREVISIONS>) { 23975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($_ =~ m/^SVN_REVISION\s=\s(\d+)$/) { 23985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $previousSvnRevision = $1; 23995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 24005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2401926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) close(BUILTREVISIONS); 24025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 24035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $result = 0; 24055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Run qmake, regadless of having a makefile or not, so that qmake can 24075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # detect changes to the configuration. 24085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @buildArgs, "-after OVERRIDE_SUBDIRS=\"@{$projects}\"" if @{$projects}; 24105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) unshift @buildArgs, File::Spec->catfile(sourceDir(), "WebKit.pro"); 24115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $command = "$qmakecommand @buildArgs"; 24125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Calling '$command' in " . $dir . "\n\n"; 24135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Installation headers directory: $installHeaders\n" if(defined($installHeaders)); 24145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Installation libraries directory: $installLibs\n" if(defined($installLibs)); 24155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $configChanged = 0; 24175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) open(QMAKE, "$command 2>&1 |") || die "Could not execute qmake"; 24185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) while (<QMAKE>) { 24195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $configChanged = 1 if $_ =~ m/The configuration was changed since the last build/; 24205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print $_; 24215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 24225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) close(QMAKE); 24245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $result = $?; 24255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($result ne 0) { 24275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "\nFailed to set up build environment using $qmakebin!\n"; 24285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 24295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $maybeNeedsCleanBuild = 0; 24315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $needsIncrementalBuild = 0; 24325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2433926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) # Full incremental build (run qmake) needed on buildbots and EWS bots always. 2434926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (grep(/CONFIG\+=buildbot/,@buildParams)) { 2435926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) $needsIncrementalBuild = 1; 2436926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 2437926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 24385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($svnRevision ne $previousSvnRevision) { 24395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Last built revision was " . $previousSvnRevision . 24405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ", now at revision $svnRevision. Full incremental build needed.\n"; 24415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $needsIncrementalBuild = 1; 24425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @fileList = listOfChangedFilesBetweenRevisions(sourceDir(), $previousSvnRevision, $svnRevision); 24445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) foreach (@fileList) { 24465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (m/\.pr[oif]$/ or 24475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) m/\.qmake.conf$/ or 24485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) m/^Tools\/qmake\// 24495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ) { 24505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Change to $_ detected, clean build may be needed.\n"; 24515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $maybeNeedsCleanBuild = 1; 24525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) last; 24535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 24545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 24555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 24565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($configChanged) { 24585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Calling '$make wipeclean' in " . $dir . "\n\n"; 24595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $result = system "$make wipeclean"; 24605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 24615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $command = "$make"; 24635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($needsIncrementalBuild) { 24645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $command .= " incremental"; 24655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 24665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "\nCalling '$command' in " . $dir . "\n\n"; 24685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $result = system $command; 24695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chdir ".." or die; 24715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($result eq 0) { 24735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Now that the build completed successfully we can save the SVN revision 2474926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) open(BUILTREVISIONS, ">>$pathToBuiltRevisions"); 2475926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) print BUILTREVISIONS "SVN_REVISION = $svnRevision\n"; 2476926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) close(BUILTREVISIONS); 24775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (!$command =~ /incremental/ && exitStatus($result)) { 24785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $exitCode = exitStatus($result); 24795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $failMessage = <<EOF; 24805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)===== BUILD FAILED ====== 24825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)The build failed with exit code $exitCode. This may have been because you 24845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) - added an #include to a source/header 24865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) - added a Q_OBJECT macro to a class 24875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) - added a new resource to a qrc file 24885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)as dependencies are not automatically re-computed for local developer builds. 24905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)You may try computing dependencies manually by running 'make qmake_all' in: 24915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $dir 24935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)or passing --makeargs="qmake_all" to build-webkit. 24955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)========================= 24975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 24985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)EOF 24995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "$failMessage"; 25005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif ($maybeNeedsCleanBuild) { 25015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "\nIncremental build failed, clean build needed. \n"; 25025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Calling '$make wipeclean' in " . $dir . "\n\n"; 25035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chdir $dir or die; 25045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) system "$make wipeclean"; 25055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 25065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "\nCalling '$make' in " . $dir . "\n\n"; 25075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $result = system $make; 25085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 25095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 25105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $result; 25115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 25125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 25135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub buildGtkProject 25145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 2515926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my ($project, $clean, $prefix, $makeArgs, $noWebKit1, $noWebKit2, @features) = @_; 25165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 25175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($project ne "WebKit" and $project ne "JavaScriptCore" and $project ne "WTF") { 25185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "Unsupported project: $project. Supported projects: WebKit, JavaScriptCore, WTF\n"; 25195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 25205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2521926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return buildAutotoolsProject($project, $clean, $prefix, $makeArgs, $noWebKit1, $noWebKit2, @features); 25225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 25235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 25245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub buildChromiumMakefile($$@) 25255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 25265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($target, $clean, @options) = @_; 25275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($clean) { 25285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system qw(rm -rf out); 25295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 25305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $config = configuration(); 25315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $numCpus = numberOfCPUs(); 25325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $makeArgs; 25335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for (@options) { 25345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $makeArgs = $1 if /^--makeargs=(.*)/i; 25355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 25365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $makeArgs = "-j$numCpus" if not $makeArgs; 25375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $command .= "make -fMakefile.chromium $makeArgs BUILDTYPE=$config $target"; 25385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 25395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "$command\n"; 25405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system $command; 25415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 25425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 25435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub buildChromiumNinja($$@) 25445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 25455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # rm -rf out requires rerunning gyp, so don't support --clean for now. 25465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($target, @options) = @_; 25475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $config = configuration(); 25485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $makeArgs = ""; 25495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for (@options) { 25505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $makeArgs = $1 if /^--makeargs=(.*)/i; 25515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 25525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $command = ""; 25535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 25545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Find ninja. 25555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $ninjaPath; 25565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (commandExists('ninja')) { 25575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ninjaPath = 'ninja'; 25585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (-e 'Source/WebKit/chromium/depot_tools/ninja') { 25595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ninjaPath = 'Source/WebKit/chromium/depot_tools/ninja'; 25605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 25615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "ninja not found. Install chromium's depot_tools by running update-webkit first\n"; 25625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 25635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 25645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $command .= "$ninjaPath -C out/$config $target $makeArgs"; 25655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 25665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "$command\n"; 25675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system $command; 25685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 25695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 25705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub buildChromiumVisualStudioProject($$) 25715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 25725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($projectPath, $clean) = @_; 25735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 25745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $config = configuration(); 25755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $action = "/build"; 25765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $action = "/clean" if $clean; 25775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 25785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Find Visual Studio installation. 25795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $vsInstallDir; 25805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $programFilesPath = $ENV{'PROGRAMFILES'} || "C:\\Program Files"; 25815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($ENV{'VSINSTALLDIR'}) { 25825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $vsInstallDir = $ENV{'VSINSTALLDIR'}; 25835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 25845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $vsInstallDir = "$programFilesPath/Microsoft Visual Studio 8"; 25855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 25865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $vsInstallDir =~ s,\\,/,g; 25875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $vsInstallDir = `cygpath "$vsInstallDir"` if isCygwin(); 25885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp $vsInstallDir; 25895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $vcBuildPath = "$vsInstallDir/Common7/IDE/devenv.com"; 25905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (! -e $vcBuildPath) { 25915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Visual Studio not found, try VC++ Express 25925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $vcBuildPath = "$vsInstallDir/Common7/IDE/VCExpress.exe"; 25935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (! -e $vcBuildPath) { 25945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "*************************************************************\n"; 25955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Cannot find '$vcBuildPath'\n"; 25965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Please execute the file 'vcvars32.bat' from\n"; 25975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "'$programFilesPath\\Microsoft Visual Studio 8\\VC\\bin\\'\n"; 25985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "to setup the necessary environment variables.\n"; 25995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "*************************************************************\n"; 26005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die; 26015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 26025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 26035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Create command line and execute it. 26055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @command = ($vcBuildPath, $projectPath, $action, $config); 26065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Building results into: ", baseProductDir(), "\n"; 26075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print join(" ", @command), "\n"; 26085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system @command; 26095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 26105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub buildChromium($@) 26125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 26135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($clean, @options) = @_; 26145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # We might need to update DEPS or re-run GYP if things have changed. 26165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (checkForArgumentAndRemoveFromArrayRef("--update-chromium", \@options)) { 26175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @updateCommand = ("perl", "Tools/Scripts/update-webkit-chromium", "--force"); 26185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @updateCommand, "--chromium-android" if isChromiumAndroid(); 26195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) system(@updateCommand) == 0 or die $!; 26205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 26215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $result = 1; 26235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isDarwin() && !isChromiumAndroid() && !isChromiumMacMake() && !isChromiumNinja()) { 26245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Mac build - builds the root xcode project. 26255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $result = buildXCodeProject("Source/WebKit/chromium/All", $clean, "-configuration", configuration(), @options); 2626926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } elsif ((isCygwin() || isWindows()) && !isChromiumNinja()) { 26275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Windows build - builds the root visual studio solution. 26285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $result = buildChromiumVisualStudioProject("Source/WebKit/chromium/All.sln", $clean); 2629926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } elsif (isChromiumNinja()) { 26305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $result = buildChromiumNinja("all", $clean, @options); 26315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isLinux() || isChromiumAndroid() || isChromiumMacMake()) { 26325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # Linux build - build using make. 26335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $result = buildChromiumMakefile("all", $clean, @options); 26345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 26355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print STDERR "This platform is not supported by chromium.\n"; 26365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 26375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $result; 26385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 26395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub appleApplicationSupportPath 26415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 26425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) open INSTALL_DIR, "</proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Apple\ Inc./Apple\ Application\ Support/InstallDir"; 26435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $path = <INSTALL_DIR>; 26445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $path =~ s/[\r\n\x00].*//; 26455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) close INSTALL_DIR; 26465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $unixPath = `cygpath -u '$path'`; 26485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp $unixPath; 26495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $unixPath; 26505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 26515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub setPathForRunningWebKitApp 26535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 26545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($env) = @_; 26555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleWinWebKit()) { 26575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $env->{PATH} = join(':', productDir(), dirname(installedSafariPath()), appleApplicationSupportPath(), $env->{PATH} || ""); 26585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isQt()) { 26595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $qtLibs = `$qmakebin -query QT_INSTALL_LIBS`; 26605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $qtLibs =~ s/[\n|\r]$//g; 26615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $env->{PATH} = join(';', $qtLibs, productDir() . "/lib", $env->{PATH} || ""); 26625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 26635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 26645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub printHelpAndExitForRunAndDebugWebKitAppIfNeeded 26665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 26675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return unless checkForArgumentAndRemoveFromARGV("--help"); 26685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($includeOptionsForDebugging) = @_; 26705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print STDERR <<EOF; 26725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)Usage: @{[basename($0)]} [options] [args ...] 26735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) --help Show this help message 26745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) --no-saved-state Launch the application without state restoration (OS X 10.7 and later) 26755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) --guard-malloc Enable Guard Malloc (OS X only) 26765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) --use-web-process-xpc-service Launch the Web Process as an XPC Service (OS X only) 26775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)EOF 26785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if ($includeOptionsForDebugging) { 26805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print STDERR <<EOF; 26815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) --target-web-process Debug the web process 26825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) --use-gdb Use GDB (this is the default when using Xcode 4.4 or earlier) 26835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) --use-lldb Use LLDB (this is the default when using Xcode 4.5 or later) 26845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)EOF 26855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 26865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) exit(1); 26885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 26895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub argumentsForRunAndDebugMacWebKitApp() 26915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 26925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @args = (); 26935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @args, ("-ApplePersistenceIgnoreState", "YES") if !isSnowLeopard() && checkForArgumentAndRemoveFromArrayRef("--no-saved-state", \@args); 26945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) push @args, ("-WebKit2UseXPCServiceForWebProcess", "YES") if shouldUseXPCServiceForWebProcess(); 26955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) unshift @args, @ARGV; 26965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return @args; 26985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 26995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub runMacWebKitApp($;$) 27015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 27025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($appPath, $useOpenCommand) = @_; 27035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $productDir = productDir(); 27045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Starting @{[basename($appPath)]} with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n"; 27055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{DYLD_FRAMEWORK_PATH} = $productDir; 27065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES"; 27075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setUpGuardMallocIfNeeded(); 27095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (defined($useOpenCommand) && $useOpenCommand == USE_OPEN_COMMAND) { 27115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system("open", "-W", "-a", $appPath, "--args", argumentsForRunAndDebugMacWebKitApp()); 27125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 27135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (architecture()) { 27145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system "arch", "-" . architecture(), $appPath, argumentsForRunAndDebugMacWebKitApp(); 27155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 27165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system { $appPath } $appPath, argumentsForRunAndDebugMacWebKitApp(); 27175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 27185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub execMacWebKitAppForDebugging($) 27205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 27215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($appPath) = @_; 27225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $architectureSwitch; 27235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $argumentsSeparator; 27245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (debugger() eq "lldb") { 27265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $architectureSwitch = "--arch"; 27275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $argumentsSeparator = "--"; 27285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (debugger() eq "gdb") { 27295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $architectureSwitch = "-arch"; 27305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $argumentsSeparator = "--args"; 27315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 27325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "Unknown debugger $debugger.\n"; 27335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 27345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $debuggerPath = `xcrun -find $debugger`; 27365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp $debuggerPath; 27375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "Can't find the $debugger executable.\n" unless -x $debuggerPath; 27385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $productDir = productDir(); 27405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{DYLD_FRAMEWORK_PATH} = $productDir; 27415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES"; 27425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setUpGuardMallocIfNeeded(); 27445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @architectureFlags = ($architectureSwitch, architecture()); 27465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!shouldTargetWebProcess()) { 27475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Starting @{[basename($appPath)]} under $debugger with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n"; 27485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) exec { $debuggerPath } $debuggerPath, @architectureFlags, $argumentsSeparator, $appPath, argumentsForRunAndDebugMacWebKitApp() or die; 27495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else { 27505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (shouldUseXPCServiceForWebProcess()) { 27515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) die "Targetting the Web Process is not compatible with using an XPC Service for the Web Process at this time."; 27525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2753fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch 2754926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) my $webProcessShimPath = File::Spec->catfile($productDir, "SecItemShim.dylib"); 27555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $webProcessPath = File::Spec->catdir($productDir, "WebProcess.app"); 27565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $webKit2ExecutablePath = File::Spec->catfile($productDir, "WebKit2.framework", "WebKit2"); 27575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) appendToEnvironmentVariableList("DYLD_INSERT_LIBRARIES", $webProcessShimPath); 27595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Starting WebProcess under $debugger with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n"; 27615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) exec { $debuggerPath } $debuggerPath, @architectureFlags, $argumentsSeparator, $webProcessPath, $webKit2ExecutablePath, "-type", "webprocess", "-client-executable", $appPath or die; 27625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 27635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 27645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub debugSafari 27665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 27675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleMacWebKit()) { 27685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) checkFrameworks(); 27695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) execMacWebKitAppForDebugging(safariPath()); 27705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 27715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleWinWebKit()) { 27735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setupCygwinEnv(); 27745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $productDir = productDir(); 27755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp($ENV{WEBKITNIGHTLY} = `cygpath -wa "$productDir"`); 27765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $safariPath = safariPath(); 27775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp($safariPath = `cygpath -wa "$safariPath"`); 27785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system { $vcBuildPath } $vcBuildPath, "/debugexe", "\"$safariPath\"", @ARGV; 27795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 27805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 1; # Unsupported platform; can't debug Safari on this platform. 27825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 27835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub runSafari 27855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 27865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleMacWebKit()) { 27885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return runMacWebKitApp(safariPath()); 27895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 27905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleWinWebKit()) { 27925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $result; 27935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $productDir = productDir(); 27945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $webKitLauncherPath = File::Spec->catfile(productDir(), "WebKit.exe"); 27955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system { $webKitLauncherPath } $webKitLauncherPath, @ARGV; 27965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 27975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 27985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 1; # Unsupported platform; can't run Safari on this platform. 27995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 28005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 28015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub runMiniBrowser 28025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 28035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleMacWebKit()) { 28045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return runMacWebKitApp(File::Spec->catfile(productDir(), "MiniBrowser.app", "Contents", "MacOS", "MiniBrowser")); 28055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 28065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 28075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 1; 28085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 28095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 28105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub debugMiniBrowser 28115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 28125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleMacWebKit()) { 28135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) execMacWebKitAppForDebugging(File::Spec->catfile(productDir(), "MiniBrowser.app", "Contents", "MacOS", "MiniBrowser")); 28145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2815fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch 28165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 1; 28175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 28185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 28195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub runWebKitTestRunner 28205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 28215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleMacWebKit()) { 28225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return runMacWebKitApp(File::Spec->catfile(productDir(), "WebKitTestRunner")); 28235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } elsif (isGtk()) { 28245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $productDir = productDir(); 28255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $injectedBundlePath = "$productDir/Libraries/.libs/libTestRunnerInjectedBundle"; 28265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) print "Starting WebKitTestRunner with TEST_RUNNER_INJECTED_BUNDLE_FILENAME set to point to $injectedBundlePath.\n"; 28275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) $ENV{TEST_RUNNER_INJECTED_BUNDLE_FILENAME} = $injectedBundlePath; 28285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my @args = ("$productDir/Programs/WebKitTestRunner", @ARGV); 28295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return system {$args[0] } @args; 28305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 28315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 28325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 1; 28335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 28345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 28355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub debugWebKitTestRunner 28365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 28375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isAppleMacWebKit()) { 28385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) execMacWebKitAppForDebugging(File::Spec->catfile(productDir(), "WebKitTestRunner")); 28395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 28405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 28415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return 1; 28425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 28435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 28445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub readRegistryString 28455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 28465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($valueName) = @_; 28475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) chomp(my $string = `regtool --wow32 get "$valueName"`); 28485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return $string; 28495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 28505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 28515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)sub writeRegistryString 28525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 28535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my ($valueName, $string) = @_; 28545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 28555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) my $error = system "regtool", "--wow32", "set", "-s", $valueName, $string; 28565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 28575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # On Windows Vista/7 with UAC enabled, regtool will fail to modify the registry, but will still 28585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # return a successful exit code. So we double-check here that the value we tried to write to the 28595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) # registry was really written. 28605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return !$error && readRegistryString($valueName) eq $string; 28615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 28625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 28635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)1; 2864