build_titan.bash 1.86 KB
Newer Older
Yann Garcia's avatar
Yann Garcia committed
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 53 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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
#!/bin/bash
# Copyright ETSI 2018
# See: https://forge.etsi.org/etsi-forge-copyright-statement.txt

set -e
#set -vx

clear

if [ -z "${TOP}" ]
then
    echo "Failed, TOP variable not defined, exit"
    exit 1
fi

CURDIR=`pwd`
TITAN_DIR=${TOP}/..

# Move to the right directory
if [ ! -d ${TITAN_DIR} ]
then
    echo "Titan directory does not exist, create it"
    # Create TITAN directories
    mkdir -p ${TITAN_DIR}
    if [ ! "$?" -eq "0" ]
    then
        echo "Failed, TOP variable not defined, exit"
        exit 2
    fi
    cd ${TITAN_DIR}
    # Clone all TITAN repositories
    if [ ! -f ${CURDIR}/titan_repos.txt ]
    then
        echo "${HOME_BIN}/titan_repos.txt file does not exist, exit"
        rm -fr ${TOP}
        rm -fr ${TOP}/..
        exit 3
    fi
    TITAN_REPOS=`cat ${CURDIR}/titan_repos.txt`
    for i in ${TITAN_REPOS};
    do
        git clone $i
        if [ ! "$?" -eq "0" ]
        then
            echo "Failed to clone $i, exit"
            exit 4
        fi
    done
else
    cd ${TITAN_DIR}
    # Update github folders
    DIRS=`find . -type d -name ".git" -exec dirname {} \;`
    for i in ${DIRS};
    do
        echo "Processing $i..."
        cd $i
        git fetch
        if [ ! "$?" -eq "0" ]
        then
            echo "Failed to fetch $i, continue"
        else 
            git pull
            if [ ! "$?" -eq "0" ]
            then
        echo "Failed to pull $i, continue"
            fi
    fi
        cd -
    done
fi

# Build TITAN core
export JNI=no
export GUI=no
export DEBUG=no
export GEN_PDF=no
if [ -d ${TTCN3_DIR} ]
then
    rm -fr ${TTCN3_DIR}
fi
mkdir ${TTCN3_DIR}
cd ./titan.core
/bin/cat <<EOF > Makefile.personal
JNI:=no
GUI:=no
DEBUG:=no
GEN_PDF:=no
EOF

echo "Starting build..."
make clean
if [ "${OSTYPE}" == "cygwin" ]
then
    make -j
else
    make
fi
make install
echo "Build done"

# Go back to initial directory
cd ${CURDIR}
exit 0