1 | #!/usr/bin/env bash
|
---|
2 | # SPDX-License-Identifier: MIT
|
---|
3 | #
|
---|
4 | # Copyright © 2022 Collabora Limited
|
---|
5 | # Author: Guilherme Gallo <[email protected]>
|
---|
6 | #
|
---|
7 | # When changing this file, you need to bump the following
|
---|
8 | # .gitlab-ci/image-tags.yml tags:
|
---|
9 | # KERNEL_ROOTFS_TAG
|
---|
10 |
|
---|
11 | SKQP_BRANCH=android-cts-12.1_r5
|
---|
12 |
|
---|
13 | # hack for skqp see the clang
|
---|
14 | pushd /usr/bin/
|
---|
15 | ln -s ../lib/llvm-15/bin/clang clang
|
---|
16 | ln -s ../lib/llvm-15/bin/clang++ clang++
|
---|
17 | popd
|
---|
18 |
|
---|
19 | create_gn_args() {
|
---|
20 | # gn can be configured to cross-compile skia and its tools
|
---|
21 | # It is important to set the target_cpu to guarantee the intended target
|
---|
22 | # machine
|
---|
23 | cp "${BASE_ARGS_GN_FILE}" "${SKQP_OUT_DIR}"/args.gn
|
---|
24 | echo "target_cpu = \"${SKQP_ARCH}\"" >> "${SKQP_OUT_DIR}"/args.gn
|
---|
25 | }
|
---|
26 |
|
---|
27 |
|
---|
28 | download_skia_source() {
|
---|
29 | if [ -z ${SKIA_DIR+x} ]
|
---|
30 | then
|
---|
31 | return 1
|
---|
32 | fi
|
---|
33 |
|
---|
34 | # Skia cloned from https://android.googlesource.com/platform/external/skqp
|
---|
35 | # has all needed assets tracked on git-fs
|
---|
36 | SKQP_REPO=https://android.googlesource.com/platform/external/skqp
|
---|
37 |
|
---|
38 | git clone --branch "${SKQP_BRANCH}" --depth 1 "${SKQP_REPO}" "${SKIA_DIR}"
|
---|
39 | }
|
---|
40 |
|
---|
41 | set -ex
|
---|
42 |
|
---|
43 | SCRIPT_DIR=$(realpath "$(dirname "$0")")
|
---|
44 | SKQP_PATCH_DIR="${SCRIPT_DIR}/patches"
|
---|
45 | BASE_ARGS_GN_FILE="${SCRIPT_DIR}/build-skqp_base.gn"
|
---|
46 |
|
---|
47 | SKQP_ARCH=${SKQP_ARCH:-x64}
|
---|
48 | SKIA_DIR=${SKIA_DIR:-$(mktemp -d)}
|
---|
49 | SKQP_OUT_DIR=${SKIA_DIR}/out/${SKQP_ARCH}
|
---|
50 | SKQP_INSTALL_DIR=${SKQP_INSTALL_DIR:-/skqp}
|
---|
51 | SKQP_ASSETS_DIR="${SKQP_INSTALL_DIR}/assets"
|
---|
52 | SKQP_BINARIES=(skqp list_gpu_unit_tests list_gms)
|
---|
53 |
|
---|
54 | download_skia_source
|
---|
55 |
|
---|
56 | pushd "${SKIA_DIR}"
|
---|
57 |
|
---|
58 | # Apply all skqp patches for Mesa CI
|
---|
59 | cat "${SKQP_PATCH_DIR}"/build-skqp_*.patch |
|
---|
60 | patch -p1
|
---|
61 |
|
---|
62 | # Fetch some needed build tools needed to build skia/skqp.
|
---|
63 | # Basically, it clones repositories with commits SHAs from ${SKIA_DIR}/DEPS
|
---|
64 | # directory.
|
---|
65 | python tools/git-sync-deps
|
---|
66 |
|
---|
67 | mkdir -p "${SKQP_OUT_DIR}"
|
---|
68 | mkdir -p "${SKQP_INSTALL_DIR}"
|
---|
69 |
|
---|
70 | create_gn_args
|
---|
71 |
|
---|
72 | # Build and install skqp binaries
|
---|
73 | bin/gn gen "${SKQP_OUT_DIR}"
|
---|
74 |
|
---|
75 | for BINARY in "${SKQP_BINARIES[@]}"
|
---|
76 | do
|
---|
77 | /usr/bin/ninja -C "${SKQP_OUT_DIR}" "${BINARY}"
|
---|
78 | # Strip binary, since gn is not stripping it even when `is_debug == false`
|
---|
79 | ${STRIP_CMD:-strip} "${SKQP_OUT_DIR}/${BINARY}"
|
---|
80 | install -m 0755 "${SKQP_OUT_DIR}/${BINARY}" "${SKQP_INSTALL_DIR}"
|
---|
81 | done
|
---|
82 |
|
---|
83 | # Move assets to the target directory, which will reside in rootfs.
|
---|
84 | mv platform_tools/android/apps/skqp/src/main/assets/ "${SKQP_ASSETS_DIR}"
|
---|
85 |
|
---|
86 | popd
|
---|
87 | rm -Rf "${SKIA_DIR}"
|
---|
88 |
|
---|
89 | set +ex
|
---|