Skip to content
Merged
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
12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,15 @@ jobs:
run: swift build
- name: Run tests
run: swift test

build-linux:
runs-on: ubuntu-latest
container: swift:6.1-jammy
steps:
- uses: actions/checkout@v4
- name: Install SQLite
run: apt-get update && apt-get install -y libsqlite3-dev
- name: Build
run: swift build
- name: Run tests
run: swift test
17 changes: 8 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@ jobs:
build:
name: Build for ${{ matrix.destination.name }}
runs-on: ${{ matrix.destination.os }}
container: ${{ matrix.destination.container }}
strategy:
matrix:
destination:
# - Swiftly is failing to install these so commenting out for now
# - { name: "ubuntu-aarch64", os: ubuntu-22.04-arm }
# - { name: "ubuntu-x86_64", os: ubuntu-22.04 }
- { name: "ubuntu-aarch64", os: ubuntu-22.04-arm, container: "swift:6.1-jammy" }
- { name: "ubuntu-x86_64", os: ubuntu-22.04, container: "swift:6.1-jammy" }
- { name: "macos-universal", os: macos-15 }
steps:
- if: startsWith(matrix.destination.name, 'ubuntu')
uses: vapor/swiftly-action@v0.2
with:
toolchain: 6.1.0
run: apt-get update && apt-get install -y make libsqlite3-dev
- if: startsWith(matrix.destination.name, 'macos')
run: sudo xcode-select -s /Applications/Xcode_16.4.app
- uses: actions/checkout@v4
Expand All @@ -46,6 +44,7 @@ jobs:
- name: Deploy the binary
uses: softprops/action-gh-release@v2
with:
files: puresql.macos-universal.tar.gz
# puresql.ubuntu-x86_64.tar.gz
# puresql.ubuntu-aarch64.tar.gz
files: |
puresql.macos-universal.tar.gz
puresql.ubuntu-x86_64.tar.gz
puresql.ubuntu-aarch64.tar.gz
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ifeq ($(UNAME_S),Darwin)
BUILD_FLAGS := -c release --product PureSQLCLI --arch arm64 --arch x86_64
BUILD_DIR := .build/apple/Products/Release
else
BUILD_FLAGS := -c release --product PureSQLCLI
BUILD_FLAGS := -c release --product PureSQLCLI --static-swift-stdlib
BUILD_DIR := .build/release
endif

Expand Down
10 changes: 10 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,21 @@ let package = Package(
]
),

.systemLibrary(
name: "CSQLite",
pkgConfig: "sqlite3",
providers: [
.apt(["libsqlite3-dev"]),
.yum(["sqlite-devel"]),
]
),

.target(
name: "PureSQL",
dependencies: [
"PureSQLMacros",
.product(name: "Collections", package: "swift-collections"),
.target(name: "CSQLite", condition: .when(platforms: [.linux])),
]
),

Expand Down
5 changes: 5 additions & 0 deletions Sources/CSQLite/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module CSQLite [system] {
header "shim.h"
link "sqlite3"
export *
}
1 change: 1 addition & 0 deletions Sources/CSQLite/shim.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <sqlite3.h>
4 changes: 4 additions & 0 deletions Sources/PureSQL/Cursor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
// Created by Wes Wickwire on 2/16/25.
//

#if canImport(SQLite3)
import SQLite3
#else
import CSQLite
#endif

/// A low-level iterator over the results of a prepared database statement.
///
Expand Down
4 changes: 4 additions & 0 deletions Sources/PureSQL/DatabaseObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
//

import Foundation
#if canImport(SQLite3)
import SQLite3
#else
import CSQLite
#endif

/// A change that happened in the database.
/// Represents many events. Changes are published
Expand Down
4 changes: 4 additions & 0 deletions Sources/PureSQL/DatabasePrimitive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
//

import Foundation
#if canImport(SQLite3)
import SQLite3
#else
import CSQLite
#endif

@usableFromInline let SQLITE_TRANSIENT = unsafeBitCast(-1, to: sqlite3_destructor_type.self)

Expand Down
2 changes: 1 addition & 1 deletion Sources/PureSQL/DatabaseValueAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public struct DecimalDatabaseValueAdapter: DatabaseValueAdapter {
public init() {}

@inlinable public func encodeToDouble(value: Value) throws(SQLError) -> Double {
Double(truncating: value as NSNumber)
NSDecimalNumber(decimal: value).doubleValue
}

@inlinable public func decode(from primitive: Double) throws(SQLError) -> Decimal {
Expand Down
4 changes: 4 additions & 0 deletions Sources/PureSQL/Row.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
// Created by Wes Wickwire on 9/6/25.
//

#if canImport(SQLite3)
import SQLite3
#else
import CSQLite
#endif

/// A raw SQLite row from a statement.
public struct Row: ~Copyable {
Expand Down
4 changes: 4 additions & 0 deletions Sources/PureSQL/SQLAny.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
//

import Foundation
#if canImport(SQLite3)
import SQLite3
#else
import CSQLite
#endif

/// SQLite supports an `ANY` type. Mapping to a `Swift.Any` would
/// not be a smart idea and would not implement things like
Expand Down
4 changes: 4 additions & 0 deletions Sources/PureSQL/SQLiteCode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
// Created by Wes Wickwire on 11/9/24.
//

#if canImport(SQLite3)
import SQLite3
#else
import CSQLite
#endif

public enum SQLiteCode: Int32, Error {
case sqliteOk = 0
Expand Down
4 changes: 4 additions & 0 deletions Sources/PureSQL/SQLiteConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

import Collections
import Foundation
#if canImport(SQLite3)
import SQLite3
#else
import CSQLite
#endif

/// Represents a raw connection to the SQLite database
public protocol RawConnection: Sendable {
Expand Down
4 changes: 4 additions & 0 deletions Sources/PureSQL/Statement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
// Created by Wes Wickwire on 2/16/25.
//

#if canImport(SQLite3)
import SQLite3
#else
import CSQLite
#endif

/// A prepared SQL statement for executing queries against the database.
///
Expand Down
Loading