TARGET=$1
DIR=build-"$TARGET"
CONFIGURE=do-"$TARGET"-configure
shift
(mkdir "$DIR" || exit 1
cd "$DIR" || exit 2
echo '##################################################'
echo '##########' ../scripts/"$CONFIGURE" -Dwerror=true -Ddebug=false "$@"
echo '##################################################'
date
../scripts/"$CONFIGURE" -Dwerror=true -Ddebug=false "$@" > config.log 2>&1
case $? in
0)
echo 'Configuration succeeded'
;;
77)
echo 'Configuration skipped'
exit 0
;;
*)
exit 3
;;
esac
echo '##########' "$TARGET" 'ninja'
date
ninja > ninja.log 2>&1 || exit 4
echo 'Build succeeded'
echo '##########' "$TARGET" 'meson test -t 20'
date
meson test -t 20 > test.log 2>&1 || exit 5
echo 'Test succeeded'
date)
case $? in
0)
rm -rf "$DIR"
;;
1)
echo '##################################'
echo '############# mkdir' "$DIR" 'failed'
echo '##################################'
exit 1
;;
2)
echo '##################################'
echo '############# cd' "$DIR" 'failed'
echo '##################################'
exit 1
;;
3)
echo '##################################'
echo '############# Configuration failed'
echo '##################################'
echo 'config.log'
echo '##################################'
cat "$DIR"/config.log
echo '##################################'
echo 'meson-logs/meson-log.txt'
echo '##################################'
cat "$DIR"/meson-logs/meson-log.txt
exit 1
;;
4)
echo '##################################'
echo '############# Build failed'
echo '##################################'
echo 'ninja.log'
echo '##################################'
cat "$DIR"/ninja.log
exit 1
;;
5)
echo '##################################'
echo '############# Test failed'
echo '##################################'
echo 'test.log'
echo '##################################'
cat "$DIR"/test.log
echo '##################################'
echo 'meson-logs/testlog.txt'
echo '##################################'
cat "$DIR"/meson-logs/testlog.txt
exit 1
;;
*)
echo '##################################'
echo '############# Unknown failure' "$?"
echo '##################################'
cat "$DIR"/meson-logs/*
exit 1
;;
esac