Skip to content

Commit

Permalink
Fix build command execution on Windows using Swift 5.10 (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
tishin authored Mar 12, 2024
1 parent 8a9d065 commit 5eab7ad
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Plugins/CodeGeneratorPlugin/plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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
}
}

Expand Down

0 comments on commit 5eab7ad

Please sign in to comment.