SwiftFormat
SwiftFormat copied to clipboard
Windows Support
I can't build this on Windows because glibc (used by CommandLineTool) isn't available. Is it feasible to make this support Windows? Does UCRT adequately fill in the shoes of glibc in this case? It seems like all Swift auto-formatting tools are either incompatible with Windows or unmaintained :(
@MarkKoz I don't have a Windows machine to test on. I'd love to add Windows support though - if it's something you'd be interested in trying to make happen, I'd be happy to assist.
#if os(macOS)
import Darwin.POSIX
#elseif os(Windows)
import ucrt
#else
import Glibc
#endif
seems to work. I've been using the tool for a few hours without issues. All the tests pass too, though I don't think any of the tests specifically cover the TTY check. I'm not sure how I could manually test that either.
I get a bunch of LNK4217 warnings (no idea why) and a warning about isatty being deprecated:
SwiftFormat-master\CommandLineTool\main.swift:61:27: warning: 'isatty' is deprecated: The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _isatty. See online help for details.
private let stderrIsTTY = isatty(STDERR_FILENO) != 0
CI could be set up to include a Windows runner, but it seems like your CI is in the middle of a migration right now. It might be tricky to do this setup step in CI though, since the instructions state to do that through a specific shell that sets up VS-specific environment variables.
it seems like your CI is in the middle of a migration right now
I'm not sure what you mean by this? I moved from Travis to GitHub actions a few weeks ago, but AFAIK that migration is complete.
Thought the build was failing, but that's just the coverage step.
The cache is hard-coded to /var/tmp, but this isn't an appropriate directory on Windows. I think a good place would be the local AppData directory.
@MarkKoz are you still interested in pursuing this?
Yes.
Any news on Windows support?
@insinfo SwiftFormat builds for Windows, and there are Windows binaries included on the releases page. As far as I know they should work?