Add disable_pty compile option

If disable_pty=yes then the PTY node and dependencies (LibuvUtils, Pipe)
will be excluded. On platforms where the PTY node is not supported (e.g.
HTML5), this will always be equivalent to `disable_pty=yes`.
This commit is contained in:
Leroy Hopson 2021-07-07 21:26:48 +07:00
parent 29ff3efc49
commit 44ea56aa0f
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
2 changed files with 12 additions and 2 deletions

View file

@ -62,6 +62,11 @@ opts.Add(EnumVariable(
allowed_values=('debug', 'release'),
ignorecase=2
))
opts.Add(BoolVariable(
'disable_pty',
'Disables the PTY and its dependencies (LibuvUtils and Pipe). Has no effect on platforms where PTY is not supported',
False
))
opts.Update(env)
Help(opts.GenerateHelpText(env))
@ -258,8 +263,11 @@ sources = []
sources.append('src/libgodotxtermnative.cpp')
sources.append('src/terminal.cpp')
# PTY not supported on HTML5 or Windows (yet).
if env['platform'] != 'javascript' and env['platform'] != 'windows':
if env['disable_pty'] or env['platform'] == 'javascript' or env['platform'] == 'windows':
env.Append(CPPDEFINES=['_PTY_DISABLED'])
else:
sources.append('src/pipe.cpp')
sources.append('src/libuv_utils.cpp')
sources.append('src/node_pty/unix/pty.cc')

View file

@ -18,9 +18,11 @@ godot_gdnative_terminate(godot_gdnative_terminate_options *o) {
extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
godot::Godot::nativescript_init(handle);
godot::register_tool_class<godot::Terminal>();
#if !defined(__EMSCRIPTEN__) && !defined(__WIN32)
#if !defined(_PTY_DISABLED)
godot::register_tool_class<godot::Pipe>();
godot::register_tool_class<godot::LibuvUtils>();
#if defined(__unix__)
godot::register_tool_class<godot::PTYUnix>();
#endif
#endif
}