lang-bootstrap/bootstrap.sh

102 lines
1.6 KiB
Bash
Raw Normal View History

2021-08-31 02:10:17 -04:00
#!/bin/sh
esc() {
: # comment out the following line to disable color output
printf '\33[%dm' "$1"
}
echo_red() {
esc 31
echo "$1"
esc 0
}
echo_green() {
esc 32
echo "$1"
esc 0
}
2021-08-31 17:16:30 -04:00
# check OS/architecture
2021-08-31 02:10:17 -04:00
if uname -a | grep -i 'x86_64' | grep -i -q 'linux'; then
: # all good
else
echo_red "Only 64-bit Linux is supported. This doesn't seem to be 64-bit Linux."
exit 1
fi
2021-09-01 18:27:51 -04:00
echo 'Processing stage 00...'
2021-08-31 02:10:17 -04:00
cd 00
2021-08-31 17:16:30 -04:00
rm -f out00
make -s out00
if [ "$(cat out00)" != 'Hello, world!' ]; then
2021-08-31 02:10:17 -04:00
echo_red 'Stage 00 failed.'
exit 1
fi
2021-08-31 17:16:30 -04:00
rm -f out00
2021-08-31 02:10:17 -04:00
cd ..
2021-09-01 18:27:51 -04:00
echo 'Processing stage 01...'
2021-09-01 17:40:39 -04:00
cd 01
2021-11-17 22:58:17 -05:00
rm -f out*
2021-09-01 17:40:39 -04:00
make -s out01
if [ "$(./out01)" != 'Hello, world!' ]; then
echo_red 'Stage 01 failed.'
exit 1
fi
2021-11-10 12:58:28 -05:00
rm -f out01
cd ..
echo 'Processing stage 02...'
cd 02
2021-11-17 22:58:17 -05:00
rm -f out*
2021-11-10 12:58:28 -05:00
make -s out02
if [ "$(./out02)" != 'Hello, world!' ]; then
echo_red 'Stage 02 failed.'
exit 1
fi
2021-09-01 17:40:39 -04:00
cd ..
2021-11-14 00:43:09 -05:00
echo 'Processing stage 03...'
cd 03
2021-11-17 22:58:17 -05:00
rm -f out*
2021-11-14 00:43:09 -05:00
make -s out03
if [ "$(./out03)" != 'Hello, world!' ]; then
echo_red 'Stage 03 failed.'
exit 1
fi
cd ..
2022-01-07 11:29:37 -05:00
echo 'Processing stage 04...'
cd 04
2021-11-17 22:58:17 -05:00
rm -f out*
2022-01-07 11:29:37 -05:00
make -s out04
if [ "$(./out04)" != 'Hello, world!' ]; then
echo_red 'Stage 04 failed.'
2021-11-17 22:58:17 -05:00
exit 1
fi
cd ..
2022-01-07 14:31:52 -05:00
echo 'Processing stage 04a...'
cd 04a
rm -f out*
make -s out04a
if [ "$(sed '/^#/d;/^$/d' out04a)" != 'Hello, world!' ]; then
echo_red 'Stage 04a failed.'
exit 1
fi
cd ..
2022-02-19 19:43:13 -08:00
echo 'Processing stage 05 (this will take some time)...'
cd 05
rm -f test.out out04 in04 *.o tcc-0.9.27/tcc0
make -s test.out > /dev/null
if [ "$(./test.out)" != 'Hello, world!' ]; then
echo_red 'Stage 05 failed.'
exit 1
fi
cd ..
2021-09-01 17:40:39 -04:00
2021-08-31 17:16:30 -04:00
echo_green 'all stages completed successfully!'