From 8de82d41f1c28194da9238096fb7d9a10501f2c1 Mon Sep 17 00:00:00 2001 From: Rockford Wei Date: Fri, 29 Mar 2019 14:57:47 -0400 Subject: [PATCH] Fully upgrading to Swift 5.0 - removing all external system module dependencies. - tested on both macOS/ubuntu --- Package.swift | 28 ++++++++++++++++++-------- README.md | 4 ++-- README.zh_CN.md | 11 ++-------- Sources/PerfectCBSON/module.modulemap | 5 +++++ Sources/PerfectCBSON/shim.h | 2 ++ Sources/PerfectCMongo/module.modulemap | 5 +++++ Sources/PerfectCMongo/shim.h | 9 +++++++++ 7 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 Sources/PerfectCBSON/module.modulemap create mode 100644 Sources/PerfectCBSON/shim.h create mode 100644 Sources/PerfectCMongo/module.modulemap create mode 100644 Sources/PerfectCMongo/shim.h diff --git a/Package.swift b/Package.swift index f018977..e3df1fc 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:4.1 +// swift-tools-version:4.2 // Package.swift // Perfect-MongoDB // @@ -25,12 +25,24 @@ let package = Package( .library(name: "PerfectMongoDB", targets: ["PerfectMongoDB"]) ], dependencies: [ - .package(url: "https://github.com/PerfectSideRepos/Perfect-CMongo.git", from: "0.1.0"), - .package(url: "https://github.com/PerfectSideRepos/Perfect-CBSON.git", from: "0.0.0"), .package(url: "https://github.com/PerfectlySoft/PerfectLib.git", from: "3.0.0") - ], - targets: [ - .target(name: "PerfectMongoDB", dependencies: ["PerfectLib"]), + ], + targets: [ + .systemLibrary(name: "PerfectCMongo", + pkgConfig: "libmongoc-1.0", + providers: [ + .apt(["libmongoc-dev"]), + .brew(["mongo-c-driver"]) + ] + ), + .systemLibrary(name: "PerfectCBSON", + pkgConfig: "libbson-1.0", + providers: [ + .apt(["libbson-dev"]), + .brew(["mongo-c-driver"]) + ] + ), + .target(name: "PerfectMongoDB", dependencies: ["PerfectCMongo", "PerfectCBSON", "PerfectLib"]), .testTarget(name: "PerfectMongoDBTests", dependencies: ["PerfectMongoDB"]) - ] -) + ] +) \ No newline at end of file diff --git a/README.md b/README.md index c1b8a9a..b113096 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Perfect - MongoDB Connector [简体中文](README.zh_CN.md)

- Swift 4.0 + Swift 5.0 Platforms OS X | Linux @@ -82,7 +82,7 @@ Building Add this project as a dependency in your Package.swift file. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.Package(url:"https://github.com/PerfectlySoft/Perfect-MongoDB.git", majorVersion: 3) +.package(url:"https://github.com/PerfectlySoft/Perfect-MongoDB.git", .branch("master")) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Documentation diff --git a/README.zh_CN.md b/README.zh_CN.md index ab9cf89..a92e1f1 100644 --- a/README.zh_CN.md +++ b/README.zh_CN.md @@ -24,7 +24,7 @@ Perfect - MongoDB 数据库连接器 [English](README.md)

- Swift 3.0 + Swift 5.0 Platforms OS X | Linux @@ -50,13 +50,6 @@ Perfect - MongoDB 数据库连接器 [English](README.md) -## 问题报告 - -我们正在过渡到 JIRA 程序错误管理系统,因此 GitHub 的问题报告功能就被禁用了。 - -如果您发现任何问题,或有任何意见和建议,请在我们的 JIRA 工作台指出 [http://jira.perfect.org:8080/servicedesk/customer/portal/1](http://jira.perfect.org:8080/servicedesk/customer/portal/1)。 - -目前的问题清单请查阅 [http://jira.perfect.org:8080/projects/ISS/issues](http://jira.perfect.org:8080/projects/ISS/issues) macOS 注意事项 ---------------- @@ -90,7 +83,7 @@ apt-get install libmongoc-dev libbson-dev libssl-dev 请在您的 Package.swift 文件下增加以下内容: ```swift -.Package(url:"https://github.com/PerfectlySoft/Perfect-MongoDB.git", majorVersion: 3) +.package(url:"https://github.com/PerfectlySoft/Perfect-MongoDB.git", .branch("master")) ``` ## 更多信息 diff --git a/Sources/PerfectCBSON/module.modulemap b/Sources/PerfectCBSON/module.modulemap new file mode 100644 index 0000000..6eb3195 --- /dev/null +++ b/Sources/PerfectCBSON/module.modulemap @@ -0,0 +1,5 @@ +module PerfectCBSON [system] { + header "shim.h" + link "bson-1.0" + export * +} \ No newline at end of file diff --git a/Sources/PerfectCBSON/shim.h b/Sources/PerfectCBSON/shim.h new file mode 100644 index 0000000..ffe0c0f --- /dev/null +++ b/Sources/PerfectCBSON/shim.h @@ -0,0 +1,2 @@ +#define BCON_H_ +#include \ No newline at end of file diff --git a/Sources/PerfectCMongo/module.modulemap b/Sources/PerfectCMongo/module.modulemap new file mode 100644 index 0000000..d0051da --- /dev/null +++ b/Sources/PerfectCMongo/module.modulemap @@ -0,0 +1,5 @@ +module PerfectCMongo [system] { + header "shim.h" + link "mongoc-1.0" + export * +} \ No newline at end of file diff --git a/Sources/PerfectCMongo/shim.h b/Sources/PerfectCMongo/shim.h new file mode 100644 index 0000000..d545b55 --- /dev/null +++ b/Sources/PerfectCMongo/shim.h @@ -0,0 +1,9 @@ +#include + +static bool _mongoc_cursor_next(mongoc_cursor_t *cursor, const void **bson) +{ + const bson_t *bson2 = NULL; + bool r = mongoc_cursor_next(cursor, &bson2); + *bson = bson2; + return r; +} \ No newline at end of file