tizen beta release
[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 chdir("Source/WebKit/chromium") or die $!;
40
41 # Find gclient or install it.
42 my $gclientPath;
43 if (commandExists('gclient')) {
44     $gclientPath = 'gclient';
45 } elsif (-e 'depot_tools/gclient') {
46     $gclientPath = 'depot_tools/gclient';
47 } else {
48     print "Installing chromium's depot_tools...\n";
49     system("svn co http://src.chromium.org/svn/trunk/tools/depot_tools") == 0 or die $1;
50     $gclientPath = 'depot_tools/gclient';
51 }
52
53 if (! -e ".gclient") {
54     # If .gclient configuration file doesn't exist, create it.
55     print "Configuring gclient...\n";
56     system($gclientPath,
57            "config", 
58            "--spec=solutions=[{'name':'./','url':None}]") == 0 or die $!;
59 }
60
61 # When building WebKit's Chromium port for Android, we need the Android NDK as
62 # it will allow us to cross-compile all sources to the target architecture.
63 if (isChromiumAndroid()) {
64     if (! -e "third_party/android-ndk-r7") {
65         print "Installing the Android NDK, version 7...\n";
66         if (! -e "third_party/") {
67             mkdir "third_party";
68         }
69         my $host_os = isLinux() ? "linux" : "darwin";
70         my $result = system("curl", "-o", "third_party/android-ndk-r7.tar.bz2", "http://dl.google.com/android/ndk/android-ndk-r7-" . $host_os . "-x86.tar.bz2");
71         die "Couldn't download the Android NDK." if $result;
72
73         $result = system("tar", "jxC", "third_party", "-f", "third_party/android-ndk-r7.tar.bz2");
74         die "Couldn't extract the Android NDK." if $result;
75     }
76
77     $ENV{ANDROID_NDK_ROOT} = sourceDir() . "/Source/WebKit/chromium/third_party/android-ndk-r7";
78     $ENV{WEBKIT_ANDROID_BUILD} = 1;
79 }
80
81 my $force = 0;
82 GetOptions(
83   'force' => \$force,
84 );
85
86 # Execute gclient sync.
87 print "Updating chromium port dependencies using gclient...\n";
88 my @gclientArgs = ($gclientPath, "sync");
89 push @gclientArgs, "--force" if $force;
90 # --reset could delete modified files if necessary to sync.
91 push @gclientArgs, "--reset" if $force;
92 push @gclientArgs, "--delete_unversioned_trees" if $force;
93 push @gclientArgs, "--deps=unix,android" if isChromiumAndroid();
94
95 my $cmd = join(" ",@gclientArgs);
96 my $max_attempts = 3;
97 my $rc = -1;
98
99 # The following will call glient up to $max_attempts times before
100 # it gives up and fails.  We need this because glcient can fail
101 # for several reasons, some of which are transient (flakiness).
102
103 for (1 .. $max_attempts) {
104     $rc = system($cmd);
105     print "Re-trying '" . $cmd . "'\n" if $rc != 0;
106     last if $rc == 0;
107 }
108
109 die "Error: '$cmd' failed $max_attempts tries and returned " . $rc if ($rc);