aboutsummaryrefslogtreecommitdiffstats
path: root/jjb/common/include-apps-build-app.sh
blob: 91105eae06ba55ffa1d3606131d69ad5a39e8fcc (plain)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
# (c) 2016 Jan-Simon Moeller dl9pf(at)gmx.de
# License GPLv2
#
# debugging purposes
set -e

################################################################################
# build the app
################################################################################

# fallback
if test -z "${GERRIT_PROJECT}"; then
    export GERRIT_PROJECT="apps/controls"
fi
if test -z "${GERRIT_BRANCH}"; then
    export GERRIT_BRANCH="master"
fi
if test -z "${GERRIT_REFSPEC}"; then
    export GERRIT_REFSPEC="refs/tags/dab_3.99.1"
fi
if test -z "${GERRIT_HOST}"; then
    export GERRIT_HOST="gerrit.automotivelinux.org"
fi

# apply GERRIT_*
if test -n "${GERRIT_PROJECT}"; then
    export TARGETPROJECT="${GERRIT_PROJECT}"
fi
if test -n "${GERRIT_BRANCH}"; then
    export TARGETBRANCH="${GERRIT_BRANCH}"
fi
if test -n "${GERRIT_REFSPEC}"; then
    export TARGETREFSPEC="${GERRIT_REFSPEC}"
fi



HANDLED="no"

# Projects in apps/*
###################
if [[ ! x"yes" = x"$HANDLED" ]] && $(echo "$TARGETPROJECT" | grep -q "apps/"); then

    MYPROJECT=`echo $TARGETPROJECT | sed -e "s#apps/##g"`

    # clone git
    rm -rf ${MYPROJECT}
    git clone --recurse-submodules --recursive https://${GERRIT_HOST}/gerrit/${GERRIT_PROJECT}.git
    pushd ${MYPROJECT}
        git log -1 --pretty=oneline
        if test x"" != x"${TARGETREFSPEC}" ; then
          git fetch origin ${TARGETREFSPEC}
          git reset --hard FETCH_HEAD
        else
          # try 
          # GERRIT_CHANGE_NUMBER="9551"
          # GERRIT_PATCHSET_NUMBER="2"
          if ( test x"" != x"${GERRIT_CHANGE_NUMBER}" -a x"" != x"${GERRIT_PATCHSET_NUMBER}" ) ; then
            pip install --user git-review
            git review -d ${GERRIT_CHANGE_NUMBER},${GERRIT_PATCHSET_NUMBER}
          fi
          sleep 2
          # if not reset, we leave it to master
        fi

        # update git submodules
        if test -f .gitmodules ; then
           git submodule init && git submodule update
        fi

        git log -1 --pretty=oneline

        # Fixme: use aglbuild script
        set -x

        export DONE=0
        export isAUTOBUILD=0
	if [[ -f autobuild/agl/autobuild ]]
	then
            mkdir -p $(pwd)/package/
	    chmod a+x autobuild/agl/autobuild
	    autobuild/agl/autobuild package DEST=$(pwd)/package
            export isAUTOBUILD=1
            export DONE=1
	else
            echo "Your binding doesn't use an autobuild script. Please add it in your project."
	    echo "It has to be stored in your root project directory in autobuild/agl/autobuild file"
	    echo "and be able to generate an AGL package in the build root directory using the call"
	    echo "autobuild/agl/autobuild package DEST=build"
        fi

        ######################################################################
        # /!\/!\/!\   DEPRECATED FALLBACK WAY TO BUILD AGL APPS /!\/!\/!\    #
        ######################################################################

        export isCMAKE=0
        export isMAKE=0
        export isQMAKE=0

        if test x"0" = x"$DONE" -a -f conf.d/autobuild/agl/autobuild ; then
            mkdir -p $(pwd)/package/
            conf.d/autobuild/agl/autobuild package DEST=$(pwd)/package/
            export isAUTOBUILD=1
            export DONE=1
        fi
        if test x"0" = x"$DONE" -a -f CMakeLists.txt; then
            rm -rf build || true
            mkdir build
            pushd build
            cmake ../
            make
            if test x"0" = x"$DONE" -a -f ../conf.d/autobuild/agl/autobuild ; then
                ../conf.d/autobuild/agl/autobuild package DEST=$(pwd)/package
                export isAUTOBUILD=1
	    else
                make package || true
	    fi
            popd
            export isCMAKE=1
            export DONE=1
        fi
        if test x"0" = x"$DONE" -a -f Makefile ; then
            make
            make package
            export isMAKE=1
            export DONE=1
        fi
        if test x"0" = x"$DONE" -a -f ${MYPROJECT}.pro; then
            qmake
            make
            make package
            export isQMAKE=1
            export DONE=1
        fi
        ######################################################################
        # /!\/!\/!\                  Ends Here                  /!\/!\/!\    #
        ######################################################################

    popd

    HANDLED="yes"
fi