3 # Copyright (C) 2009 Google Inc. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
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.
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.
29 # Update script for the WebKit Chromium Port.
34 use lib $FindBin::Bin;
37 determineIsChromiumAndroid();
40 chdir("Source/WebKit/chromium") or die $!;
42 # Find gclient or install it.
44 if (commandExists('gclient')) {
45 $gclientPath = 'gclient';
46 } elsif (-e 'depot_tools/gclient') {
47 $gclientPath = 'depot_tools/gclient';
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';
54 if (! -e ".gclient") {
55 # If .gclient configuration file doesn't exist, create it.
56 print "Configuring gclient...\n";
59 "--spec=solutions=[{'name':'./','url':None}]") == 0 or die $!;
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;
71 $result = system("tar", "jx", "-f", "android-ndk-r7b.tar.bz2");
72 die "Couldn't extract the Android NDK." if $result;
75 my $androidNdkRoot = sourceDir() . "/Source/WebKit/chromium/android-ndk-r7b";
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();
81 $ENV{ANDROID_NDK_ROOT} = $androidNdkRoot;
82 $ENV{WEBKIT_ANDROID_BUILD} = 1;
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();
99 my $cmd = join(" ",@gclientArgs);
100 my $max_attempts = 3;
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).
107 for (1 .. $max_attempts) {
109 print "Re-trying '" . $cmd . "'\n" if $rc != 0;
113 die "Error: '$cmd' failed $max_attempts tries and returned " . $rc if ($rc);