Skip to content

Migrate to Zig 0.15.2#122

Open
pmarreck wants to merge 1 commit intocapy-ui:masterfrom
pmarreck:pr/zig-0.15.2-migration
Open

Migrate to Zig 0.15.2#122
pmarreck wants to merge 1 commit intocapy-ui:masterfrom
pmarreck:pr/zig-0.15.2-migration

Conversation

@pmarreck
Copy link
Copy Markdown

Summary

This migrates the entire codebase from Zig 0.14.1 to Zig 0.15.2. No new features or behavioral changes — this is purely a language/API migration.

This is the first of several focused PRs that replace the monolithic #121 (which the maintainer correctly identified as too large to review).

Key API changes

  • usingnamespace removal — replaced with explicit re-exports for every mixin declaration throughout components, backends, and examples
  • ArrayList API.init(allocator).empty + pass allocator to each method call
  • Calling conventionscallconv(.C)callconv(.c) (lowercase enum literals)
  • Win32 APIstd.os.windows.WINAPIstd.builtin.CallingConvention.winapi
  • String formattingstd.fmt.allocPrintZstd.fmt.allocPrintSentinel
  • Atomicsstd.atomic.Atomicstd.atomic.Value
  • Sortingstd.sort.sortstd.mem.sort
  • Sleepstd.time.sleepstd.Thread.sleep
  • Data structuresSinglyLinkedList became intrusive (compat wrapper added), BoundedArray removed (replacement added)
  • Asyncanyframe removed (async.zig stubbed since the async subsystem was already incomplete)
  • URIstd.Uri.path.toRaw signature changed
  • zigimgStreamSourceReadStream API
  • vendor/zigwin32 — mechanical migration of all 293 files for 0.15.2 compatibility
  • build.zig / build_capy.zig — updated for 0.15.2 build API changes
  • build.zig.zon — updated dependency hashes for zig-objc and zigimg
  • flake.nix — updated to Zig 0.15.2 toolchain

Test plan

  • All 28 examples compile on x86_64-windows-gnu (cross-compile)
  • Native macOS build compiles and runs
  • GTK/Linux build (needs Linux environment with GTK4 dev packages)
  • WASM build
  • Android build

This migrates the entire codebase from Zig 0.14.1 to Zig 0.15.2.

Key API changes:
- Remove `usingnamespace` (removed from the language) — all mixins
  now use explicit re-export of each declaration
- `ArrayList.init(allocator)` → `.empty` + pass allocator to each
  method call (deinit, append, appendSlice, etc.)
- `callconv(.C)` → `callconv(.c)` (lowercase enum literals)
- `std.os.windows.WINAPI` → `std.builtin.CallingConvention.winapi`
- `std.fmt.allocPrintZ` → `std.fmt.allocPrintSentinel`
- `std.atomic.Atomic` → `std.atomic.Value`
- `std.sort.sort` → `std.mem.sort`
- `std.time.sleep` → `std.Thread.sleep`
- `SinglyLinkedList` became intrusive (compat wrapper added in data.zig)
- `BoundedArray` removed (compat replacement in containers.zig)
- `anyframe` removed (async.zig stubbed)
- `std.Uri.path` API changes (toRaw signature)
- format function signatures changed
- zigimg StreamSource → ReadStream API

Also updates:
- vendor/zigwin32 for 0.15.2 compatibility
- build.zig / build_capy.zig for 0.15.2 build API
- build.zig.zon dependency hashes (zig-objc, zigimg)
- flake.nix / flake.lock for Zig 0.15.2 toolchain

All 28 examples compile successfully on both x86_64-windows-gnu
(cross-compile) and native macOS (aarch64-macos).
@pmarreck
Copy link
Copy Markdown
Author

I'm newish to Zig, and I'm finding that Zig upgrade PR's are beasts. (Ghostty apparently had a ton of required updates, too.)

It's possible that you might not want to go through this pain again for 0.16 and will want to wait for that (likely this year) to drop.

If you want, we can just leave this open as the "comprehensive upgrade PR" and just update it for 0.16 when that's appropriate.

Comment thread examples/demo.zig
@zenith391
Copy link
Copy Markdown
Member

A more general thing is that the vendor/zigwin32 comes from https://github.com/marlersoft/zigwin32 which has been independently updated for zig 0.15.0, so instead of letting an AI agent update those files, the best course of action would have been to just take the upstream repository.
Besides, I vendored zigwin32 back when the Zig package system wasn't ready (and the library had a few bugs I fixed manually), but now this serves a purpose that no longer exists. So something even better would be to use build.zig.zon instead.

@pmarreck
Copy link
Copy Markdown
Author

pmarreck commented Mar 2, 2026

ah, makes sense, then you get the upstream whenever you update. will rejigger it

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.

2 participants