3 # Copyright (C) 2022 Collabora Limited
4 # Author: Guilherme Gallo <guilherme.gallo@collabora.com>
6 # Permission is hereby granted, free of charge, to any person obtaining a
7 # copy of this software and associated documentation files (the "Software"),
8 # to deal in the Software without restriction, including without limitation
9 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 # and/or sell copies of the Software, and to permit persons to whom the
11 # Software is furnished to do so, subject to the following conditions:
13 # The above copyright notice and this permission notice (including the next
14 # paragraph) shall be included in all copies or substantial portions of the
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 # gn can be configured to cross-compile skia and its tools
28 # It is important to set the target_cpu to guarantee the intended target
30 cp "${BASE_ARGS_GN_FILE}" "${SKQP_OUT_DIR}"/args.gn
31 echo "target_cpu = \"${SKQP_ARCH}\"" >> "${SKQP_OUT_DIR}"/args.gn
35 download_skia_source() {
36 if [ -z ${SKIA_DIR+x} ]
41 # Skia cloned from https://android.googlesource.com/platform/external/skqp
42 # has all needed assets tracked on git-fs
43 SKQP_REPO=https://android.googlesource.com/platform/external/skqp
44 SKQP_BRANCH=android-cts-11.0_r7
46 git clone --branch "${SKQP_BRANCH}" --depth 1 "${SKQP_REPO}" "${SKIA_DIR}"
51 SCRIPT_DIR=$(realpath "$(dirname "$0")")
52 SKQP_PATCH_DIR="${SCRIPT_DIR}"
53 BASE_ARGS_GN_FILE="${SCRIPT_DIR}/build-skqp_base.gn"
55 SKQP_ARCH=${SKQP_ARCH:-x64}
56 SKIA_DIR=${SKIA_DIR:-$(mktemp -d)}
57 SKQP_OUT_DIR=${SKIA_DIR}/out/${SKQP_ARCH}
58 SKQP_INSTALL_DIR=${SKQP_INSTALL_DIR:-/skqp}
59 SKQP_ASSETS_DIR="${SKQP_INSTALL_DIR}/assets"
60 SKQP_BINARIES=(skqp list_gpu_unit_tests list_gms)
66 # Apply all skqp patches for Mesa CI
67 cat "${SKQP_PATCH_DIR}"/build-skqp_*.patch |
70 # Fetch some needed build tools needed to build skia/skqp.
71 # Basically, it clones repositories with commits SHAs from ${SKIA_DIR}/DEPS
73 python tools/git-sync-deps
75 mkdir -p "${SKQP_OUT_DIR}"
76 mkdir -p "${SKQP_INSTALL_DIR}"
80 # Build and install skqp binaries
81 bin/gn gen "${SKQP_OUT_DIR}"
83 for BINARY in "${SKQP_BINARIES[@]}"
85 /usr/bin/ninja -C "${SKQP_OUT_DIR}" "${BINARY}"
86 # Strip binary, since gn is not stripping it even when `is_debug == false`
87 ${STRIP_CMD:-strip} "${SKQP_OUT_DIR}/${BINARY}"
88 install -m 0755 "${SKQP_OUT_DIR}/${BINARY}" "${SKQP_INSTALL_DIR}"
91 # Move assets to the target directory, which will reside in rootfs.
92 mv platform_tools/android/apps/skqp/src/main/assets/ "${SKQP_ASSETS_DIR}"