-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathbuild-tinycc.sh
67 lines (53 loc) · 1.6 KB
/
build-tinycc.sh
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
#!/bin/bash
set -ex
ROOT=$(pwd)
VERSION=$1
if echo "${VERSION}" | grep 'trunk'; then
VERSION=trunk-$(date +%Y%m%d)
URL=git://repo.or.cz/tinycc.git
BRANCH=mob
else
MAJOR=$(echo "${VERSION}" | grep -oE '^[0-9]+')
MAJOR_MINOR_BUILD=$(echo "${VERSION}" | grep -oE '^[0-9]+\.[0-9]+\.[0-9]+')
MINOR=$(echo "${MAJOR_MINOR_BUILD}" | cut -d. -f2)
BUILD=$(echo "${MAJOR_MINOR_BUILD}" | cut -d. -f3)
VERSION_UNDERSCORES="${MAJOR}_${MINOR}_${BUILD}"
URL=git://repo.or.cz/tinycc.git
BRANCH=release_${VERSION_UNDERSCORES}
fi
FULLNAME=tinycc-${VERSION}.tar.xz
OUTPUT=${ROOT}/${FULLNAME}
S3OUTPUT=
if [[ $2 =~ ^s3:// ]]; then
S3OUTPUT=$2
else
if [[ -d "${2}" ]]; then
OUTPUT=$2/${FULLNAME}
else
OUTPUT=${2-$OUTPUT}
fi
fi
TINYCC_REVISION=$(git ls-remote --heads ${URL} refs/heads/${BRANCH} | cut -f 1)
REVISION="tinycc-${TINYCC_REVISION}"
LAST_REVISION="${3}"
echo "ce-build-revision:${REVISION}"
echo "ce-build-output:${OUTPUT}"
if [[ "${REVISION}" == "${LAST_REVISION}" ]]; then
echo "ce-build-status:SKIPPED"
exit
fi
STAGING_DIR=/opt/compiler-explorer/tinycc-${VERSION}
rm -rf "${STAGING_DIR}"
mkdir -p "${STAGING_DIR}"
rm -rf "tinycc-${VERSION}"
git clone -q --depth 1 --single-branch -b "${BRANCH}" "${URL}" "tinycc-${VERSION}"
cd "tinycc-${VERSION}"
./configure --prefix="${STAGING_DIR}"
make
make install
export XZ_DEFAULTS="-T 0"
tar Jcf "${OUTPUT}" --transform "s,^./,./tinycc-${VERSION}/," -C "${STAGING_DIR}" .
if [[ -n "${S3OUTPUT}" ]]; then
aws s3 cp --storage-class REDUCED_REDUNDANCY "${OUTPUT}" "${S3OUTPUT}"
fi
echo "ce-build-status:OK"