|
| 1 | +// swift-tools-version:6.0 |
| 2 | + |
| 3 | +import PackageDescription |
| 4 | + |
| 5 | +// needed for CI to test the local version of the library |
| 6 | +import class Foundation.ProcessInfo |
| 7 | +import struct Foundation.URL |
| 8 | + |
| 9 | +#if os(macOS) |
| 10 | +let platforms: [PackageDescription.SupportedPlatform]? = [.macOS(.v15)] |
| 11 | +#else |
| 12 | +let platforms: [PackageDescription.SupportedPlatform]? = nil |
| 13 | +#endif |
| 14 | + |
| 15 | +let package = Package( |
| 16 | + name: "swift-aws-lambda-runtime-example", |
| 17 | + platforms: platforms, |
| 18 | + products: [ |
| 19 | + .executable(name: "APIGAtewayLambda", targets: ["APIGAtewayLambda"]) |
| 20 | + ], |
| 21 | + dependencies: [ |
| 22 | + // dependency on swift-aws-lambda-runtime is added dynamically below |
| 23 | + // .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main") |
| 24 | + |
| 25 | + .package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", branch: "main") |
| 26 | + ], |
| 27 | + targets: [ |
| 28 | + .executableTarget( |
| 29 | + name: "APIGAtewayLambda", |
| 30 | + dependencies: [ |
| 31 | + .product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"), |
| 32 | + .product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"), |
| 33 | + ], |
| 34 | + path: "." |
| 35 | + ) |
| 36 | + ] |
| 37 | +) |
| 38 | + |
| 39 | +if let localDepsPath = ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"], |
| 40 | + localDepsPath != "", |
| 41 | + let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), |
| 42 | + let _ = v.isDirectory |
| 43 | +{ |
| 44 | + print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") |
| 45 | + package.dependencies += [ |
| 46 | + .package(name: "swift-aws-lambda-runtime", path: localDepsPath) |
| 47 | + ] |
| 48 | + |
| 49 | +} else { |
| 50 | + print("[INFO] LAMBDA_USE_LOCAL_DEPS is not pointing to your local swift-aws-lambda-runtime code") |
| 51 | + print("[INFO] This project will compile against the main branch of the Lambda Runtime on GitHub") |
| 52 | + package.dependencies += [ |
| 53 | + .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main") |
| 54 | + ] |
| 55 | +} |
0 commit comments