Skip to content

Commit

Permalink
Merge pull request #627 from groue/dev/SPM
Browse files Browse the repository at this point in the history
Swift Package Manager: define SQLite as a system library target
  • Loading branch information
groue authored Oct 4, 2019
2 parents 37477ad + 3cc5bb7 commit 5f085f2
Show file tree
Hide file tree
Showing 11 changed files with 383 additions and 8 deletions.
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.
File renamed without changes.
Loading

0 comments on commit 5f085f2

Please sign in to comment.