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 11SKQP_BRANCH=android-cts-12.1_r5 12 13# hack for skqp see the clang 14pushd /usr/bin/ 15ln -s ../lib/llvm-15/bin/clang clang 16ln -s ../lib/llvm-15/bin/clang++ clang++ 17popd 18 19create_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 28download_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 41set -ex 42 43SCRIPT_DIR=$(realpath "$(dirname "$0")") 44SKQP_PATCH_DIR="${SCRIPT_DIR}/patches" 45BASE_ARGS_GN_FILE="${SCRIPT_DIR}/build-skqp_base.gn" 46 47SKQP_ARCH=${SKQP_ARCH:-x64} 48SKIA_DIR=${SKIA_DIR:-$(mktemp -d)} 49SKQP_OUT_DIR=${SKIA_DIR}/out/${SKQP_ARCH} 50SKQP_INSTALL_DIR=${SKQP_INSTALL_DIR:-/skqp} 51SKQP_ASSETS_DIR="${SKQP_INSTALL_DIR}/assets" 52SKQP_BINARIES=(skqp list_gpu_unit_tests list_gms) 53 54download_skia_source 55 56pushd "${SKIA_DIR}" 57 58# Apply all skqp patches for Mesa CI 59cat "${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. 65python tools/git-sync-deps 66 67mkdir -p "${SKQP_OUT_DIR}" 68mkdir -p "${SKQP_INSTALL_DIR}" 69 70create_gn_args 71 72# Build and install skqp binaries 73bin/gn gen "${SKQP_OUT_DIR}" 74 75for BINARY in "${SKQP_BINARIES[@]}" 76do 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}" 81done 82 83# Move assets to the target directory, which will reside in rootfs. 84mv platform_tools/android/apps/skqp/src/main/assets/ "${SKQP_ASSETS_DIR}" 85 86popd 87rm -Rf "${SKIA_DIR}" 88 89set +ex 90