[CherryPick] Input Method upversion
[framework/web/webkit-efl.git] / Tools / Scripts / update-webkit-chromium
1 #!/usr/bin/perl -w
2
3 # Copyright (C) 2009 Google Inc. All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 #
9 # 1.  Redistributions of source code must retain the above copyright
10 #     notice, this list of conditions and the following disclaimer. 
11 # 2.  Redistributions in binary form must reproduce the above copyright
12 #     notice, this list of conditions and the following disclaimer in the
13 #     documentation and/or other materials provided with the distribution. 
14 # 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15 #     its contributors may be used to endorse or promote products derived
16 #     from this software without specific prior written permission. 
17 #
18 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 # Update script for the WebKit Chromium Port.
30
31 use File::Path;
32 use FindBin;
33 use Getopt::Long;
34 use lib $FindBin::Bin;
35 use webkitdirs;
36
37 determineIsChromiumAndroid();
38
39 chdirWebKit();
40 chdir("Source/WebKit/chromium") or die $!;
41
42 # Find gclient or install it.
43 my $gclientPath;
44 if (commandExists('gclient')) {
45     $gclientPath = 'gclient';
46 } elsif (-e 'depot_tools/gclient') {
47     $gclientPath = 'depot_tools/gclient';
48 } else {
49     print "Installing chromium's depot_tools...\n";
50     system("svn co http://src.chromium.org/svn/trunk/tools/depot_tools") == 0 or die $1;
51     $gclientPath = 'depot_tools/gclient';
52 }
53
54 if (! -e ".gclient") {
55     # If .gclient configuration file doesn't exist, create it.
56     print "Configuring gclient...\n";
57     system($gclientPath,
58            "config",
59            "--spec=solutions=[{'name':'./','url':None}]") == 0 or die $!;
60 }
61
62 # When building WebKit's Chromium port for Android, we need the Android NDK as
63 # it will allow us to cross-compile all sources to the target architecture.
64 if (isChromiumAndroid()) {
65     if (! -e "android-ndk-r7b") {
66         print "Installing the Android NDK, version 7b...\n";
67         my $host_os = isLinux() ? "linux" : "darwin";
68         my $result = system("curl", "-o", "android-ndk-r7b.tar.bz2", "http://dl.google.com/android/ndk/android-ndk-r7b-" . $host_os . "-x86.tar.bz2");
69         die "Couldn't download the Android NDK." if $result;
70
71         $result = system("tar", "jx", "-f", "android-ndk-r7b.tar.bz2");
72         die "Couldn't extract the Android NDK." if $result;
73     }
74
75     my $androidNdkRoot = sourceDir() . "/Source/WebKit/chromium/android-ndk-r7b";
76
77     # Attempt to replace the NDK's linker with a 64-bit version if the host
78     # OS is Linux. This will significantly speed up link times.
79     chromiumInstall64BitAndroidLinkerIfNeeded($androidNdkRoot) if isLinux();
80
81     $ENV{ANDROID_NDK_ROOT} = $androidNdkRoot;
82     $ENV{WEBKIT_ANDROID_BUILD} = 1;
83 }
84
85 my $force = 0;
86 GetOptions(
87   'force' => \$force,
88 );
89
90 # Execute gclient sync.
91 print "Updating chromium port dependencies using gclient...\n";
92 my @gclientArgs = ($gclientPath, "sync");
93 push @gclientArgs, "--force" if $force;
94 # --reset could delete modified files if necessary to sync.
95 push @gclientArgs, "--reset" if $force;
96 push @gclientArgs, "--delete_unversioned_trees" if $force;
97 push @gclientArgs, "--deps=unix,android" if isChromiumAndroid();
98
99 my $cmd = join(" ",@gclientArgs);
100 my $max_attempts = 3;
101 my $rc = -1;
102
103 # The following will call glient up to $max_attempts times before
104 # it gives up and fails.  We need this because glcient can fail
105 # for several reasons, some of which are transient (flakiness).
106
107 for (1 .. $max_attempts) {
108     $rc = system($cmd);
109     print "Re-trying '" . $cmd . "'\n" if $rc != 0;
110     last if $rc == 0;
111 }
112
113 die "Error: '$cmd' failed $max_attempts tries and returned " . $rc if ($rc);