mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 06:03:09 +00:00
Implement a way to dump the gdnative_interface.h file from the executable
This commit is contained in:
parent
5aadc618b6
commit
55010a2d9f
1
.gitignore
vendored
1
.gitignore
vendored
@ -37,6 +37,7 @@ platform/windows/godot_res.res
|
||||
|
||||
# Generated by Godot binary
|
||||
.import/
|
||||
/gdnative_interface.h
|
||||
extension_api.json
|
||||
logs/
|
||||
|
||||
|
@ -3,10 +3,15 @@
|
||||
Import("env")
|
||||
|
||||
import make_wrappers
|
||||
import make_interface_dumper
|
||||
from platform_methods import run_in_subprocess
|
||||
|
||||
env.CommandNoCache(["ext_wrappers.gen.inc"], "make_wrappers.py", run_in_subprocess(make_wrappers.run))
|
||||
|
||||
env.CommandNoCache(
|
||||
"gdnative_interface_dump.gen.h",
|
||||
["gdnative_interface.h", "make_interface_dumper.py"],
|
||||
run_in_subprocess(make_interface_dumper.run),
|
||||
)
|
||||
|
||||
env_extension = env.Clone()
|
||||
|
||||
|
47
core/extension/make_interface_dumper.py
Normal file
47
core/extension/make_interface_dumper.py
Normal file
@ -0,0 +1,47 @@
|
||||
def run(target, source, env):
|
||||
src = source[0]
|
||||
dst = target[0]
|
||||
f = open(src, "r", encoding="utf-8")
|
||||
g = open(dst, "w", encoding="utf-8")
|
||||
|
||||
g.write(
|
||||
"""/* THIS FILE IS GENERATED DO NOT EDIT */
|
||||
#ifndef GDNATIVE_INTERFACE_DUMP_H
|
||||
#define GDNATIVE_INTERFACE_DUMP_H
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
#include "core/io/file_access.h"
|
||||
#include "core/string/ustring.h"
|
||||
|
||||
class GDNativeInterfaceDump {
|
||||
private:
|
||||
static constexpr char const *gdnative_interface_dump ="""
|
||||
)
|
||||
for line in f:
|
||||
g.write('"' + line.rstrip().replace('"', '\\"') + '\\n"\n')
|
||||
g.write(";\n")
|
||||
|
||||
g.write(
|
||||
"""
|
||||
public:
|
||||
static void generate_gdnative_interface_file(const String &p_path) {
|
||||
Ref<FileAccess> fa = FileAccess::open(p_path, FileAccess::WRITE);
|
||||
CharString cs(gdnative_interface_dump);
|
||||
fa->store_buffer((const uint8_t *)cs.ptr(), cs.length());
|
||||
};
|
||||
};
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
#endif // GDNATIVE_INTERFACE_DUMP_H
|
||||
"""
|
||||
)
|
||||
g.close()
|
||||
f.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from platform_methods import subprocess_main
|
||||
|
||||
subprocess_main(globals())
|
@ -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 [<path>] Dump the engine API reference to the given <path> (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 <path> 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;
|
||||
}
|
||||
|
||||
|
6
misc/dist/linux/godot.6
vendored
6
misc/dist/linux/godot.6
vendored
@ -150,6 +150,12 @@ Disallow dumping the base types (used with \fB\-\-doctool\fR).
|
||||
\fB\-\-build\-solutions\fR
|
||||
Build the scripting solutions (e.g. for C# projects). Implies \-\-editor and requires a valid project to edit.
|
||||
.TP
|
||||
\fB\-\-dump\-gdextension\-interface\fR
|
||||
Generate GDExtension header file 'gdnative_interface.h' in the current folder. This file is the base file required to implement a GDExtension.
|
||||
.TP
|
||||
\fB\-\-dump\-extension\-api\fR
|
||||
Generate JSON dump of the Godot API for GDExtension bindings named 'extension_api.json' in the current folder.
|
||||
.TP
|
||||
\fB\-\-test\fR <test>
|
||||
Run a unit test ('string', 'math', 'physics', 'physics_2d', 'render', 'oa_hash_map', 'gui', 'shaderlang', 'gd_tokenizer', 'gd_parser', 'gd_compiler', 'gd_bytecode', 'ordered_hash_map', 'astar').
|
||||
.SH FILES
|
||||
|
1
misc/dist/shell/_godot.zsh-completion
vendored
1
misc/dist/shell/_godot.zsh-completion
vendored
@ -84,5 +84,6 @@ _arguments \
|
||||
'--doctool[dump the engine API reference to the given path in XML format, merging if existing files are found]:path to base Godot build directory (optional):_dirs' \
|
||||
'--no-docbase[disallow dumping the base types (used with --doctool)]' \
|
||||
'--build-solutions[build the scripting solutions (e.g. for C# projects)]' \
|
||||
'--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.]' \
|
||||
'--dump-extension-api[generate JSON dump of the Godot API for GDExtension bindings named "extension_api.json" in the current folder]' \
|
||||
'--test[run all unit tests; run with "--test --help" for more information]'
|
||||
|
1
misc/dist/shell/godot.bash-completion
vendored
1
misc/dist/shell/godot.bash-completion
vendored
@ -86,6 +86,7 @@ _complete_godot_options() {
|
||||
--doctool
|
||||
--no-docbase
|
||||
--build-solutions
|
||||
--dump-gdextension-interface
|
||||
--dump-extension-api
|
||||
--test
|
||||
" -- "$1"))
|
||||
|
1
misc/dist/shell/godot.fish
vendored
1
misc/dist/shell/godot.fish
vendored
@ -106,5 +106,6 @@ complete -c godot -l validate-conversion-3to4 -d "Shows what elements will be re
|
||||
complete -c godot -l doctool -d "Dump the engine API reference to the given path in XML format, merging if existing files are found" -r
|
||||
complete -c godot -l no-docbase -d "Disallow dumping the base types (used with --doctool)"
|
||||
complete -c godot -l build-solutions -d "Build the scripting solutions (e.g. for C# projects)"
|
||||
complete -c godot -l dump-gdextension-interface -d "Generate GDExtension header file 'gdnative_interface.h' in the current folder. This file is the base file required to implement a GDExtension"
|
||||
complete -c godot -l dump-extension-api -d "Generate JSON dump of the Godot API for GDExtension bindings named 'extension_api.json' in the current folder"
|
||||
complete -c godot -l test -d "Run all unit tests; run with '--test --help' for more information" -x
|
||||
|
Loading…
Reference in New Issue
Block a user