Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
unit-tests:
uses: vapor/ci/.github/workflows/run-unit-tests.yml@main
secrets: inherit
with:
with_wasm: true

# Make sure downstream dependents still work
dependents-check:
Expand Down
21 changes: 17 additions & 4 deletions Package@swift-5.9.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// swift-tools-version:5.9
import PackageDescription

/// This list matches the [supported platforms on the Swift 5.10 release of SPM](https://github.com/swiftlang/swift-package-manager/blob/release/5.10/Sources/PackageDescription/SupportedPlatforms.swift#L34-L71)
/// Don't add new platforms here unless raising the swift-tools-version of this manifest.
let allPlatforms: [Platform] = [.macOS, .macCatalyst, .iOS, .tvOS, .watchOS, .visionOS, .driverKit, .linux, .windows, .android, .wasi, .openbsd]
let nonWASIPlatforms: [Platform] = allPlatforms.filter { $0 != .wasi }
let wasiPlatform: [Platform] = [.wasi]

let package = Package(
name: "sqlite-kit",
platforms: [
Expand All @@ -13,16 +19,23 @@ let package = Package(
.library(name: "SQLiteKit", targets: ["SQLiteKit"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.65.0"),
.package(url: "https://github.com/vapor/sqlite-nio.git", from: "1.9.0"),
.package(url: "https://github.com/vapor/sql-kit.git", from: "3.29.3"),
.package(url: "https://github.com/vapor/async-kit.git", from: "1.19.0"),
.package(url: "https://github.com/PassiveLogic/nio-async-runtime.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.89.0"),

// TODO: SM: Update below once everything is merged and release to the proper repositories
// .package(url: "https://github.com/vapor/sqlite-nio.git", from: "1.9.0"),
.package(url: "https://github.com/PassiveLogic/sqlite-nio.git", branch: "feat/swift-wasm-support-v2"),
.package(url: "https://github.com/vapor/sql-kit.git", from: "3.33.1"),
// .package(url: "https://github.com/vapor/async-kit.git", from: "1.19.0"),
.package(url: "https://github.com/PassiveLogic/async-kit.git", branch: "feat/swift-wasm-support-v2"),
],
targets: [
.target(
name: "SQLiteKit",
dependencies: [
.product(name: "NIOFoundationCompat", package: "swift-nio"),
.product(name: "NIOAsyncRuntime", package: "nio-async-runtime", condition: .when(platforms: wasiPlatform)),
.product(name: "NIOPosix", package: "swift-nio", condition: .when(platforms: nonWASIPlatforms)),
.product(name: "AsyncKit", package: "async-kit"),
.product(name: "SQLiteNIO", package: "sqlite-nio"),
.product(name: "SQLKit", package: "sql-kit"),
Expand Down
10 changes: 10 additions & 0 deletions Sources/SQLiteKit/SQLiteConnectionSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import Foundation
#endif
import Logging
import AsyncKit
#if canImport(NIOAsyncRuntime)
import NIOAsyncRuntime
#elseif canImport(NIOPosix)
import NIOPosix
#endif
import SQLiteNIO
import NIOCore

Expand All @@ -16,7 +20,13 @@ public struct SQLiteConnectionSource: ConnectionPoolSource, Sendable {
private let threadPool: NIOThreadPool

private var connectionStorage: SQLiteConnection.Storage {
#if os(WASI)
// NOTE: File urls and paths cause runtime errors currently. Currently using
// in-memory connection for WASI targets.
.memory
#else
.file(path: self.actualURL.absoluteString)
#endif
}

/// Create a new ``SQLiteConnectionSource``.
Expand Down
Loading