source: branches/properties/util/jenkins_build.sh

Last change on this file was 19441, checked in by westram, 20 months ago
  • provide source etc. by debian11 buildhost.
File size: 6.5 KB
Line 
1#!/bin/bash -u
2set -o errexit
3
4ARG=${1:-}
5
6show_help() {
7    echo "Usage: jenkins_build.sh [--skip_leak_check] fake_build|from_tarball|clean_before_make"
8    echo "    fake_build: do not build (test rest of this script)"
9    echo "    from_tarball: run build from source tarball (implies 'clean_before_make')"
10    echo "    clean_before_make: call 'make clean' before build"
11    echo ""
12    echo "This script uses or expects the following environment variables:"
13    echo "    variable       accepted-values                         description"
14    echo "    -----------------------------------------------------------------------------"
15    echo "    MODE           DEBUG/NDEBUG/RELEASE    required        build mode"
16    echo "    TGTNAME        <any>                   required        part of tarball name"
17    echo "    SVN_REVISION   <number>                alternative     part of tarball name"
18    echo "    SVN_TAG        <tagname>               alternative     part of tarball name"
19    echo ""
20    echo "    ISINA          0/1                     default=1       build with sina"
21    echo "    OPENGL         0/1                     default=0       build with opengl"
22}
23
24SKIP_LEAK_CHECK=0
25if [ "${ARG}" = "--skip_leak_check" ]; then
26    SKIP_LEAK_CHECK=1
27    shift ; ARG=${1:-}
28    echo "h1"
29fi
30echo "h2"
31
32if [ "$ARG" = "--help" ]; then
33    show_help
34    false
35fi
36
37# echo all into buildlog:
38set -x
39
40# set standard variables expected by ARB build
41export ARBHOME=`pwd`
42export PATH=$ARBHOME/bin:$PATH
43export LD_LIBRARY_PATH=$ARBHOME/lib
44
45# OS dependant settings
46OSNAME=`uname -s`
47case $OSNAME in
48    Darwin)
49        export PREFIX=/opt/local
50        export PATH=$PATH:$PREFIX/sbin:$PREFIX/bin
51        export CC=clang
52        export CXX=clang++
53        export MACH=DARWIN
54        ;;
55    Linux)
56        ;;
57    *)
58        echo "Error: unhandled OSNAME '$OSNAME'"
59        false
60        ;;
61esac
62
63# fallback language (avoid perl spam)
64if [ -z "${LANG:-}" ]; then
65    echo "Note: LANG was unset (using fallback 'C')"
66    export LANG=C
67else
68    echo "Note: LANG is '$LANG'"
69fi
70
71# prepare config.makefile
72CFG=config.makefile
73rm -f $CFG
74
75TARSUF=""
76UNIT_TESTS=1
77DEBUG=0
78if [ ${SKIP_LEAK_CHECK} = 1 ]; then
79    SANITIZE="2" # disables leak-check and address-sanitizer; see ../Makefile@SANITIZE
80else
81    SANITIZE="all"
82fi
83DEVELOPER="JENKINS" # does not influence RELEASE build; see ../UNIT_TESTER/README.txt@DEVEL_JENKINS
84
85case $MODE in
86    DEBUG)
87        DEBUG=1
88        TARSUF="-dbg"
89        ;;
90    NDEBUG)
91        TARSUF="-ndbg"
92        ;;
93    RELEASE)
94        DEVELOPER="RELEASE"
95        UNIT_TESTS=0
96        SANITIZE=0 # never sanitize release!
97        ;;
98    *)
99        echo "Error: unknown MODE '$MODE' passed to jenkins_build.sh"
100        false
101        ;;
102esac
103
104case $OSNAME in
105    Darwin)
106        echo "DARWIN := 1" >> $CFG
107        echo "MACH := DARWIN" >> $CFG
108        # OSX make causes random failures if called with '-j 2'
109        # (e.g. target 'binlink' gets triggered multiple times, causing build failure when it's executed concurrently)
110        JMAKE="make --print-directory"
111        ;;
112    Linux)
113        echo "LINUX := 1" >> $CFG
114        echo "MACH := LINUX" >> $CFG
115        JMAKE="/usr/bin/time --verbose make -j `util/usecores.pl`"
116        ;;
117    *)
118        echo "Error: unhandled OSNAME '$OSNAME'"
119        false
120        ;;
121esac
122
123if [ -z "${TGTNAME:-}" ]; then
124    echo "Error: unknown TGTNAME - build refused"
125    false
126fi
127
128echo "DEBUG := $DEBUG" >> $CFG
129echo "UNIT_TESTS := $UNIT_TESTS" >> $CFG
130echo "DEVELOPER := $DEVELOPER" >> $CFG
131echo "DEBUG_GRAPHICS := 0" >> $CFG
132echo "ARB_64 := 1" >> $CFG
133echo "TRACESYM := 1" >> $CFG
134echo "SANITIZE := $SANITIZE" >> $CFG
135echo "COVERAGE := 0" >> $CFG
136
137# injectable config settings
138echo "OPENGL := ${OPENGL:-0}" >> $CFG
139echo "ISINA := ${ISINA:-1}" >> $CFG
140
141# done with config.makefile
142
143# build, test and tar
144if [ "$ARG" == "fake_build" ]; then
145    echo "Faking build"
146    echo "Faked arb.tgz"     > arb.tgz
147else
148    JMAKE_TARGET=TARFILE_QUICK
149    if [ "$ARG" == "from_tarball" ]; then
150        echo "Test clean before make (tarball build)"
151        JMAKE_TARGET=TARFILE
152    fi
153    if [ "$ARG" == "clean_before_make" ]; then
154        echo "Forcing clean before make"
155        JMAKE_TARGET=TARFILE
156    fi
157    ${JMAKE} ${JMAKE_TARGET}
158fi
159
160# jenkins archieves all files matching "**/arb*.tgz"
161# jenkins publishes     files matching "**/arb*.tgz", but not "**/arb*dev*.tgz,**/arb*bin*.tgz"
162
163if [ -n "${SVN_TAG:-}" ]; then
164    # tagged build
165    VERSION_ID=${SVN_TAG}${TARSUF}
166    # remove arb-prefixes (added below)
167    VERSION_ID="${VERSION_ID##arb[-_]}"
168else
169    if [ -z "${SVN_REVISION:-}" ]; then
170        echo "Error: either SVN_REVISION or SVN_TAG required - build refused"
171        false
172    fi
173
174    # normal build
175    VERSION_ID=r${SVN_REVISION}${TARSUF}
176fi
177
178VERSION_ID=arb-${VERSION_ID}
179VERSION_ID_TARGET=${VERSION_ID}.${TGTNAME}
180
181if [ "$MODE" == "RELEASE" ]; then
182    if [ "${TGTNAME}" == "debian11-amd64" ]; then
183        # perform things needed only once (pack source, copy README + install script):
184        # 1. pack source (svn version of slave and master must match!)
185        if [ "$ARG" == "fake_build" ]; then
186            echo "Faked ${VERSION_ID}-source.tgz" > ${VERSION_ID}-source.tgz
187        else
188            if [ "$ARG" == "from_tarball" ]; then
189                echo "Note: build from tarball - do not attempt to create a tarball"
190            else
191                # check resource usage:
192                ${JMAKE} check_res
193
194                # save source tarball:
195                ${JMAKE} save
196                # archived and published on ftp:
197                cp --dereference arbsrc.tgz ${VERSION_ID}-source.tgz
198                rm arbsrc*.tgz
199            fi
200        fi
201        # 2. move extra files into folder 'toftp' - content is copied to release directory
202        mkdir toftp
203        cp -p arb_README.txt toftp
204        cp -p arb_install.sh toftp
205        ls -al toftp
206    fi
207
208    # will be published on arb-home.de:
209    mv arb.tgz ${VERSION_ID_TARGET}.tgz
210else
211    # (formerly needed by SINA) @@@ superfluous now?
212    mv arb.tgz ${VERSION_ID_TARGET}-bin.tgz
213fi
214
215if [ -e arb-sina-fat.tgz ]; then
216    # will be published on arb-home.de
217    # (debian-10 version works e.g. on debian 8)
218    mv arb-sina-fat.tgz ${VERSION_ID_TARGET}-sina-fat.tgz
219fi
220
221${JMAKE} ut
222
223echo "-------------------- compiled-in version info:"
224(bin/arb_ntree --help || true)
225
226echo "-------------------- cleanup relinkable binaries:"
227${JMAKE} cleanRelinkable || echo "cleanRelinkable failed (ignored)"
228
229echo "-------------------- existing tarballs:"
230ls -al arb*.tgz
231echo "--------------------"
Note: See TracBrowser for help on using the repository browser.