Files
HanjaKanaMun/justfile
T
SansanandClaude Sonnet 5 ad7d19b85a
Build and Test / build (push) Successful in 22s
Build and Test / windows (push) Successful in 1m8s
Embed fonts into the executable, ship release artifacts as bare binaries
Fonts are now baked in with #load and loaded via LoadFontFromMemory
instead of LoadFontEx reading assets/*.ttf from disk, so a build no
longer needs an assets/ folder next to it at runtime - the chdir to
the executable's own directory in main.odin is dead code, removed.

just package / just package-windows now produce a single executable
(build/<name>_<version>_<os>_<arch>[.exe]) instead of a tar.gz/zip,
and the release workflow's upload/release-asset globs and the lld/zip
toolchain package list are updated to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-03 20:11:47 +02:00

104 lines
4.5 KiB
Makefile

name := "HanjaKanaMun"
build_dir := "build"
odin_version := "dev-2026-09"
xwin_version := "0.10.0"
# Windows cross-compilation inputs (see `windows-deps`)
xwin := env("XWIN", build_dir / "xwin")
xwin_sdk := env("XWIN_SDK", build_dir / "xwin-sdk")
raylib_windows := env("RAYLIB_WINDOWS", build_dir / "raylib-windows")
lld_link := env("LLD_LINK", "lld-link")
# List available recipes
default:
@just --list
# Debug build
build:
odin build . -vet -debug -out:{{name}}
# Build and run (debug)
run:
odin run . -vet -debug -out:{{name}}
# Type-check with vet, no binary
check:
odin check . -vet
# Run the test suite (single-threaded: the tests share the memory game's global state)
test:
mkdir -p {{build_dir}}
# If the stack rlimit is "unlimited" (RLIM_INFINITY, as some CI/container hosts set it),
# Odin's core:thread passes that straight to pthread_attr_setstacksize, pthread_create
# then fails, and thread.create() returns nil - which core:testing's pool_init
# dereferences unconditionally, segfaulting the whole test binary. Clamp it.
# (One line: just runs each recipe line in its own shell, so a separate
# `ulimit` line wouldn't carry over to the `odin test` line.)
ulimit -s 8192 && odin test tests -vet -define:ODIN_TEST_THREADS=1 -out:{{build_dir}}/tests
# Optimized native build into build/<os>/<name> (self-contained: fonts are embedded)
release:
mkdir -p {{build_dir}}/{{os()}}
odin build . -vet -o:speed -out:{{build_dir}}/{{os()}}/{{name}}
# Native release build as build/<name>_<version>_<os>_<arch>
package version="dev": release
cp {{build_dir}}/{{os()}}/{{name}} {{build_dir}}/{{name}}_{{version}}_{{os()}}_{{arch()}}
@echo "{{build_dir}}/{{name}}_{{version}}_{{os()}}_{{arch()}}"
# Download the Windows SDK + CRT (via xwin, accepting Microsoft's license) and raylib.lib. Linux x86_64 only.
windows-deps:
#!/usr/bin/env bash
set -euo pipefail
mkdir -p {{build_dir}}
if [ ! -x "{{xwin}}" ]; then
curl -fsSL https://github.com/Jake-Shadle/xwin/releases/download/{{xwin_version}}/xwin-{{xwin_version}}-x86_64-unknown-linux-musl.tar.gz \
| tar -xz -C {{build_dir}} --strip-components=1 xwin-{{xwin_version}}-x86_64-unknown-linux-musl/xwin
fi
if [ ! -d "{{xwin_sdk}}/crt" ]; then
"{{xwin}}" --accept-license --arch x86_64 --cache-dir {{build_dir}}/xwin-cache splat --output "{{xwin_sdk}}"
fi
# Odin's Linux/macOS releases don't ship raylib's Windows library, so take it from the Windows release
if [ ! -f "{{raylib_windows}}/raylib.lib" ]; then
mkdir -p "{{raylib_windows}}"
curl -fsSL -o {{build_dir}}/odin-windows.zip \
https://github.com/odin-lang/Odin/releases/download/{{odin_version}}/odin-windows-amd64-{{odin_version}}.zip
unzip -o -j {{build_dir}}/odin-windows.zip 'dist/vendor/raylib/windows/raylib.lib' -d "{{raylib_windows}}"
fi
# Cross-compile a self-contained Windows x86_64 build into build/windows/ (run `just windows-deps` first)
windows:
#!/usr/bin/env bash
set -euo pipefail
obj_dir={{build_dir}}/obj-windows
out_dir={{build_dir}}/windows
mkdir -p "$obj_dir" "$out_dir"
rm -f "$obj_dir"/*.obj
odin build . -vet -o:speed -target:windows_amd64 -build-mode:obj -out:"$obj_dir/{{name}}.obj"
# Odin can't link for Windows from other platforms, so link with lld-link.
# The VC runtime is linked statically (no VCRUNTIME140.dll needed); the
# Universal CRT is used from Windows itself (built into Windows 10+).
{{lld_link}} /nologo /machine:x64 /subsystem:windows /entry:mainCRTStartup \
/out:"$out_dir/{{name}}.exe" "$obj_dir"/*.obj "{{raylib_windows}}/raylib.lib" \
/libpath:"{{xwin_sdk}}/crt/lib/x86_64" \
/libpath:"{{xwin_sdk}}/sdk/lib/um/x86_64" \
/libpath:"{{xwin_sdk}}/sdk/lib/ucrt/x86_64" \
/nodefaultlib:msvcrt /nodefaultlib:vcruntime /nodefaultlib:libucrt \
libcmt.lib libvcruntime.lib ucrt.lib \
kernel32.lib user32.lib gdi32.lib winmm.lib shell32.lib opengl32.lib \
advapi32.lib bcrypt.lib ntdll.lib synchronization.lib ole32.lib
# Windows build as build/<name>_<version>_windows_x86_64.exe
package-windows version="dev": windows
cp {{build_dir}}/windows/{{name}}.exe {{build_dir}}/{{name}}_{{version}}_windows_x86_64.exe
@echo "{{build_dir}}/{{name}}_{{version}}_windows_x86_64.exe"
# Format all Odin files with odinfmt (settings in odinfmt.json)
fmt:
odinfmt -w .
# Remove build output
clean:
if [ -d {{build_dir}} ]; then rm -r -- {{build_dir}}; fi
rm -f -- {{name}}