diff --git a/Plugins/CodeGeneratorPlugin/plugin.swift b/Plugins/CodeGeneratorPlugin/plugin.swift index b3b599a59..7a8037f64 100644 --- a/Plugins/CodeGeneratorPlugin/plugin.swift +++ b/Plugins/CodeGeneratorPlugin/plugin.swift @@ -11,6 +11,7 @@ import PackagePlugin /// Generates the API for the SwiftGodot from the Godot exported Json API @main struct SwiftCodeGeneratorPlugin: BuildToolPlugin { func createBuildCommands(context: PluginContext, target: Target) throws -> [Command] { + var commands: [Command] = [] // Configure the commands to write to a "GeneratedSources" directory. let genSourcesDir = context.pluginWorkDirectory.appending("GeneratedSources") @@ -26,23 +27,27 @@ import PackagePlugin outputFiles.append(genSourcesDir.appending(subpath: "Generated.swift")) arguments.append(context.package.directory.appending(subpath: "doc")) arguments.append("--singlefile") - let cmd: Command = Command.prebuildCommand( + commands.append(Command.prebuildCommand( displayName: "Generating Swift API from \(api) to \(genSourcesDir)", executable: generator, arguments: arguments, - outputFilesDirectory: genSourcesDir) + outputFilesDirectory: genSourcesDir)) #else outputFiles.append (contentsOf: knownBuiltin.map { genSourcesDir.appending(["generated-builtin", $0])}) outputFiles.append (contentsOf: known.map { genSourcesDir.appending(["generated", $0])}) - let cmd: Command = Command.buildCommand( + #endif + + // For Windows with Swift 5.10 both prebuildCommand and buildCommand are needed + #if !os(Windows) || swift(>=5.10) + commands.append(Command.buildCommand( displayName: "Generating Swift API from \(api) to \(genSourcesDir)", executable: generator, arguments: arguments, inputFiles: [api], - outputFiles: outputFiles) + outputFiles: outputFiles)) #endif - return [cmd] + return commands } }