[webkit-reviews] build script changes for review
Darin Adler
darin at apple.com
Sun Jun 12 01:30:39 PDT 2005
The patch at the end of this message contains a bunch of tweaks to
the build scripts.
Changes include:
1) if you don't have a build products preference in Xcode, the
build directory defaults to WebKitBuild inside the same directory as
your WebKit sources (instead of ~/WebKitBuild)
2) you can set a configuration of "Development" or "Deployment"
and have that be a default, or pass the configuration on the command
line to the tools if you prefer that; the code to support Xcode 2.1
is now quite a bit more streamlined (although it needs testing)
3) The scripts work harder to find the WebKitTools directory, so
they can be run even from deep in a subdirectory of your WebKit sources.
Maybe I did some other stuff I forgot, but I think those are the big
ones.
-------------- next part --------------
Index: Scripts/build-dumprendertree
===================================================================
RCS file: /cvs/root/WebKitTools/Scripts/build-dumprendertree,v
retrieving revision 1.6
diff -p -u -p -u -r1.6 Scripts/build-dumprendertree
--- Scripts/build-dumprendertree 9 Jun 2005 23:17:56 -0000 1.6
+++ Scripts/build-dumprendertree 12 Jun 2005 07:57:02 -0000
@@ -35,9 +35,9 @@ use FindBin;
use lib $FindBin::Bin;
use webkitdirs;
+setConfiguration();
chdirWebKit();
-my $productDir = productDir();
# Build
chdir "WebKitTools/DumpRenderTree" or die;
-exit system "xcodebuild", symrootXcodeOptions(), "-buildstyle", "Deployment";
+exit system "xcodebuild", XcodeOptions();
Index: Scripts/build-webkit
===================================================================
RCS file: /cvs/root/WebKitTools/Scripts/build-webkit,v
retrieving revision 1.9
diff -p -u -p -u -r1.9 Scripts/build-webkit
--- Scripts/build-webkit 9 Jun 2005 23:17:56 -0000 1.9
+++ Scripts/build-webkit 12 Jun 2005 07:57:02 -0000
@@ -29,15 +29,11 @@
# Simplified build script for Web Kit Open Source Project.
use strict;
-use Getopt::Long;
use FindBin;
use lib $FindBin::Bin;
use webkitdirs;
-my $debug = 0;
-GetOptions("debug!" => \$debug);
-
-my $style = $debug ? "Development" : "Deployment";
+setConfiguration();
chdirWebKit();
my $productDir = productDir();
@@ -53,33 +49,28 @@ for my $dir (@projects, @otherDirs) {
# Copy library and header from WebKitLibraries to a findable place in the product directory.
my $srcLib = "WebKitLibraries/libWebKitSystemInterface.a";
-my $lib = "${productDir}/libWebKitSystemInterface.a";
+my $lib = "$productDir/libWebKitSystemInterface.a";
if (!-e $lib || -M $lib > -M $srcLib) {
print "Updating $lib\n";
system "ditto", $srcLib, $lib;
system "ranlib", $lib;
}
my $srcHeader = "WebKitLibraries/WebKitSystemInterface.h";
-my $header = "${productDir}/usr/local/include/WebKitSystemInterface.h";
+my $header = "$productDir/usr/local/include/WebKitSystemInterface.h";
if (!-e $header || -M $header > -M $srcHeader) {
print "Updating $header\n";
- system "mkdir", "-p", "${productDir}/usr/local/include";
+ system "mkdir", "-p", "$productDir/usr/local/include";
system "ditto", $srcHeader, $header;
}
-# Make symlinks so Xcode 2.1 can find the WebKitLibraries files.
-`mkdir -p "${productDir}/${style}"`;
-`ln -fs "../usr" "${productDir}/${style}"`;
-`ln -fs "../libWebKitSystemInterface.a" "${productDir}/${style}"`;
-
# Build, and abort if the build fails.
for my $dir (@projects) {
chdir $dir or die;
my $result;
if ($dir eq "JavaScriptCore") {
- $result = system "xcodebuild", symrootXcodeOptions(), "-target", "All", "-buildstyle", $style;
+ $result = system "xcodebuild", XcodeOptions(), "-target", "All";
} else {
- $result = system "xcodebuild", symrootXcodeOptions(), "-buildstyle", $style;
+ $result = system "xcodebuild", XcodeOptions();
}
exit $result if $result;
chdir ".." or die;
Index: Scripts/run-safari
===================================================================
RCS file: /cvs/root/WebKitTools/Scripts/run-safari,v
retrieving revision 1.6
diff -p -u -p -u -r1.6 Scripts/run-safari
--- Scripts/run-safari 9 Jun 2005 06:14:17 -0000 1.6
+++ Scripts/run-safari 12 Jun 2005 07:57:02 -0000
@@ -29,14 +29,11 @@
# Simplified "run" script for Web Kit Open Source Project.
use strict;
-use Getopt::Long;
use FindBin;
use lib $FindBin::Bin;
use webkitdirs;
-my $debug = 0;
-GetOptions("debug!" => \$debug);
-
+setConfiguration();
my $productDir = productDir();
# Check to see that Safari is in the usual place.
@@ -45,25 +42,10 @@ if (! -x $safariPath) {
die "Can't find executable at $safariPath.\n";
}
-# Search for build products; first test Xcode 2.0 location, then Xcode 2.1 locations.
-# For Xcode 2.1, prefer Deployment if both directories are present.
-my @testDirs;
-if ($debug) {
- @testDirs = ("$productDir", "$productDir/Deployment", "$productDir/Development");
-} else {
- @testDirs = ("$productDir", "$productDir/Development", "$productDir/Deployment");
-}
-my $found = 0;
-for my $testDir (@testDirs) {
- next if !-x "$testDir/JavaScriptCore.framework/Versions/A/JavaScriptCore";
- next if !-x "$testDir/WebCore.framework/Versions/A/WebCore";
- next if !-x "$testDir/WebKit.framework/Versions/A/WebKit";
- $productDir = $testDir;
- $found = 1;
- last;
-}
-if (!$found) {
- die "Could not locate frameworks.\n";
+# Check to see that all the frameworks are built.
+for my $framework ("JavaScriptCore", "WebCore", "WebKit") {
+ my $path = "$productDir/$framework.framework/Versions/A/$framework";
+ die "Can't find built framework at $path.\n" unless -x $path;
}
# Set up DYLD_FRAMEWORK_PATH to point to the product directory.
Index: Scripts/set-webkit-configuration
===================================================================
RCS file: Scripts/set-webkit-configuration
diff -N Scripts/set-webkit-configuration
--- Scripts/set-webkit-configuration 1 Jan 1970 00:00:00 -0000
+++ Scripts/set-webkit-configuration 12 Jun 2005 07:57:02 -0000
@@ -0,0 +1,41 @@
+#!/usr/bin/perl -w
+
+# Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+# its contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use FindBin;
+use lib $FindBin::Bin;
+use webkitdirs;
+
+my $configuration = passedConfiguration();
+die "Please specify either Development or Deployment\n" if !$configuration;
+
+my $baseProductDir = baseProductDir();
+system "mkdir", "-p", "$baseProductDir";
+open CONFIGURATION, ">", "$baseProductDir/Configuration" or die;
+print CONFIGURATION $configuration;
+close CONFIGURATION;
Index: Scripts/update-webkit
===================================================================
RCS file: /cvs/root/WebKitTools/Scripts/update-webkit,v
retrieving revision 1.4
diff -p -u -p -u -r1.4 Scripts/update-webkit
--- Scripts/update-webkit 9 Jun 2005 06:14:17 -0000 1.4
+++ Scripts/update-webkit 12 Jun 2005 07:57:02 -0000
@@ -29,11 +29,8 @@
# Update script for Web Kit Open Source Project.
use strict;
-use FindBin;
-use lib $FindBin::Bin;
-use webkitdirs;
-# Read the CVS root out of one project that's guaranteed to already be checked out.
+# Read the CVS root out of one project that's guaranteed to already be checked out (this one).
open ROOT, "WebKitTools/CVS/Root" or die;
my $root = <ROOT>;
chomp $root;
Index: Scripts/webkitdirs.pm
===================================================================
RCS file: /cvs/root/WebKitTools/Scripts/webkitdirs.pm,v
retrieving revision 1.3
diff -p -u -p -u -r1.3 Scripts/webkitdirs.pm
--- Scripts/webkitdirs.pm 9 Jun 2005 23:17:56 -0000 1.3
+++ Scripts/webkitdirs.pm 12 Jun 2005 07:57:02 -0000
@@ -34,63 +34,124 @@ BEGIN {
our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
$VERSION = 1.00;
@ISA = qw(Exporter);
- @EXPORT = qw(&chdirWebKit &productDir &symrootXcodeOptions);
+ @EXPORT = qw(&chdirWebKit &baseProductDir &productDir &XcodeOptions &passedConfiguration &setConfiguration);
%EXPORT_TAGS = ( );
@EXPORT_OK = ();
}
our @EXPORT_OK;
-my $productDir;
-my @options;
+my $baseProductDir;
+my @baseProductDirOption;
+my $configuration;
+my $configurationProductDir;
+my $didChdirWebKit;
+my $XcodeVersion;
# Check that we're in the right directory.
sub chdirWebKit
{
- if (! -d "WebKitTools") {
- if (-d "../WebKitTools") {
- chdir ".." or die;
- }
- if (-d "../../WebKitTools") {
- chdir "../.." or die;
- }
- if (! -d "WebKitTools") {
+ return if $didChdirWebKit;
+ $didChdirWebKit = 1;
+ my $root = (stat "/")[1];
+ my $dir = ".";
+ while (1) {
+ if ((stat $dir)[1] == $root) {
die "No WebKitTools directory found. Please run this script from the directory containing WebKitTools.\n";
}
+ if (-d "$dir/WebKitTools") {
+ chdir $dir or die;
+ return;
+ }
+ $dir = "$dir/..";
}
}
-# Check that an Xcode product directory is set, setting the SYMROOT environment variable
-# as a side effect in case it's not so that we will effectively have a temporary Xcode
-# product directory for xcodebuild commands called from the script.
-sub findProductDir
+sub determineXCodeVersion
{
- return if defined $productDir;
+ return if defined $XcodeVersion;
+ # Could use "xcodebuild -version" instead.
+ open VERSION, "defaults read /Developer/Applications/Xcode.app/Contents/Info CFBundleShortVersionString 2> /dev/null |" or die;
+ $XcodeVersion = <VERSION>;
+ close VERSION;
+ chomp $XcodeVersion;
+}
+
+sub determineBaseProductDir
+{
+ return if defined $baseProductDir;
open PRODUCT, "defaults read com.apple.Xcode PBXProductDirectory 2> /dev/null |" or die;
- $productDir = <PRODUCT>;
+ $baseProductDir = <PRODUCT>;
close PRODUCT;
- if ($productDir) {
- chomp $productDir;
- @options = ();
+ if ($baseProductDir) {
+ chomp $baseProductDir;
+ @baseProductDirOption = ();
+ } else {
+ chdirWebKit();
+ $baseProductDir = `pwd` . "/WebKitBuild";
+ @baseProductDirOption = ("SYMROOT=$baseProductDir");
+ }
+ $baseProductDir =~ s|^~/|$ENV{HOME}/|;
+}
+
+sub determineConfiguration
+{
+ return if defined $configuration;
+ determineBaseProductDir();
+ open CONFIGURATION, "$baseProductDir/Configuration" or die;
+ $configuration = <CONFIGURATION>;
+ close CONFIGURATION;
+ if ($configuration) {
+ chomp $configuration;
+ } else {
+ $configuration = "Deployment";
+ }
+}
+
+sub determineConfigurationProductDir
+{
+ determineConfiguration();
+ determineXCodeVersion();
+ if ($XcodeVersion eq "2.0") {
+ $configurationProductDir = $baseProductDir;
} else {
- $productDir = "$ENV{HOME}/WebKitBuild";
- @options = ("SYMROOT=$productDir");
+ $configurationProductDir = "$baseProductDir/$configuration";
}
- $productDir =~ s|^~/|$ENV{HOME}/|;
}
-# Get product directory.
+sub baseProductDir
+{
+ determineBaseProductDir();
+ return $baseProductDir;
+}
+
sub productDir
{
- findProductDir();
- return $productDir;
+ determineConfigurationProductDir();
+ return $configurationProductDir;
+}
+
+sub XcodeOptions
+{
+ determineBaseProductDir();
+ determineConfiguration();
+ return (@baseProductDirOption, "-buildstyle", $configuration);
+}
+
+sub passedConfiguration
+{
+ my $opt = $ARGV[0];
+ if ($opt) {
+ return "Development" if $opt =~ /^-*devel/i;
+ return "Deployment" if $opt =~ /^-*deploy/i;
+ }
+ return undef;
}
-# Get SYMROOT options for Xcode.
-sub symrootXcodeOptions
+sub setConfiguration
{
- findProductDir();
- return @options;
+ my $passed = passedConfiguration();
+ $configuration = $passed if $passed;
}
1;
-------------- next part --------------
-- Darin
More information about the webkit-reviews
mailing list