Skip to content

Commit aef48de

Browse files
authored
generator: Add an environment variable to choose the container runtime (#172)
There are now many alternative container runtimes. These often expose a socket interface which is compatible with the `docker` CLI, but may also have their own command line utilities. For our limited requirements, these alternative CLIs are often compatible enough with the `docker` CLI that we can use them directly. This PR adds an environment variable to allow users running alternative container runtimes to use their CLIs directly when building SDKs, removing the need to have the `docker` CLI tools installed as well. I've tested the generator with `podman`; it produced identical SDKs to the current implementation (#171), with good performance. The `docker` CLI is currently still required to run the SDK generator tests.
1 parent 0c65e75 commit aef48de

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Copy.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extension SwiftSDKGenerator {
1818
baseDockerImage: String,
1919
sdkDirPath: FilePath
2020
) async throws {
21-
logGenerationStep("Launching a Docker container to copy Swift SDK for the target triple from it...")
21+
logGenerationStep("Launching a container to extract the Swift SDK for the target triple...")
2222
try await withDockerContainer(fromImage: baseDockerImage) { containerID in
2323
try await inTemporaryDirectory { generator, _ in
2424
let sdkUsrPath = sdkDirPath.appending("usr")

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public actor SwiftSDKGenerator {
6060
}
6161

6262
private let fileManager = FileManager.default
63-
private static let dockerCommand = "docker"
63+
private static let dockerCommand = ProcessInfo.processInfo.environment["SWIFT_SDK_GENERATOR_CONTAINER_RUNTIME"] ?? "docker"
6464

6565
public static func getCurrentTriple(isVerbose: Bool) throws -> Triple {
6666
let current = UnixName.current!

0 commit comments

Comments
 (0)