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