@@ -115,11 +115,24 @@ struct AWSLambdaPackager: CommandPlugin {
115
115
for product in products {
116
116
print ( " building \" \( product. name) \" " )
117
117
let buildCommand = " swift build -c \( buildConfiguration. rawValue) --product \( product. name) --static-swift-stdlib "
118
- try self . execute (
119
- executable: dockerToolPath,
120
- arguments: [ " run " , " --rm " , " -v " , " \( packageDirectory. string) :/workspace " , " -w " , " /workspace " , baseImage, " bash " , " -cl " , buildCommand] ,
121
- logLevel: verboseLogging ? . debug : . output
122
- )
118
+ if ProcessInfo . processInfo. environment [ " LAMBDA_USE_LOCAL_DEPS " ] != nil {
119
+ // when developing locally, we must have the full swift-aws-lambda-runtime project in the container
120
+ // because Examples' Package.swift have a dependency on ../..
121
+ // just like Package.swift's examples assume ../.., we assume we are two levels below the root project
122
+ let lastComponent = packageDirectory. lastComponent
123
+ let beforeLastComponent = packageDirectory. removingLastComponent ( ) . lastComponent
124
+ try self . execute (
125
+ executable: dockerToolPath,
126
+ arguments: [ " run " , " --rm " , " --env " , " LAMBDA_USE_LOCAL_DEPS=true " , " -v " , " \( packageDirectory. string) /../..:/workspace " , " -w " , " /workspace/ \( beforeLastComponent) / \( lastComponent) " , baseImage, " bash " , " -cl " , buildCommand] ,
127
+ logLevel: verboseLogging ? . debug : . output
128
+ )
129
+ } else {
130
+ try self . execute (
131
+ executable: dockerToolPath,
132
+ arguments: [ " run " , " --rm " , " -v " , " \( packageDirectory. string) :/workspace " , " -w " , " /workspace " , baseImage, " bash " , " -cl " , buildCommand] ,
133
+ logLevel: verboseLogging ? . debug : . output
134
+ )
135
+ }
123
136
let productPath = buildOutputPath. appending ( product. name)
124
137
guard FileManager . default. fileExists ( atPath: productPath. string) else {
125
138
Diagnostics . error ( " expected ' \( product. name) ' binary at \" \( productPath. string) \" " )
0 commit comments