source: trunk/build/run-bitten.sh @ 2533

Last change on this file since 2533 was 2533, checked in by sam, 10 years ago

build: make sure the builds _and_ the autobuilds work around the
memory leak in OS X llvm-g++.

  • Property svn:executable set to *
File size: 4.9 KB
Line 
1#!/bin/sh
2
3tmpdir="$TMPDIR"
4if [ -z "${tmpdir}" ]; then tmpdir="$TEMP"; fi
5if [ -z "${tmpdir}" ]; then tmpdir="$TEMPDIR"; fi
6if [ -z "${tmpdir}" ]; then tmpdir="$TMP"; fi
7if [ -z "${tmpdir}" ]; then tmpdir="/tmp"; fi
8
9conffile="`mktemp -q "${tmpdir}/lol-bitten-XXXXXXXX" 2>/dev/null`"
10if [ "${conffile}" = "" ]; then
11    conffile="`mktemp 2>/dev/null`"
12fi
13scriptfile=""
14builddir="${tmpdir}/lol-bitten-`whoami`"
15url="http://lol.zoy.org/builds"
16
17#
18# Utility functions
19#
20
21append() {
22    echo "$*" >> "${conffile}"
23}
24
25cleanup() {
26    rm -f "${conffile}" "${scriptfile}"
27    rm -rf "${builddir}"
28}
29
30bailout() {
31    cleanup
32    # Exit gracefully
33    exit 0
34}
35
36trap bailout EXIT HUP INT QUIT ABRT KILL ALRM TERM
37
38#
39# Fork if necessary
40#
41
42if [ "$1" = "--forked" ]; then
43    shift
44    scriptfile="$1"
45    shift
46else
47    cp "$0" "${conffile}"
48    chmod +x "${conffile}"
49    exec "${conffile}" --forked "${conffile}" "$@"
50    exit 0
51fi
52
53#
54# Check for command line
55#
56
57if [ "$#" != 2 ]; then
58    echo "Usage: run-bitten.sh <username> <password>"
59    exit 1
60fi
61
62#
63# Clean up working directory
64#
65cleanup
66if [ -e "${builddir}" ]; then
67    echo "Error: cannot get rid of ${builddir}"
68    exit 1
69fi
70
71#
72# Operating system information
73#
74
75append "[os]"
76append "name = `uname -srmo 2>/dev/null || uname -srm`"
77append "version = 0"
78family="`uname -s | tr A-Z a-z`"
79case "$family" in
80  mingw*) family="windows" ;;
81  darwin*) family="osx" ;;
82esac
83append "family = $family"
84# This random token prevents HTTP conflicts when several instances
85# are run from the same machine.
86append "token = $$$RANDOM"
87append ""
88
89#
90# Hardware information
91#
92
93append "[machine]"
94name="`uname -n | tr A-Z a-z | sed 's/[.].*//'`"
95case "$name" in
96  d*e*s*o*v*) name="putois" ;;
97esac
98append "name = $name"
99processor="`uname -m`"
100case "$processor" in
101  x86_64) processor="amd64" ;;
102  i*86) processor="i386" ;;
103esac
104# Windows defines a lot of crazy shit, try to make sense of it
105case "$PROCESSOR_ARCHITECTURE" in
106  amd64|AMD64) processor="amd64" ;;
107  x86|X86) processor="i386" ;;
108esac
109case "$PROCESSOR_ARCHITEW6432" in
110  amd64|AMD64) processor="amd64" ;;
111  x86|X86) processor="i386" ;;
112esac
113append "processor = $processor"
114append ""
115
116#
117# Authentication information
118#
119
120append "[authentication]"
121append "username = $1"
122append "password = $2"
123append ""
124
125#
126# Visual Studio configuration
127#
128
129# FIXME: we also need to check for the Visual Studio SDK
130append "[msvc]"
131if [ -n "$VS100COMNTOOLS" ]; then
132    append "version = 10"
133elif [ -n "$VS110COMNTOOLS" ]; then
134    append "version = 11"
135elif [ -n "$VS90COMNTOOLS" ]; then
136    append "version = 9"
137fi
138append ""
139
140#
141# Xbox development kit
142#
143
144append "[xdk]"
145if [ -n "$XEDK" ]; then
146    # FIXME: we don't know how to check the version
147    append "version = 2.0.20675.0"
148fi
149append ""
150
151#
152# PS3 development kit
153#
154
155append "[ps3sdk]"
156# Try to "detect" the SNC compiler on Windows
157if [ -n "$SN_PS3_PATH" ]; then
158    append "version = 410"
159fi
160# The setup is easier to detect on Linux
161if [ -f "$CELLSDK/version-SDK" ]; then
162    append "version = $(cat "$CELLSDK/version-SDK")"
163fi
164append ""
165
166#
167# mingw32 / mingw-w64
168#
169
170append "[mingw64]"
171if x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
172    append "version = $(x86_64-w64-mingw32-g++ --version | sed -ne 's/.*g++ *([^)]*) *//p')"
173fi
174append ""
175
176append "[mingw32]"
177if i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
178    append "version = $(i686-w64-mingw32-g++ --version | sed -ne 's/.*g++ *([^)]*) *//p')"
179fi
180append ""
181
182#
183# Android NDK
184#
185
186append "[ndk]"
187if [ "$family" != "windows" ]; then
188    if [ -f "$ANDROID_NDK_ROOT/RELEASE.TXT" ]; then
189        append "version = $(cat "$ANDROID_NDK_ROOT/RELEASE.TXT")"
190    fi
191fi
192append ""
193
194#
195# Google NaCl SDK
196#
197
198append "[pepper]"
199if [ "$family" != "windows" ]; then
200    if [ -d "$NACL_SDK_ROOT" ]; then
201        pepper_version=0
202        for dir in "$NACL_SDK_ROOT/pepper_"*; do
203            new_version="$(echo "$dir" | sed 's/.*_//')"
204            if [ "$new_version" -gt "$pepper_version" ]; then
205                pepper_version="$new_version"
206            fi
207        done
208        if [ "$pepper_version" != 0 ]; then
209            append "version = $pepper_version"
210        fi
211    fi
212fi
213append ""
214
215#
216# Raspberry Pi cross-compiler
217#
218
219append "[raspi]"
220if [ "$family" != "windows" ]; then
221    if [ -d "$RASPI_SDK_ROOT/tools" ]; then
222        append "version = 0"
223    fi
224fi
225append ""
226
227#
228# Show what we just did here
229#
230
231cat "${conffile}"
232
233#
234# Fix system
235#
236
237if [ "$family" = "osx" ]; then
238    # The version of Subversion shipped by Apple is antique; try to
239    # use the one in /usr/local/bin instead.
240    PATH="/usr/local/bin:$PATH"
241    export PATH
242    # HACK: the version of llvm-g++ shipped by Apple has an insane
243    # memory leak; use clang++ instead.
244    CC="clang"
245    export CC
246    CXX="clang++"
247    export CXX
248fi
249
250#
251# Launch everything
252#
253
254while : ; do
255    bitten-slave "$url" \
256        -f "${conffile}" \
257        --name "$name" \
258        --work-dir="${builddir}"
259    rm -rf "${builddir}"
260    sleep 10
261done
262
263exit 0
264
Note: See TracBrowser for help on using the repository browser.