adding script to build two new platforms

This commit is contained in:
Jelani 2018-01-05 17:44:51 -08:00
Родитель ac0b0f65fe
Коммит b0a9577931
3 изменённых файлов: 134 добавлений и 1 удалений

Просмотреть файл

@ -9,6 +9,8 @@ build_root=$(cd "${script_dir}/../.." && pwd)
run_unit_tests=ON
run_valgrind=0
build_folder=$build_root"/cmake/umqtt_linux"
toolchainfile=" "
cmake_install_prefix=" "
run_unittests=OFF
usage ()
@ -18,6 +20,7 @@ usage ()
echo " -cl, --compileoption <value> specify a compile option to be passed to gcc"
echo " Example: -cl -O1 -cl ..."
echo "-rv, --run_valgrind will execute ctest with valgrind"
echo "--toolchain-file <file> pass cmake a toolchain file for cross compiling"
echo "--run-unittests do not build or run unit tests"
echo ""
exit 1
@ -34,15 +37,32 @@ process_args ()
# save arg to pass to gcc
extracloptions="$arg $extracloptions"
save_next_arg=0
elif [ $save_next_arg == 2 ]
then
# save arg to pass as toolchain file
toolchainfile="$arg"
save_next_arg=0
else
case "$arg" in
"-cl" | "--compileoption" ) save_next_arg=1;;
"-rv" | "--run_valgrind" ) run_valgrind=1;;
"--toolchain-file" ) save_next_arg=2;;
"--run-unittests" ) run_unittests=ON;;
* ) usage;;
esac
fi
done
if [ "$toolchainfile" != " " ]
then
toolchainfile=$(readlink -f $toolchainfile)
toolchainfile="-DCMAKE_TOOLCHAIN_FILE=$toolchainfile"
fi
if [ "$cmake_install_prefix" != " " ]
then
cmake_install_prefix="-DCMAKE_INSTALL_PREFIX=$cmake_install_prefix"
fi
}
process_args $*
@ -50,7 +70,8 @@ process_args $*
rm -r -f $build_folder
mkdir -p $build_folder
pushd $build_folder
cmake -DcompileOption_C:STRING="$extracloptions" -Drun_valgrind:BOOL=$run_valgrind $build_root -Drun_unittests:BOOL=$run_unittests
cmake $toolchainfile $cmake_install_prefix -Drun_valgrind:BOOL=$run_valgrind -DcompileOption_C:STRING="$extracloptions" $build_root -Drun_unittests:BOOL=$run_unittests
make --jobs=$(nproc)
if [[ $run_valgrind == 1 ]] ;

29
jenkins/debian_c.sh Executable file
Просмотреть файл

@ -0,0 +1,29 @@
#!/bin/bash
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#
set -e
script_dir=$(cd "$(dirname "$0")" && pwd)
build_root=$(cd "${script_dir}/.." && pwd)
log_dir=$build_root
make_install=
build_folder=$build_root"/cmake_debian"
rm -r -f $build_folder
mkdir -p $build_folder
pushd $build_folder
cmake .. -Drun_unittests:bool=ON
cmake --build . -- --jobs=$(nproc)
ctest -C "debug" -V
if [[ $make_install == 1 ]] ;
then
echo "Installing packaging"
# install the package
make install
fi
popd
:

83
jenkins/raspberrypi_c.sh Executable file
Просмотреть файл

@ -0,0 +1,83 @@
#!/bin/bash
# Copyright (c) Microsoft. All rights reserved. Licensed under the MIT
# license. See LICENSE file in the project root for full license
# information.
# Tested on RPi2 debian verion 7.8
install_root="$HOME"
build_root=$(cd "$(dirname "$0")/.." && pwd)
cd $build_root
# -----------------------------------------------------------------------------
# -- helper subroutines
# -----------------------------------------------------------------------------
checkExists() {
if hash $1 2>/dev/null;
then
return 1
else
echo "$1" not found. Please make sure that "$1" is installed and available in the path.
exit 1
fi
}
# -----------------------------------------------------------------------------
# -- Check for environment pre-requisites. This script requires -- that
# the following programs work: -- curl build-essential(g++,gcc,make)
# cmake git
# -----------------------------------------------------------------------------
checkExists curl
checkExists g++
checkExists gcc
checkExists make
checkExists cmake
checkExists git
# -----------------------------------------------------------------------------
# -- Check for RPiTools directory.
# -----------------------------------------------------------------------------
if [ ! -d "$install_root/RPiTools" ];
then
echo ---------- Raspberry Pi tool-chain absent ----------
exit 1
fi
# -----------------------------------------------------------------------------
# -- Set environment variable
# -----------------------------------------------------------------------------
cd $install_root/RPiTools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf
export RPI_ROOT=$(pwd)
# -----------------------------------------------------------------------------
# -- Create toolchain-rpi.cmake
# -----------------------------------------------------------------------------
echo ---------- Creating toolchain cmake file ----------
FILE="$build_root/build_all/linux/toolchain-rpi.cmake"
/bin/cat <<EOM >$FILE
INCLUDE(CMakeForceCompiler)
SET(CMAKE_SYSTEM_NAME Linux) # this one is important
SET(CMAKE_SYSTEM_VERSION 1) # this one not so much
# this is the location of the amd64 toolchain targeting the Raspberry Pi
SET(CMAKE_C_COMPILER ${RPI_ROOT}/../bin/arm-linux-gnueabihf-gcc)
# this is the file system root of the target
SET(CMAKE_FIND_ROOT_PATH ${RPI_ROOT})
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
EOM
# -----------------------------------------------------------------------------
# -- Build the SDK
# -----------------------------------------------------------------------------
echo ---------- Building the SDK by executing build.sh script ----------
cd $build_root/build_all/linux
./build.sh --toolchain-file toolchain-rpi.cmake -cl --sysroot=$RPI_ROOT
[ $? -eq 0 ] || exit $?