1#!/bin/bash
2set -e
3
4ROOT="$(dirname "$(realpath "$0")")"
5SRC_FILES="src/*.cpp"
6
7# =====================
8# ==== Parse flags ====
9# =====================
10for arg in "$@"; do
11 if [[ "$arg" == "-r" ]]; then
12 BUILD="Release"
13 fi
14done
15
16
17# ===================
18# === Directories ===
19# ===================
20[ ! -d "build" ] && mkdir build
21#[ ! -d "external" ] && mkdir external
22
23
24# ====================
25# === Dependencies ===
26# ====================
27# brew sdl2
28SDL_CFLAGS=$(sdl2-config --cflags)
29SDL_LDFLAGS=$(sdl2-config --libs)
30
31
32# =========================
33# === Compilation Flags ===
34# =========================
35if [ "$BUILD" == "Release" ]; then
36 CFLAGS="-std=c++20 -O2 -o renderer"
37 LFLAGS=""
38else
39 CFLAGS="-std=c++20 -g -O0 -o renderer"
40 LFLAGS=""
41fi
42
43
44# ===================
45# === Compilation ===
46# ===================
47#clang++ $CFLAGS $SDL_CFLAGS "$SRC_FILES" -o "$" $SDL_LDFLAGS
48
49pushd build > /dev/null
50clang++ \
51 $CFLAGS \
52 $SDL_CFLAGS \
53 $ROOT/$SRC_FILES \
54 $LFLAGS \
55 $SDL_LDFLAGS
56popd > /dev/null