diff --git a/.circleci/config.yml b/.circleci/config.yml index 481a3dc..0e0b6c0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,6 +12,29 @@ jobs: - run: mysql -u root -e "create database IF NOT EXISTS test;" - run: swift build - run: swift test + mac-swift5.0: + macos: + xcode: "10.2.0" + steps: + - checkout + - run: brew update + - run: brew install https://gist.github.com/novi/dd21d48d260379e8919d9490bf5cfaec/raw/6ea4daa02d93f4ab0110ad30d87ea2b497a71cd0/cmysqlmariadb.rb #cmysql + - run: mkdir -p /usr/local/etc/my.cnf.d #workaround + - run: mysql.server start + - run: mysql -u root -e "create database IF NOT EXISTS test;" + - run: swift build + - run: swift test + mac-swift5.0-mysql: + macos: + xcode: "10.2.0" + steps: + - checkout + - run: brew update + - run: brew install https://gist.githubusercontent.com/novi/c6d4afa6e9f9cc9c426e3ccd140c3c74/raw/7130ad1d5062cdb2f7492d42e8d5574b864f3e18/cmysql.rb + - run: mysql.server start + - run: mysql -u root -e "create database IF NOT EXISTS test;" + - run: swift build + - run: swift test linux-swift4.1: docker: - image: yusukeito/swift-basic:swift4.1 @@ -42,11 +65,29 @@ jobs: - run: sleep 5 #wait for mysql - run: swift build - run: swift test + linux-swift5.0: + docker: + - image: yusukeito/swift-basic:swift5.0 + - image: mariadb:10.3 + environment: + MYSQL_USER: root + MYSQL_DATABASE: "test" + MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_ROOT_HOST: "%" + DATABASE_HOST: "%" + steps: + - checkout + - run: sleep 5 #wait for mysql + - run: swift build + - run: swift test workflows: version: 2 build_and_test: jobs: - mac-swift4.2 + - mac-swift5.0 + - mac-swift5.0-mysql - linux-swift4.1 - - linux-swift4.2 \ No newline at end of file + - linux-swift4.2 + - linux-swift5.0 \ No newline at end of file diff --git a/Package.resolved b/Package.resolved deleted file mode 100644 index 669e9dd..0000000 --- a/Package.resolved +++ /dev/null @@ -1,16 +0,0 @@ -{ - "object": { - "pins": [ - { - "package": "CMySQL", - "repositoryURL": "https://github.com/novi/cmysql.git", - "state": { - "branch": null, - "revision": "dee1732e79a4e49cb4433804983eccb262e2e5d8", - "version": "2.0.4" - } - } - ] - }, - "version": 1 -} diff --git a/Package@swift-5.swift b/Package@swift-5.swift new file mode 100644 index 0000000..97362ff --- /dev/null +++ b/Package@swift-5.swift @@ -0,0 +1,42 @@ +// swift-tools-version:5.0 +import PackageDescription + +let package = Package( + name: "MySQL", + products: [ + .library(name: "MySQL", targets: ["MySQL"]) + ], + targets: [ + .systemLibrary( + name: "CMySQL", + path: "Sources/cmysql", + pkgConfig: "cmysql", + providers: [ + .brew(["cmysql"]), + .apt(["libmysqlclient-dev"]) + ] + ), + .target( + name: "SQLFormatter" + ), + .target( + name: "MySQL", + dependencies: [ + "CMySQL", + "SQLFormatter", + ] + ), + .testTarget( + name: "MySQLTests", + dependencies: [ + "MySQL" + ] + ), + .testTarget( + name: "SQLFormatterTests", + dependencies: [ + "MySQL" + ] + ) + ] +) diff --git a/README.md b/README.md index ab83b31..0bcccde 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ mysql-swift =========== -[![Swift 4.1](https://img.shields.io/badge/Swift-4.1-orange.svg)](https://swift.org) ![Platform Linux, macOS](https://img.shields.io/badge/Platforms-Linux%2C%20macOS-lightgray.svg) [![CircleCI](https://circleci.com/gh/novi/mysql-swift.svg?style=svg)](https://circleci.com/gh/novi/mysql-swift) @@ -71,9 +70,9 @@ Install pkg-config `.pc` file in [cmysql](https://github.com/vapor-community/cmy ```sh # cmysql -$ brew tap vapor/homebrew-tap && brew install cmysql +$ brew install https://gist.githubusercontent.com/novi/c6d4afa6e9f9cc9c426e3ccd140c3c74/raw/7130ad1d5062cdb2f7492d42e8d5574b864f3e18/cmysql.rb # cmysql-mariadb -$ brew install https://gist.github.com/novi/dd21d48d260379e8919d9490bf5cfaec/raw/6ea4daa02d93f4ab0110ad30d87ea2b497a71cd0/cmysqlmariadb.rb +$ brew install https://gist.githubusercontent.com/novi/dd21d48d260379e8919d9490bf5cfaec/raw/6ea4daa02d93f4ab0110ad30d87ea2b497a71cd0/cmysqlmariadb.rb ``` ## Ubuntu diff --git a/Sources/MySQL/IDType.swift b/Sources/MySQL/IDType.swift index cdb066c..b5bfa6f 100644 --- a/Sources/MySQL/IDType.swift +++ b/Sources/MySQL/IDType.swift @@ -19,9 +19,15 @@ public extension IDType { func queryParameter(option: QueryParameterOption) throws -> QueryParameterType { return try id.queryParameter(option: option) } + #if swift(>=4.2) + func hash(into hasher: inout Hasher) { + hasher.combine(id) + } + #else var hashValue: Int { return id.hashValue } + #endif } extension IDType where Self: SQLRawStringDecodable, Self.T: SQLRawStringDecodable { diff --git a/Sources/cmysql/macos.pc b/Sources/cmysql/macos.pc new file mode 100644 index 0000000..055b192 --- /dev/null +++ b/Sources/cmysql/macos.pc @@ -0,0 +1,9 @@ +prefix=/usr/local/opt/mysql +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include +Name: MySQL +Description: MySQL client library +Version: 2.0 +Cflags: -I${includedir} +Libs: -L${libdir} -lmysqlclient diff --git a/Sources/cmysql/module.modulemap b/Sources/cmysql/module.modulemap new file mode 100644 index 0000000..849eb6b --- /dev/null +++ b/Sources/cmysql/module.modulemap @@ -0,0 +1,5 @@ +module CMySQL [system] { + header "shim.h" + link "mysqlclient" + export * +} diff --git a/Sources/cmysql/shim.h b/Sources/cmysql/shim.h new file mode 100644 index 0000000..290fc66 --- /dev/null +++ b/Sources/cmysql/shim.h @@ -0,0 +1,11 @@ +#ifndef __CMYSQL_SHIM_H__ +#define __CMYSQL_SHIM_H__ + +#include + +#if LIBMYSQL_VERSION_ID >= 80000 +typedef int my_bool; +#endif + +#endif +