Skip to content

refactor(ipc-codegen/zig): collapse codegen onto ipc-runtime/zig#23499

Open
charlielye wants to merge 1 commit into
cl/ipc-runtime-tsfrom
cl/ipc-runtime-zig
Open

refactor(ipc-codegen/zig): collapse codegen onto ipc-runtime/zig#23499
charlielye wants to merge 1 commit into
cl/ipc-runtime-tsfrom
cl/ipc-runtime-zig

Conversation

@charlielye
Copy link
Copy Markdown
Contributor

Summary

Stacked on #23498 (cl/ipc-runtime-ts → cl/ipc-bbapi-server-signals → cl/ipc-codegen-migrate-bb-wsdb).

Final language in the cross-language collapse — Zig codegen now uses the shared `ipc-runtime/zig` transport instead of per-service UDS templates.

Changes

Templates deleted (all reimplemented length-prefix UDS framing that ipc-runtime/zig already exposes):

  • `ipc-codegen/templates/zig/uds_backend.zig`
  • `ipc-codegen/templates/zig/ipc_server.zig`
  • `ipc-codegen/templates/zig/ipc_client.zig` (was already unreferenced)
  • `ipc-codegen/templates/zig/ffi_client.zig` (was already unreferenced)
  • `backend.zig` stays for FFI consumers.

Codegen (`zig_codegen.ts`):

  • `generateServer` no longer emits a `serve(path)` wrapper that pulled in the deleted template. Now emits `dispatch` + `DispatchResult` + handler stubs only; the consumer wires the transport (recommended: `ipc_runtime.Server.fromPath/listen/run`).

Runtime (`ipc-runtime/zig/src/main.zig`):

  • Added `Client.destroy()` as an alias for `deinit()` so the runtime's `Client` satisfies the codegen's `Backend` contract (expects `destroy(self: *T) void`) and slots directly into the generated `Client(BackendType)`.

Echo example:

  • `echo_client.zig` imports `ipc_runtime` and uses `ipc_runtime.Client` as the Backend.
  • `echo_server.zig` uses `ipc_runtime.Server.fromPath/listen/run` with manual msgpack decode/encode (the codegen's `dispatch()` is invoked from the byte handler).
  • `build.zig` + `build.zig.zon` add the ipc_runtime path dep.

Test plan

  • All zig templates referenced for UDS are gone: `ls ipc-codegen/templates/zig/` → `backend.zig ffi_backend.zig`
  • `ipc-codegen ./bootstrap.sh test` → 18/18 cross-language tests green
  • `zig build` clean in the echo example

…nsport

Drops the per-service UDS/server template duplication on the Zig side,
mirroring the C++ and Rust codegens:

ipc-codegen/templates/zig/
- Delete uds_backend.zig and ipc_server.zig — both reimplemented the
  4-byte-LE length-prefix UDS framing that ipc-runtime/zig already
  exposes via Client/Server.
- Delete ipc_client.zig and ffi_client.zig — already unreferenced.
- backend.zig stays for FFI consumers.

ipc-codegen/src/zig_codegen.ts
- generateServer no longer emits a `serve(socket_path)` wrapper that
  pulled in the ipc_server.zig template. It now emits `dispatch` +
  `DispatchResult` + handler stubs only; consumers wire the transport
  (typically `ipc_runtime.Server.fromPath` + `listen` + `run`).

ipc-runtime/zig/src/main.zig
- Added `Client.destroy()` as an alias for `deinit()` so the runtime's
  Client satisfies the codegen Backend contract (which expects
  `destroy(self: *T) void`) and slots directly into the generated
  `<Service>Client(BackendType)`.

ipc-codegen/examples/zig/echo
- echo_client.zig now imports `ipc_runtime` and constructs
  `ipc_runtime.Client` as the Backend. No more template-copied
  uds_backend.zig in generated/.
- echo_server.zig now uses `ipc_runtime.Server.fromPath/listen/run`
  with manual msgpack decode/encode (the codegen's `dispatch()` is
  invoked from inside the byte handler).
- build.zig + build.zig.zon depend on ipc_runtime via path:
  `../../../../ipc-runtime/zig`.

Verified: full 18-test cross-language matrix (4×4 + 2 golden) passes
end-to-end with the new wiring.
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