-
Notifications
You must be signed in to change notification settings - Fork 440
Linux: Use a DispatchSourceRead instead of a FileHandle.readabilityHandler #5
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
Conversation
…ndler - swift-corelibs-foundation does not currently support FileHandle handlers so use DispatchSource.makeReadSource instead of FileHandle.readabilityHandlerForReading if not on macOS.
@spevans, @akyrtzi, @ahoppen, @aciidb0mb3r
I have been using a SwiftSyntax on Linux for a while now (for documentation generation and proofreading), though I have been doing it with the source from the 4.1.2 release. There were only three things I needed to adjust: (I was lazy and hoisted SwiftSyntax up above several other modules to make it easier, so you won’t want to copy what I did, but the links will still help you find the issues.)
Looking at the current source, changing this... private static let _swiftcURL: URL? = SwiftcRunner.locateSwiftc() ...to... public static var swiftcURL: URL? = SwiftcRunner.locateSwiftc() ...would probably suffice. (private → public, let → var, drop underscore?)
|
For the compiler search, it looks like the full path can be passed to the |
Hmm... You’re right. But the structure itself is internal. Does it actually surface in the API somewhere?... ...never mind. I found it. It does. I guess that’s been dealt with since 4.1.2. |
stdoutPipe.fileHandleForReading.readabilityHandler = { file in | ||
stdoutData.append(file.availableData) | ||
} | ||
#else | ||
// Temporary fix until swift-corelibs-foundation supports .readabilityHandler | ||
let stdoutSource = DispatchSource.makeReadSource( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to also use DispatchSource
on macOS? That way we wouldn't need to differentiate between macOS and Linux which would feel desirable to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to keep it like this for now just incase the solution for Linux is missing something as I don't want to regress the macOS part, but I will get the fix into corelibs-foundation asap so that this temp fix can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having it consistent between the two platforms would mean that the two hit the same issues. That way we would catch any bugs earlier when developing on Mac because it also fails on that platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ahoppen I've updated it to use makeReadSource
on both platforms.
Thanks for the great work here. The ability to specify the The |
Looks good! Thanks a lot for tackling this. I would like for PR testing to be set up before merging this but that shouldn't take much longer. Also, as I understand it, SwiftSyntax will completely work on Linux with this PR, right? If so, you can also close SR-8670 once this is merged. |
@ahoppen Ive just updated the tests so the |
That's amazing! Thanks for all your work on this. |
https://ci.swift.org/view/Pull%20Request/job/swift-PR-osx/7361/ CI for linux is not activated yet, but Mac is passing so let's 🛳 it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM.
Linux: Use a DispatchSourceRead instead of a FileHandle.readabilityHandler
[4.2] Merge pull request #5 from spevans/pr_linux_fix
# This is the 1st commit message: fixed testAvailabilityQuery34 and testAvailabilityQueryUnavailability28 # This is the commit message swiftlang#2: Update Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift Co-authored-by: Kim de Vos <[email protected]> # This is the commit message swiftlang#3: added fixedSource in test case # This is the commit message swiftlang#4: minor changes # This is the commit message swiftlang#5: implemented recovery inside the parser # This is the commit message swiftlang#6: runned format.py # This is the commit message swiftlang#7: minor changes # This is the commit message swiftlang#8: minor changes
Ensure a space after `@unknown` in a default case.
so use DispatchSource.makeReadSource instead of
FileHandle.readabilityHandlerForReading if not on macOS.
This is only a temporary fix and there may be other Linux issues, but it was enough to get the example in the readme working (although I had to rebase this fix on top of tag
swift-DEVELOPMENT-SNAPSHOT-2018-08-25-a
for testing).