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
321target_path = ARGUMENTS .pop ("target_path" , "demo/addons/godot-sqlite/bin/" )
422target_name = ARGUMENTS .pop ("target_name" , "libgdsqlite" )
23+ parsed_options = {x .key : ARGUMENTS .pop (x .key , x .default ) for x in options }
524
625env = SConscript ("godot-cpp/SConstruct" )
726
827env_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 ]
1030env_vars .Update (env )
1131Help (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.
2646env .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
2949if 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
3961if env ["platform" ] == "macos" :
4062 library = env .SharedLibrary (
0 commit comments