update-webkit revision 81bc750723a18f21cd17d1b173cd2a4dda9cea6e
1#!/usr/bin/perl -w
2
3# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4# Copyright (C) 2009 Google Inc. All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9#
10# 1.  Redistributions of source code must retain the above copyright
11#     notice, this list of conditions and the following disclaimer. 
12# 2.  Redistributions in binary form must reproduce the above copyright
13#     notice, this list of conditions and the following disclaimer in the
14#     documentation and/or other materials provided with the distribution. 
15# 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
16#     its contributors may be used to endorse or promote products derived
17#     from this software without specific prior written permission. 
18#
19# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30# Update script for WebKit Open Source Project.
31
32use strict;
33use FindBin;
34use lib $FindBin::Bin;
35use File::Basename;
36use File::Path;
37use File::Spec;
38use Getopt::Long;
39use VCSUtils;
40use webkitdirs;
41
42sub runSvnUpdate();
43sub runGitUpdate();
44
45# Handle options
46my $quiet = '';
47my $showHelp;
48
49determineIsChromium();
50
51chdirWebKit();
52
53my $getOptionsResult = GetOptions(
54    'h|help'  => \$showHelp,
55    'q|quiet' => \$quiet,
56); 
57
58if (!$getOptionsResult || $showHelp) {
59    print STDERR <<__END__;
60Usage: @{[ basename($0) ]} [options]
61  --chromium  also update dependencies of the chromium port
62  -h|--help   show the help message
63  -q|--quiet  pass -q to svn update for quiet updates
64__END__
65    exit 1;
66}
67
68my $startTime = time();
69
70my @svnOptions = ();
71push @svnOptions, '-q' if $quiet;
72
73# Don't prompt when using svn-1.6 or newer.
74push @svnOptions, qw(--accept postpone) if isSVNVersion16OrNewer();
75
76print "Updating OpenSource\n" unless $quiet;
77runSvnUpdate() if isSVN();
78runGitUpdate() if isGit();
79
80if (-d "../Internal") {
81    chdir("../Internal");
82    print "Updating Internal\n" unless $quiet;
83    runSvnUpdate() if isSVN();
84    runGitUpdate() if isGit();
85} elsif (isChromium()) {
86    # Workaround for https://bugs.webkit.org/show_bug.cgi?id=38926
87    # We should remove the following "if" block when we find a right fix.
88    if ((isCygwin() || isWindows()) && (stat("WebKit/chromium/features.gypi"))[9] >= $startTime) {
89        print "features.gypi has been updated. Cleaning the build directories.\n";
90        rmtree(["WebKit/chromium/Debug", "WebKit/chromium/Release"]);
91    }
92
93    system("perl", "Tools/Scripts/update-webkit-chromium") == 0 or die $!;
94} elsif (isAppleWinWebKit()) {
95    system("perl", "Tools/Scripts/update-webkit-auxiliary-libs") == 0 or die;
96}
97
98setupAppleWinEnv() if isAppleWinWebKit();
99
100exit 0;
101
102sub runSvnUpdate()
103{
104    open UPDATE, "-|", "svn", "update", @svnOptions or die;
105    my @conflictedChangeLogs;
106    while (my $line = <UPDATE>) {
107        print $line;
108        $line =~ m/^C\s+(.+?)[\r\n]*$/;
109        if ($1) {
110          my $filename = normalizePath($1);
111          push @conflictedChangeLogs, $filename if basename($filename) eq "ChangeLog";
112        }
113    }
114    close UPDATE or die;
115
116    if (@conflictedChangeLogs) {
117        print "Attempting to merge conflicted ChangeLogs.\n";
118        my $resolveChangeLogsPath = File::Spec->catfile(dirname($0), "resolve-ChangeLogs");
119        (system($resolveChangeLogsPath, "--no-warnings", @conflictedChangeLogs) == 0)
120            or die "Could not open resolve-ChangeLogs script: $!.\n";
121    }
122}
123
124sub runGitUpdate()
125{
126    # Doing a git fetch first allows setups with svn-remote.svn.fetch = trunk:refs/remotes/origin/master
127    # to perform the rebase much much faster.
128    system("git", "fetch") == 0 or die;
129    if (isGitSVN()) {
130        system("git", "svn", "rebase") == 0 or die;
131    } else {
132        # This will die if branch.$BRANCHNAME.merge isn't set, which is
133        # almost certainly what we want.
134        system("git", "pull") == 0 or die;
135    }
136}
137