mirror of
https://github.com/swift-server/swift-aws-lambda-runtime.git
synced 2026-05-03 07:22:27 +00:00
c22f5271a0
* add HelloJSON example + README * multiple corrections of typos and grammatical errors Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
60 lines
1.9 KiB
Swift
60 lines
1.9 KiB
Swift
// swift-tools-version:6.0
|
|
|
|
import PackageDescription
|
|
|
|
// needed for CI to test the local version of the library
|
|
import struct Foundation.URL
|
|
|
|
#if os(macOS)
|
|
let platforms: [PackageDescription.SupportedPlatform]? = [.macOS(.v15)]
|
|
#else
|
|
let platforms: [PackageDescription.SupportedPlatform]? = nil
|
|
#endif
|
|
|
|
let package = Package(
|
|
name: "swift-aws-lambda-runtime-example",
|
|
platforms: platforms,
|
|
products: [
|
|
.executable(name: "HelloJSON", targets: ["HelloJSON"])
|
|
],
|
|
dependencies: [
|
|
// during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below
|
|
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main")
|
|
],
|
|
targets: [
|
|
.executableTarget(
|
|
name: "HelloJSON",
|
|
dependencies: [
|
|
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime")
|
|
]
|
|
)
|
|
]
|
|
)
|
|
|
|
if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"],
|
|
localDepsPath != "",
|
|
let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]),
|
|
v.isDirectory == true
|
|
{
|
|
// when we use the local runtime as deps, let's remove the dependency added above
|
|
let indexToRemove = package.dependencies.firstIndex { dependency in
|
|
if case .sourceControl(
|
|
name: _,
|
|
location: "https://github.com/swift-server/swift-aws-lambda-runtime.git",
|
|
requirement: _
|
|
) = dependency.kind {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
if let indexToRemove {
|
|
package.dependencies.remove(at: indexToRemove)
|
|
}
|
|
|
|
// then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..)
|
|
print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)")
|
|
package.dependencies += [
|
|
.package(name: "swift-aws-lambda-runtime", path: localDepsPath)
|
|
]
|
|
}
|