-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
SwiftSDKTool: convert previously blocking code to async
#6623
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift open source project | ||
// | ||
// Copyright (c) 2023 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See http://swift.org/LICENSE.txt for license information | ||
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import SwiftSDKTool | ||
|
||
// This is quite ugly, but it works in terms of unambiguously specifying the async overload of `main()`. | ||
_ = await { () async -> () in | ||
await SwiftSDKTool.main() | ||
}() | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,14 +22,14 @@ let execName = (try? AbsolutePath(validating: firstArg).basenameWithoutExt) ?? | |
|
||
@main | ||
struct SwiftPM { | ||
static func main() { | ||
static func main() async { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we had trouble with this change in the past, are we out of the wood on that now? cc @neonichu There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIR those were CI issues, but I don't see them reproduced now and this passes tests and runs well locally. I don't plan to cherry-pick this to 5.9, so we'll have enough time to investigate anything that could potentially go wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Windows is another question, I think? Supposedly async doesn't really work well there IIRC. cc @compnerd There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe also check the toolchain CI, ie try to create a toolchain with this PR, I remember we had SwiftPM green but it caused downstream issues. in any case, I think we should not merge this in the immediate timeframe to avoid 🔥 in a sensitive time There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be ok to merge now? I only need a review approval for that. |
||
switch execName { | ||
case "swift-package": | ||
SwiftPackageTool.main() | ||
case "swift-build": | ||
SwiftBuildTool.main() | ||
case "swift-experimental-sdk": | ||
SwiftSDKTool.main() | ||
await SwiftSDKTool.main() | ||
case "swift-test": | ||
SwiftTestTool.main() | ||
case "swift-run": | ||
|
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.
cant we make this into a struct with a @main instead?
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.
We had it previously in Sources/swift-experimental-sdk/SwiftSDKTool.swift, which you can see removed in the diff right above this file, but that required duplicating
SwiftSDKTool
fromSwiftSDKTool
module verbatim, which I think is much worse than this. Unfortunately,@main
can't be added to a type declared in a different module.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.
Why not define a private "Runner" struct with @main that calls the underlying static main as the closure does?
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.
That's a great point, addressed now.