Debian Codegraph @

src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/jenkins/raspberrypi_c.sh

raw
1 #!/bin/bash
2 # Copyright (c) Microsoft. All rights reserved. Licensed under the MIT
3 # license. See LICENSE file in the project root for full license
4 # information.
5
6 # Tested on RPi2 debian verion 7.8
7
8 install_root="/home/jenkins"
9 build_root=$(cd "$(dirname "$0")/.." && pwd)
10 cd $build_root
11
12 # -----------------------------------------------------------------------------
13 # -- helper subroutines
14 # -----------------------------------------------------------------------------
15 checkExists() {
16 if hash $1 2>/dev/null;
17 then
18 return 1
19 else
20 echo "$1" not found. Please make sure that "$1" is installed and available in the path.
21 exit 1
22 fi
23 }
24
25 # -----------------------------------------------------------------------------
26 # -- Check for environment pre-requisites. This script requires -- that
27 # the following programs work: -- curl build-essential(g++,gcc,make)
28 # cmake git
29 # -----------------------------------------------------------------------------
30 checkExists curl
31 checkExists g++
32 checkExists gcc
33 checkExists make
34 checkExists cmake
35 checkExists git
36
37 # -----------------------------------------------------------------------------
38 # -- Check for RPiTools directory.
39 # -----------------------------------------------------------------------------
40 if [ ! -d "$install_root/RPiTools" ];
41 then
42 echo ---------- Raspberry Pi tool-chain absent ----------
43 exit 1
44 fi
45
46 # -----------------------------------------------------------------------------
47 # -- Set environment variable
48 # -----------------------------------------------------------------------------
49 cd $install_root/RPiTools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf
50 export RPI_ROOT=$(pwd)
51
52 # -----------------------------------------------------------------------------
53 # -- Create toolchain-rpi.cmake
54 # -----------------------------------------------------------------------------
55 echo ---------- Creating toolchain cmake file ----------
56 FILE="$build_root/build_all/linux/toolchain-rpi.cmake"
57
58 /bin/cat <<EOM >$FILE
59 INCLUDE(CMakeForceCompiler)
60
61 SET(CMAKE_SYSTEM_NAME Linux) # this one is important
62 SET(CMAKE_SYSTEM_VERSION 1) # this one not so much
63
64 # this is the location of the amd64 toolchain targeting the Raspberry Pi
65 SET(CMAKE_C_COMPILER ${RPI_ROOT}/../bin/arm-linux-gnueabihf-gcc)
66
67 # this is the file system root of the target
68 SET(CMAKE_FIND_ROOT_PATH ${RPI_ROOT})
69
70 # search for programs in the build host directories
71 SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
72
73 # for libraries and headers in the target directories
74 SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
75 SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
76 EOM
77
78 build_folder=$build_root"/cmake"
79
80 # Set the default cores
81 CORES=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)
82
83 rm -r -f $build_folder
84 mkdir -p $build_folder
85 pushd $build_folder
86
87 cmake -DCMAKE_TOOLCHAIN_FILE=$FILE -DcompileOption_C:STRING="--sysroot=$RPI_ROOT" $build_root -Duse_wsio:BOOL=ON
88 make --jobs=$CORES
89
90 [ $? -eq 0 ] || exit $?