aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/tools/web_to_skp
blob: cde5dce645c17002269019179a3582f7ac02e263 (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
#! /bin/sh

# Copyright 2018 Google Inc.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

if [ "$(uname)" = Linux ]; then
  EXAMPLE='/opt/google/chrome/chrome'
elif [ "$(uname)" = Darwin ]; then
  EXAMPLE='"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"'
else
  EXAMPLE='"/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"'
fi

if [ $# -ne 3 ] || ! [ -x "$1" ]; then
  cat >&2 << EOF
usage:
  $0 CHROMIUM_BINARY SOURCE_URL DESTINATION_DIRECTORY
e.g:
  $0 $EXAMPLE https://www.google.com/ /tmp/
EOF
  exit 1
fi

EXE="$1"
URL="$2"
DST="$3"

CRASH=~/tmp/headless_crash_dumps
mkdir -p "$CRASH" "$DST"

printf 'chrome.gpuBenchmarking.printToSkPicture("%s");\nquit\n' "$DST" | \
  "$EXE" --headless --disable-gpu --repl -crash-dumps-dir="$CRASH" \
    --no-sandbox --enable-gpu-benchmarking "$URL"