summaryrefslogtreecommitdiff
path: root/scripts/download-d8.sh
blob: 05cf1d58035a07ee6415d6124dfbc543ad2f0715 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
set -o nounset
set -o errexit

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
ROOT_DIR="$(dirname "${SCRIPT_DIR}")"
OUT_DIR="${ROOT_DIR}/out"

V8_SHA=1e3d7a199848a4850085e5c7f9dcb524d3f23d6a
BUCKET_URL=https://storage.googleapis.com/webassembly/v8-native-prototype/${V8_SHA}

Download() {
  local URL=$1
  local FILENAME=$2
  echo "Downloading ${URL}..."
  CURL_ARGS="--fail --location"
  if [ -t 1 ]; then
    # Add --progress-bar but only if stdout is a TTY device.
    CURL_ARGS+=" --progress-bar"
  else
    # otherwise suppress all status output, since curl always
    # assumes a TTY and writes \r and \b characters.
    CURL_ARGS+=" --silent"
  fi
  if which curl > /dev/null ; then
    curl ${CURL_ARGS} -o "${FILENAME}" "${URL}"
  else
    echo "error: could not find 'curl' in your PATH"
    exit 1
  fi
}

mkdir -p "${OUT_DIR}"

for file in d8 natives_blob.bin snapshot_blob.bin; do
  Download ${BUCKET_URL}/${file} "${OUT_DIR}/${file}"
done

# Make d8 executable
chmod ug+x "${OUT_DIR}/d8"