@@ -17,9 +17,9 @@ import PackagePlugin
1717
1818@main
1919struct AWSLambdaPackager : CommandPlugin {
20-
20+
2121 func performCommand( context: PackagePlugin . PluginContext , arguments: [ String ] ) async throws {
22-
22+
2323 // values to pass to the AWSLambdaPluginHelper
2424 let outputDirectory : URL
2525 let products : [ Product ]
@@ -29,15 +29,15 @@ struct AWSLambdaPackager: CommandPlugin {
2929 let packageDirectory = context. package . directoryURL
3030 let dockerToolPath = try context. tool ( named: " docker " ) . url
3131 let zipToolPath = try context. tool ( named: " zip " ) . url
32-
32+
3333 // extract arguments that require PluginContext to fully resolve
3434 // resolve them here and pass them to the AWSLambdaPluginHelper as arguments
3535 var argumentExtractor = ArgumentExtractor ( arguments)
36-
36+
3737 let outputPathArgument = argumentExtractor. extractOption ( named: " output-path " )
3838 let productsArgument = argumentExtractor. extractOption ( named: " products " )
3939 let configurationArgument = argumentExtractor. extractOption ( named: " configuration " )
40-
40+
4141 if let outputPath = outputPathArgument. first {
4242 #if os(Linux)
4343 var isDirectory : Bool = false
@@ -52,7 +52,7 @@ struct AWSLambdaPackager: CommandPlugin {
5252 } else {
5353 outputDirectory = context. pluginWorkDirectoryURL. appending ( path: " \( AWSLambdaPackager . self) " )
5454 }
55-
55+
5656 let explicitProducts = !productsArgument. isEmpty
5757 if explicitProducts {
5858 let _products = try context. package . products ( named: productsArgument)
@@ -62,11 +62,11 @@ struct AWSLambdaPackager: CommandPlugin {
6262 }
6363 }
6464 products = _products
65-
65+
6666 } else {
6767 products = context. package . products. filter { $0 is ExecutableProduct }
6868 }
69-
69+
7070 if let _buildConfigurationName = configurationArgument. first {
7171 guard let _buildConfiguration = PackageManager . BuildConfiguration ( rawValue: _buildConfigurationName) else {
7272 throw BuilderErrors . invalidArgument ( " invalid build configuration named ' \( _buildConfigurationName) ' " )
@@ -75,22 +75,23 @@ struct AWSLambdaPackager: CommandPlugin {
7575 } else {
7676 buildConfiguration = . release
7777 }
78-
78+
7979 // TODO: When running on Amazon Linux 2, we have to build directly from the plugin
8080 // launch the build, then call the helper just for the ZIP part
81-
81+
8282 let tool = try context. tool ( named: " AWSLambdaPluginHelper " )
83- let args = [
84- " build " ,
85- " --output-path " , outputDirectory. path ( ) ,
86- " --products " , products. map { $0. name } . joined ( separator: " , " ) ,
87- " --configuration " , buildConfiguration. rawValue,
88- " --package-id " , packageID,
89- " --package-display-name " , packageDisplayName,
90- " --package-directory " , packageDirectory. path ( ) ,
91- " --docker-tool-path " , dockerToolPath. path,
92- " --zip-tool-path " , zipToolPath. path
93- ] + arguments
83+ let args =
84+ [
85+ " build " ,
86+ " --output-path " , outputDirectory. path ( ) ,
87+ " --products " , products. map { $0. name } . joined ( separator: " , " ) ,
88+ " --configuration " , buildConfiguration. rawValue,
89+ " --package-id " , packageID,
90+ " --package-display-name " , packageDisplayName,
91+ " --package-directory " , packageDirectory. path ( ) ,
92+ " --docker-tool-path " , dockerToolPath. path,
93+ " --zip-tool-path " , zipToolPath. path,
94+ ] + arguments
9495
9596 // Invoke the plugin helper on the target directory, passing a configuration
9697 // file from the package directory.
@@ -103,52 +104,52 @@ struct AWSLambdaPackager: CommandPlugin {
103104 Diagnostics . error ( " AWSLambdaPluginHelper invocation failed: \( problem) " )
104105 }
105106 }
106-
107+
107108 // TODO: When running on Amazon Linux 2, we have to build directly from the plugin
108- // private func build(
109- // packageIdentity: Package.ID,
110- // products: [Product],
111- // buildConfiguration: PackageManager.BuildConfiguration,
112- // verboseLogging: Bool
113- // ) throws -> [LambdaProduct: URL] {
114- // print("-------------------------------------------------------------------------")
115- // print("building \"\(packageIdentity)\"")
116- // print("-------------------------------------------------------------------------")
117- //
118- // var results = [LambdaProduct: URL]()
119- // for product in products {
120- // print("building \"\(product.name)\"")
121- // var parameters = PackageManager.BuildParameters()
122- // parameters.configuration = buildConfiguration
123- // parameters.otherSwiftcFlags = ["-static-stdlib"]
124- // parameters.logging = verboseLogging ? .verbose : .concise
125- //
126- // let result = try packageManager.build(
127- // .product(product.name),
128- // parameters: parameters
129- // )
130- // guard let artifact = result.executableArtifact(for: product) else {
131- // throw Errors.productExecutableNotFound(product.name)
132- // }
133- // results[.init(product)] = artifact.url
134- // }
135- // return results
136- // }
137-
138- // private func isAmazonLinux2() -> Bool {
139- // if let data = FileManager.default.contents(atPath: "/etc/system-release"),
140- // let release = String(data: data, encoding: .utf8)
141- // {
142- // return release.hasPrefix("Amazon Linux release 2")
143- // } else {
144- // return false
145- // }
146- // }
109+ // private func build(
110+ // packageIdentity: Package.ID,
111+ // products: [Product],
112+ // buildConfiguration: PackageManager.BuildConfiguration,
113+ // verboseLogging: Bool
114+ // ) throws -> [LambdaProduct: URL] {
115+ // print("-------------------------------------------------------------------------")
116+ // print("building \"\(packageIdentity)\"")
117+ // print("-------------------------------------------------------------------------")
118+ //
119+ // var results = [LambdaProduct: URL]()
120+ // for product in products {
121+ // print("building \"\(product.name)\"")
122+ // var parameters = PackageManager.BuildParameters()
123+ // parameters.configuration = buildConfiguration
124+ // parameters.otherSwiftcFlags = ["-static-stdlib"]
125+ // parameters.logging = verboseLogging ? .verbose : .concise
126+ //
127+ // let result = try packageManager.build(
128+ // .product(product.name),
129+ // parameters: parameters
130+ // )
131+ // guard let artifact = result.executableArtifact(for: product) else {
132+ // throw Errors.productExecutableNotFound(product.name)
133+ // }
134+ // results[.init(product)] = artifact.url
135+ // }
136+ // return results
137+ // }
138+
139+ // private func isAmazonLinux2() -> Bool {
140+ // if let data = FileManager.default.contents(atPath: "/etc/system-release"),
141+ // let release = String(data: data, encoding: .utf8)
142+ // {
143+ // return release.hasPrefix("Amazon Linux release 2")
144+ // } else {
145+ // return false
146+ // }
147+ // }
147148}
148149
149150private enum BuilderErrors : Error , CustomStringConvertible {
150151 case invalidArgument( String )
151-
152+
152153 var description : String {
153154 switch self {
154155 case . invalidArgument( let description) :
0 commit comments