-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·74 lines (66 loc) · 2.54 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·74 lines (66 loc) · 2.54 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
70
71
72
73
74
#!/usr/bin/env bash
# machin-escouade — a top-down tactical POC.
#
# ./build.sh build bin/esc
# ./build.sh test headless assertions, no window
#
# The engine is machin-ressort's, referenced rather than copied.
set -euo pipefail
cd "$(dirname "$0")"
MACHIN="${MACHIN:-machin}"
RESSORT="${RESSORT:-$HOME/ai/machin-ressort}"
if [ ! -f "$RESSORT/engine/00_core.src" ]; then
echo "no ressort engine at $RESSORT (set RESSORT=/path)" >&2
exit 1
fi
# The top-down half of the engine. No rig, no forge, no side-view physics:
# what this game wants from ressort is the grid (flow fields and line of
# sight), the camera, the particles and the C boundary.
ENGINE=("$RESSORT/engine/00_core.src" "$RESSORT/engine/10_scene.src"
"$RESSORT/engine/20_tilemap.src" "$RESSORT/engine/25_grid.src"
"$RESSORT/engine/50_ffi.src" "$RESSORT/engine/60_view.src")
ES=(es/10_defs.src es/20_map.src es/25_art.src es/30_sim.src es/40_ai.src
es/50_draw.src es/60_avatar.src es/70_hud.src es/80_main.src)
have_system_raylib() {
pkg-config --exists raylib 2>/dev/null && return 0
[ -f /usr/include/raylib.h ] || [ -f /usr/local/include/raylib.h ]
}
RL_VER=5.0
RL_TAR="raylib-${RL_VER}_linux_amd64"
RL_DIR="vendor/${RL_TAR}"
[ -f "$RESSORT/vendor/${RL_TAR}/lib/libraylib.a" ] && RL_DIR="$RESSORT/vendor/${RL_TAR}"
CACHE="/tmp/rl/${RL_TAR}"
vendor_raylib() {
if [ -f "${RL_DIR}/lib/libraylib.a" ]; then return; fi
mkdir -p vendor
RL_DIR="vendor/${RL_TAR}"
if [ -f "${CACHE}/lib/libraylib.a" ]; then cp -r "${CACHE}" "${RL_DIR}"
else curl -fsSL "https://github.com/raysan5/raylib/releases/download/${RL_VER}/${RL_TAR}.tar.gz" | tar xz -C vendor
fi
}
encode() {
local out="$1"; shift
if have_system_raylib; then
"$MACHIN" encode "$@" > "$out"
else
vendor_raylib
local INC LIB
INC="$(cd "${RL_DIR}" && pwd)/include"
LIB="$(cd "${RL_DIR}" && pwd)/lib"
"$MACHIN" encode "$@" \
| sed "s#header \"raylib.h\"#cflags \"-I${INC} -L${LIB}\" header \"raylib.h\"#; \
s#link \"raylib\"#link \":libraylib.a\"#" > "$out"
fi
}
mkdir -p bin
if [ "${1:-}" = "test" ]; then
encode /tmp/esc_test.mfl "${ENGINE[@]}" es/10_defs.src es/20_map.src \
es/25_art.src es/30_sim.src es/40_ai.src es/50_draw.src es/60_avatar.src \
es/70_hud.src tests/es_test.src
"$MACHIN" build /tmp/esc_test.mfl -o bin/esc-test
./bin/esc-test
exit $?
fi
encode /tmp/esc.mfl "${ENGINE[@]}" "${ES[@]}"
"$MACHIN" build /tmp/esc.mfl -o bin/esc
echo "built ./bin/esc"