Skip to content

Add Zig build for WhipLib (Phase 1)#9

Draft
deevus wants to merge 1 commit into
masterfrom
feature/zig-build
Draft

Add Zig build for WhipLib (Phase 1)#9
deevus wants to merge 1 commit into
masterfrom
feature/zig-build

Conversation

@deevus
Copy link
Copy Markdown
Collaborator

@deevus deevus commented May 8, 2026

Summary

  • Brings the project under a single Zig-driven build system, mirroring the ROLLER repo's mise + build.zig pattern.
  • WhipLib compiles cleanly for macOS arm64 (native), aarch64-linux-gnu (cross), and x86_64-windows-gnu (cross) from one zig build invocation on a Mac, replacing the per-platform Makefile / vcxproj split for this library.
  • Lays the foundation for getting the editor working on macOS, where the existing build is currently unbuildable.

What's in this PR

  • mise.toml pins Zig 0.15.2 (matches ROLLER) with build / clean / test tasks.
  • build.zig + build.zig.zon produce zig-out/lib/libWhipLib.a for any supported target.
  • Reuses bundled external/glew / external/glm / external/stb headers — no Homebrew dependency required for Phase 1.
  • .gitignore updated for zig-out/ and .zig-cache/.

Build configuration choices worth flagging for review

  • GLEW_NO_GLU=1 defined globally. GLEW's header includes <GL/glu.h> by default; codebase has zero GLU calls (verified by grep), so this avoids needing libGLU on every cross target.
  • WHIPLIB_LIB=1 defined. WhipLib.h's WLFUNC macro defaults to __declspec(dllimport) on Windows when neither WHIPLIB_LIB nor WHIPLIB_DLL is set — that broke the Windows static-lib build. Defining WHIPLIB_LIB keeps the implementations linkable.
  • FBXExporter.cpp gated behind -Dfbx=true. FBX SDK 2020.3.7 headers don't compile cleanly with modern clang (typo mLefttChild in fbxredblacktree.h, deprecated vsprintf, non-trivially-copyable memcpy). Resolving that is Phase 2 along with the CLI tools that actually link FBX.

Out of scope (future phases)

  • Phase 2: ModelExporter / TrackAnalyzer / CarPlansParser CLI binaries; FBX SDK header compatibility.
  • Phase 3: TrackEditor Qt5 GUI app (needs moc / uic / rcc orchestration over Homebrew's qt@5).

Test plan

  • mise exec -- zig build on macOS arm64 produces zig-out/lib/libWhipLib.a (~11 MB)
  • mise exec -- zig build -Dtarget=aarch64-linux-gnu succeeds
  • mise exec -- zig build -Dtarget=x86_64-windows-gnu succeeds
  • mise exec -- zig build -Doptimize=ReleaseFast succeeds
  • Verify on a Linux host (cross-build only tested from Mac)
  • Verify on a Windows host

Bring the project under a single Zig-driven build system, mirroring the
ROLLER repo's mise + build.zig pattern. WhipLib compiles cleanly for
macOS arm64 (native), aarch64-linux-gnu (cross), and x86_64-windows-gnu
(cross) from a Mac, replacing the per-platform Makefile / vcxproj split
for this library.

Build configuration:
- mise.toml pins Zig 0.15.2 (matches ROLLER) with build/clean/test tasks
- GLEW_NO_GLU is defined globally (codebase has zero GLU calls; avoids
  needing libGLU on cross-compiles)
- WHIPLIB_LIB is defined so the static archive's WLFUNC declarations
  don't accidentally become __declspec(dllimport) on Windows
- FBXExporter.cpp is gated behind -Dfbx=true. FBX SDK 2020.3.7 headers
  have known clang compatibility issues (deprecated vsprintf, internal
  typo mLefttChild); resolving those is Phase 2 work along with adding
  the CLI tools that link FBX

Out of scope here: ModelExporter / TrackAnalyzer / CarPlansParser
binaries, and TrackEditor (Qt5 GUI, needs moc/uic/rcc orchestration).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant