Skip to content

feat: Windows FFI build tooling + livekit_ffi.dll/pdb with symbols - #70

Merged
alejandro-jimenez-dcl merged 1 commit into
mainfrom
feat/windows-ffi-build-tooling
Jun 29, 2026
Merged

feat: Windows FFI build tooling + livekit_ffi.dll/pdb with symbols#70
alejandro-jimenez-dcl merged 1 commit into
mainfrom
feat/windows-ffi-build-tooling

Conversation

@alejandro-jimenez-dcl

@alejandro-jimenez-dcl alejandro-jimenez-dcl commented Jun 24, 2026

Copy link
Copy Markdown

Add BuildScripts~/windows, a config-driven tool to build livekit_ffi.dll plus matching livekit_ffi.pdb on Windows (x86_64-pc-windows-msvc):

  • build.config.psd1: Tag, SourceDir, InstallToPlugins, CleanSourceAfterBuild
  • env-setup.ps1: one-time toolchain install (VS2022 + Win11 SDK, Git, Rust, libclang, protoc); checks Python is present
  • build-win.ps1: downloads the rust-sdks source for the tag into a gitignored clone dir, patches [profile.release] for PDB output, builds livekit-ffi, and places the DLL + PDB per config
  • BUILD-WINDOWS.md: usage, config reference, troubleshooting

The folder lives under BuildScripts~ so Unity ignores it; the downloaded source and any staged binaries are gitignored. Also updates the shipped Windows DLL and adds its PDB for symbolication, tracked via Git LFS (adds *.pdb to .gitattributes).

Configuring build.config.psd1

This is the settings file for the Windows FFI build (build-win.ps1). It's a PowerShell data file: keep the @{ ... } wrapper, don't rename keys, use single-quoted strings and $true/$false for booleans.

Steps:

  1. Set the values you want (see below).
  2. From BuildScripts~/windows, run .\build-win.ps1.
    (First time only: run .\env-setup.ps1 once to install the toolchain.)

Settings:

  • Tag — the livekit-ffi release to build, e.g. 'livekit-ffi/v0.12.48'. Pick one from the rust-sdks releases (the livekit-ffi/vX.Y.Z tags). Must match the FFI version the C# bindings expect.
  • SourceDir — where the Rust source gets cloned. Relative paths resolve against the tool folder; absolute ('C:\src') works too. Default '.src' is gitignored; if you point it at another in-repo folder, add it to .gitignore yourself.
  • InstallToPlugins — $true drops the built livekit_ffi.dll + .pdb straight into Runtime/Plugins/ffi-windows-x86_64 (ready to ship). $false leaves them in the tool folder for inspection (you copy them manually).
  • CleanSourceAfterBuild — $false keeps the cloned source so re-runs skip the clone (faster, more disk). $true deletes it after a successful build.

Typical flow: bump Tag to the version you need, leave InstallToPlugins = $true, run .\build-win.ps1, commit the updated DLL/PDB.

@github-actions

Copy link
Copy Markdown

🔗 Merge Alignment Reminder

If this PR targets main, please make sure the corresponding changes in unity-explorer are also ready to merge.

Both repos should be merged in coordination to avoid breaking changes. Do not merge one without the other being ready.

Comment thread BuildScripts~/windows/BUILD-WINDOWS.md Outdated
Comment thread BuildScripts~/windows/BUILD-WINDOWS.md Outdated
Comment thread BuildScripts~/windows/build-win.ps1 Outdated
Comment thread BuildScripts~/windows/build-win.ps1 Outdated
Comment thread BuildScripts~/windows/env-setup.ps1 Outdated
@alejandro-jimenez-dcl
alejandro-jimenez-dcl force-pushed the feat/windows-ffi-build-tooling branch 2 times, most recently from 80de493 to 2056452 Compare June 25, 2026 17:35

@NickKhalow NickKhalow left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with minor comments

Comment thread BuildScripts~/windows/build-win.ps1 Outdated
Comment thread BuildScripts~/windows/build-win.ps1 Outdated
docs: drop regex comparison and script-side Patch.toml flag explanations

Address PR review:
- remove the redundant 'unlike a regex' / 'rather than a fragile regex' note
- stop explaining Patch.toml's flags in build-win.py; point to Patch.toml,
  which is the single source for them (also fix its stale build-win.ps1 ref)

refactor: port Windows FFI build script to Python

The reviewer pushed back on shelling out to cmd for the dasel patch step.
Root cause was Windows PowerShell 5.1 stdin handling: dasel v3 reads its
input only from a real file handle, which PS 5.1 cannot provide without cmd
(no `<` operator, and pipes / RedirectStandardInput deliver nothing to it).

Porting the build to Python sidesteps this: subprocess hands dasel the open
Cargo.toml as stdin (a real fd), so no shell redirect is needed.

- build-win.py replaces build-win.ps1; reads build.config.toml via stdlib
  tomllib instead of build.config.psd1.
- env-setup.ps1 stays in PowerShell (bootstrap for a bare machine) and now
  installs Python 3 too, since build-win.py runs on it.
- The one remaining cmd call sources vcvarsall.bat (a batch file) - no native
  alternative, and unrelated to the dasel stdin issue.
- Docs: BUILD-WINDOWS.md updated for the Python flow, with a clearer MAX_PATH
  (260) long-path note + troubleshooting row (webrtc headers nest to ~390
  chars; use a short SourceDir like C:/src, or enable LongPathsEnabled).

Verified end-to-end: built livekit_ffi.dll + .pdb from C:/src (exit 0,
valid x64 PE with paired PDB).

fix: address PR review - pin toolchain versions, fix dasel stdin

Review feedback on the Windows FFI build tooling:

- env-setup.ps1: pin protoc (35.1) and dasel (v3.11.1) instead of pulling
  "latest". "latest" had silently moved dasel v2 -> v3, whose selector
  syntax differs and broke build-win.ps1; pinning makes the build
  reproducible and removes the supply-chain risk.
- build-win.ps1: feed dasel via `cmd /c "... < file"` input redirection
  instead of a `type ... |` pipe. dasel v3 on Windows only reads stdin
  from an OS file-handle redirect; pipes (pwsh, cmd, .NET stdin) deliver
  nothing, so the old pipe path never actually patched the profile.
- build-win.ps1: rename cargoToml/patchToml vars to *Path to disambiguate
  path from content.
- Patch.toml: make it the single source for the profile flags; annotate
  each flag with its purpose.
- BUILD-WINDOWS.md: drop the redundant "(via dasel)" note and the
  duplicated flag list, point at Patch.toml instead.

fix: add livekit_ffi.pdb.meta so Unity imports the debug symbols

refactor: patch [profile.release] via dasel + Patch.toml

Replace the regex rewrite of the downloaded Cargo.toml's [profile.release]
with a dasel overlay (proper TOML parsing instead of fragile pattern matching),
per code review.

- Patch.toml: the [profile.release] to overlay (mirrors upstream rust-sdks'
  own release profile); edit here to change build flags
- build-win.ps1: apply Patch.toml with dasel, routed through cmd so the stdin
  pipe works across PowerShell versions; resolve dasel from PATH or env-setup's
  copy and fail loudly if a tag defines no [profile.release]
- env-setup.ps1: download dasel to %LOCALAPPDATA%\dasel
- build.config.psd1: add a header explaining how to use the config
- BUILD-WINDOWS.md: document Patch.toml, dasel, and related troubleshooting

Verified end to end: dasel patches Cargo.toml to the exact profile and the
livekit-ffi release build (DLL + PDB) completes.

feat: Windows FFI build tooling + livekit_ffi.dll/pdb with symbols

Add BuildScripts~/windows, a config-driven tool to build livekit_ffi.dll
plus matching livekit_ffi.pdb on Windows (x86_64-pc-windows-msvc):

- build.config.psd1: Tag, SourceDir, InstallToPlugins, CleanSourceAfterBuild
- env-setup.ps1: one-time toolchain install (VS2022 + Win11 SDK, Git, Rust,
  libclang, protoc); checks Python is present
- build-win.ps1: downloads the rust-sdks source for the tag into a gitignored
  clone dir, patches [profile.release] for PDB output, builds livekit-ffi, and
  places the DLL + PDB per config
- BUILD-WINDOWS.md: usage, config reference, troubleshooting

The folder lives under BuildScripts~ so Unity ignores it; the downloaded
source and any staged binaries are gitignored. Also updates the shipped
Windows DLL and adds its PDB for symbolication, tracked via Git LFS
(adds *.pdb to .gitattributes).
@alejandro-jimenez-dcl
alejandro-jimenez-dcl force-pushed the feat/windows-ffi-build-tooling branch from 55d3333 to 8cec6a5 Compare June 29, 2026 10:33
@alejandro-jimenez-dcl
alejandro-jimenez-dcl merged commit 222d67c into main Jun 29, 2026
@alejandro-jimenez-dcl
alejandro-jimenez-dcl deleted the feat/windows-ffi-build-tooling branch June 29, 2026 10:34
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