0330d7b4818c0a05ce9810b5cf981c6140814337
[platform/upstream/mesa.git] / .gitlab-ci / create-cross-file.sh
1 #!/bin/bash
2
3 arch=$1
4 cross_file="/cross_file-$arch.txt"
5 /usr/share/meson/debcrossgen --arch $arch -o "$cross_file"
6 # Explicitly set ccache path for cross compilers
7 sed -i "s|/usr/bin/\([^-]*\)-linux-gnu\([^-]*\)-g|/usr/lib/ccache/\\1-linux-gnu\\2-g|g" "$cross_file"
8 if [ "$arch" = "i386" ]; then
9     # Work around a bug in debcrossgen that should be fixed in the next release
10     sed -i "s|cpu_family = 'i686'|cpu_family = 'x86'|g" "$cross_file"
11 fi
12 # Rely on qemu-user being configured in binfmt_misc on the host
13 sed -i -e '/\[properties\]/a\' -e "needs_exe_wrapper = False" "$cross_file"
14
15 # Add a line for rustc, which debcrossgen is missing.
16 cc=`sed -n 's|c = .\(.*\).|\1|p' < $cross_file`
17 if [[ "$arch" = "arm64" ]]; then
18     rust_target=aarch64-unknown-linux-gnu
19 elif [[ "$arch" = "armhf" ]]; then
20     rust_target=armv7-unknown-linux-gnueabihf
21 elif [[ "$arch" = "i386" ]]; then
22     rust_target=i686-unknown-linux-gnu
23 elif [[ "$arch" = "ppc64el" ]]; then
24     rust_target=powerpc64le-unknown-linux-gnu
25 elif [[ "$arch" = "s390x" ]]; then
26     rust_target=s390x-unknown-linux-gnu
27 else
28     echo "Needs rustc target mapping"
29 fi
30 sed -i -e '/\[binaries\]/a\' -e "rust = ['rustc', '--target=$rust_target', '-C', 'linker=$cc']" "$cross_file"
31
32 # Set up cmake cross compile toolchain file for dEQP builds
33 toolchain_file="/toolchain-$arch.cmake"
34 if [[ "$arch" = "arm64" ]]; then
35     GCC_ARCH="aarch64-linux-gnu"
36     DE_CPU="DE_CPU_ARM_64"
37     CMAKE_ARCH=arm
38 elif [[ "$arch" = "armhf" ]]; then
39     GCC_ARCH="arm-linux-gnueabihf"
40     DE_CPU="DE_CPU_ARM"
41     CMAKE_ARCH=arm
42 fi
43
44 if [[ -n "$GCC_ARCH" ]]; then
45     echo "set(CMAKE_SYSTEM_NAME Linux)" > "$toolchain_file"
46     echo "set(CMAKE_SYSTEM_PROCESSOR arm)" >> "$toolchain_file"
47     echo "set(CMAKE_C_COMPILER /usr/lib/ccache/$GCC_ARCH-gcc)" >> "$toolchain_file"
48     echo "set(CMAKE_CXX_COMPILER /usr/lib/ccache/$GCC_ARCH-g++)" >> "$toolchain_file"
49     echo "set(ENV{PKG_CONFIG} \"/usr/bin/$GCC_ARCH-pkg-config\")" >> "$toolchain_file"
50     echo "set(DE_CPU $DE_CPU)" >> "$toolchain_file"
51 fi