Skip to content

fix: enable Windows compilation with platform-specific build tags - #2108

Merged
Seanstoppable merged 4 commits into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-windows-compatibility
Jul 23, 2026
Merged

Seanstoppable merged 4 commits into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-windows-compatibility

Conversation

@Seanstoppable

Copy link
Copy Markdown
Collaborator

Summary

Makes wtfutil compile and run on Windows by splitting platform-specific code into build-tagged files.

Fixes #1574

Changes

modules/cmdrunner/ — PTY support split

  • Extracted PTY/SIGWINCH code into pty_unix.go (!windows build tag)
  • Created pty_windows.go that returns a clear error when PTY mode is requested (since creack/pty and syscall.SIGWINCH are Unix-only)

modules/security/ — Firewall build fix

  • Moved firewallStateLinux() and checkFirewalld() (which use syscall.WaitStatus) into firewall_unix.go (!windows build tag)
  • Added firewall_windows.go stub (the Windows firewall implementation in the main file already works)

modules/power/ — Windows battery support

  • Added battery_windows.go using WMI (Win32_Battery) via PowerShell
  • Added source_windows.go for power source detection
  • Narrowed existing macOS-specific files (battery.go, source.go) to exclude Windows with !linux && !freebsd && !windows

modules/mercurial/ — Cross-platform path handling

  • Replaced path with path/filepath in hg_repo.go for correct Windows path separators

Testing

  • ✅ GOOS=windows go build ./... — compiles cleanly
  • ✅ GOOS=linux go build ./... — compiles cleanly
  • ✅ GOOS=darwin go build ./... — compiles cleanly
  • ✅ Tested running on Windows — TUI launches and modules render correctly

- Split cmdrunner PTY/SIGWINCH code into pty_unix.go (build tag !windows)
  and pty_windows.go stub that returns an error (fixes wtfutil#1574)
- Extract firewall Linux-specific syscall.WaitStatus usage into
  firewall_unix.go (!windows) with a Windows stub
- Add battery_windows.go and source_windows.go for the power module
  using WMI via PowerShell (instead of macOS-only pmset)
- Fix mercurial hg_repo.go: use path/filepath instead of path for
  cross-platform path handling
Replace runtime.GOOS dispatch with build-tagged files so each platform
has a proper FirewallState()/FirewallStealthState() implementation.
Eliminates stub functions for cross-platform compilation.
…ows)

Each platform now has its own dedicated file with a direct
FirewallState()/FirewallStealthState() implementation.
Added firewall_other.go as a no-op fallback for unsupported platforms.
The statusLabel helper is only used by the darwin firewall implementation.
Moving it there eliminates the shared firewall.go file entirely.
@Seanstoppable
Seanstoppable merged commit 515d61d into wtfutil:trunk Jul 23, 2026
4 checks passed
@Seanstoppable
Seanstoppable deleted the seanstoppable-windows-compatibility branch July 23, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Build failed in Windows

1 participant

⌂ 换网址