Files
SideStore/Plugins/IntentBuilderPlugin/IntentBuilderPlugin.swift
Joe Mattiello 8b1e87d2dd spm app builds
2023-03-10 19:30:17 -05:00

35 lines
1.1 KiB
Swift

// Copyright 2022 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
import PackagePlugin
import Foundation
@main
struct IntentBuilderPlugin: BuildToolPlugin {
func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
let outputDirectory = context.pluginWorkDirectory.appending("GeneratedSources")
guard let target = target as? SourceModuleTarget else {
Diagnostics.error("Attempted to use `IntentBuilderPlugin` on an unsupported module target")
return []
}
return target.sourceFiles(withSuffix: "intentdefinition")
.map { file in
.prebuildCommand(
displayName: "Generate intents sources",
executable: Path("/usr/bin/xcrun"),
arguments: [
"intentbuilderc", "generate",
"-input", file.path.string,
"-output", outputDirectory,
"-language", "Swift",
"-swiftVersion", "5.6",
"-classPrefix", ""
],
outputFilesDirectory: outputDirectory
)
}
}
}