Skip to content

Commit f7172b6

Browse files
committed
Tidy up and test some misc stuff in common. Fixes some builds
1 parent 8ddf3ca commit f7172b6

8 files changed

+50
-189
lines changed

Dockerfile.misc

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ RUN cd /tmp && \
5252
./aws/install && \
5353
rm -rf aws*
5454

55-
RUN pip3 install conan
56-
5755
RUN mkdir -p /opt/compiler-explorer
5856

5957
# Add github public key to known_hosts, to enable interaction-less clone
@@ -79,5 +77,6 @@ ENV PATH=/cmake/bin:${PATH}
7977

8078
RUN mkdir -p /root
8179
COPY misc /root/
80+
COPY common.sh /root/
8281

8382
WORKDIR /root

common.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ get_remote_revision() {
1010
local BRANCH="$2"
1111
local REVISION
1212
REVISION=$(git ls-remote --tags --heads "${URL}" "refs/${BRANCH}" | cut -f 1)
13-
[[ -z "$REVISION" ]] && exit 255
13+
if [[ -z "$REVISION" ]]; then
14+
>&2 echo "Unable to get remote revision for ${URL} refs/${BRANCH}"
15+
exit 255
16+
fi
1417
echo "$REVISION"
1518
}
1619

misc/build-6502-c++.sh

+16-40
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
22

33
set -ex
4+
source common.sh
45

5-
ROOT=$(pwd)
66
VERSION=$1
7-
if echo ${VERSION} | grep 'trunk'; then
7+
if [[ "${VERSION}" = "trunk" ]]; then
88
VERSION=trunk-$(date +%Y%m%d)
99
BRANCH=master
1010
else
@@ -14,55 +14,31 @@ fi
1414
URL=https://github.com/lefticus/6502-cpp.git
1515

