| 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 Ubuntu version 14.04 |
| 7 |
|
| 8 |
toolchain_root="/opt/poky-edison" |
| 9 |
|
| 10 |
install_root="$HOME" |
| 11 |
build_root=$(cd "$(dirname "$0")/.." && pwd) |
| 12 |
|
| 13 |
cd $build_root |
| 14 |
|
| 15 |
# ----------------------------------------------------------------------------- |
| 16 |
# -- helper subroutines |
| 17 |
# ----------------------------------------------------------------------------- |
| 18 |
checkExists() { |
| 19 |
if hash $1 2>/dev/null; |
| 20 |
then |
| 21 |
return 1 |
| 22 |
else |
| 23 |
echo "$1" not found. Please make sure that "$1" is installed and available in the path. |
| 24 |
exit 1 |
| 25 |
fi |
| 26 |
} |
| 27 |
|
| 28 |
# ----------------------------------------------------------------------------- |
| 29 |
# -- setup Intel edison Tool chain for cross compilation on Ubuntu |
| 30 |
# -- This method is not called in this script and kept only for showing the set of instructions needed to setup the cross compilation tool chain. |
| 31 |
# -- Tool chain is already installed on the Jenkins slave. |
| 32 |
# -- In future, If slave changes ,run these commands manually on new slave to setup the tool chain. |
| 33 |
# ----------------------------------------------------------------------------- |
| 34 |
setupIntelEdisonToolChain() { |
| 35 |
|
| 36 |
mkdir IntelEdisonSdk |
| 37 |
cd IntelEdisonSdk |
| 38 |
wget http://downloadmirror.intel.com/25028/eng/edison-sdk-linux64-ww25.5-15.zip |
| 39 |
unzip edison-sdk-linux64-ww25.5-15.zip |
| 40 |
SdkInstallScript=$(ls | grep .sh) |
| 41 |
printf '\n' | ./$SdkInstallScript |
| 42 |
DirName=$toolchain_root/$(ls $toolchain_root) |
| 43 |
EnvFileName=$(DirName)/$(ls $DirName | grep environment) |
| 44 |
source $EnvFileName |
| 45 |
} |
| 46 |
|
| 47 |
# ----------------------------------------------------------------------------- |
| 48 |
# -- Check for environment pre-requisites. |
| 49 |
# -- This script requires that the following programs work: |
| 50 |
# -- curl build-essential(g++,gcc,make) cmake git |
| 51 |
# ----------------------------------------------------------------------------- |
| 52 |
checkExists g++ |
| 53 |
checkExists gcc |
| 54 |
checkExists make |
| 55 |
checkExists cmake |
| 56 |
checkExists git |
| 57 |
|
| 58 |
# ----------------------------------------------------------------------------- |
| 59 |
# -- Check for Intel Edison tool-chain (default directory). |
| 60 |
# ----------------------------------------------------------------------------- |
| 61 |
if [ ! -d $toolchain_root ]; |
| 62 |
then |
| 63 |
echo ---------- Intel Edison tool-chain absent ---------- |
| 64 |
exit 1 |
| 65 |
fi |
| 66 |
|
| 67 |
# ----------------------------------------------------------------------------- |
| 68 |
# -- Set environment variable |
| 69 |
# ----------------------------------------------------------------------------- |
| 70 |
DirName=$toolchain_root/$(ls $toolchain_root) |
| 71 |
cd $DirName |
| 72 |
cd $(ls -d */) |
| 73 |
cd core2-32-poky-linux |
| 74 |
export INTELEDISON_ROOT=$(pwd) |
| 75 |
|
| 76 |
# ----------------------------------------------------------------------------- |
| 77 |
# -- Create toolchain-inteledison.cmake |
| 78 |
# ----------------------------------------------------------------------------- |
| 79 |
mkdir $build_root/cmake |
| 80 |
cd $build_root/cmake |
| 81 |
echo ---------- Creating toolchain cmake file ---------- |
| 82 |
FILE="$build_root/cmake/toolchain-inteledison.cmake" |
| 83 |
|
| 84 |
/bin/cat <<EOM >$FILE |
| 85 |
INCLUDE(CMakeForceCompiler) |
| 86 |
|
| 87 |
SET(CMAKE_SYSTEM_NAME Linux) # this one is important |
| 88 |
SET(CMAKE_SYSTEM_VERSION 1) # this one not so much |
| 89 |
|
| 90 |
# this is the location of the amd64 toolchain targeting the Intel Edison |
| 91 |
SET(CMAKE_C_COMPILER ${INTELEDISON_ROOT}/../x86_64-pokysdk-linux/usr/libexec/i586-poky-linux/gcc/i586-poky-linux/4.9.1/gcc) |
| 92 |
|
| 93 |
# this is the file system root of the target |
| 94 |
SET(CMAKE_FIND_ROOT_PATH ${INTELEDISON_ROOT}) |
| 95 |
|
| 96 |
# search for programs in the build host directories |
| 97 |
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) |
| 98 |
|
| 99 |
# for libraries and headers in the target directories |
| 100 |
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) |
| 101 |
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) |
| 102 |
EOM |
| 103 |
|
| 104 |
# ----------------------------------------------------------------------------- |
| 105 |
# -- Build uAMQP |
| 106 |
# ----------------------------------------------------------------------------- |
| 107 |
echo ---------- Building the SDK by executing build.sh script ---------- |
| 108 |
cd $build_root/cmake |
| 109 |
cmake .. -DCMAKE_TOOLCHAIN_FILE=toolchain-inteledison.cmake -DcompileOption_C:STRING="--sysroot=$INTELEDISON_ROOT" |
| 110 |
make |
| 111 |
[ $? -eq 0 ] || exit $? |