Debian Codegraph @

experimental/tools/web_to_skp

raw
1 #! /bin/sh
2
3 # Copyright 2018 Google Inc.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 if [ "$(uname)" = Linux ]; then
8 EXAMPLE='/opt/google/chrome/chrome'
9 elif [ "$(uname)" = Darwin ]; then
10 EXAMPLE='"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"'
11 else
12 EXAMPLE='"/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"'
13 fi
14
15 if [ $# -lt 3 ] || ! [ -x "$1" ]; then
16 cat >&2 << EOF
17 usage:
18 $0 CHROMIUM_BINARY SOURCE_URL DESTINATION_DIRECTORY
19 $0 CHROMIUM_BINARY SOURCE_URL DESTINATION_DIRECTORY OPTIONAL_WAIT_TIME # 5 second sleep before capture
20 e.g:
21 $0 $EXAMPLE https://www.google.com/ /tmp/
22 $0 $EXAMPLE https://www.google.com/ /tmp/ 5
23 EOF
24 exit 1
25 fi
26
27 EXE="$1"
28 URL="$2"
29 DST="$3"
30 SLP=${4:-0} # sleep in seconds before capture. 4th param iff provided, else 0.
31
32 CRASH=~/tmp/headless_crash_dumps
33 mkdir -p "$CRASH" "$DST"
34
35 (sleep $SLP; printf 'chrome.gpuBenchmarking.printToSkPicture("%s");\nquit\n' "$DST") | \
36 "$EXE" --headless --disable-gpu --repl -crash-dumps-dir="$CRASH" \
37 --no-sandbox --enable-gpu-benchmarking "$URL"