1 # Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions
7 # 1. Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # 2. Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
12 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
13 # its contributors may be used to endorse or promote products derived
14 # from this software without specific prior written permission.
16 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
17 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
20 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 # Module to share code to get to WebKit directories.
36 our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
39 @EXPORT = qw(&chdirWebKit &baseProductDir &productDir &XcodeOptions &passedConfiguration &setConfiguration &checkFrameworks);
47 my @baseProductDirOption;
49 my $configurationProductDir;
53 # Check that we're in the right directory.
56 return if $didChdirWebKit;
58 chdir "$FindBin::Bin/../.." or die;
61 sub determineXcodeVersion
63 return if defined $XcodeVersion;
64 # Could use "xcodebuild -version" instead.
65 open VERSION, "defaults read /Developer/Applications/Xcode.app/Contents/Info CFBundleShortVersionString 2> /dev/null |" or die;
66 $XcodeVersion = <VERSION>;
71 sub determineBaseProductDir
73 return if defined $baseProductDir;
74 open PRODUCT, "defaults read com.apple.Xcode PBXProductDirectory 2> /dev/null |" or die;
75 $baseProductDir = <PRODUCT>;
77 if ($baseProductDir) {
78 chomp $baseProductDir;
79 @baseProductDirOption = ();
82 $baseProductDir = getcwd() . "/WebKitBuild";
83 @baseProductDirOption = ("SYMROOT=$baseProductDir");
85 $baseProductDir =~ s|^~/|$ENV{HOME}/|;
88 sub determineConfiguration
90 return if defined $configuration;
91 determineBaseProductDir();
92 if (open CONFIGURATION, "$baseProductDir/Configuration") {
93 $configuration = <CONFIGURATION>;
99 $configuration = "Deployment";
105 determineXcodeVersion();
106 return $XcodeVersion =~ /^1\./ || $XcodeVersion eq "2.0";
109 sub determineConfigurationProductDir
111 determineConfiguration();
112 determineXcodeVersion();
114 $configurationProductDir = $baseProductDir;
116 $configurationProductDir = "$baseProductDir/$configuration";
122 determineBaseProductDir();
123 return $baseProductDir;
128 determineConfigurationProductDir();
129 return $configurationProductDir;
134 determineBaseProductDir();
135 determineConfiguration();
136 determineXcodeVersion();
137 return (@baseProductDirOption, "-buildstyle", $configuration) if oldXcode();
138 return (@baseProductDirOption, "-configuration", $configuration);
141 sub passedConfiguration
143 for my $opt (@ARGV) {
144 return "Development" if $opt =~ /^--devel/i;
145 return "Deployment" if $opt =~ /^--deploy/i;
152 my $passed = passedConfiguration();
153 $configuration = $passed if $passed;
156 # Check to see that all the frameworks are built.
159 determineConfigurationProductDir();
160 for my $framework ("JavaScriptCore", "WebCore", "WebKit") {
161 my $path = "$configurationProductDir/$framework.framework/Versions/A/$framework";
162 die "Can't find built framework at \"$path\".\n" unless -x $path;