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: Unable to build SwiftGodot using Swift 5.10 toolchain #418

Closed
tishin opened this issue Mar 9, 2024 · 3 comments · Fixed by #423
Closed

Windows: Unable to build SwiftGodot using Swift 5.10 toolchain #418

tishin opened this issue Mar 9, 2024 · 3 comments · Fixed by #423

Comments

@tishin
Copy link
Contributor

tishin commented Mar 9, 2024

Building SwiftGodot on Windows using Swift 5.10 fails during generator plugin execution:

error: failed: PrebuildCommand(configuration: SPMBuildCore.BuildToolPluginInvocationResult.CommandConfiguration(displayName: Optional("Generating Swift API from /Projects/SwiftGodot/Sources/ExtensionApi/extension_api.json to /Projects/SwiftGodot/.build/plugins/outputs/swiftgodot/SwiftGodot/CodeGeneratorPlugin/GeneratedSources"), executable: <AbsolutePath:"\Projects\SwiftGodot\.build\plugins\tools\debug\Generator.exe">, arguments: ["/Projects/SwiftGodot/Sources/ExtensionApi/extension_api.json", "/Projects/SwiftGodot/.build/plugins/outputs/swiftgodot/SwiftGodot/CodeGeneratorPlugin/GeneratedSources", "/Projects/SwiftGodot/doc", "--singlefile"], environment: [:], workingDirectory: nil), outputFilesDirectory: <AbsolutePath:"\Projects\SwiftGodot\.build\plugins\outputs\swiftgodot\SwiftGodot\CodeGeneratorPlugin\GeneratedSources">)

Generator/main.swift:30: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"
Current stack trace:
0    (null)                             0x00007ffac5964ae0 swift_stdlib_reportFatalErrorInFile + 132
@tishin
Copy link
Contributor Author

tishin commented Mar 9, 2024

Looks like Foundation file management is broken in Swift 5.10 on Windows. I made a trivial Swift script replicating extension api opening by Generator:

import Foundation

let url = URL(fileURLWithPath: "/Projects/SwiftGodot/Sources/ExtensionApi/extension_api.json")
print(try! Data(contentsOf: url))

It works fine on 5.9.2 release:

PS C:\Projects\UrlIssue> swift --version
Swift version 5.9.2 (swift-5.9.2-RELEASE)
Target: x86_64-unknown-windows-msvc
PS C:\Projects\UrlIssue> swift run      
Building for debugging...
Build complete! (0.07s)
9467198 bytes

But fails on 5.10 release:

PS C:\Projects\UrlIssue> swift --version
Swift version 5.10 (swift-5.10-RELEASE)
Target: x86_64-unknown-windows-msvc
PS C:\Projects\UrlIssue> swift run      
Building for debugging...
Build complete! (0.13s)
Generator/main.swift:4: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"
Current stack trace:
0    (null)                             0x00007fffe8764ae0 swift_stdlib_reportFatalErrorInFile + 132

@tishin
Copy link
Contributor Author

tishin commented Mar 10, 2024

Reported the issue at swiftlang/swift-corelibs-foundation#4921

@tishin
Copy link
Contributor Author

tishin commented Mar 10, 2024

After fixing extension api reading Windows build still fails throwing a whole bunch of errors like

C:\Projects\SwiftGodot\Sources\SwiftGodot\Core\VariantCollection.swift:50:24: error: cannot find 'GArray' in scope
        if let array = GArray (variant) {
                       ^~~~~~
C:\Projects\SwiftGodot\Sources\SwiftGodot\Core\VariantRepresentable.swift:91:11: error: cannot find type 'Vector2' in scope
extension Vector2: SelfVariantRepresentable {
          ^~~~~~~
C:\Projects\SwiftGodot\Sources\SwiftGodot\Core\VariantRepresentable.swift:95:11: error: cannot find type 'Vector2i' in scope
extension Vector2i: SelfVariantRepresentable {
          ^~~~~~~~
C:\Projects\SwiftGodot\Sources\SwiftGodot\Core\VariantRepresentable.swift:99:11: error: cannot find type 'Rect2' in scope
extension Rect2: SelfVariantRepresentable {
          ^~~~~

and so on, basically it does not include generated sources into the build for some reason.
I'd guess that prebuildCommand workaround does not work anymore. Need to test it on a simpler package.

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 a pull request may close this issue.

1 participant