1# Usage: ./update.sh [blink-core-source-directory]
2#
3# Copies the needed files from a directory containing the original
4# Decimal.h and Decimal.cpp source that we need.
5# If [blink-core-source-directory] is not specified, this script will
6# attempt to download the latest versions using git.
7
8set -e
9
10FILES=(
11  "Decimal.h"
12  "Decimal.cpp"
13)
14
15OWN_NAME=`basename $0`
16
17if [ $# -gt 1 ]; then
18  echo "$OWN_NAME: Too many arguments">&2
19  exit 1
20fi
21
22if [ $# -eq 1 ]; then
23  BLINK_CORE_DIR="$1"
24  for F in "${FILES[@]}"
25  do
26    P="$BLINK_CORE_DIR/$F"
27    if [ ! -f "$P" ]; then
28      echo "$OWN_NAME: Couldn't find file: $P">&2
29      exit 1
30    fi
31  done
32  for F in "${FILES[@]}"
33  do
34    P="$BLINK_CORE_DIR/$F"
35    cp "$P" .
36  done
37else
38  #LATEST_SHA=$(cat UPSTREAM-GIT-SHA)
39  LATEST_SHA=$(git ls-remote https://chromium.googlesource.com/chromium/src.git/ | awk "/refs\/heads\/master/ {print \$1}")
40  REPO_PATH="https://chromium.googlesource.com/chromium/src.git/+/$LATEST_SHA/third_party/WebKit/Source/platform"
41  #REPO_PATH="https://github.com/WebKit/webkit/tree/master/Source/WebCore/platform"
42  for F in "${FILES[@]}"
43  do
44    printf "Downloading `basename $F`..."
45    curl "$REPO_PATH/${F}?format=TEXT" | base64 -D > "$F"
46    echo done.
47  done
48  echo $LATEST_SHA > UPSTREAM-GIT-SHA
49fi
50
51# Apply patches:
52
53patch -p4 < zero-serialization.patch
54patch -p4 < comparison-with-nan.patch
55patch -p4 < mfbt-abi-markers.patch
56patch -p4 < to-moz-dependencies.patch
57patch -p4 < add-doubleconversion-impl.patch
58# The following is disabled. See
59# https://bugzilla.mozilla.org/show_bug.cgi?id=1208357#c7
60#patch -p4 < fix-wshadow-warnings.patch
61