-
-
Notifications
You must be signed in to change notification settings - Fork 727
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
SPM support #202
SPM support #202
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @zmeyc. Thanks a lot for this PR. And Linux support in also on the way, which is a pretty good news ;-) I've asked a few questions, I wonder if you can have a look at them, because you know SPM much better than I do. And I also have a request: if it is not too hard, that would be great if the Makefile had a new test_SPM_install target which would assert SPM can integrate GRDB with SPM. That would greatly help me granting constant SPM support even if I don't use SPM much often, you see? There's also the topic of unit tests, but I know this is a delicate question, and we'll see that later.
Package.swift
Outdated
import PackageDescription | ||
|
||
let package = Package( | ||
name: "GRDB.swift", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the name of the package also used when one imports it from Swift with import
? Wouldn't be GRDB
a better name, then? (Honest question, I really don't know)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it affects anything at all, it doesn't seem to affect filenames in build dir nor import name. Can be changed to GRDB probably.
Module name is derived from directory name (it's currently 'GRDB', so it's 'import GRDB').
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, you made it clear that it's not quite clear ;-) In doubt let's rename to GRDB
. This .swift
suffix can only add confusion or nasty surprises ;-)
Package.swift
Outdated
let package = Package( | ||
name: "GRDB.swift", | ||
dependencies: [ | ||
.Package(url: "https://github.com/groue/SQLiteSDK.git", majorVersion: 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the convention of prefixing C packages with the letter C dead? The SPM documentation still uses it: Clibgit, CJPEG...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I used SQLiteSDK because there were 'import SQLiteSDK' in most of the files and this allowed not patching source code at all. I had to restore these imports as they were removed in latest master. It's probably better to rename the repo to "CSQLite" and adjust imports accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right! groue/SQLiteSDK has just been renamed https://github.com/groue/CSQLite :-)
Package.swift
Outdated
dependencies: [ | ||
.Package(url: "https://github.com/groue/SQLiteSDK.git", majorVersion: 0) | ||
], | ||
exclude: ["GRDB.xcworkspace", "Playgrounds", "SQLCipher", "SQLiteCustom", "Support", "DemoApps", "Tests", "Documentation"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list looks like a maintenance burden. Not a big problem, but if gathering sources in a Sources
directory would avoid it, then maybe we should follow the recommended convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can move GRDB dir into Sources/
There are three possible layouts:
-
Dirs for each module in root (currently used). The downside is having to exclude everything which SPM doesn't know how to handle.
-
For single module repos, Sources/ can contain source files without directories.
-
If at least one directory is present in Sources/, dirs are treated as distinct modules and no other source files are allowed at top level in Sources/
We can use this layout. So, it will become:
Sources/GRDB/...other files...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks for this detailed info. I don't feel like holding this PR just because we can't decide how to layout the files and directories: the status quo is good enough, even if we have to maintain an exclude list. 👍
Answering your comment, @zmeyc:
This checks that the package can build, and that's already great! OK, I'll add those lines to the Makefile myself. And this is well enough for a start. I'll want later to check that GRBD package can actually be integrated in a minimal binary package - but this PR doesn't need that.
All right. And unit tests will need a deep overhaul in the future Linux PR... So let's not lose time with unit tests right now. Just make me a little favor and tell me that you were actually able to use SQLite with GRDB through SPM :-) If I sum up:
|
(BTW @zmeyc, my personal machine is currently being repaired - I may be quick to talk but slow to actually perform my part of the job - please be patient, and assured I have the deepest interest in this PR) |
@groue One reason we might want to consider another name is because some other frameworks (notably Kitura and Perfect) have their own versions of CSQLite which will clash with GRDB's one. :( |
@groue But I hope that unlike SwiftyJSON, CSQLite is not imported and used in these frameworks by default. So maybe it's not a problem. |
When this problem happens, we'll deal with it. Unless you feel like a trendsetter (which I'm not on the SPM topic), sticking with existing conventions is better than crafting an nth standard. Besides, server stacks already have their database packages. And last, GRDB is not ready at all (really not) for the server. I even think that a hypothetical server-enabled GRDB will live with another name in another repo. Did I miss something? |
@groue I fully agree. |
@groue for what it's worth there is the application of GRDB for framework usage. SPM support fits in nicely with that use case. |
@zmeyc I took the liberty to complete the renaming tasks on your pr_spm1 branch.
I still can't check integration since GRDB is not yet published as an SPM package, and top-of-tree development doesn't look available yet with Xcode 8.3.1. I'll do that. Thanks for this PR, and your patience. |
@groue Thanks for finishing the PR, I suddenly felt ill yesterday. Hopefully I'll recover in a few days and will continue with Linux PR.
and it seems everything is built and linked correctly. Top of trunk development can be done like this:
After this SPM will use whatever is present in Packages/GRDB directory.
also seems to work. Btw, last tag seems to be misspelled (no 'v' prefix). |
Yes, thanks to you. There is a small executable in Tests/SPM which simply checks access to an in-memory database, and to the C API. Your tip for the top of trunk development made it suitable for an automated test (see 5804c04).
It was because of an old tag without
Take care, and recover first and foremost :-) |
No description provided.