buildLocally.sh 4.25 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
#!/bin/bash

function usage {
    echo "OAI Local Build Check script"
    echo "   Original Author: Raphael Defosseux"
    echo ""
    echo "Usage:"
    echo "------"
    echo "    buildLocally.sh [OPTIONS]"
    echo ""
    echo "Options:"
    echo "--------"
    echo "    --workspace #### OR -ws ####"
    echo "    Specify the workspace"
    echo ""
    echo "    --help OR -h"
    echo "    Print this help message."
    echo ""
}

if [ $# -ne 2 ] && [ $# -ne 1 ]
then
    echo "Syntax Error: not the correct number of arguments"
    echo ""
    usage
    exit 1
fi

while [[ $# -gt 0 ]]
do
key="$1"

case $key in
    -h|--help)
    shift
    usage
    exit 0
    ;;
    -ws|--workspace)
    JENKINS_WKSP="$2"
    shift
    shift
    ;;
    *)
    echo "Syntax Error: unknown option: $key"
    echo ""
    usage
    exit 1
esac
done

cd $JENKINS_WKSP
53
STATUS=0
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

############################################################
# Creating a tmp folder to store results and artifacts
############################################################
if [ ! -d $JENKINS_WKSP/archives ]
then
    mkdir $JENKINS_WKSP/archives
fi

source oaienv
cd $JENKINS_WKSP/cmake_targets

############################################################
# Building eNb with USRP option
############################################################
ARCHIVES_LOC=$JENKINS_WKSP/archives/enb_usrp
if [ ! -d $ARCHIVES_LOC ]
then
    mkdir $ARCHIVES_LOC
fi
./build_oai --eNB -w USRP -c

# Generated log files:
if [ -f $JENKINS_WKSP/cmake_targets/log/lte-softmodem.Rel14.txt ]
then
79 80
    LOCAL_STAT=`egrep -c "Built target lte-softmodem" $JENKINS_WKSP/cmake_targets/log/lte-softmodem.Rel14.txt`
    if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi
81
    cp $JENKINS_WKSP/cmake_targets/log/lte-softmodem.Rel14.txt $ARCHIVES_LOC
82 83
else
    STATUS=-1
84 85 86
fi
if [ -f $JENKINS_WKSP/cmake_targets/log/params_libconfig.Rel14.txt ]
then
87 88
    LOCAL_STAT=`egrep -c "Built target params_libconfig" $JENKINS_WKSP/cmake_targets/log/params_libconfig.Rel14.txt`
    if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi
89
    cp $JENKINS_WKSP/cmake_targets/log/params_libconfig.Rel14.txt $ARCHIVES_LOC
90 91
else
    STATUS=-1
92 93 94
fi
if [ -f $JENKINS_WKSP/cmake_targets/log/coding.Rel14.txt ]
then
95 96
    LOCAL_STAT=`egrep -c "Built target coding" $JENKINS_WKSP/cmake_targets/log/coding.Rel14.txt`
    if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi
97
    cp $JENKINS_WKSP/cmake_targets/log/coding.Rel14.txt $ARCHIVES_LOC
98 99
else
    STATUS=-1
100 101 102
fi
if [ -f $JENKINS_WKSP/cmake_targets/log/oai_usrpdevif.Rel14.txt ]
then
103 104
    LOCAL_STAT=`egrep -c "Built target oai_usrpdevif" $JENKINS_WKSP/cmake_targets/log/oai_usrpdevif.Rel14.txt`
    if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi
105
    cp $JENKINS_WKSP/cmake_targets/log/oai_usrpdevif.Rel14.txt $ARCHIVES_LOC
106 107
else
    STATUS=-1
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
fi

############################################################
# Building basic simulator
############################################################
ARCHIVES_LOC=$JENKINS_WKSP/archives/basic_sim
if [ ! -d $ARCHIVES_LOC ]
then
    mkdir $ARCHIVES_LOC
fi
cd $JENKINS_WKSP/cmake_targets
./build_oai --basic-simulator -c

# Generated log files:
if [ -f $JENKINS_WKSP/cmake_targets/log/basic_simulator_enb.txt ]
then
124 125
    LOCAL_STAT=`egrep -c "Built target lte-softmodem" $JENKINS_WKSP/cmake_targets/log/basic_simulator_enb.txt`
    if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi
126
    cp $JENKINS_WKSP/cmake_targets/log/basic_simulator_enb.txt $ARCHIVES_LOC
127 128
else
    STATUS=-1
129 130 131
fi
if [ -f $JENKINS_WKSP/cmake_targets/log/basic_simulator_ue.txt ]
then
132 133
    LOCAL_STAT=`egrep -c "Built target lte-uesoftmodem" $JENKINS_WKSP/cmake_targets/log/basic_simulator_ue.txt`
    if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi
134
    cp $JENKINS_WKSP/cmake_targets/log/basic_simulator_ue.txt $ARCHIVES_LOC
135 136
else
    STATUS=-1
137 138 139
fi
if [ -f $JENKINS_WKSP/cmake_targets/log/conf2uedata.Rel14.txt ]
then
140 141
    LOCAL_STAT=`egrep -c "Built target conf2uedata" $JENKINS_WKSP/cmake_targets/log/conf2uedata.Rel14.txt`
    if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi
142
    cp $JENKINS_WKSP/cmake_targets/log/conf2uedata.Rel14.txt $ARCHIVES_LOC
143 144
else
    STATUS=-1
145 146 147 148 149 150 151
fi

############################################################
# Creating a zip for Jenkins archiving
############################################################
cd $JENKINS_WKSP/archives/
zip -r local_build_logs.zip basic_sim enb_usrp
152 153

exit $STATUS