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

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

misc: fix a few URLs.

  • Property svn:executable set to *
File size: 5.1 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://lolengine.net/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# iOS development kit
142#
143
144append "[ios]"
145if [ -d "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk" ]; then
146    append "version = 6.1"
147fi
148append ""
149
150#
151# Xbox development kit
152#
153
154append "[xdk]"
155if [ -n "$XEDK" ]; then
156    # FIXME: we don't know how to check the version
157    append "version = 2.0.20675.0"
158fi
159append ""
160
161#
162# PS3 development kit
163#
164
165append "[ps3sdk]"
166# Try to "detect" the SNC compiler on Windows
167if [ -n "$SN_PS3_PATH" ]; then
168    append "version = 410"
169fi
170# The setup is easier to detect on Linux
171if [ -f "$CELLSDK/version-SDK" ]; then
172    append "version = $(cat "$CELLSDK/version-SDK")"
173fi
174append ""
175
176#
177# mingw32 / mingw-w64
178#
179
180append "[mingw64]"
181if x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
182    append "version = $(x86_64-w64-mingw32-g++ --version | sed -ne 's/.*g++ *([^)]*) *//p')"
183fi
184append ""
185
186append "[mingw32]"
187if i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
188    append "version = $(i686-w64-mingw32-g++ --version | sed -ne 's/.*g++ *([^)]*) *//p')"
189fi
190append ""
191
192#
193# Android NDK
194#
195
196append "[ndk]"
197if [ "$family" != "windows" ]; then
198    if [ -f "$ANDROID_NDK_ROOT/RELEASE.TXT" ]; then
199        append "version = $(cat "$ANDROID_NDK_ROOT/RELEASE.TXT")"
200    fi
201fi
202append ""
203
204#
205# Google NaCl SDK
206#
207
208append "[pepper]"
209if [ "$family" != "windows" ]; then
210    if [ -d "$NACL_SDK_ROOT" ]; then
211        pepper_version=0
212        for dir in "$NACL_SDK_ROOT/pepper_"*; do
213            new_version="$(echo "$dir" | sed 's/.*_//')"
214            if [ "$new_version" -gt "$pepper_version" ]; then
215                pepper_version="$new_version"
216            fi
217        done
218        if [ "$pepper_version" != 0 ]; then
219            append "version = $pepper_version"
220        fi
221    fi
222fi
223append ""
224
225#
226# Raspberry Pi cross-compiler
227#
228
229append "[raspi]"
230if [ "$family" != "windows" ]; then
231    if [ -d "$RASPI_SDK_ROOT/tools" ]; then
232        append "version = 0"
233    fi
234fi
235append ""
236
237#
238# Show what we just did here
239#
240
241cat "${conffile}"
242
243#
244# Fix system
245#
246
247if [ "$family" = "osx" ]; then
248    # The version of Subversion shipped by Apple is antique; try to
249    # use the one in /usr/local/bin instead.
250    PATH="/usr/local/bin:$PATH"
251    export PATH
252    # HACK: the version of llvm-g++ shipped by Apple has an insane
253    # memory leak; use clang++ instead.
254    CC="clang"
255    export CC
256    CXX="clang++"
257    export CXX
258fi
259
260#
261# Launch everything
262#
263
264while : ; do
265    bitten-slave "$url" \
266        -f "${conffile}" \
267        --name "$name" \
268        --work-dir="${builddir}"
269    rm -rf "${builddir}"
270    sleep 10
271done
272
273exit 0
274
Note: See TracBrowser for help on using the repository browser.