#!/bin/bash # $./run.unittest.sh release 5.12.5 /media/sf_VMSHARE #setup Qt dir version if [[ "$2" = "" ]]; then QT_VER="" else QT_VER=$2 fi #Setting up server folder if [[ "$3" = "" ]]; then SERVER_DIR="/media/XDrive" else SERVER_DIR=$3 fi #setup environment device=root@192.168.10.135 # project pro file pro_path=application pro_name=denali.pro pro_type_debug="debug" pro_type_release="release" pro_type=$pro_type_release pro_debug="CONFIG+=debug CONFIG+=qml_debug" pro_release="CONFIG+=qtquickcompiler" pro_build=$pro_release out_path="build" REMOTE_DIR="$SERVER_DIR/Users/Bamboo-Projects" REPORT_DIR="$timeStamp-BuildNo-$buildNumber-$buildPlan" REPORT=Report # gcc env gcc_qmake="/opt/Qt$QT_VER/5.12.5/gcc_64/bin/qmake" gcc_make="/usr/bin/make" gcc_out_base="gcc_64" gcc_out=$gcc_out_base"_"$pro_type gcc_spec="-spec linux-g++" # poky env poky_qmake="/opt/b2qt/2.5.3/sysroots/x86_64-pokysdk-linux/usr/bin/qmake" poky_make="/opt/b2qt/2.5.3/sysroots/x86_64-pokysdk-linux/usr/bin/make" poky_out_base="poky_64" poky_out=$poky_out_base"_"$pro_type poky_spec="-spec devices/linux-oe-generic-g++" #build type detection and set function (debug/release) function buildType() { echo if [[ "$1" = "debug" ]]; then pro_build=$pro_debug pro_type=$pro_type_debug gcc_out=$gcc_out_base"_"$pro_type poky_out=$poky_out_base"_"$pro_type echo " ------------------------------ DEBUG BUILD" else echo " ------------------------------ RELASE BUILD" fi echo } #check if the out folders already exists if [[ -e $out_path ]]; then rm -frd $out_path fi if [[ -e $pro_path ]]; then rm -frd $pro_path fi if [[ "$1" = "clean" ]]; then exit 0 fi echo " ------------------------------ clone the application repository" git clone ssh://git@dvm-linux02:7999/ui/application.git echo " ------------------------------ set the build type (debug/release)" buildType "$1" echo " ------------------------------ create the build folder" mkdir $out_path cd $out_path echo " ------------------------------ run the cppcheck" app_path=../$pro_path cppcheck $app_path -v \ -I$app_path/sources \ -I$app_path/sources/gui \ -I$app_path/sources/storage \ -I$app_path/sources/configuration \ -I$app_path/sources/canbus \ --enable=all \ 1> cppcheck.log \ 2> cppcheck.err if [[ $(grep \(error\) cppcheck.err) != "" ]]; then echo "ERROR: Static Code Analysis Failed" exit 1 fi # ============================================================= echo " ------------------------------ Start building [$gcc_out]" mkdir -p $gcc_out cd $gcc_out echo " ------------------------------ run qmake" $gcc_qmake ../../$pro_path/$pro_name $gcc_spec $pro_build echo " ------------------------------ run make" build_err=../build_$gcc_out.err build_log=../build_$gcc_out.log $gcc_make -j4 1> $build_log 2> $build_err if [[ $(grep "error:" $build_err) != "" ]]; then echo "ERROR: Application Build Failed [$gcc_out]" exit 2 fi if [[ $(grep "warning:" $build_err) != "" ]]; then echo "WARNING: Application Build Has Warnings [$gcc_out]" #exit 3 fi cd .. # ============================================================= echo " ------------------------------ Start building [$poky_out]" mkdir -p $poky_out cd $poky_out echo " ------------------------------ run qmake" $poky_qmake ../../$pro_path/$pro_name $poky_spec $pro_build echo " ------------------------------ run make" build_err=../build_$poky_out.err build_log=../build_$poky_out.log $poky_make -j4 1> $build_log 2> $build_err if [[ $(grep "error:" $build_err) != "" ]]; then echo "ERROR: Application Build Failed [$poky_out]" exit 2 fi if [[ $(grep "warning:" $build_err) != "" ]]; then echo "WARNING: Application Build Has Warnings [$poky_out]" #exit 3 fi # ============================================================= echo " ------------------------------ stop denali on device" ssh $device 'killall denali' sleep 1 echo " ------------------------------ copy denali on device" scp ./denali $device://home/root/ sync;sync;sync; echo " ------------------------------ start denali on device" ssh $device '~/denali &' #return back to out path cd .. #return back to main folder cd .. echo " ------------------------------ copy the out file into the server" LOG=Logs echo " ------------------------------ $poky_out" mkdir -p $REMOTE_DIR/$REPORT_DIR/$LOG cp $out_path/* $REMOTE_DIR/$REPORT_DIR/$LOG mkdir -p $REMOTE_DIR/$REPORT_DIR/bin/$poky_out cp $out_path/$poky_out/denali $REMOTE_DIR/$REPORT_DIR/bin/$poky_out sync;sync;sync; echo " ------------------------------ $gcc_out" mkdir -p $REMOTE_DIR/$REPORT_DIR/$LOG cp $out_path/* $REMOTE_DIR/$REPORT_DIR/$LOG mkdir -p $REMOTE_DIR/$REPORT_DIR/bin/$gcc_out cp $out_path/$gcc_out/denali $REMOTE_DIR/$REPORT_DIR/bin/$gcc_out sync;sync;sync;