ci: Drop the git dependency in tracie
[mesa.git] / .gitlab-ci / container / x86_build.sh
1 #!/bin/bash
2
3 set -e
4 set -o xtrace
5
6 export DEBIAN_FRONTEND=noninteractive
7
8 CROSS_ARCHITECTURES="i386 ppc64el s390x"
9 for arch in $CROSS_ARCHITECTURES; do
10 dpkg --add-architecture $arch
11 done
12
13 apt-get install -y \
14 ca-certificates \
15 gnupg \
16 unzip \
17 wget
18
19 # Upstream LLVM package repository
20 apt-key add .gitlab-ci/container/llvm-snapshot.gpg.key
21 echo "deb https://apt.llvm.org/buster/ llvm-toolchain-buster-9 main" >/etc/apt/sources.list.d/llvm9.list
22
23 sed -i -e 's/http:\/\/deb/https:\/\/deb/g' /etc/apt/sources.list
24 echo 'deb https://deb.debian.org/debian buster-backports main' >/etc/apt/sources.list.d/backports.list
25
26 apt-get update
27
28 # Use newer packages from backports by default
29 cat >/etc/apt/preferences <<EOF
30 Package: *
31 Pin: release a=buster-backports
32 Pin-Priority: 500
33 EOF
34
35 apt-get dist-upgrade -y
36
37 apt-get install -y --no-remove \
38 autoconf \
39 automake \
40 autotools-dev \
41 bison \
42 ccache \
43 clang-9 \
44 cmake \
45 flex \
46 g++ \
47 gcc \
48 gettext \
49 git \
50 libclang-6.0-dev \
51 libclang-7-dev \
52 libclang-8-dev \
53 libclang-9-dev \
54 libclc-dev \
55 libelf-dev \
56 libepoxy-dev \
57 libexpat1-dev \
58 libgbm-dev \
59 libgtk-3-dev \
60 libomxil-bellagio-dev \
61 libpciaccess-dev \
62 libtool \
63 libunwind-dev \
64 libva-dev \
65 libvdpau-dev \
66 libvulkan-dev \
67 libvulkan-dev:ppc64el \
68 libx11-dev \
69 libx11-xcb-dev \
70 libxdamage-dev \
71 libxext-dev \
72 libxml2-utils \
73 libxrandr-dev \
74 libxrender-dev \
75 libxshmfence-dev \
76 libxvmc-dev \
77 libxxf86vm-dev \
78 llvm-6.0-dev \
79 llvm-7-dev \
80 llvm-9-dev \
81 meson \
82 pkg-config \
83 python-mako \
84 python3-mako \
85 python3-pil \
86 python3-requests \
87 qemu-user \
88 scons \
89 x11proto-dri2-dev \
90 x11proto-gl-dev \
91 x11proto-randr-dev \
92 xz-utils \
93 zlib1g-dev
94
95 # Cross-build Mesa deps
96 for arch in $CROSS_ARCHITECTURES; do
97 apt-get install -y --no-remove \
98 crossbuild-essential-${arch} \
99 libdrm-dev:${arch} \
100 libelf-dev:${arch} \
101 libexpat1-dev:${arch} \
102 libffi-dev:${arch} \
103 libllvm8:${arch} \
104 libstdc++6:${arch} \
105 libtinfo-dev:${arch}
106
107 if [ "$arch" == "i386" ]; then
108 # libpciaccess-dev is only needed for Intel.
109 apt-get install -y --no-remove \
110 libpciaccess-dev:${arch}
111 fi
112
113 mkdir /var/cache/apt/archives/${arch}
114 # Download llvm-* packages, but don't install them yet, since they can
115 # only be installed for one architecture at a time
116 apt-get install -o Dir::Cache::archives=/var/cache/apt/archives/$arch --download-only -y --no-remove \
117 llvm-8-dev:${arch}
118 done
119
120 apt-get install -y --no-remove \
121 llvm-8-dev \
122
123 # for 64bit windows cross-builds
124 apt-get install -y --no-remove \
125 libz-mingw-w64-dev \
126 mingw-w64 \
127 wine \
128 wine32 \
129 wine64
130
131 # Debian's pkg-config wrapers for mingw are broken, and there's no sign that
132 # they're going to be fixed, so we'll just have to fix it ourselves
133 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=930492
134 cat >/usr/local/bin/x86_64-w64-mingw32-pkg-config <<EOF
135 #!/bin/sh
136
137 PKG_CONFIG_LIBDIR=/usr/x86_64-w64-mingw32/lib/pkgconfig pkg-config \$@
138 EOF
139 chmod +x /usr/local/bin/x86_64-w64-mingw32-pkg-config
140
141
142 # Generate cross build files for Meson
143 for arch in $CROSS_ARCHITECTURES; do
144 cross_file="/cross_file-$arch.txt"
145 /usr/share/meson/debcrossgen --arch "$arch" -o "$cross_file"
146 # Explicitly set ccache path for cross compilers
147 sed -i "s|/usr/bin/\([^-]*\)-linux-gnu\([^-]*\)-g|/usr/lib/ccache/\\1-linux-gnu\\2-g|g" "$cross_file"
148 if [ "$arch" = "i386" ]; then
149 # Work around a bug in debcrossgen that should be fixed in the next release
150 sed -i "s|cpu_family = 'i686'|cpu_family = 'x86'|g" "$cross_file"
151 fi
152
153 # Rely on qemu-user being configured in binfmt_misc on the host
154 sed -i -e '/\[properties\]/a\' -e "needs_exe_wrapper = False" "$cross_file"
155 done
156
157
158 # for the vulkan overlay layer
159 wget https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Release.zip
160 unzip glslang-master-linux-Release.zip bin/glslangValidator
161 install -m755 bin/glslangValidator /usr/local/bin/
162 rm bin/glslangValidator glslang-master-linux-Release.zip
163
164
165 # dependencies where we want a specific version
166 export XORG_RELEASES=https://xorg.freedesktop.org/releases/individual
167 export XCB_RELEASES=https://xcb.freedesktop.org/dist
168 export WAYLAND_RELEASES=https://wayland.freedesktop.org/releases
169
170 export XORGMACROS_VERSION=util-macros-1.19.0
171 export LIBDRM_VERSION=libdrm-2.4.100
172 export XCBPROTO_VERSION=xcb-proto-1.13
173 export LIBXCB_VERSION=libxcb-1.13
174 export LIBWAYLAND_VERSION=wayland-1.15.0
175 export WAYLAND_PROTOCOLS_VERSION=wayland-protocols-1.12
176
177 wget $XORG_RELEASES/util/$XORGMACROS_VERSION.tar.bz2
178 tar -xvf $XORGMACROS_VERSION.tar.bz2 && rm $XORGMACROS_VERSION.tar.bz2
179 cd $XORGMACROS_VERSION; ./configure; make -j4 install; cd ..
180 rm -rf $XORGMACROS_VERSION
181
182 wget $XCB_RELEASES/$XCBPROTO_VERSION.tar.bz2
183 tar -xvf $XCBPROTO_VERSION.tar.bz2 && rm $XCBPROTO_VERSION.tar.bz2
184 cd $XCBPROTO_VERSION; ./configure; make -j4 install; cd ..
185 rm -rf $XCBPROTO_VERSION
186
187 wget $XCB_RELEASES/$LIBXCB_VERSION.tar.bz2
188 tar -xvf $LIBXCB_VERSION.tar.bz2 && rm $LIBXCB_VERSION.tar.bz2
189 cd $LIBXCB_VERSION; ./configure; make -j4 install; cd ..
190 rm -rf $LIBXCB_VERSION
191
192 wget https://dri.freedesktop.org/libdrm/$LIBDRM_VERSION.tar.bz2
193 tar -xvf $LIBDRM_VERSION.tar.bz2 && rm $LIBDRM_VERSION.tar.bz2
194 cd $LIBDRM_VERSION
195 meson build -D vc4=true -D freedreno=true -D etnaviv=true -D libdir=lib/x86_64-linux-gnu; ninja -j4 -C build install
196 rm -rf build; meson --cross-file=/cross_file-ppc64el.txt build -D libdir=lib/powerpc64le-linux-gnu; ninja -j4 -C build install
197 rm -rf build; meson --cross-file=/cross_file-i386.txt build -D libdir=lib/i386-linux-gnu; ninja -j4 -C build install
198 cd ..
199 rm -rf $LIBDRM_VERSION
200
201 wget $WAYLAND_RELEASES/$LIBWAYLAND_VERSION.tar.xz
202 tar -xvf $LIBWAYLAND_VERSION.tar.xz && rm $LIBWAYLAND_VERSION.tar.xz
203 cd $LIBWAYLAND_VERSION; ./configure --enable-libraries --without-host-scanner --disable-documentation --disable-dtd-validation; make -j4 install; cd ..
204 rm -rf $LIBWAYLAND_VERSION
205
206 wget $WAYLAND_RELEASES/$WAYLAND_PROTOCOLS_VERSION.tar.xz
207 tar -xvf $WAYLAND_PROTOCOLS_VERSION.tar.xz && rm $WAYLAND_PROTOCOLS_VERSION.tar.xz
208 cd $WAYLAND_PROTOCOLS_VERSION; ./configure; make -j4 install; cd ..
209 rm -rf $WAYLAND_PROTOCOLS_VERSION
210
211
212 # The version of libglvnd-dev in debian is too old
213 # Check this page to see when this local compilation can be dropped in favour of the package:
214 # https://packages.debian.org/libglvnd-dev
215 GLVND_VERSION=1.2.0
216 wget https://gitlab.freedesktop.org/glvnd/libglvnd/-/archive/v$GLVND_VERSION/libglvnd-v$GLVND_VERSION.tar.gz
217 tar -xvf libglvnd-v$GLVND_VERSION.tar.gz && rm libglvnd-v$GLVND_VERSION.tar.gz
218 pushd libglvnd-v$GLVND_VERSION; ./autogen.sh; ./configure; make -j4 install; popd
219 rm -rf libglvnd-v$GLVND_VERSION
220
221
222 pushd /usr/local
223 git clone https://gitlab.freedesktop.org/mesa/shader-db.git --depth 1
224 rm -rf shader-db/.git
225 cd shader-db
226 make -j4
227 popd
228
229
230 # Remove ccache directory, useless for the build jobs
231 rm -rf $(ccache --get-config=cache_dir)
232
233
234 ############### Uninstall the build software
235
236 apt-get purge -y \
237 autoconf \
238 automake \
239 autotools-dev \
240 cmake \
241 git \
242 gnupg \
243 libgbm-dev \
244 libtool \
245 unzip \
246 wget
247
248 apt-get autoremove -y --purge