1616
FULLNAME=6502-c++-${VERSION}.tar.xz
17-
OUTPUT=${ROOT}/${FULLNAME}
18-
S3OUTPUT=
19-
if [[ $2 =~ ^s3:// ]]; then
20-
S3OUTPUT=$2
21-
else
22-
if [[ -d "${2}" ]]; then
23-
OUTPUT=$2/${FULLNAME}
24-
else
25-
OUTPUT=${2-$OUTPUT}
26-
fi
27-
fi
17+
OUTPUT=$2/${FULLNAME}
2818

29-
GIT_REVISION=$(git ls-remote --heads ${URL} refs/heads/${BRANCH} | cut -f 1)
30-
REVISION="6502-c++-${GIT_REVISION}"
31-
LAST_REVISION="${3}"
19+
REVISION="6502-c++-$(get_remote_revision "${URL}" "heads/${BRANCH}")"
20+
LAST_REVISION="${3:-}"
3221

33-
echo "ce-build-revision:${REVISION}"
34-
echo "ce-build-output:${OUTPUT}"
22+
initialise "${REVISION}" "${OUTPUT}" "${LAST_REVISION}"
3523

36-
if [[ "${REVISION}" == "${LAST_REVISION}" ]]; then
37-
echo "ce-build-status:SKIPPED"
38-
exit
39-
fi
24+
pip3 install conan==1.59.0
4025

4126
PREFIX=$(pwd)/prefix
4227
DIR=$(pwd)/6502-c++
4328
BUILDDIR=${DIR}/build
4429

45-
OPT=/opt/compiler-explorer
46-
GXXPATH=/opt/compiler-explorer/gcc-12.1.0
47-
48-
git clone ${URL} ${DIR}
30+
git clone "${URL}" "${DIR}"
4931

50-
mkdir ${BUILDDIR}
51-
cd ${BUILDDIR}
32+
mkdir "${BUILDDIR}"
33+
cd "${BUILDDIR}"
5234

35+
GXXPATH=/opt/compiler-explorer/gcc-12.1.0
5336
CXX=${GXXPATH}/bin/g++ cmake ..
54-
make 6502-c++
55-
56-
patchelf --set-rpath /opt/compiler-explorer/gcc-12.1.0/lib64 bin/6502-c++
37+
make "-j$(nproc)" 6502-c++
5738

58-
mkdir -p ${PREFIX}
59-
mv bin ${PREFIX}/bin
39+
patchelf --set-rpath "${GXXPATH}/lib64" bin/6502-c++
6040

61-
export XZ_DEFAULTS="-T 0"
62-
tar Jcf ${OUTPUT} --transform "s,^./,./6502-c++-${VERSION}/," -C ${PREFIX} .
63-
64-
if [[ -n "${S3OUTPUT}" ]]; then
65-
aws s3 cp --storage-class REDUCED_REDUNDANCY "${OUTPUT}" "${S3OUTPUT}"
66-
fi
41+
mkdir -p "${PREFIX}"
42+
mv bin "${PREFIX}/bin"
6743

68-
echo "ce-build-status:OK"
44+
complete "${PREFIX}" "6502-c++-${VERSION}" "${OUTPUT}"

misc/build-beebasm.sh

+13-37
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
22

33
set -ex
4+
source common.sh
45

5-
ROOT=$(pwd)
66
VERSION=$1
7-
if echo ${VERSION} | grep 'trunk'; then
7+
if [[ "${VERSION}" = "trunk" ]]; then
88
VERSION=trunk-$(date +%Y%m%d)
99
BRANCH=master
1010
else
@@ -14,45 +14,21 @@ fi
1414
URL=https://github.com/stardot/beebasm
1515

1616
FULLNAME=beebasm-${VERSION}.tar.xz
17-
OUTPUT=${ROOT}/${FULLNAME}
18-
S3OUTPUT=
19-
if [[ $2 =~ ^s3:// ]]; then
20-
S3OUTPUT=$2
21-
else
22-
if [[ -d "${2}" ]]; then
23-
OUTPUT=$2/${FULLNAME}
24-
else
25-
OUTPUT=${2-$OUTPUT}
26-
fi
27-
fi
17+
OUTPUT=$2/${FULLNAME}
2818

29-
BEEBASM_REVISION=$(git ls-remote --heads ${URL} refs/heads/${BRANCH} | cut -f 1)
30-
REVISION="beebasm-${BEEBASM_REVISION}"
31-
LAST_REVISION="${3}"
19+
REVISION="beebasm-$(get_remote_revision "${URL}" "heads/${BRANCH}")"
20+
LAST_REVISION="${3:-}"
3221

33-
echo "ce-build-revision:${REVISION}"
34-
echo "ce-build-output:${OUTPUT}"
35-
36-
if [[ "${REVISION}" == "${LAST_REVISION}" ]]; then
37-
echo "ce-build-status:SKIPPED"
38-
exit
39-
fi
22+
initialise "${REVISION}" "${OUTPUT}" "${LAST_REVISION}"
4023

4124
PREFIX=$(pwd)/prefix
4225
DIR=$(pwd)/beebasm
43-
git clone --depth 1 -b ${BRANCH} ${URL} ${DIR}
26+
BUILD=$(pwd)/build
27+
git clone --depth 1 -b "${BRANCH}" "${URL}" "${DIR}"
4428

45-
cd ${DIR}/src
46-
make all
47-
mkdir -p ${PREFIX}
48-
cd ..
49-
cp beebasm ${PREFIX}
50-
51-
export XZ_DEFAULTS="-T 0"
52-
tar Jcf ${OUTPUT} --transform "s,^./,./beebasm-${VERSION}/," -C ${PREFIX} .
53-
54-
if [[ -n "${S3OUTPUT}" ]]; then
55-
aws s3 cp --storage-class REDUCED_REDUNDANCY "${OUTPUT}" "${S3OUTPUT}"
56-
fi
29+
cmake -S "${DIR}" -B "${BUILD}" -DCMAKE_BUILD_TYPE=Release -GNinja
30+
ninja -C "${BUILD}"
31+
mkdir -p "${PREFIX}"
32+
cp "${BUILD}/beebasm" "${PREFIX}"
5733

58-
echo "ce-build-status:OK"
34+
complete "${PREFIX}" "beebasm-${VERSION}" "${OUTPUT}"

misc/build-chibicc.sh

+8-43
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/bin/bash
22

33
## $1 : version, chibicc does not have any and only uses main branch.
4-
## $2 : destination: a directory or S3 path (eg. s3://...)
4+
## $2 : destination: a directory
55
## $3 : last revision successfully build
66

77
set -ex
8+
source common.sh
89

9-
ROOT=$PWD
1010
VERSION="${1}"
11-
LAST_REVISION="${3}"
11+
LAST_REVISION="${3:-}"
1212

1313
if [[ "${VERSION}" != "main" ]]; then
1414
echo "Only support building main"
@@ -17,50 +17,15 @@ fi
1717

1818
URL="https://github.com/rui314/chibicc.git"
1919
BRANCH="main"
20-
21-
REVISION=$(git ls-remote --heads "${URL}" "refs/heads/${BRANCH}" | cut -f 1)
22-
echo "ce-build-revision:${REVISION}"
23-
24-
if [[ "${REVISION}" == "${LAST_REVISION}" ]]; then
25-
echo "ce-build-status:SKIPPED"
26-
exit
27-
fi
20+
REVISION=$(get_remote_revision "${URL}" "heads/${BRANCH}")
2821

2922
FULLNAME=chibicc-${VERSION}-$(date +%Y%m%d)
23+
OUTPUT=$(realpath "$2/${FULLNAME}.tar.xz")
3024

31-
OUTPUT=${ROOT}/${FULLNAME}.tar.xz
32-
S3OUTPUT=
33-
if [[ $2 =~ ^s3:// ]]; then
34-
S3OUTPUT=$2
35-
else
36-
if [[ -d "${2}" ]]; then
37-
OUTPUT=$2/${FULLNAME}.tar.xz
38-
else
39-
OUTPUT=${2-$OUTPUT}
40-
fi
41-
fi
42-
43-
## From now, no unset variable
44-
set -u
45-
46-
OUTPUT=$(realpath "${OUTPUT}")
47-
48-
rm -rf build-chibicc
49-
mkdir -p build-chibicc
50-
51-
pushd build-chibicc
25+
initialise "${REVISION}" "${OUTPUT}" "${LAST_REVISION}"
5226

5327
git clone --depth 1 "${URL}" --branch "${BRANCH}"
54-
pushd chibicc
55-
56-
make chibicc -j"$(nproc)"
5728

58-
export XZ_DEFAULTS="-T 0"
59-
tar Jcf "${OUTPUT}" --transform "s,^./,./${FULLNAME}/," ./
60-
61-
if [[ -n "${S3OUTPUT}" ]]; then
62-
aws s3 cp --storage-class REDUCED_REDUNDANCY "${OUTPUT}" "${S3OUTPUT}"
63-
fi
29+
make -C chibicc chibicc -j"$(nproc)"
6430

65-
popd
66-
popd
31+
complete chibicc "${FULLNAME}" "${OUTPUT}"

misc/build-z88dk.sh

+7-28
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22

33
set -ex
4+
source common.sh
45

5-
ROOT=$(pwd)
66
VERSION=$1
77
if echo ${VERSION} | grep 'trunk'; then
88
VERSION=trunk-$(date +%Y%m%d)
@@ -14,29 +14,15 @@ fi
1414
URL=https://github.com/z88dk/z88dk.git
1515

1616
FULLNAME=z88dk-${VERSION}.tar.xz
17-
OUTPUT=${ROOT}/${FULLNAME}
18-
S3OUTPUT=
19-
if [[ $2 =~ ^s3:// ]]; then
20-
S3OUTPUT=$2
21-
else
22-
if [[ -d "${2}" ]]; then
23-
OUTPUT=$2/${FULLNAME}
24-
else
25-
OUTPUT=${2-$OUTPUT}
26-
fi
27-
fi
17+
OUTPUT=$2/${FULLNAME}
2818

29-
GIT_REVISION=$(git ls-remote --heads ${URL} refs/heads/${BRANCH} | cut -f 1)
19+
GIT_REVISION=$(get_remote_revision "${URL}" "heads/${BRANCH}")
3020
REVISION="z88dk-${GIT_REVISION}"
31-
LAST_REVISION="${3}"
21+
LAST_REVISION="${3:-}"
3222

33-
echo "ce-build-revision:${REVISION}"
34-
echo "ce-build-output:${OUTPUT}"
23+
initialise "${REVISION}" "${OUTPUT}" "${LAST_REVISION}"
3524

36-
if [[ "${REVISION}" == "${LAST_REVISION}" ]]; then
37-
echo "ce-build-status:SKIPPED"
38-
exit
39-
fi
25+
pip3 install conan==1.59.0
4026

4127
PREFIX=$(pwd)/prefix
4228
DIR=$(pwd)/z88dk
@@ -58,11 +44,4 @@ export CXXFLAGS=$(pkg-config boost --cflags)
5844
./build.sh -i ${PREFIX}
5945
make install DESTDIR=${PREFIX}
6046

61-
export XZ_DEFAULTS="-T 0"
62-
tar Jcf ${OUTPUT} --transform "s,^./,./z88dk-${VERSION}/," -C ${PREFIX} .
63-
64-
if [[ -n "${S3OUTPUT}" ]]; then
65-
aws s3 cp --storage-class REDUCED_REDUNDANCY "${OUTPUT}" "${S3OUTPUT}"
66-
fi
67-
68-
echo "ce-build-status:OK"
47+
complete "${PREFIX}" "${FULLNAME}" "${OUTPUT}"

misc/custom-clean-fetch.sh

-37
This file was deleted.

rust-cg-gcc/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
## $1 : version, currently rustc_cg_gcc does not have any and only uses master branch.
4-
## $2 : destination: a directory or S3 path (eg. s3://...)
4+
## $2 : destination: a directory
55
## $3 : last revision (as mangled below) successfully build (optional)
66

77
set -eu

0 commit comments

Comments
 (0)