diff options
| author | Joel Stålnacke <joel@saker.fi> | 2026-03-23 19:50:18 +0200 |
|---|---|---|
| committer | Joel Stålnacke <joel@saker.fi> | 2026-03-23 19:50:18 +0200 |
| commit | 3a1f9fe6800ef5fe7bbf1c0a5976720383ba84fe (patch) | |
| tree | f1218eb4085a654f6bb70671b41b4a74e646c052 /lib/build.sh | |
| parent | 3870982f640260822bf605e693782ce9f5d79cf6 (diff) | |
Rewrite native code in Odin and use ECSodin
Diffstat (limited to 'lib/build.sh')
| -rwxr-xr-x | lib/build.sh | 29 |
1 files changed, 23 insertions, 6 deletions
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 |
