1#!/bin/bash
2
3# Travis CI setup script for Botan build
4#
5# (C) 2015,2017 Simon Warta
6# (C) 2016,2017,2018 Jack Lloyd
7
8command -v shellcheck > /dev/null && shellcheck "$0" # Run shellcheck on this if available
9
10set -ev
11
12if [ "$TRAVIS_OS_NAME" = "linux" ]; then
13
14    if [ "$TARGET" = "valgrind" ]; then
15        sudo apt-get -qq update
16        sudo apt-get install valgrind
17
18    elif [ "$TARGET" = "gcc4.8" ]; then
19        sudo apt-get -qq update
20        sudo apt-get install g++-4.8
21
22    elif [ "$TARGET" = "clang8" ]; then
23        sudo apt-get -qq update
24        sudo apt-get install clang-8
25
26    elif [ "$TARGET" = "cross-i386" ]; then
27        sudo apt-get -qq update
28        sudo apt-get install g++-multilib linux-libc-dev libc6-dev-i386
29
30    elif [ "$TARGET" = "cross-win64" ]; then
31        sudo apt-get -qq update
32        sudo apt-get install wine-development g++-mingw-w64-x86-64
33
34    elif [ "$TARGET" = "cross-arm32" ]; then
35        sudo dpkg --add-architecture armhf
36        sudo apt-get -qq update
37        sudo apt-get install g++-arm-linux-gnueabihf
38        sudo apt-get install -o APT::Immediate-Configure=0 libc6:armhf libstdc++6:armhf
39
40    elif [ "$TARGET" = "cross-arm64" ]; then
41        sudo apt-get -qq update
42        sudo apt-get install qemu-user g++-aarch64-linux-gnu
43
44    elif [ "$TARGET" = "cross-ppc32" ]; then
45        sudo apt-get -qq update
46        sudo apt-get install qemu-user g++-powerpc-linux-gnu
47
48    elif [ "$TARGET" = "cross-ppc64" ]; then
49        sudo apt-get -qq update
50        sudo apt-get install qemu-user g++-powerpc64le-linux-gnu
51
52    elif [ "$TARGET" = "cross-mips64" ]; then
53        sudo apt-get -qq update
54        sudo apt-get install qemu-user g++-mips64-linux-gnuabi64
55
56    elif [ "$TARGET" = "cross-android-arm32" ] || [ "$TARGET" = "cross-android-arm64" ]; then
57        wget -nv https://dl.google.com/android/repository/"$ANDROID_NDK"-linux-x86_64.zip
58        unzip -qq "$ANDROID_NDK"-linux-x86_64.zip
59
60    elif [ "$TARGET" = "baremetal" ]; then
61        sudo apt-get -qq update
62        sudo apt-get install gcc-arm-none-eabi libstdc++-arm-none-eabi-newlib
63
64        echo 'extern "C" void __sync_synchronize() {}' >> src/tests/main.cpp
65        echo 'extern "C" void __sync_synchronize() {}' >> src/cli/main.cpp
66
67    elif [ "$TARGET" = "lint" ]; then
68        sudo apt-get -qq update
69        sudo apt-get install pylint
70
71    elif [ "$TARGET" = "coverage" ]; then
72        sudo apt-get -qq update
73        sudo apt-get install g++-8 softhsm2 libtspi-dev lcov python-coverage libboost-all-dev gdb
74        pip install --user codecov
75        git clone --depth 1 --branch runner-changes-golang1.10 https://github.com/randombit/boringssl.git
76
77        sudo chgrp -R "$(id -g)" /var/lib/softhsm/ /etc/softhsm
78        sudo chmod g+w /var/lib/softhsm/tokens
79
80        softhsm2-util --init-token --free --label test --pin 123456 --so-pin 12345678
81
82    elif [ "$TARGET" = "docs" ]; then
83        sudo apt-get -qq update
84        sudo apt-get install doxygen python-docutils python3-sphinx
85    fi
86
87elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
88    HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache
89fi
90