bloat-buster/build.sh
2025-01-05 21:54:19 -06:00

43 lines
1001 B
Bash
Executable File

#!/usr/bin/env bash
set -eu
if [[ -z "${BB_CI-}" ]]; then
BB_CI=0
fi
if [[ -z "${BB_BUILD_TYPE-}" ]]; then
BB_BUILD_TYPE=debug
fi
BUILD_DIR=cache
mkdir -p $BUILD_DIR
if [[ "${BB_CI}" == "0" ]]; then
glslangValidator -V bootstrap/std/shaders/rect.vert -o $BUILD_DIR/rect.vert.spv --quiet
glslangValidator -V bootstrap/std/shaders/rect.frag -o $BUILD_DIR/rect.frag.spv --quiet
fi
BUILD_OUT=$BUILD_DIR/build
C_COMPILER=cc
TIME_TRACE=1
BB_TIMETRACE=0
GCC_ARGS=
CLANG_ARGS=
TIME_TRACE_ARG=
if [[ $C_COMPILER == "clang"* ]]; then
CLANG_ARGS=-ferror-limit=1
if [[ "$TIME_TRACE" == "1" ]]; then
CLANG_ARGS="$CLANG_ARGS -ftime-trace"
BB_TIMETRACE=1
else
CLANG_ARGS="$CLANG_ARGS -ftime-trace"
fi
elif [[ $C_COMPILER == "gcc"* ]]; then
GCC_ARGS=-fmax-errors=1
fi
$C_COMPILER build.c -g -o $BUILD_OUT -Ibootstrap -std=gnu2x $CLANG_ARGS $GCC_ARGS -DBB_TIMETRACE=$BB_TIMETRACE -DBB_CI=$BB_CI -DBB_BUILD_TYPE=\"$BB_BUILD_TYPE\"
$BUILD_OUT $@
exit 0