-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
33 lines (27 loc) · 871 Bytes
/
build.sh
File metadata and controls
33 lines (27 loc) · 871 Bytes
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
#!/bin/sh
set -e
# Setup basics
COMPILER="gcc"
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "Usage: ./build.sh [COMPILER] [OPTIONS...]"
echo " COMPILER : gcc (default), clang, icx, cc, tcc"
echo " OPTIONS : Flags applied directly to compilation (e.g. -O3, -Wall)"
echo "Examples :"
echo " ./build.sh (Uses gcc)"
echo " ./build.sh clang -O2 -g (Uses clang with flags)"
exit 0
fi
# Determine compiler from first argument if matched
case "$1" in
gcc|clang|icx|cc|tcc)
COMPILER="$1"
shift
;;
esac
# Export the chosen setup so nob.c can read it to build the actual library
export NOB_COMPILER="$COMPILER"
export CC="$COMPILER"
echo "=> 1. Compiling build script (nob.c) with $COMPILER..."
$COMPILER -o nob nob.c
echo "=> 2. Running build script with custom options..."
./nob "$@"