1#!/usr/bin/env bash 2# shellcheck disable=SC2086 # we want word splitting 3 4# When changing this file, you need to bump the following 5# .gitlab-ci/image-tags.yml tags: 6# DEBIAN_TEST_ANDROID_TAG 7# DEBIAN_TEST_GL_TAG 8# DEBIAN_TEST_VK_TAG 9# KERNEL_ROOTFS_TAG 10 11set -uex -o pipefail 12 13# shellcheck disable=SC2153 14deqp_api=${DEQP_API,,} 15 16uncollapsed_section_start deqp-$deqp_api "Building dEQP $DEQP_API" 17 18# See `deqp_build_targets` below for which release is used to produce which 19# binary. Unless this comment has bitrotten: 20# - the commit from the main branch produces the deqp tools and `deqp-vk`, 21# - the VK release produces `deqp-vk`, 22# - the GL release produces `glcts`, and 23# - the GLES release produces `deqp-gles*` and `deqp-egl` 24 25DEQP_MAIN_COMMIT=a9f7069b9a5ba94715a175cb1818ed504add0107 26DEQP_VK_VERSION=1.3.10.0 27DEQP_GL_VERSION=4.6.5.0 28DEQP_GLES_VERSION=3.2.11.0 29 30# Patches to VulkanCTS may come from commits in their repo (listed in 31# cts_commits_to_backport) or patch files stored in our repo (in the patch 32# directory `$OLDPWD/.gitlab-ci/container/patches/` listed in cts_patch_files). 33# Both list variables would have comments explaining the reasons behind the 34# patches. 35 36# shellcheck disable=SC2034 37main_cts_commits_to_backport=( 38 # If you find yourself wanting to add something in here, consider whether 39 # bumping DEQP_MAIN_COMMIT is not a better solution :) 40 41 # Build testlog-* and other tools also on Android 42 0fcd87248f83a2174e5c938cb105dc2da03f3683 43) 44 45# shellcheck disable=SC2034 46main_cts_patch_files=( 47) 48 49# shellcheck disable=SC2034 50vk_cts_commits_to_backport=( 51 # Remove multi-line test results in DRM format modifier tests 52 8c95af68a2a85cbdc7e1d9267ab029f73e9427d2 53) 54 55# shellcheck disable=SC2034 56vk_cts_patch_files=( 57) 58 59# shellcheck disable=SC2034 60gl_cts_commits_to_backport=( 61 # Add #include <cmath> in deMath.h when being compiled by C++ 62 71808fe7d0a640dfd703e845d93ba1c5ab751055 63 # Revert "Add #include <cmath> in deMath.h when being compiled by C++ compiler" 64 # This also adds an alternative fix along with the revert. 65 6164879a0acce258637d261592a9c395e564b361 66) 67 68# shellcheck disable=SC2034 69gl_cts_patch_files=( 70) 71 72if [ "${DEQP_TARGET}" = 'android' ]; then 73 gl_cts_patch_files+=( 74 build-deqp-gl_Allow-running-on-Android-from-the-command-line.patch 75 build-deqp-gl_Android-prints-to-stdout-instead-of-logcat.patch 76 ) 77fi 78 79# shellcheck disable=SC2034 80# GLES builds also EGL 81gles_cts_commits_to_backport=( 82 # Add #include <cmath> in deMath.h when being compiled by C++ 83 71808fe7d0a640dfd703e845d93ba1c5ab751055 84 # Revert "Add #include <cmath> in deMath.h when being compiled by C++ compiler" 85 # This also adds an alternative fix along with the revert. 86 6164879a0acce258637d261592a9c395e564b361 87) 88 89# shellcheck disable=SC2034 90gles_cts_patch_files=( 91) 92 93if [ "${DEQP_TARGET}" = 'android' ]; then 94 gles_cts_patch_files+=( 95 build-deqp-gles_Allow-running-on-Android-from-the-command-line.patch 96 build-deqp-gles_Android-prints-to-stdout-instead-of-logcat.patch 97 ) 98fi 99 100 101### Careful editing anything below this line 102 103 104git config --global user.email "mesa@example.com" 105git config --global user.name "Mesa CI" 106 107# shellcheck disable=SC2153 108case "${DEQP_API}" in 109 tools) DEQP_VERSION="$DEQP_MAIN_COMMIT";; 110 *-main) DEQP_VERSION="$DEQP_MAIN_COMMIT";; 111 VK) DEQP_VERSION="vulkan-cts-$DEQP_VK_VERSION";; 112 GL) DEQP_VERSION="opengl-cts-$DEQP_GL_VERSION";; 113 GLES) DEQP_VERSION="opengl-es-cts-$DEQP_GLES_VERSION";; 114 *) echo "Unexpected DEQP_API value: $DEQP_API"; exit 1;; 115esac 116 117mkdir -p /VK-GL-CTS 118pushd /VK-GL-CTS 119[ -e .git ] || { 120 git init 121 git remote add origin https://github.com/KhronosGroup/VK-GL-CTS.git 122} 123git fetch --depth 1 origin "$DEQP_VERSION" 124git checkout FETCH_HEAD 125DEQP_COMMIT=$(git rev-parse FETCH_HEAD) 126 127if [ "$DEQP_VERSION" = "$DEQP_MAIN_COMMIT" ]; then 128 git fetch origin main 129 if ! git merge-base --is-ancestor "$DEQP_MAIN_COMMIT" origin/main; then 130 echo "VK-GL-CTS commit $DEQP_MAIN_COMMIT is not a commit from the main branch." 131 exit 1 132 fi 133fi 134 135mkdir -p /deqp-$deqp_api 136 137if [ "$DEQP_VERSION" = "$DEQP_MAIN_COMMIT" ]; then 138 prefix="main" 139else 140 prefix="$deqp_api" 141fi 142 143cts_commits_to_backport="${prefix}_cts_commits_to_backport[@]" 144for commit in "${!cts_commits_to_backport}" 145do 146 PATCH_URL="https://github.com/KhronosGroup/VK-GL-CTS/commit/$commit.patch" 147 echo "Apply patch to ${DEQP_API} CTS from $PATCH_URL" 148 curl -L --retry 4 -f --retry-all-errors --retry-delay 60 $PATCH_URL | \ 149 GIT_COMMITTER_DATE=$(LC_TIME=C date -d@0) git am - 150done 151 152cts_patch_files="${prefix}_cts_patch_files[@]" 153for patch in "${!cts_patch_files}" 154do 155 echo "Apply patch to ${DEQP_API} CTS from $patch" 156 GIT_COMMITTER_DATE=$(LC_TIME=C date -d@0) git am < $OLDPWD/.gitlab-ci/container/patches/$patch 157done 158 159{ 160 if [ "$DEQP_VERSION" = "$DEQP_MAIN_COMMIT" ]; then 161 commit_desc=$(git show --no-patch --format='commit %h on %ci' --abbrev=10 "$DEQP_COMMIT") 162 echo "dEQP $DEQP_API at $commit_desc" 163 else 164 echo "dEQP $DEQP_API version $DEQP_VERSION" 165 fi 166 if [ "$(git rev-parse HEAD)" != "$DEQP_COMMIT" ]; then 167 echo "The following local patches are applied on top:" 168 git log --reverse --oneline "$DEQP_COMMIT".. --format='- %s' 169 fi 170} > /deqp-$deqp_api/deqp-$deqp_api-version 171 172# --insecure is due to SSL cert failures hitting sourceforge for zlib and 173# libpng (sigh). The archives get their checksums checked anyway, and git 174# always goes through ssh or https. 175python3 external/fetch_sources.py --insecure 176 177if [[ "$DEQP_API" = tools ]]; then 178 # Save the testlog stylesheets: 179 cp doc/testlog-stylesheet/testlog.{css,xsl} /deqp-$deqp_api 180fi 181 182popd 183 184pushd /deqp-$deqp_api 185 186if [ "${DEQP_API}" = 'GLES' ]; then 187 if [ "${DEQP_TARGET}" = 'android' ]; then 188 cmake -S /VK-GL-CTS -B . -G Ninja \ 189 -DDEQP_TARGET=android \ 190 -DCMAKE_BUILD_TYPE=Release \ 191 ${EXTRA_CMAKE_ARGS:-} 192 ninja modules/egl/deqp-egl 193 mv modules/egl/deqp-egl{,-android} 194 else 195 # When including EGL/X11 testing, do that build first and save off its 196 # deqp-egl binary. 197 cmake -S /VK-GL-CTS -B . -G Ninja \ 198 -DDEQP_TARGET=x11_egl_glx \ 199 -DCMAKE_BUILD_TYPE=Release \ 200 ${EXTRA_CMAKE_ARGS:-} 201 ninja modules/egl/deqp-egl 202 mv modules/egl/deqp-egl{,-x11} 203 204 cmake -S /VK-GL-CTS -B . -G Ninja \ 205 -DDEQP_TARGET=wayland \ 206 -DCMAKE_BUILD_TYPE=Release \ 207 ${EXTRA_CMAKE_ARGS:-} 208 ninja modules/egl/deqp-egl 209 mv modules/egl/deqp-egl{,-wayland} 210 fi 211fi 212 213cmake -S /VK-GL-CTS -B . -G Ninja \ 214 -DDEQP_TARGET=${DEQP_TARGET} \ 215 -DCMAKE_BUILD_TYPE=Release \ 216 ${EXTRA_CMAKE_ARGS:-} 217 218# Make sure `default` doesn't silently stop detecting one of the platforms we care about 219if [ "${DEQP_TARGET}" = 'default' ]; then 220 grep -q DEQP_SUPPORT_WAYLAND=1 build.ninja 221 grep -q DEQP_SUPPORT_X11=1 build.ninja 222 grep -q DEQP_SUPPORT_XCB=1 build.ninja 223fi 224 225deqp_build_targets=() 226case "${DEQP_API}" in 227 VK|VK-main) 228 deqp_build_targets+=(deqp-vk) 229 ;; 230 GL) 231 deqp_build_targets+=(glcts) 232 ;; 233 GLES) 234 deqp_build_targets+=(deqp-gles{2,3,31}) 235 deqp_build_targets+=(glcts) # needed for gles*-khr tests 236 # deqp-egl also comes from this build, but it is handled separately above. 237 ;; 238 tools) 239 deqp_build_targets+=(testlog-to-xml) 240 deqp_build_targets+=(testlog-to-csv) 241 deqp_build_targets+=(testlog-to-junit) 242 ;; 243esac 244 245ninja "${deqp_build_targets[@]}" 246 247if [ "$DEQP_API" != tools ]; then 248 # Copy out the mustpass lists we want. 249 mkdir -p mustpass 250 251 if [ "${DEQP_API}" = 'VK' ] || [ "${DEQP_API}" = 'VK-main' ]; then 252 for mustpass in $(< /VK-GL-CTS/external/vulkancts/mustpass/main/vk-default.txt) ; do 253 cat /VK-GL-CTS/external/vulkancts/mustpass/main/$mustpass \ 254 >> mustpass/vk-main.txt 255 done 256 fi 257 258 if [ "${DEQP_API}" = 'GL' ]; then 259 cp \ 260 /VK-GL-CTS/external/openglcts/data/gl_cts/data/mustpass/gl/khronos_mustpass/main/*-main.txt \ 261 mustpass/ 262 cp \ 263 /VK-GL-CTS/external/openglcts/data/gl_cts/data/mustpass/gl/khronos_mustpass_single/main/*-single.txt \ 264 mustpass/ 265 fi 266 267 if [ "${DEQP_API}" = 'GLES' ]; then 268 cp \ 269 /VK-GL-CTS/external/openglcts/data/gl_cts/data/mustpass/gles/aosp_mustpass/main/*.txt \ 270 mustpass/ 271 cp \ 272 /VK-GL-CTS/external/openglcts/data/gl_cts/data/mustpass/egl/aosp_mustpass/main/egl-main.txt \ 273 mustpass/ 274 cp \ 275 /VK-GL-CTS/external/openglcts/data/gl_cts/data/mustpass/gles/khronos_mustpass/main/*-main.txt \ 276 mustpass/ 277 fi 278 279 # Compress the caselists, since Vulkan's in particular are gigantic; higher 280 # compression levels provide no real measurable benefit. 281 zstd -1 --rm mustpass/*.txt 282fi 283 284if [ "$DEQP_API" = tools ]; then 285 # Save *some* executor utils, but otherwise strip things down 286 # to reduct deqp build size: 287 mv executor/testlog-to-* . 288 rm -rf executor 289fi 290 291# Remove other mustpass files, since we saved off the ones we wanted to conventient locations above. 292rm -rf external/**/mustpass/ 293rm -rf external/vulkancts/modules/vulkan/vk-main* 294rm -rf external/vulkancts/modules/vulkan/vk-default 295 296rm -rf external/openglcts/modules/cts-runner 297rm -rf modules/internal 298rm -rf execserver 299rm -rf framework 300find . -depth \( -iname '*cmake*' -o -name '*ninja*' -o -name '*.o' -o -name '*.a' \) -exec rm -rf {} \; 301if [ "${DEQP_API}" = 'VK' ] || [ "${DEQP_API}" = 'VK-main' ]; then 302 ${STRIP_CMD:-strip} external/vulkancts/modules/vulkan/deqp-vk 303fi 304if [ "${DEQP_API}" = 'GL' ] || [ "${DEQP_API}" = 'GLES' ]; then 305 ${STRIP_CMD:-strip} external/openglcts/modules/glcts 306fi 307if [ "${DEQP_API}" = 'GLES' ]; then 308 ${STRIP_CMD:-strip} modules/*/deqp-* 309fi 310du -sh ./* 311popd 312 313section_end deqp-$deqp_api 314