Skip to content

Commit

Permalink
Fix warning, cleanup (#101)
Browse files Browse the repository at this point in the history
* fix warning
* add package manifesto for Swift 5
* support MySQL 8 on macOS
  • Loading branch information
novi authored Jun 9, 2019
1 parent 9192a9b commit 355d4db
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 20 deletions.
43 changes: 42 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
- linux-swift4.2
- linux-swift5.0
16 changes: 0 additions & 16 deletions Package.resolved

This file was deleted.

42 changes: 42 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -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"
]
)
]
)
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Sources/MySQL/IDType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions Sources/cmysql/macos.pc
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions Sources/cmysql/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module CMySQL [system] {
header "shim.h"
link "mysqlclient"
export *
}
11 changes: 11 additions & 0 deletions Sources/cmysql/shim.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef __CMYSQL_SHIM_H__
#define __CMYSQL_SHIM_H__

#include <mysql/mysql.h>

#if LIBMYSQL_VERSION_ID >= 80000
typedef int my_bool;
#endif

#endif

0 comments on commit 355d4db

Please sign in to comment.