-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash.sh
More file actions
69 lines (56 loc) · 1.51 KB
/
bash.sh
File metadata and controls
69 lines (56 loc) · 1.51 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
set -euo pipefail
set -x
OS="$(uname -s)"
have() { command -v "$1" >/dev/null 2>&1; }
# Pick a native C++ compiler (allow override via CXX env).
if [[ -n "${CXX:-}" ]]; then
CXX_BIN="$CXX"
elif have g++; then
CXX_BIN="g++"
elif have clang++; then
CXX_BIN="clang++"
else
echo "error: no C++ compiler found (g++/clang++)." >&2
exit 1
fi
BASE_CXX_FLAGS=(-Wall -Wextra -Wpedantic -std=c++17 -O2)
DBG_FLAGS=()
case "$OS" in
Darwin*) DBG_FLAGS+=(-g) ;; # clang on macOS
Linux*) DBG_FLAGS+=(-ggdb) ;;
*) DBG_FLAGS+=(-g) ;;
esac
"$CXX_BIN" "${BASE_CXX_FLAGS[@]}" "${DBG_FLAGS[@]}" -o runnable main.cpp
./runnable
# clang++ -Wall -Wextra --target=wasm32 -o wasm.o -c ./webm/render_web.cpp
# wasm-ld -m wasm32 --no-entry --export-all -allow-undefined -o ./webm/wasm.wasm ./webm/wasm.o
if have clang++ && have wasm-ld; then
clang++ \
-Wall -Wextra \
--target=wasm32 \
-nostdlib \
-fno-exceptions \
-fno-rtti \
-c webm/render_web.cpp \
-o webm/render_web.o
clang++ \
-Wall -Wextra \
--target=wasm32 \
-nostdlib \
-fno-exceptions \
-fno-rtti \
-c physics/physics.cpp \
-o webm/physics.o
wasm-ld \
--no-entry \
--allow-undefined \
webm/render_web.o \
webm/physics.o \
-o webm/wasm.wasm
else
echo "note: skipping wasm build (need clang++ and wasm-ld)." >&2
fi
# good to know
# This below converts files that are returned by ls with ppm extension to png!
# ls | grep ppm | sed 's/.ppm//' | xargs -Ixx convert xx.ppm xx.png