source: branches/stable/util/jenkins_build.sh

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