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