Skip to content

Commit 0811d83

Browse files
committed
New GDNative API
This uses the new GDNative API from Godot 4. Major change is in the ability to wrap the builtin types as well, so we don't have to implement wrappers manually anymore (not on Godot side nor here). The bindings generator now takes that into account to create the new wrappers, including a case for utility functions, which are also exposed from Godot (like print() which now should be called from Utilities). A few special functions are still provided for convenience, like print_error(). Some builtin types that are used in math are reimplemented here with a copy from Godot source (with a few compatibility changes). This is so you can make use of inlined functions. It is possible that this might cause problems when marshalling from or to the engine, given difference in memory alignment between compilers. I haven't experienced this and that was pretty much already the case before, so it shouldn't be a problem.
1 parent 77d41fa commit 0811d83

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+6688
-7114
lines changed

SConstruct

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,23 @@ opts.Add(BoolVariable(
170170
"Generate a template version of the Node class's get_node.",
171171
True
172172
))
173+
opts.Add(BoolVariable(
174+
'use_precise_math_checks',
175+
'Math checks use very precise epsilon (debug option)',
176+
False
177+
))
178+
173179

174180
opts.Update(env)
175181
Help(opts.GenerateHelpText(env))
176182

183+
if env['target'] == 'debug':
184+
env.Append(CPPDEFINES=['MATH_CHECKS'])
185+
186+
if env["use_precise_math_checks"]:
187+
env.Append(CPPDEFINES=["PRECISE_MATH_CHECKS"])
188+
189+
177190
# This makes sure to keep the session environment variables on Windows.
178191
# This way, you can run SCons in a Visual Studio 2017 prompt and it will find
179192
# all the required tools
@@ -274,9 +287,11 @@ elif env['platform'] == 'windows':
274287
# MSVC
275288
env.Append(LINKFLAGS=['/WX'])
276289
if env['target'] == 'debug':
277-
env.Append(CCFLAGS=['/Z7', '/Od', '/EHsc', '/D_DEBUG', '/MDd'])
290+
env.Append(CCFLAGS=['/Z7', '/Od', '/EHsc', '/MDd'])
291+
env.Append(CPPDEFINES=['_DEBUG'])
278292
elif env['target'] == 'release':
279-
env.Append(CCFLAGS=['/O2', '/EHsc', '/DNDEBUG', '/MD'])
293+
env.Append(CCFLAGS=['/O2', '/EHsc', '/MD'])
294+
env.Append(CPPDEFINES=['NDEBUG'])
280295

281296
elif host_platform == 'linux' or host_platform == 'osx':
282297
# Cross-compilation using MinGW
@@ -290,7 +305,7 @@ elif env['platform'] == 'windows':
290305
env['AR'] = "i686-w64-mingw32-ar"
291306
env['RANLIB'] = "i686-w64-mingw32-ranlib"
292307
env['LINK'] = "i686-w64-mingw32-g++"
293-
308+
294309
elif host_platform == 'windows' and env['use_mingw']:
295310
# Don't Clone the environment. Because otherwise, SCons will pick up msvc stuff.
296311
env = Environment(ENV = os.environ, tools=["mingw"])
@@ -381,17 +396,24 @@ env.Append(CPPPATH=[
381396

382397
# Generate bindings?
383398
json_api_file = ''
399+
json_builtin_api_file = ''
384400

385401
if 'custom_api_file' in env:
386402
json_api_file = env['custom_api_file']
387403
else:
388404
json_api_file = os.path.join(os.getcwd(), env['headers_dir'], 'api.json')
389405

406+
if 'custom_builtin_api_file' in env:
407+
json_builtin_api_file = env['custom_builtin_api_file']
408+
else:
409+
json_builtin_api_file = os.path.join(os.getcwd(), env['headers_dir'], 'builtin_api.json')
410+
390411
if env['generate_bindings']:
391412
# Actually create the bindings here
392413
import binding_generator
393414

394415
binding_generator.generate_bindings(json_api_file, env['generate_template_get_node'])
416+
binding_generator.generate_builtin_bindings(json_builtin_api_file)
395417

396418
# Sources to compile
397419
sources = []

0 commit comments

Comments
 (0)