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

Fix build command execution on Windows using Swift 5.10 #423

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading