Merge pull request #92336 from van800/DAP
[DAP] Add `--dap-port` as a command line argument
This commit is contained in:
commit
cd8bd0380d
|
@ -35,6 +35,8 @@
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
|
|
||||||
|
int DebugAdapterServer::port_override = -1;
|
||||||
|
|
||||||
DebugAdapterServer::DebugAdapterServer() {
|
DebugAdapterServer::DebugAdapterServer() {
|
||||||
_EDITOR_DEF("network/debug_adapter/remote_port", remote_port);
|
_EDITOR_DEF("network/debug_adapter/remote_port", remote_port);
|
||||||
_EDITOR_DEF("network/debug_adapter/request_timeout", protocol._request_timeout);
|
_EDITOR_DEF("network/debug_adapter/request_timeout", protocol._request_timeout);
|
||||||
|
@ -67,7 +69,7 @@ void DebugAdapterServer::_notification(int p_what) {
|
||||||
}
|
}
|
||||||
protocol._request_timeout = EDITOR_GET("network/debug_adapter/request_timeout");
|
protocol._request_timeout = EDITOR_GET("network/debug_adapter/request_timeout");
|
||||||
protocol._sync_breakpoints = EDITOR_GET("network/debug_adapter/sync_breakpoints");
|
protocol._sync_breakpoints = EDITOR_GET("network/debug_adapter/sync_breakpoints");
|
||||||
int port = _EDITOR_GET("network/debug_adapter/remote_port");
|
int port = (DebugAdapterServer::port_override > -1) ? DebugAdapterServer::port_override : (int)_EDITOR_GET("network/debug_adapter/remote_port");
|
||||||
if (port != remote_port) {
|
if (port != remote_port) {
|
||||||
stop();
|
stop();
|
||||||
start();
|
start();
|
||||||
|
@ -77,9 +79,9 @@ void DebugAdapterServer::_notification(int p_what) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugAdapterServer::start() {
|
void DebugAdapterServer::start() {
|
||||||
remote_port = (int)_EDITOR_GET("network/debug_adapter/remote_port");
|
remote_port = (DebugAdapterServer::port_override > -1) ? DebugAdapterServer::port_override : (int)_EDITOR_GET("network/debug_adapter/remote_port");
|
||||||
if (protocol.start(remote_port, IPAddress("127.0.0.1")) == OK) {
|
if (protocol.start(remote_port, IPAddress("127.0.0.1")) == OK) {
|
||||||
EditorNode::get_log()->add_message("--- Debug adapter server started ---", EditorLog::MSG_TYPE_EDITOR);
|
EditorNode::get_log()->add_message("--- Debug adapter server started on port " + itos(remote_port) + " ---", EditorLog::MSG_TYPE_EDITOR);
|
||||||
set_process_internal(true);
|
set_process_internal(true);
|
||||||
started = true;
|
started = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ private:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static int port_override;
|
||||||
DebugAdapterServer();
|
DebugAdapterServer();
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
|
@ -90,6 +90,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
|
#include "editor/debugger/debug_adapter/debug_adapter_server.h"
|
||||||
#include "editor/debugger/editor_debugger_node.h"
|
#include "editor/debugger/editor_debugger_node.h"
|
||||||
#include "editor/doc_data_class_path.gen.h"
|
#include "editor/doc_data_class_path.gen.h"
|
||||||
#include "editor/doc_tools.h"
|
#include "editor/doc_tools.h"
|
||||||
|
@ -518,8 +519,9 @@ void Main::print_help(const char *p_binary) {
|
||||||
print_help_option("-e, --editor", "Start the editor instead of running the scene.\n", CLI_OPTION_AVAILABILITY_EDITOR);
|
print_help_option("-e, --editor", "Start the editor instead of running the scene.\n", CLI_OPTION_AVAILABILITY_EDITOR);
|
||||||
print_help_option("-p, --project-manager", "Start the project manager, even if a project is auto-detected.\n", CLI_OPTION_AVAILABILITY_EDITOR);
|
print_help_option("-p, --project-manager", "Start the project manager, even if a project is auto-detected.\n", CLI_OPTION_AVAILABILITY_EDITOR);
|
||||||
print_help_option("--debug-server <uri>", "Start the editor debug server (<protocol>://<host/IP>[:port], e.g. tcp://127.0.0.1:6007)\n", CLI_OPTION_AVAILABILITY_EDITOR);
|
print_help_option("--debug-server <uri>", "Start the editor debug server (<protocol>://<host/IP>[:port], e.g. tcp://127.0.0.1:6007)\n", CLI_OPTION_AVAILABILITY_EDITOR);
|
||||||
|
print_help_option("--dap-port <port>", "Use the specified port for the GDScript Debugger Adaptor protocol. Recommended port range [1024, 49151].\n", CLI_OPTION_AVAILABILITY_EDITOR);
|
||||||
#if defined(MODULE_GDSCRIPT_ENABLED) && !defined(GDSCRIPT_NO_LSP)
|
#if defined(MODULE_GDSCRIPT_ENABLED) && !defined(GDSCRIPT_NO_LSP)
|
||||||
print_help_option("--lsp-port <port>", "Use the specified port for the GDScript language server protocol. The port should be between 1025 and 49150.\n", CLI_OPTION_AVAILABILITY_EDITOR);
|
print_help_option("--lsp-port <port>", "Use the specified port for the GDScript language server protocol. Recommended port range [1024, 49151].\n", CLI_OPTION_AVAILABILITY_EDITOR);
|
||||||
#endif // MODULE_GDSCRIPT_ENABLED && !GDSCRIPT_NO_LSP
|
#endif // MODULE_GDSCRIPT_ENABLED && !GDSCRIPT_NO_LSP
|
||||||
#endif
|
#endif
|
||||||
print_help_option("--quit", "Quit after the first iteration.\n");
|
print_help_option("--quit", "Quit after the first iteration.\n");
|
||||||
|
@ -1714,6 +1716,21 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
#endif // TOOLS_ENABLED && MODULE_GDSCRIPT_ENABLED && !GDSCRIPT_NO_LSP
|
#endif // TOOLS_ENABLED && MODULE_GDSCRIPT_ENABLED && !GDSCRIPT_NO_LSP
|
||||||
|
#if defined(TOOLS_ENABLED)
|
||||||
|
} else if (arg == "--dap-port") {
|
||||||
|
if (N) {
|
||||||
|
int port_override = N->get().to_int();
|
||||||
|
if (port_override < 0 || port_override > 65535) {
|
||||||
|
OS::get_singleton()->print("<port> argument for --dap-port <port> must be between 0 and 65535.\n");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
DebugAdapterServer::port_override = port_override;
|
||||||
|
N = N->next();
|
||||||
|
} else {
|
||||||
|
OS::get_singleton()->print("Missing <port> argument for --dap-port <port>.\n");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
#endif // TOOLS_ENABLED
|
||||||
} else if (arg == "--" || arg == "++") {
|
} else if (arg == "--" || arg == "++") {
|
||||||
adding_user_args = true;
|
adding_user_args = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue