diff options
Diffstat (limited to 'modules/gdnative')
-rw-r--r-- | modules/gdnative/SCsub | 20 | ||||
-rw-r--r-- | modules/gdnative/gdnative_builders.py | 97 |
2 files changed, 0 insertions, 117 deletions
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub index 0cdd585558..a18c75fa27 100644 --- a/modules/gdnative/SCsub +++ b/modules/gdnative/SCsub @@ -30,23 +30,3 @@ _, gensource = env_gdnative.CommandNoCache(['include/gdnative_api_struct.gen.h', env_gdnative.add_source_files(env.modules_sources, [gensource]) env.use_ptrcall = True - - -if ARGUMENTS.get('gdnative_wrapper', False): - gensource, = env_gdnative.CommandNoCache('gdnative_wrapper_code.gen.cpp', 'gdnative_api.json', run_in_subprocess(gdnative_builders.build_gdnative_wrapper_code)) - - gd_wrapper_env = env.Clone() - gd_wrapper_env.Prepend(CPPPATH=['#modules/gdnative/include/']) - - if gd_wrapper_env['use_lto']: - if not env.msvc: - gd_wrapper_env.Append(CCFLAGS=['-fno-lto']) - gd_wrapper_env.Append(LINKFLAGS=['-fno-lto']) - else: - gd_wrapper_env.Append(CCFLAGS=['/GL-']) - gd_wrapper_env.Append(LINKFLAGS=['/LTCG:OFF']) - - if not env.msvc: - gd_wrapper_env.Append(CCFLAGS=['-fPIC']) - - lib = gd_wrapper_env.add_library("#bin/gdnative_wrapper_code", [gensource]) diff --git a/modules/gdnative/gdnative_builders.py b/modules/gdnative/gdnative_builders.py index 20c1a2233c..0d95a65b7e 100644 --- a/modules/gdnative/gdnative_builders.py +++ b/modules/gdnative/gdnative_builders.py @@ -12,30 +12,6 @@ def _spaced(e): def _build_gdnative_api_struct_header(api): - gdnative_api_init_macro = [ - '\textern const godot_gdnative_core_api_struct *_gdnative_wrapper_api_struct;' - ] - - for ext in api['extensions']: - name = ext['name'] - gdnative_api_init_macro.append( - '\textern const godot_gdnative_ext_{0}_api_struct *_gdnative_wrapper_{0}_api_struct;'.format(name)) - - gdnative_api_init_macro.append('\t_gdnative_wrapper_api_struct = options->api_struct;') - gdnative_api_init_macro.append('\tfor (unsigned int i = 0; i < _gdnative_wrapper_api_struct->num_extensions; i++) { ') - gdnative_api_init_macro.append('\t\tswitch (_gdnative_wrapper_api_struct->extensions[i]->type) {') - - for ext in api['extensions']: - name = ext['name'] - gdnative_api_init_macro.append( - '\t\t\tcase GDNATIVE_EXT_%s:' % ext['type']) - gdnative_api_init_macro.append( - '\t\t\t\t_gdnative_wrapper_{0}_api_struct = (godot_gdnative_ext_{0}_api_struct *)' - ' _gdnative_wrapper_api_struct->extensions[i];'.format(name)) - gdnative_api_init_macro.append('\t\t\t\tbreak;') - gdnative_api_init_macro.append('\t\t}') - gdnative_api_init_macro.append('\t}') - out = [ '/* THIS FILE IS GENERATED DO NOT EDIT */', '#ifndef GODOT_GDNATIVE_API_STRUCT_H', @@ -49,8 +25,6 @@ def _build_gdnative_api_struct_header(api): '#include <pluginscript/godot_pluginscript.h>', '#include <videodecoder/godot_videodecoder.h>', '', - '#define GDNATIVE_API_INIT(options) do { \\\n' + ' \\\n'.join(gdnative_api_init_macro) + ' \\\n } while (0)', - '', '#ifdef __cplusplus', 'extern "C" {', '#endif', @@ -238,76 +212,5 @@ def build_gdnative_api_struct(target, source, env): fd.write(_build_gdnative_api_struct_source(api)) -def _build_gdnative_wrapper_code(api): - out = [ - '/* THIS FILE IS GENERATED DO NOT EDIT */', - '', - '#include <gdnative/gdnative.h>', - '#include <nativescript/godot_nativescript.h>', - '#include <pluginscript/godot_pluginscript.h>', - '#include <arvr/godot_arvr.h>', - '#include <videodecoder/godot_videodecoder.h>', - '', - '#include <gdnative_api_struct.gen.h>', - '', - '#ifdef __cplusplus', - 'extern "C" {', - '#endif', - '', - 'godot_gdnative_core_api_struct *_gdnative_wrapper_api_struct = 0;', - ] - - for ext in api['extensions']: - name = ext['name'] - out.append('godot_gdnative_ext_' + name + '_api_struct *_gdnative_wrapper_' + name + '_api_struct = 0;') - - out += [''] - - for funcdef in api['core']['api']: - args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']]) - out.append('%s%s(%s) {' % (_spaced(funcdef['return_type']), funcdef['name'], args)) - - args = ', '.join(['%s' % n for t, n in funcdef['arguments']]) - - return_line = '\treturn ' if funcdef['return_type'] != 'void' else '\t' - return_line += '_gdnative_wrapper_api_struct->' + funcdef['name'] + '(' + args + ');' - - out.append(return_line) - out.append('}') - out.append('') - - for ext in api['extensions']: - name = ext['name'] - for funcdef in ext['api']: - args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']]) - out.append('%s%s(%s) {' % (_spaced(funcdef['return_type']), funcdef['name'], args)) - - args = ', '.join(['%s' % n for t, n in funcdef['arguments']]) - - return_line = '\treturn ' if funcdef['return_type'] != 'void' else '\t' - return_line += '_gdnative_wrapper_' + name + '_api_struct->' + funcdef['name'] + '(' + args + ');' - - out.append(return_line) - out.append('}') - out.append('') - - out += [ - '#ifdef __cplusplus', - '}', - '#endif' - ] - - return '\n'.join(out) - - -def build_gdnative_wrapper_code(target, source, env): - with open(source[0], 'r') as fd: - api = json.load(fd) - - wrapper_file = target[0] - with open(wrapper_file, 'w') as fd: - fd.write(_build_gdnative_wrapper_code(api)) - - if __name__ == '__main__': subprocess_main(globals()) |