Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Port #5030

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Windows Port #5030

wants to merge 7 commits into from

Conversation

compnerd
Copy link

@compnerd compnerd commented May 22, 2023

This is currently not possible to build on Windows. It requires that SourceKitten changes are merged (jpsim/SourceKitten#769) and some changes to the toolchain that are still in the process of getting merged upstream (swiftlang/swift-package-manager#6573) which depends on a toolchain that is not yet tagged.

It is not possible to build the tests on Windows due to the use of the executable target as a dependency for the tests which results in multiple definitions of main.

This will require a fix for libdispatch (swiftlang/swift-corelibs-libdispatch#791) as well. With that, it seems that I can now swiftlint on Windows as well!

@SwiftLintBot
Copy link

2 Warnings
⚠️ If this is a user-facing change, please include a CHANGELOG entry to credit yourself!
You can find it at CHANGELOG.md.
⚠️ This PR may need tests.
1 Message
📖 Skipping OSSCheck because SwiftLint hasn't changed compared to 'main'

Here's an example of your CHANGELOG entry:

* Windows Port.  
  [compnerd](https://github.com/compnerd)
  [#issue_number](https://github.com/realm/SwiftLint/issues/issue_number)

note: There are two invisible spaces after the entry's text.

Generated by 🚫 Danger

Add some Windows specific handling for the paths in SwiftLintCore.  The
one piece that this change does not cover is the handling of `glob` as
that is not an ISO C standard function and as such there is no `glob` on
Windows.  This will be worked through separately.
This enables building the swiftlint command on Windows.  There is no
system ioctl for terminal access, instead, we can use the Win32 Console
API surface to query the console size.  In the case of a failure, assume
the width to be 80-columns (as the standard VGA console is 80x25).
Windows does not support `glob` as a standard C library function as that
is not part of the C standard.  Attempt to emulate that through the use
of `FindFirstFileW` and `FindNextFile` to iterate the matching files
given a pattern.  This should allow us to start enumerating the files as
if we had `glob` available.
Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

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

This basically looks fine to me. What about the open issues/PRs from other repositories you mentioned in the PR description? Is there anything more required to make SwiftLint work on Windows?

Source/SwiftLintCore/Helpers/Reachability.swift Outdated Show resolved Hide resolved
Source/swiftlint/Commands/Rules.swift Outdated Show resolved Hide resolved
@compnerd
Copy link
Author

compnerd commented Jan 8, 2024

The only thing needed is to get the SourceKitten changes in (but haven't been able to get response from @jpsim to get those resolved and merged).

@compnerd compnerd marked this pull request as ready for review January 8, 2024 18:50
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
@jpsim
Copy link
Collaborator

jpsim commented Jan 8, 2024

The only thing needed is to get the SourceKitten changes in (but haven't been able to get response from @jpsim to get those resolved and merged).

Last I checked the windows PRs for some SwiftLint dependencies failed to build or failed tests for macOS or Linux. I’m happy to review again when those failures are addressed.

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.

4 participants