Skip to content

Commit fb18613

Browse files
committed
Merge branch 'feature/add-math-functions'
2 parents e1e2f9d + 03be636 commit fb18613

File tree

4 files changed

+52
-11
lines changed

4 files changed

+52
-11
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,7 @@ vsproj/x86/
6464
vsproj/gdsqlite.vcxproj.*
6565

6666
.vscode
67+
68+
# Python generated
69+
__pycache__/
70+
*.pyc

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,16 +346,22 @@ Follow the steps described in the Godot documentation as found [here](https://do
346346
ldd --version
347347
```
348348
349-
### 5. Does this plugin support the FTS5 Extension?
349+
### 5. Does this plugin support the XYZ Extension of SQLite?
350350
351-
Yes, the [SQLite FTS5 Extension](https://sqlite.org/fts5.html) is supported by this plugin, although it requires the user to re-compile the plugin.
351+
Following SQLite extensions are supported by this plugin, although they require the user to re-compile the plugin:
352352
353-
To re-compile the plugin with FTS5 enabled, follow the instructions as defined in the 'How to contribute?'-section below.
353+
| Extension | flag | default |
354+
|------------------------------------------------------------------------------|-----------------------|---------|
355+
| [SQLite FTS5 Extension](https://sqlite.org/fts5.html) | enable_fts5 | no |
356+
| [Built-In Mathematical SQL Functions](https://sqlite.org/lang_mathfunc.html) | enable_math_functions | no |
357+
358+
To re-compile the plugin with XYZ enabled, follow the instructions as defined in the 'How to contribute?'-section below.
354359
Depending on your choice, following modifications have to be made:
355360
356361
#### A. Using your own device
357362
358-
Add the `enable_fts5`-flag to the compilation command:
363+
Add the relevant flag(s), as defined in table above, to the compilation command.
364+
For example, if you want to enable the FTS5 Extension, use following command:
359365
360366
```
361367
scons platform=<platform> target_path=<target_path> target_name=libgdsqlite enable_fts5=yes

SConstruct

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
11
#!/usr/bin/env python
2+
from misc.utility.classes import CompileTimeOption
3+
4+
options: list = [
5+
CompileTimeOption(
6+
key="enable_fts5",
7+
name="FTS5",
8+
help="Enable SQLite's FTS5 extension which provides full-test search functionality to database applications",
9+
define="SQLITE_ENABLE_FTS5",
10+
default=False,
11+
),
12+
CompileTimeOption(
13+
key="enable_math_functions",
14+
name="MATH_FUNCTIONS",
15+
help="Enable SQLite's Built-in Mathematical SQL Functions",
16+
define="SQLITE_ENABLE_MATH_FUNCTIONS",
17+
default=False,
18+
),
19+
]
220

321
target_path = ARGUMENTS.pop("target_path", "demo/addons/godot-sqlite/bin/")
422
target_name = ARGUMENTS.pop("target_name", "libgdsqlite")
23+
parsed_options = {x.key: ARGUMENTS.pop(x.key, x.default) for x in options}
524

625
env = SConscript("godot-cpp/SConstruct")
726

827
env_vars = Variables()
9-
env_vars.Add(BoolVariable("enable_fts5", "Enable SQLite's FTS5 extension which provides full-test search functionality to database applications", False))
28+
option: CompileTimeOption
29+
[env_vars.Add(BoolVariable(x.key, x.help, False)) for x in options]
1030
env_vars.Update(env)
1131
Help(env_vars.GenerateHelpText(env))
1232

@@ -24,17 +44,19 @@ target = "{}{}".format(
2444

2545
# tweak this if you want to use different folders, or more folders, to store your source code in.
2646
env.Append(CPPPATH=["src/"])
27-
sources = [Glob('src/*.cpp'), Glob('src/vfs/*.cpp'), 'src/sqlite/sqlite3.c']
47+
sources = [Glob("src/*.cpp"), Glob("src/vfs/*.cpp"), "src/sqlite/sqlite3.c"]
2848

2949
if env["target"] in ["editor", "template_debug"]:
3050
doc_data = env.GodotCPPDocData("src/gen/doc_data.gen.cpp", source=Glob("doc_classes/*.xml"))
3151
sources.append(doc_data)
3252

33-
if env["enable_fts5"]:
34-
print("FTS5 is enabled.")
35-
env.Append(CPPDEFINES=['SQLITE_ENABLE_FTS5'])
36-
else:
37-
print("FTS5 is disabled.")
53+
option: CompileTimeOption
54+
for option in options:
55+
if parsed_options[option.key]:
56+
print(f"{option.name} is enabled.")
57+
env.Append(CPPDEFINES=[option.define])
58+
else:
59+
print(f"{option.name} is disabled.")
3860

3961
if env["platform"] == "macos":
4062
library = env.SharedLibrary(

misc/utility/classes.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from dataclasses import dataclass
2+
3+
@dataclass
4+
class CompileTimeOption:
5+
key: str
6+
name: str
7+
default: bool
8+
help: str
9+
define: str

0 commit comments

Comments
 (0)