tayloraswift / godot-swift

swift language support for the godot game engine
116 stars 5 forks source link

cannot find type 'TargetBuildContext' in scope #10

Closed nvanfleet closed 1 year ago

nvanfleet commented 1 year ago

I am trying to see if I can get this working for Mac OS these days. But somehow it just doesn't seem to find TargetBuildContext. I can't really find anything interesting about the error. My setup is slightly different than the examples

I'd be interested to help with this stuff but it's a bit new to me so any help is appreciated.

command:

error: plugin compilation failed: error: emit-module command failed with exit code 1 (use -v to see invocation)
/<path>/godot-swift/sources/godot-nativescript/main.swift:4:39: error: cannot find type 'TargetBuildContext' in scope
    func createBuildCommands(context: TargetBuildContext) throws -> [Command] {
                                      ^~~~~~~~~~~~~~~~~~

sources/godot-nativescript/main.swift

import PackagePlugin

@main struct GodotNativeScriptGeneratorPlugin: BuildToolPlugin {
    func createBuildCommands(context: TargetBuildContext) throws -> [Command] {
        let tool: TargetBuildContext.Tool = try context.tool(named: "GodotNativeScriptGenerator")
        let directory:Path = targetBuildContext.pluginWorkDirectory
        let sources:[Path] = targetBuildContext.inputFiles
            .filter { $0.type == .source }
            .map(\.path)

        let output:(staged:Path, common:Path, classes:Path) =
        (
            directory.appending("registration.swift"),
            directory.appending("common.swift"),
            directory.appending("classes.swift")
        )

        return [
            .buildCommand(
                displayName: "Generating files '\(output.common)', '\(output.classes)'",
                executable: context.tool.path,
                arguments: [
                    "generate",
                    "--output-common", "\(output.common)",
                    "--output-classes", "\(output.classes)",
                ],
                environment: [:],
                inputFiles: sources,
                outputFiles:
                [
                    output.common,
                    output.classes,
                ]
            ),
            .buildCommand(
                displayName: "Generating file '\(output.staged)'",
                executable: context.tool.path,
                arguments: [
                    "synthesize",
                    "--workspace", "\(directory)",
                    "--output", "\(output.staged)",
                    "--target", targetBuildContext.targetName,
                    "--package-path", "\(targetBuildContext.packageDirectory)",
                ],
                environment: [:],
                inputFiles: sources,
                outputFiles: [output.staged]
            ),
        ]
    }
}