/
compile
executable file
·73 lines (57 loc) · 1.73 KB
/
compile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
# bin/compile <build-dir> <cache-dir>
# fail fast
set -e
# if any command in a pipe fails, kill the script (useful for indent)
set -o pipefail
indent() {
while read line; do
echo " ${line}"
done
}
mktmpdir() {
dir=$(mktemp -t node-$1-XXXX)
rm -rf $dir
mkdir -p $dir
echo $dir
}
# config
MONO_VERSION="2.10.8"
XSP_VERSION="2.10.2"
# s3 packages
MONO_PACKAGE="https://s3.amazonaws.com/heroku-buildpack-mono/mono-${MONO_VERSION}.tgz"
XSP_PACKAGE="https://s3.amazonaws.com/heroku-buildpack-mono/xsp-${XSP_VERSION}.tgz"
# important directories: https://gist.github.com/fe7f04abbd9538b656c5
BUILD_DIR=$1
CACHE_DIR=$2
cd ${BUILD_DIR}
# cache may not exist yet
mkdir -p ${CACHE_DIR}
echo "-----> Bundling Mono v$MONO_VERSION"
if [ ! -d "${CACHE_DIR}/mono" ]; then
echo "Fetching ${MONO_PACKAGE}" | indent
curl ${MONO_PACKAGE} --silent --max-time 60 -o - | tar xzf - -C ${CACHE_DIR}
fi
cp -r "${CACHE_DIR}/mono" .
echo "-----> Bundling XSP v$XSP_VERSION"
if [ ! -d "${CACHE_DIR}/xsp" ]; then
echo "Fetching ${XSP_PACKAGE}" | indent
curl ${XSP_PACKAGE} --silent --max-time 60 -o - | tar xzf - -C ${CACHE_DIR}
echo "Copying libraries to the GAC" | indent
cp -r ${CACHE_DIR}/xsp/lib/mono/gac/* ${CACHE_DIR}/mono/lib/mono/gac/
fi
cp -r "${CACHE_DIR}/xsp" .
# find a solution file
SLN=$(find . -maxdepth 1 -iname "*.sln")
if [ $( echo "${SLN}" | wc -l ) -gt 1 ]; then
echo "-----> Too many *.sln files" 1>&2
exit 1
fi
# compile an uploaded application
if [ "${SLN}" != "" ]; then
echo "-----> Compiling Mono application"
# need Mono in its expected location for xbuild to work
ln -s "${CACHE_DIR}/mono" /app
export PATH="/app/mono/bin:${PATH}"
xbuild /property:Configuration=Release ${SLN} | indent
fi