1#!/bin/sh
2# Copyright 2018 Google LLC.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6# Notes:
7#
8#    You may need to run as root for docker permissions.
9#
10#    You *must* run `tools/git-sync-deps` first.
11
12if [ "$SKQP_OUTPUT_DIR" ]; then
13    mkdir -p "$SKQP_OUTPUT_DIR" || exit 1
14    OUT="$(cd "$SKQP_OUTPUT_DIR"; pwd)"
15else
16    OUT="$(mktemp -d "${TMPDIR:-/tmp}/skqp_apk.XXXXXXXXXX")"
17fi
18SKIA_ROOT="$(cd "$(dirname "$0")/../.."; pwd)"
19
20cd "${SKIA_ROOT}/infra/skqp/docker"
21
22docker build -t android-skqp ./android-skqp/
23
24NAME=$(date +android_em_%Y%m%d_%H%M%S)
25
26docker run --rm -d --name "$NAME" \
27        --env=DEVICE="Samsung Galaxy S6" \
28        --volume="$SKIA_ROOT":/SRC \
29        --volume="$OUT":/OUT \
30        android-skqp
31
32BUILD="$(docker exec "$NAME" mktemp -d)"
33
34docker exec \
35    --env=SKQP_OUTPUT_DIR=/OUT \
36    --env=SKQP_BUILD_DIR="$BUILD" \
37    "$NAME" /SRC/tools/skqp/make_universal_apk.py
38
39if [ -f "$OUT"/skqp-universal-debug.apk ]; then
40    docker exec "$NAME" find /OUT -type f -exec chmod 0666 '{}' '+'
41fi
42
43docker kill "$NAME"
44
45ls -l "$OUT"/*.apk 2> /dev/null
46