Skip to content

Commit b0b6e76

Browse files
committed
Add (partial) support for building on Windows using SwiftPM
This adds a dependency on the new swift-toolchain-sqlite package, which allows swift-package-manager to build using swift build on Windows (including tests) without any additional flags or preinstalled dependencies. It's "partial" because there is still one final blocker, which is that linking fails because we exceed the 65k exported symbol limit due to limitations in the build system, which can be addressed separately.
1 parent 06aa77e commit b0b6e76

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Package.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ let package = Package(
191191
name: "Basics",
192192
dependencies: [
193193
"_AsyncFileSystem",
194-
"SPMSQLite3",
194+
.target(name: "SPMSQLite3", condition: .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .visionOS, .macCatalyst, .linux])),
195+
.product(name: "CSQLite", package: "swift-toolchain-sqlite", condition: .when(platforms: [.windows])),
195196
.product(name: "DequeModule", package: "swift-collections"),
196197
.product(name: "OrderedCollections", package: "swift-collections"),
197198
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
@@ -646,6 +647,7 @@ let package = Package(
646647
"processInputs/exit4",
647648
"processInputs/simple-stdout-stderr",
648649
"processInputs/deadlock-if-blocking-io",
650+
"processInputs/echo",
649651
"processInputs/in-to-out",
650652
]
651653
),
@@ -854,7 +856,8 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
854856
.package(url: "https://github.com/swiftlang/swift-syntax.git", branch: relatedDependenciesBranch),
855857
.package(url: "https://github.com/apple/swift-system.git", "1.1.1" ..< "1.4.0"),
856858
.package(url: "https://github.com/apple/swift-collections.git", "1.0.1" ..< "1.2.0"),
857-
.package(url: "https://github.com/apple/swift-certificates.git", "1.0.1" ..< "1.4.0"),
859+
.package(url: "https://github.com/apple/swift-certificates.git", "1.0.1" ..< "1.6.0"),
860+
.package(url: "https://github.com/swiftlang/swift-toolchain-sqlite.git", from: "0.1.0"),
858861
]
859862
} else {
860863
package.dependencies += [
@@ -866,5 +869,6 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
866869
.package(path: "../swift-system"),
867870
.package(path: "../swift-collections"),
868871
.package(path: "../swift-certificates"),
872+
.package(path: "../swift-toolchain-sqlite"),
869873
]
870874
}

Sources/Basics/SQLite.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,19 @@
1212

1313
import Foundation
1414

15+
#if SWIFT_PACKAGE && os(Windows)
16+
#if USE_IMPL_ONLY_IMPORTS
17+
@_implementationOnly import CSQLite
18+
#else
19+
import CSQLite
20+
#endif
21+
#else
1522
#if USE_IMPL_ONLY_IMPORTS
1623
@_implementationOnly import SPMSQLite3
1724
#else
1825
import SPMSQLite3
1926
#endif
27+
#endif
2028

2129
/// A minimal SQLite wrapper.
2230
package final class SQLite {

Tests/BasicsTests/Environment/EnvironmentKeyTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ final class EnvironmentKeyTests: XCTestCase {
4545

4646
#if os(Windows)
4747
// Test case insensitivity on windows
48-
let key2 = EnvironmentKey("teSt")
49-
XCTAssertEqual(key0, key2)
48+
let key3 = EnvironmentKey("teSt")
49+
XCTAssertEqual(key0, key3)
5050
#endif
5151
}
5252

0 commit comments

Comments
 (0)