Skip to content

Commit

Permalink
Update readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
Malkverbena committed Feb 1, 2024
1 parent e21d229 commit 40e7aaf
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 92 deletions.
2 changes: 1 addition & 1 deletion 3party/boost
68 changes: 25 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,51 @@
# MySQL Module to Godot 4.

# MySQL Module to Godot 4

### This module was built using Boost.MySQL.
**Check out the Boost repository:** [**Boost.MySQL**](https://github.com/boostorg/mysql?tab=readme-ov-file)
### **This module is a wrapper for Boost.MySQL.**

### This module works only with Godot 4.
### If you use this module, let me know it. Leave a star.
Boost.MySQL is a client for MySQL and MariaDB database servers, based on Boost.Asio.
Boost.MySQL is part of Boost.
This module takes advantage of C++20.
Check out the Boost repository: [Boost.MySQL](https://github.com/boostorg/mysql?tab=readme-ov-file).

### Old version note:
Version 2.0 uses C++ MySQL Connector Library. You can find it here: [**Godot MySQL 2.0**](https://github.com/Malkverbena/mysql/tree/2.0)

## Features:
- Supports TCP and UNIX SOCKET connections.
- Supports TLS
- Supports asynchronous queries.
- Supports multi queries.

##### This module works only with Godot 4.

## Supported platforms: (Under development).
* MacOS - soon (need help).
* X11/Unix - dev.
* Windows - dev.
* javascript - need help.
* O̶S̶X̶ - possibly (need help).
* A̶n̶d̶r̶o̶i̶d̶ - possibly.
I have no plans to back port this module to Godot 3.x, but I will accept help from anyone who wants to port it.


## Requirements:
- A C++20 capable compiler as GCC, Clang (x11) , Visual C++ (Windows) or Apple Clang (Apple).
- [**NASM - Only for Windows**](https://www.nasm.us/pub/nasm/releasebuilds/)
- Git
- All requirements to compile Godot.
##### If you use this module, let me know it. Leave a star ;).

##### Do you have any suggestion? Would you like to share experiences while using the module? Please open a issue.

## Installation:
##### Old version note:

Clone this repository with the following command to checkout all the dependencies: Boost and OpenSSL.
Version 1.0 uses C++ MySQL Connector Library from [Oracle](https://dev.mysql.com/doc/connector-cpp/8.3/en/). You can find it here: [Godot MySQL 2.0](https://github.com/Malkverbena/mysql/releases/tag/V2.0).

```
$ git clone --recurse-submodules [email protected]:Malkverbena/mysql.git
```

If you already checked out the branch use the following commands to update the dependencies:

```
$ git submodule update --init --recursive
```
## Supported platforms: (Work in progress).

* MacOS - soon (need help).
* X11/Unix - dev.
* Windows - dev.
* OSX- possibly (need help).
* Android - In the future.
* Web - need help.

## Compilation:
For now, it is necessary to compile the entire mechanism.
### [See the full list of features here.](https://github.com/Malkverbena/mysql/blob/3.0/capabilities.md)

In the future there will be a version for GDExtension.
### [Compilation intruction here!](https://github.com/Malkverbena/mysql/blob/3.0/compilation.md)

It is highly recommended to compile the engine with the "precision=double" option.

Clone this repository inside the godot modules folder and compile the engine normally.
## Usage:

* **[Documentation.](https://github.com/Malkverbena/mysql/wiki)**
* **[Check out some exemples here.](https://github.com/Malkverbena/mysql/wiki)**

## Usage:
**See the docs here** [**Docs**](https://github.com/Malkverbena/mysql/tree/Docs-%26-Exemples-3.0)


# Disclaimer

> THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

> HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 changes: 24 additions & 28 deletions capabilities.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
## Capabilities:

### Connection:
- Set/Get Properties
- SSL/TLS connections
- Map of properties

### Simple text queries:
- Query
- Execute
- Update
- Transactions & Save Points
* TCP and UNIX socket connections.
* Encrypted connections (TLS). For both, TCP and UNIX socket connections.
* Authentication methods: mysql_native_password and caching_sha2_password.

### Prepared Statement for:
- Query
- Execute
- Update
- Transactions & Save Points

### **Methods:**

### Supported Godot & SQL data types:

TYPE | GODOT | SQL -> sql::DataType
-------|------------|----------------------
||
NULL | null | NILL / res->isNull
BOOL | bool | BIT
INT32 | integer 32 | TINYINT / SMALLINT / MEDIUMINT
INT64 | integer 64 | INTEGER / BIGINT
FLOAT | float | REAL / DOUBLE / DECIMAL / NUMERIC
TIME | Array | DATE / TIME / TIMESTAMP / YEAR
CHAR | String | ENUM / CHAR / VARCHAR / LONGVARCHAR
JSON | JsonString | JSON / TEXT
BINARY | ByteArray | BINARY / VARBINARY / LONGVARBINARY

* Supports asynchronous methods using C++20 coroutines.
* Supports Multi-function operations.
* Stored procedures. It can be used within Multi-function operations.
* Text querie: MySQL refers to this as the "text protocol", as all information is passed using text (as opposed to prepared statements).
* Prepared statements: MySQL refers to this as the "binary protocol", as the result of executing a prepared statement is sent in binary format rather than in text.


### **EQUIVALENT DATA TYPES:**

| DATA TYPE | GODOT DATA TYPE | C++ DATA TYPE | MYSQL DATA TYPE |
| :-------: | :---------------: | :--------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------: |
| NULL | null | std::nullptr_t | NILL |
| BOOL | bool | bool | TINYINT |
| INT32 | integer 32 | signed char, short, int, long, long long | SIGNED TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT |
| INT64 | integer 64 | unsigned char, unsigned short, unsigned,<br />int, unsigned long, unsigned long long | UNSIGNED BIGINT, UNSIGNED TINYINT, SMALLINT,<br />MEDIUMINT, INT, BIGINT, YEAR, BIT |
| FLOAT | float | float | FLOAT |
| DOUBLE | float | double | DOUBLE |
| BINARY | PackedByteArray | std::basic_vector<unsigned char, Allocator> | BINARY, VARBINARY, BLOB (all sizes), GEOMETRY |
| CHAR | String | std::basic_string<char, std::char_traits `<char>`, Allocator> (including std::string),<br />string_view, std::string_view, const char* | CHAR, VARCHAR, TEXT(all sizes),<br />ENUM, JSON, DECIMAL, NUMERIC |
| DATE | Dictionary | boost::mysql::date AKA std::chrono::time_point<br /><std::chrono::system_clock, days> | DATE |
| TIME | Dictionary | boost::mysql::time AKA std::chrono::microseconds | TIME |
| DATETIME | Dictionary | boost::mysql::datetime AKA std::chrono::time_point<br /><std::chrono::system_clock, std::chrono::duration<std::int64_t, std::micro>> | DATETIME, TIMESTAMP |
| CHAR | PackedStringArray | std::basic_string<char, std::char_traits, Allocator> (including std::string),<br />string_view, std::string_view, const char* | SET |
55 changes: 55 additions & 0 deletions compilation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Instructions for compilation:


This module has two dependencies, Openssl and Boost.
The dependencies will be automatically compiled during engine compilation.

You do not need to compile dependencies every time you compile the engine, but you must recompile dependencies when updating Boost and/or Openssl or when you are compiling the module for some platform that you haven't compiled before.

You can use the "recompile_sql" option when invoking scons to compile openssl and Boost or not.

* All: It will compile BOTH Boost and Openssl.
* openssl: It will only compile Openssl.
* boost: It will only compile Boost.
* none: It will **NOT** compile either Open or Boost.


## Requirements:

- A C++20 capable compiler as GCC, Clang (x11) , Visual C++ (Windows) or Apple Clang (Apple).
- [**NASM - Only for Windows**](https://www.nasm.us/pub/nasm/releasebuilds/)
- Git
- All requirements to compile Godot.


## Compilation:

It is necessary recompile the engine together with this module.

It is highly recommended to compile the engine with the "*precision=double*" option.

Clone this repository inside the godot modules folder or an external folder with the following command to checkout all the dependencies: Boost and OpenSSL.

```
git clone --recurse-submodules [email protected]:Malkverbena/mysql.git
```

If you already checked out the branch use the following commands to update the dependencies:

```
$ git submodule update --init --recursive
```

In case you use an external folder, you must use "*custom_modules*" when invoke Scons.

```
custom_modules=../path/to/mysql/folder
```

compile the engine normally.

You can use the command belloww to update the module the submodules at once.

```
git pull --recurse-submodules
```
11 changes: 0 additions & 11 deletions notes_doc.md

This file was deleted.

2 changes: 1 addition & 1 deletion tools/boost.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def compile_boost(env):
"headers"
]

#print(cmd_b2)
print(cmd_b2)

subprocess.check_call(cmd_b2, shell=True, cwd=boost_path, env={"PATH": f"{boost_path}:{os.environ['PATH']}"})
cmd_b2.pop()
Expand Down
34 changes: 26 additions & 8 deletions tools/openssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ def compile_openssl(env):
cmd_compile = ['nmake'] if win_host else ["make", "-j" + jobs]
cmd_install = ["nmake install"] if win_host else ["make", "install"]

cross_compilation_param = get_cross_compilation_param(env)
if cross_compilation_param != []:
cmd_config += cross_compilation_param

target = get_target(env)
cmd_config.append(target)

options = ssl_options(target_platform)
cmd_config.extend(options)

cross_compilation_param = get_cross_compilation_param(env)
if cross_compilation_param != []:
cmd_config += cross_compilation_param

openssl_path = get_openssl_path(env)
lib_path = get_openssl_install_path(env)
cmd_config.append("--prefix=" + lib_path)
Expand All @@ -38,6 +37,12 @@ def compile_openssl(env):
if not os.path.exists(lib_path):
os.makedirs(lib_path)


print(cmd_config)
print(cmd_depend)
print(cmd_compile)
print(cmd_install)

subprocess.check_call(cmd_config, cwd=openssl_path, env={"PATH": f"{openssl_path}:{os.environ['PATH']}"})
subprocess.check_call(cmd_depend, cwd=openssl_path, env={"PATH": f"{openssl_path}:{os.environ['PATH']}"})
subprocess.check_call(cmd_compile, cwd=openssl_path, env={"PATH": f"{openssl_path}:{os.environ['PATH']}"})
Expand All @@ -59,13 +64,24 @@ def get_cross_compilation_param(env):
target_bits = "64" if env["arch"] in ["x86_64", "arm64", "rv64", "ppc64"] else "32"
host_bits = helpers.get_host_bits()
is_cross_compile = (host != platform or host_bits != target_bits)
llvm = env["use_llvm"]

if platform == "windows":
if not (is_win_host(env) or env.get("is_msvc", False)):
if target_bits == "64":
return ["--cross-compile-prefix=x86_64-w64-mingw32-"]
if llvm:
if target_bits == "64":
return ["--cross-compile-prefix=x86_64-w64-mingw32-"]
else:
return ["--cross-compile-prefix=i686-w64-mingw32-"]
else:
return ["--cross-compile-prefix=i686-w64-mingw32-"]
if target_bits == "64":
return ["--cross-compile-prefix=mingw-w64-x86_64-gcc"]
else:
return ["--cross-compile-prefix=mingw-w64-i686-gcc"]





elif platform == "linuxbsd":
if is_cross_compile:
Expand Down Expand Up @@ -162,11 +178,13 @@ def get_target(env):
return "VC-WIN32"
if arch == "x86_64":
return "VC-WIN64A"
if arch == "arm32":
return "VC-WIN64-ARM"
else:
if arch == "x86_32":
return "mingw"
if arch == "x86_64":
return "mingw64"
return "mingw"

elif platform == "macos":
llvm = env["use_llvm"] == True
Expand Down

0 comments on commit 40e7aaf

Please sign in to comment.