From 3a1f9fe6800ef5fe7bbf1c0a5976720383ba84fe Mon Sep 17 00:00:00 2001 From: Joel Stålnacke Date: Mon, 23 Mar 2026 19:50:18 +0200 Subject: Rewrite native code in Odin and use ECS --- lib/build.sh | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'lib/build.sh') diff --git a/lib/build.sh b/lib/build.sh index 3f8b5a6..1695dfe 100755 --- a/lib/build.sh +++ b/lib/build.sh @@ -5,11 +5,9 @@ fail() { exit 1 } -CC=cc -CFLAGS="-std=c99 -Wall -Wextra -Wpedantic -Og -g -D_POSIX_C_SOURCE=200809L" -LDFLAGS="-fPIC -lm" -SOURCES="test.c vec2.c snapshot.c log.c player.c physics.c" -output="build" +ODIN_FLAGS="-vet -warnings-as-errors -reloc-mode=pic" + +output="output" for arg ; do case "$arg" in @@ -19,6 +17,15 @@ for arg ; do --output=*) output="${arg#*=}" ;; + --release) + release=1 + ;; + --client) + ODIN_FLAGS="$ODIN_FLAGS -define:DJUP_CLIENT=true" + ;; + --server) + ODIN_FLAGS="$ODIN_FLAGS -define:DJUP_SERVER=true" + ;; *) echo "usage" ;; @@ -42,10 +49,20 @@ fi case "$runtime" in linux-x64) sofile="libdjup.so" + target="linux_amd64" ;; *) fail "Unsupported runtime $runtime" esac +if [ ! -z "$release" ]; then + optimize="-o=speed" +else + optimize="-o=none" +fi + echo Building for runtime "$runtime ..." -mkdir -p "$output/$runtime" && $CC $CFLAGS $SOURCES -shared $LDFLAGS -o "$output/$runtime/$sofile" && echo Done +echo ODIN_FLAGS=$ODIN_FLAGS +mkdir -p "$output/$runtime" && \ + odin build . -build-mode=shared -out="$output/$runtime/$sofile" $ODIN_FLAGS $optimize && \ + echo Done -- cgit v1.2.3