1 | #!/bin/bash -u |
---|
2 | set -o errexit |
---|
3 | |
---|
4 | ARG=${1:-} |
---|
5 | |
---|
6 | show_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 | |
---|
13 | SKIP_LEAK_CHECK=0 |
---|
14 | if [ "${ARG}" = "--skip_leak_check" ]; then |
---|
15 | SKIP_LEAK_CHECK=1 |
---|
16 | shift ; ARG=${1:-} |
---|
17 | echo "h1" |
---|
18 | fi |
---|
19 | echo "h2" |
---|
20 | |
---|
21 | if [ "$ARG" = "--help" ]; then |
---|
22 | show_help |
---|
23 | false |
---|
24 | fi |
---|
25 | |
---|
26 | # echo all into buildlog: |
---|
27 | set -x |
---|
28 | |
---|
29 | # set standard variables expected by ARB build |
---|
30 | export ARBHOME=`pwd` |
---|
31 | export PATH=$ARBHOME/bin:$PATH |
---|
32 | export LD_LIBRARY_PATH=$ARBHOME/lib |
---|
33 | |
---|
34 | # OS dependant settings |
---|
35 | OSNAME=`uname -s` |
---|
36 | case $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 | ;; |
---|
50 | esac |
---|
51 | |
---|
52 | # fallback language (avoid perl spam) |
---|
53 | if [ -z "${LANG:-}" ]; then |
---|
54 | echo "Note: LANG was unset (using fallback 'C')" |
---|
55 | export LANG=C |
---|
56 | else |
---|
57 | echo "Note: LANG is '$LANG'" |
---|
58 | fi |
---|
59 | |
---|
60 | # prepare config.makefile |
---|
61 | CFG=config.makefile |
---|
62 | rm -f $CFG |
---|
63 | |
---|
64 | TARSUF="" |
---|
65 | UNIT_TESTS=1 |
---|
66 | DEBUG=0 |
---|
67 | if [ ${SKIP_LEAK_CHECK} = 1 ]; then |
---|
68 | SANITIZE="2" # disables leak-check and address-sanitizer; see ../Makefile@SANITIZE |
---|
69 | else |
---|
70 | SANITIZE="all" |
---|
71 | fi |
---|
72 | DEVELOPER="JENKINS" # does not influence RELEASE build; see ../UNIT_TESTER/README.txt@DEVEL_JENKINS |
---|
73 | |
---|
74 | case $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 | ;; |
---|
91 | esac |
---|
92 | |
---|
93 | case $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 | ;; |
---|
110 | esac |
---|
111 | |
---|
112 | if [ -z "${TGTNAME:-}" ]; then |
---|
113 | echo "Error: unknown TGTNAME - build refused" |
---|
114 | false |
---|
115 | fi |
---|
116 | |
---|
117 | echo "DEBUG := $DEBUG" >> $CFG |
---|
118 | echo "UNIT_TESTS := $UNIT_TESTS" >> $CFG |
---|
119 | echo "OPENGL := 0" >> $CFG |
---|
120 | echo "DEVELOPER := $DEVELOPER" >> $CFG |
---|
121 | echo "DEBUG_GRAPHICS := 0" >> $CFG |
---|
122 | echo "ARB_64 := 1" >> $CFG |
---|
123 | echo "TRACESYM := 1" >> $CFG |
---|
124 | echo "SANITIZE := $SANITIZE" >> $CFG |
---|
125 | echo "COVERAGE := 0" >> $CFG |
---|
126 | # done with config.makefile |
---|
127 | |
---|
128 | # build, tar and test |
---|
129 | if [ "$ARG" == "fake_build" ]; then |
---|
130 | echo "Faking build" |
---|
131 | echo "Faked arb.tgz" > arb.tgz |
---|
132 | echo "Faked arb-dev.tgz" > arb-dev.tgz |
---|
133 | else |
---|
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 |
---|
144 | fi |
---|
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 | |
---|
149 | if [ -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[-_]}" |
---|
154 | else |
---|
155 | # normal build |
---|
156 | VERSION_ID=r${SVN_REVISION}${TARSUF} |
---|
157 | fi |
---|
158 | |
---|
159 | VERSION_ID=arb-${VERSION_ID} |
---|
160 | VERSION_ID_TARGET=${VERSION_ID}.${TGTNAME} |
---|
161 | |
---|
162 | if [ "$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 |
---|
191 | else |
---|
192 | # only archived (needed by SINA): |
---|
193 | mv arb.tgz ${VERSION_ID_TARGET}-bin.tgz |
---|
194 | fi |
---|
195 | # only archived (needed by SINA): |
---|
196 | mv arb-dev.tgz ${VERSION_ID_TARGET}-dev.tgz |
---|
197 | |
---|
198 | ${JMAKE} ut |
---|
199 | |
---|
200 | echo "-------------------- compiled-in version info:" |
---|
201 | (bin/arb_ntree --help || true) |
---|
202 | |
---|
203 | echo "-------------------- cleanup relinkable binaries:" |
---|
204 | ${JMAKE} cleanRelinkable || echo "cleanRelinkable failed (ignored)" |
---|
205 | |
---|
206 | echo "-------------------- existing tarballs:" |
---|
207 | ls -al arb*.tgz |
---|
208 | echo "--------------------" |
---|