Skip to content

Commit 13fafaa

Browse files
committed
add directory hint
1 parent 17a1b5c commit 13fafaa

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ let package = Package(
2828
.executableTarget(name: "CodeGeneratorExecutable"),
2929
.plugin(
3030
name: "CodeGeneratorPlugin",
31-
capability: .buildTool(),
31+
capability: .buildTool,
3232
dependencies: ["CodeGeneratorExecutable"]
3333
),
3434
.target(

Plugins/CodeGeneratorPlugin.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import PackagePlugin
44
@main
55
struct CodeGeneratorPlugin: BuildToolPlugin {
66
func createBuildCommands(context: PackagePlugin.PluginContext, target: PackagePlugin.Target) async throws -> [PackagePlugin.Command] {
7-
87
let output = context.pluginWorkDirectoryURL.appending(component: "GeneratedCode")
8+
99
let floatingPointTypes: [String] = ["Float", "Double"]
1010
let simdSizes = [2, 4, 8, 16, 32, 64]
1111

Sources/CodeGeneratorExecutable/CodeGenerator.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22

33
@main
44
struct CodeGenerator {
5-
static func main() async throws {
5+
static func main() throws {
66
// Use swift-argument-parser or just CommandLine, here we just imply that 2 paths are passed in: input and output
77
guard CommandLine.arguments.count == 2 else {
88
throw CodeGeneratorError.invalidArguments
@@ -20,13 +20,19 @@ struct CodeGenerator {
2020

2121
for floatingPointType in floatingPointTypes {
2222
// Generator Derivatives for RealFunctions for floating point types
23-
let realFunctionDerivativesFileURL = output.appending(component: "\(floatingPointType)+RealFunctions+Derivatives.swift")
23+
let realFunctionDerivativesFileURL = output.appending(
24+
component: "\(floatingPointType)+RealFunctions+Derivatives.swift",
25+
directoryHint: .notDirectory
26+
)
2427
let type = floatingPointType
2528
let realFunctionsDerivativesExtensionCode = RealFunctionsDerivativesGenerator.realFunctionsDerivativesExtension(type: type, floatingPointType: floatingPointType)
2629
try realFunctionsDerivativesExtensionCode.write(to: realFunctionDerivativesFileURL, atomically: true, encoding: .utf8)
2730

2831
for simdSize in simdSizes {
29-
let realFunctionFileURL = output.appending(component: "SIMD\(simdSize)+\(floatingPointType)+RealFunctions.swift")
32+
let realFunctionFileURL = output.appending(
33+
component: "SIMD\(simdSize)+\(floatingPointType)+RealFunctions.swift",
34+
directoryHint: .notDirectory
35+
)
3036
let simdType = "SIMD\(simdSize)<\(floatingPointType)>"
3137

3238
// no simd methods exist for simd size >= 16 and scalar > Float so we don't add acceleration to those.

0 commit comments

Comments
 (0)