From 55010a2d9f91798f08bd2deded9445a4354ee3ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gilles=20Roudi=C3=A8re?= Date: Wed, 12 Oct 2022 16:21:34 +0200 Subject: Implement a way to dump the gdnative_interface.h file from the executable --- main/main.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'main') diff --git a/main/main.cpp b/main/main.cpp index 08a9b4c310..85415e24d2 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -36,6 +36,7 @@ #include "core/crypto/crypto.h" #include "core/debugger/engine_debugger.h" #include "core/extension/extension_api_dump.h" +#include "core/extension/gdnative_interface_dump.gen.h" #include "core/extension/native_extension_manager.h" #include "core/input/input.h" #include "core/input/input_map.h" @@ -199,6 +200,7 @@ static MovieWriter *movie_writer = nullptr; static bool disable_vsync = false; static bool print_fps = false; #ifdef TOOLS_ENABLED +static bool dump_gdnative_interface = false; static bool dump_extension_api = false; #endif bool profile_gpu = false; @@ -414,6 +416,7 @@ void Main::print_help(const char *p_binary) { OS::get_singleton()->print(" --doctool [] Dump the engine API reference to the given (defaults to current dir) in XML format, merging if existing files are found.\n"); OS::get_singleton()->print(" --no-docbase Disallow dumping the base types (used with --doctool).\n"); OS::get_singleton()->print(" --build-solutions Build the scripting solutions (e.g. for C# projects). Implies --editor and requires a valid project to edit.\n"); + OS::get_singleton()->print(" --dump-gdextension-interface Generate GDExtension header file 'gdnative_interface.h' in the current folder. This file is the base file required to implement a GDExtension.\n"); OS::get_singleton()->print(" --dump-extension-api Generate JSON dump of the Godot API for GDExtension bindings named 'extension_api.json' in the current folder.\n"); OS::get_singleton()->print(" --startup-benchmark Benchmark the startup time and print it to console.\n"); OS::get_singleton()->print(" --startup-benchmark-file Benchmark the startup time and save it to a given file in JSON format.\n"); @@ -1054,6 +1057,16 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph auto_build_solutions = true; editor = true; cmdline_tool = true; + } else if (I->get() == "--dump-gdextension-interface") { + // Register as an editor instance to use low-end fallback if relevant. + editor = true; + cmdline_tool = true; + dump_gdnative_interface = true; + print_line("Dumping gdnative interface header file"); + // Hack. Not needed but otherwise we end up detecting that this should + // run the project instead of a cmdline tool. + // Needs full refactoring to fix properly. + main_args.push_back(I->get()); } else if (I->get() == "--dump-extension-api") { // Register as an editor instance to use low-end fallback if relevant. editor = true; @@ -2549,8 +2562,15 @@ bool Main::start() { return false; } + if (dump_gdnative_interface) { + GDNativeInterfaceDump::generate_gdnative_interface_file("gdnative_interface.h"); + } + if (dump_extension_api) { NativeExtensionAPIDump::generate_extension_json_file("extension_api.json"); + } + + if (dump_gdnative_interface || dump_extension_api) { return false; } -- cgit v1.2.3