diff --git a/README.md b/README.md index 8bb1db6..022fe10 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,40 @@ -# Qutheory - CMySQL - (Not Tested) +# CMySQL +C module for MySQL -## Install MySQL via Brew (OS X) -follow link to download page http://dev.mysql.com/downloads/mysql/ +## Building -You may need to use the following command to build if you experience errors. +**To build on macOS:** ```sh -swift build -Xswiftc -I -Xswiftc /usr/local/mysql/include/ -Xlinker -L -Xlinker /usr/local/mysql/lib/ +swift build -Xswiftc -I/usr/local/include/mysql -Xlinker -L/usr/local/lib ``` -## Install MySQL via APT-GET (Linux) +- `-I` tells the compiler where to find the MySQL header file `mysql.h`. +- `-L` tells the linker where to find MySQL library `libmysqlclient`. -* Update your system (you may need ```sudo```): -``` -apt-get update -apt-get upgrade -``` +**To build on Linux:** + +`swift build` should work normally. + +## MariaDB + +To use MariaDB instead of MySQL, you just need to change a couple of the compiler flags. -* To install MySQL ... +**macOS:** +```sh +swift build -Xlinker -L/usr/local/lib -Xswiftc -DMARIADB -Xswiftc -DNOJSON ``` -apt-get install mysql-server + +- `-DMARIADB` tells the compiler to link the MariaDB library instead of the MySQL library. +- `-DNOJSON` tells the package to ignore the `JSON` type (not supported as of MariaDB 10.1.16). + +**Linux:** + +```sh +swift build -Xswiftc -I/usr/include/mariadb -Xlinker -L/usr/lib/x86_64-linux-gnu -Xswiftc -DMARIADB -Xswiftc -DNOJSON ``` +- This simply changes the library/header paths and sets the same compatibility options shown above. +- Note that on macOS the library is called `libmysqlclient`, while on Linux the library is called `libmariadb`. diff --git a/module.modulemap b/module.modulemap index 0c2f759..22165c1 100644 --- a/module.modulemap +++ b/module.modulemap @@ -4,6 +4,12 @@ module CMySQLLinux [system] { export * } +module CMariaDBLinux [system] { + header "/usr/include/mariadb/mysql.h" + link "mariadb" + export * +} + module CMySQLMac [system] { header "/usr/local/include/mysql/mysql.h" link "mysqlclient"