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