wip
This commit is contained in:
@@ -9,6 +9,7 @@ let package = Package(
|
|||||||
],
|
],
|
||||||
products: [
|
products: [
|
||||||
.library(name: "GitVersion", targets: ["GitVersion"]),
|
.library(name: "GitVersion", targets: ["GitVersion"]),
|
||||||
|
.plugin(name: "GenerateVersionBuildPlugin", targets: ["GenerateVersionBuildPlugin"]),
|
||||||
.plugin(name: "GenerateVersionPlugin", targets: ["GenerateVersionPlugin"]),
|
.plugin(name: "GenerateVersionPlugin", targets: ["GenerateVersionPlugin"]),
|
||||||
.plugin(name: "UpdateVersionPlugin", targets: ["UpdateVersionPlugin"])
|
.plugin(name: "UpdateVersionPlugin", targets: ["UpdateVersionPlugin"])
|
||||||
],
|
],
|
||||||
@@ -35,6 +36,13 @@ let package = Package(
|
|||||||
name: "GitVersionTests",
|
name: "GitVersionTests",
|
||||||
dependencies: ["GitVersion"]
|
dependencies: ["GitVersion"]
|
||||||
),
|
),
|
||||||
|
.plugin(
|
||||||
|
name: "GenerateVersionBuildPlugin",
|
||||||
|
capability: .buildTool(),
|
||||||
|
dependencies: [
|
||||||
|
"git-version"
|
||||||
|
]
|
||||||
|
),
|
||||||
.plugin(
|
.plugin(
|
||||||
name: "GenerateVersionPlugin",
|
name: "GenerateVersionPlugin",
|
||||||
capability: .command(
|
capability: .command(
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import Foundation
|
||||||
|
import PackagePlugin
|
||||||
|
|
||||||
|
@main
|
||||||
|
struct GenerateVersionBuildPlugin: BuildToolPlugin {
|
||||||
|
func createBuildCommands(
|
||||||
|
context: PackagePlugin.PluginContext,
|
||||||
|
target: PackagePlugin.Target
|
||||||
|
) async throws -> [PackagePlugin.Command] {
|
||||||
|
guard let target = target as? SourceModuleTarget else { return [] }
|
||||||
|
let outputPath = context.pluginWorkDirectory
|
||||||
|
let tool = try context.tool(named: "git-version")
|
||||||
|
let outputFile = outputPath.appending(subpath: "Version.swift")
|
||||||
|
return [
|
||||||
|
.buildCommand(
|
||||||
|
displayName: "Build With Version",
|
||||||
|
executable: tool.path,
|
||||||
|
arguments: ["generate", "\(target.name)"],
|
||||||
|
environment: [:],
|
||||||
|
inputFiles: target.sourceFiles.map(\.path),
|
||||||
|
outputFiles: [outputFile]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,7 +33,7 @@ public struct SwiftBuild {
|
|||||||
/// The configuration for the build command.
|
/// The configuration for the build command.
|
||||||
public let configuration: Configuration
|
public let configuration: Configuration
|
||||||
|
|
||||||
/// Create a ``SwiftBuild`` instance for the ``Configuration/debug`` configuration.
|
/// Create a ``SwiftBuild`` instance for the ``SwiftBuild/Configuration/debug`` configuration.
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - arguments: The arguments for the `swift build` command.
|
/// - arguments: The arguments for the `swift build` command.
|
||||||
@@ -41,7 +41,7 @@ public struct SwiftBuild {
|
|||||||
.init(configuration: .debug, arguments: arguments)
|
.init(configuration: .debug, arguments: arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a ``SwiftBuild`` instance for the ``Configuration/release`` configuration.
|
/// Create a ``SwiftBuild`` instance for the ``SwiftBuild/Configuration/release`` configuration.
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - arguments: The arguments for the `swift build` command.
|
/// - arguments: The arguments for the `swift build` command.
|
||||||
|
|||||||
Reference in New Issue
Block a user