Skip to content

Commit 1f78f51

Browse files
committed
adjust for Swift 6
1 parent 62e1025 commit 1f78f51

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

Plugins/AWSLambdaDeployer/Plugin.swift

+12-25
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct AWSLambdaDeployer: CommandPlugin {
2828

2929
// gather file paths
3030
#if swift(>=6.0)
31-
let samDeploymentDescriptorFilePath = "\(context.package.directoryURL)/template.yaml"
31+
let samDeploymentDescriptorFilePath = "\(context.package.directoryURL.path())template.yaml"
3232
#else
3333
let samDeploymentDescriptorFilePath = "\(context.package.directory)/template.yaml"
3434
#endif
@@ -136,7 +136,7 @@ struct AWSLambdaDeployer: CommandPlugin {
136136

137137
let _ = try packageManager.build(
138138
.product("AWSLambdaDeploymentDescriptor"),
139-
parameters: .init(configuration: .release, echoLogs: true)
139+
parameters: .init(configuration: .inherit, echoLogs: true)
140140
)
141141
}
142142

@@ -169,10 +169,10 @@ struct AWSLambdaDeployer: CommandPlugin {
169169
let sharedLibraryName = "AWSLambdaDeploymentDescriptor" // provided by the swift lambda runtime
170170
var cmd = [
171171
"\"\(swiftExecutable.path())\"",
172-
"-L \(projectDirectory.path())/.build/\(buildConfiguration)/",
173-
"-I \(projectDirectory.path())/.build/\(buildConfiguration)/",
172+
"-L\(projectDirectory.path()).build/\(buildConfiguration)/",
173+
"-I\(projectDirectory.path()).build/\(buildConfiguration)/Modules",
174174
"-l\(sharedLibraryName)",
175-
"\"\(deploymentDescriptorFilePath)\""
175+
"\(deploymentDescriptorFilePath)"
176176
]
177177
if let archive = archivePath {
178178
cmd = cmd + ["--archive-path", archive]
@@ -186,25 +186,12 @@ struct AWSLambdaDeployer: CommandPlugin {
186186
print("Swift command:\n\n\(helperCmd)\n")
187187
}
188188

189-
// create and execute a plugin helper to run the "swift" command
190-
let helperFilePath = "\(FileManager.default.temporaryDirectory.path)/compile.sh"
191-
FileManager.default.createFile(atPath: helperFilePath,
192-
contents: helperCmd.data(using: .utf8),
193-
attributes: [.posixPermissions: 0o755])
194-
defer { try? FileManager.default.removeItem(atPath: helperFilePath) }
195-
196-
// running the swift command directly from the plugin does not work 🤷‍♂️
197-
// the below launches a bash shell script that will launch the `swift` command
198-
let samDeploymentDescriptor = try Utils.execute(
199-
executable: shellExecutable,
200-
arguments: ["-c", helperFilePath],
201-
customWorkingDirectory: projectDirectory,
202-
logLevel: verboseLogging ? .debug : .silent)
203-
// let samDeploymentDescriptor = try Utils.execute(
204-
// executable: swiftExecutable,
205-
// arguments: Array(cmd.dropFirst()),
206-
// customWorkingDirectory: projectDirectory,
207-
// logLevel: verboseLogging ? .debug : .silent)
189+
// launch the command to compile and execute Deploy.swift
190+
let samDeploymentDescriptor = try Utils.execute(
191+
executable: swiftExecutable,
192+
arguments: Array(cmd.dropFirst()),
193+
customWorkingDirectory: projectDirectory,
194+
logLevel: verboseLogging ? .debug : .silent)
208195

209196
// write the generated SAM deployment descriptor to disk
210197
if FileManager.default.fileExists(atPath: samDeploymentDescriptorFilePath) && !force {
@@ -289,7 +276,7 @@ struct AWSLambdaDeployer: CommandPlugin {
289276
force: Bool,
290277
verboseLogging: Bool) throws {
291278

292-
let samConfigFilePath = "\(projetDirectory)/samconfig.toml" // the default value for SAM
279+
let samConfigFilePath = "\(projetDirectory.path())samconfig.toml" // the default value for SAM
293280
let samConfigTemplate = """
294281
version = 0.1
295282
[\(buildConfiguration)]

0 commit comments

Comments
 (0)