Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift Package Manager: define SQLite as a system library target #627

Merged
merged 2 commits into from
Oct 4, 2019
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: 10 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,16 @@ jobs:
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode11
env:
- TID=SPM
script: make test_install_SPM
- TID=SPM Package
script: make test_install_SPM_Package

# SPM Install
- stage: Test Installation Xcode 11
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode11
env:
- TID=SPM Package in Xcode Project
script: make test_install_SPM_Project

###########################################
## Test GRDB Xcode 10.3
Expand Down
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -324,17 +324,27 @@ test_install_manual:
clean build \
$(XCPRETTY)

test_install_SPM:
cd Tests/SPM && \
test_install_SPM: test_install_SPM_Package test_install_SPM_Project

test_install_SPM_Package:
cd Tests/SPM/PlainPackage && \
( if [ -a .build ] && [ -a Package.resolved ]; then $(SWIFT) package reset; fi ) && \
rm -rf Packages/GRDB && \
$(SWIFT) package edit GRDB --revision master && \
rm -rf Packages/GRDB && \
ln -s ../../.. Packages/GRDB && \
ln -s ../../../.. Packages/GRDB && \
$(SWIFT) build && \
./.build/debug/SPM && \
$(SWIFT) package unedit --force GRDB

test_install_SPM_Project:
$(XCODEBUILD) \
-project Tests/SPM/PlainProject/Plain.xcodeproj \
-scheme Plain \
-configuration Release \
clean build \
$(XCPRETTY)

test_install_GRDB_CocoaPods: test_install_GRDB_CocoaPods_framework test_install_GRDB_CocoaPods_static

test_install_GRDB_CocoaPods_framework:
Expand Down
11 changes: 8 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ let package = Package(
.library(name: "GRDB", targets: ["GRDB"]),
],
dependencies: [
.package(url: "https://github.com/groue/CSQLite.git", from: "0.2.0"),
],
targets: [
.target(name: "GRDB", path: "GRDB"),
.systemLibrary(
name: "sqlite3",
providers: [.apt(["libsqlite3-dev"])]),
.target(
name: "GRDB",
dependencies: ["sqlite3"],
path: "GRDB"),
.testTarget(
name: "GRDBTests",
dependencies: ["GRDB"],
Expand All @@ -21,7 +26,7 @@ let package = Package(
"CocoaPods",
"Crash",
"Performance",
"SPM"
"SPM",
])
],
swiftLanguageVersions: [.v4_2, .version("5")]
Expand Down
5 changes: 5 additions & 0 deletions Sources/sqlite3/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module CSQLite {
header "shim.h"
link "sqlite3"
export *
}
9 changes: 9 additions & 0 deletions Sources/sqlite3/shim.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <sqlite3.h>

typedef void(*errorLogCallback)(void *pArg, int iErrCode, const char *zMsg);

// Wrapper around sqlite3_config(SQLITE_CONFIG_LOG, ...) which is a variadic
// function that can't be used from Swift.
static inline void registerErrorLogCallback(errorLogCallback callback) {
sqlite3_config(SQLITE_CONFIG_LOG, callback, 0);
}
File renamed without changes.
Loading