Skip to content

Commit 355d4db

Browse files
authored
Fix warning, cleanup (#101)
* fix warning * add package manifesto for Swift 5 * support MySQL 8 on macOS
1 parent 9192a9b commit 355d4db

File tree

8 files changed

+117
-20
lines changed

8 files changed

+117
-20
lines changed

.circleci/config.yml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,29 @@ jobs:
1212
- run: mysql -u root -e "create database IF NOT EXISTS test;"
1313
- run: swift build
1414
- run: swift test
15+
mac-swift5.0:
16+
macos:
17+
xcode: "10.2.0"
18+
steps:
19+
- checkout
20+
- run: brew update
21+
- run: brew install https://gist.github.com/novi/dd21d48d260379e8919d9490bf5cfaec/raw/6ea4daa02d93f4ab0110ad30d87ea2b497a71cd0/cmysqlmariadb.rb #cmysql
22+
- run: mkdir -p /usr/local/etc/my.cnf.d #workaround
23+
- run: mysql.server start
24+
- run: mysql -u root -e "create database IF NOT EXISTS test;"
25+
- run: swift build
26+
- run: swift test
27+
mac-swift5.0-mysql:
28+
macos:
29+
xcode: "10.2.0"
30+
steps:
31+
- checkout
32+
- run: brew update
33+
- run: brew install https://gist.githubusercontent.com/novi/c6d4afa6e9f9cc9c426e3ccd140c3c74/raw/7130ad1d5062cdb2f7492d42e8d5574b864f3e18/cmysql.rb
34+
- run: mysql.server start
35+
- run: mysql -u root -e "create database IF NOT EXISTS test;"
36+
- run: swift build
37+
- run: swift test
1538
linux-swift4.1:
1639
docker:
1740
- image: yusukeito/swift-basic:swift4.1
@@ -42,11 +65,29 @@ jobs:
4265
- run: sleep 5 #wait for mysql
4366
- run: swift build
4467
- run: swift test
68+
linux-swift5.0:
69+
docker:
70+
- image: yusukeito/swift-basic:swift5.0
71+
- image: mariadb:10.3
72+
environment:
73+
MYSQL_USER: root
74+
MYSQL_DATABASE: "test"
75+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
76+
MYSQL_ROOT_HOST: "%"
77+
DATABASE_HOST: "%"
78+
steps:
79+
- checkout
80+
- run: sleep 5 #wait for mysql
81+
- run: swift build
82+
- run: swift test
4583

4684
workflows:
4785
version: 2
4886
build_and_test:
4987
jobs:
5088
- mac-swift4.2
89+
- mac-swift5.0
90+
- mac-swift5.0-mysql
5191
- linux-swift4.1
52-
- linux-swift4.2
92+
- linux-swift4.2
93+
- linux-swift5.0

Package.resolved

Lines changed: 0 additions & 16 deletions
This file was deleted.

[email protected]

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// swift-tools-version:5.0
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "MySQL",
6+
products: [
7+
.library(name: "MySQL", targets: ["MySQL"])
8+
],
9+
targets: [
10+
.systemLibrary(
11+
name: "CMySQL",
12+
path: "Sources/cmysql",
13+
pkgConfig: "cmysql",
14+
providers: [
15+
.brew(["cmysql"]),
16+
.apt(["libmysqlclient-dev"])
17+
]
18+
),
19+
.target(
20+
name: "SQLFormatter"
21+
),
22+
.target(
23+
name: "MySQL",
24+
dependencies: [
25+
"CMySQL",
26+
"SQLFormatter",
27+
]
28+
),
29+
.testTarget(
30+
name: "MySQLTests",
31+
dependencies: [
32+
"MySQL"
33+
]
34+
),
35+
.testTarget(
36+
name: "SQLFormatterTests",
37+
dependencies: [
38+
"MySQL"
39+
]
40+
)
41+
]
42+
)

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
mysql-swift
22
===========
33

4-
[![Swift 4.1](https://img.shields.io/badge/Swift-4.1-orange.svg)](https://swift.org)
54
![Platform Linux, macOS](https://img.shields.io/badge/Platforms-Linux%2C%20macOS-lightgray.svg)
65
[![CircleCI](https://circleci.com/gh/novi/mysql-swift.svg?style=svg)](https://circleci.com/gh/novi/mysql-swift)
76

@@ -71,9 +70,9 @@ Install pkg-config `.pc` file in [cmysql](https://github.com/vapor-community/cmy
7170

7271
```sh
7372
# cmysql
74-
$ brew tap vapor/homebrew-tap && brew install cmysql
73+
$ brew install https://gist.githubusercontent.com/novi/c6d4afa6e9f9cc9c426e3ccd140c3c74/raw/7130ad1d5062cdb2f7492d42e8d5574b864f3e18/cmysql.rb
7574
# cmysql-mariadb
76-
$ brew install https://gist.github.com/novi/dd21d48d260379e8919d9490bf5cfaec/raw/6ea4daa02d93f4ab0110ad30d87ea2b497a71cd0/cmysqlmariadb.rb
75+
$ brew install https://gist.githubusercontent.com/novi/dd21d48d260379e8919d9490bf5cfaec/raw/6ea4daa02d93f4ab0110ad30d87ea2b497a71cd0/cmysqlmariadb.rb
7776
```
7877

7978
## Ubuntu

Sources/MySQL/IDType.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ public extension IDType {
1919
func queryParameter(option: QueryParameterOption) throws -> QueryParameterType {
2020
return try id.queryParameter(option: option)
2121
}
22+
#if swift(>=4.2)
23+
func hash(into hasher: inout Hasher) {
24+
hasher.combine(id)
25+
}
26+
#else
2227
var hashValue: Int {
2328
return id.hashValue
2429
}
30+
#endif
2531
}
2632

2733
extension IDType where Self: SQLRawStringDecodable, Self.T: SQLRawStringDecodable {

Sources/cmysql/macos.pc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
prefix=/usr/local/opt/mysql
2+
exec_prefix=${prefix}
3+
libdir=${exec_prefix}/lib
4+
includedir=${prefix}/include
5+
Name: MySQL
6+
Description: MySQL client library
7+
Version: 2.0
8+
Cflags: -I${includedir}
9+
Libs: -L${libdir} -lmysqlclient

Sources/cmysql/module.modulemap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module CMySQL [system] {
2+
header "shim.h"
3+
link "mysqlclient"
4+
export *
5+
}

Sources/cmysql/shim.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef __CMYSQL_SHIM_H__
2+
#define __CMYSQL_SHIM_H__
3+
4+
#include <mysql/mysql.h>
5+
6+
#if LIBMYSQL_VERSION_ID >= 80000
7+
typedef int my_bool;
8+
#endif
9+
10+
#endif
11+

0 commit comments

Comments
 (0)