Auto-Increment Debugger Port
Note: This PR also changes the port of the GDScript Language Server from 6008 to 6005. This opens enough ports above the debug port (6007) for this change to be useful.
This commit is contained in:
parent
2a9dd654bc
commit
de7873c2d8
10 changed files with 106 additions and 48 deletions
|
|
@ -31,6 +31,7 @@
|
|||
#include "editor_run.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor_settings.h"
|
||||
#include "servers/display_server.h"
|
||||
|
||||
|
|
@ -42,20 +43,17 @@ String EditorRun::get_running_scene() const {
|
|||
return running_scene;
|
||||
}
|
||||
|
||||
Error EditorRun::run(const String &p_scene, const String &p_custom_args, const List<String> &p_breakpoints, const bool &p_skip_breakpoints) {
|
||||
Error EditorRun::run(const String &p_scene) {
|
||||
List<String> args;
|
||||
|
||||
String resource_path = ProjectSettings::get_singleton()->get_resource_path();
|
||||
String remote_host = EditorSettings::get_singleton()->get("network/debug/remote_host");
|
||||
int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
|
||||
|
||||
if (resource_path != "") {
|
||||
if (!resource_path.is_empty()) {
|
||||
args.push_back("--path");
|
||||
args.push_back(resource_path.replace(" ", "%20"));
|
||||
}
|
||||
|
||||
args.push_back("--remote-debug");
|
||||
args.push_back("tcp://" + remote_host + ":" + String::num(remote_port));
|
||||
args.push_back(EditorDebuggerNode::get_singleton()->get_server_uri());
|
||||
|
||||
args.push_back("--allow_focus_steal_pid");
|
||||
args.push_back(itos(OS::get_singleton()->get_process_id()));
|
||||
|
|
@ -162,10 +160,13 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
|
|||
} break;
|
||||
}
|
||||
|
||||
if (p_breakpoints.size()) {
|
||||
List<String> breakpoints;
|
||||
EditorNode::get_editor_data().get_editor_breakpoints(&breakpoints);
|
||||
|
||||
if (!breakpoints.is_empty()) {
|
||||
args.push_back("--breakpoints");
|
||||
String bpoints;
|
||||
for (const List<String>::Element *E = p_breakpoints.front(); E; E = E->next()) {
|
||||
for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) {
|
||||
bpoints += E->get().replace(" ", "%20");
|
||||
if (E->next()) {
|
||||
bpoints += ",";
|
||||
|
|
@ -175,7 +176,7 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
|
|||
args.push_back(bpoints);
|
||||
}
|
||||
|
||||
if (p_skip_breakpoints) {
|
||||
if (EditorDebuggerNode::get_singleton()->is_skip_breakpoints()) {
|
||||
args.push_back("--skip-breakpoints");
|
||||
}
|
||||
|
||||
|
|
@ -185,20 +186,21 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
|
|||
|
||||
String exec = OS::get_singleton()->get_executable_path();
|
||||
|
||||
if (p_custom_args != "") {
|
||||
const String raw_custom_args = ProjectSettings::get_singleton()->get("editor/run/main_run_args");
|
||||
if (!raw_custom_args.is_empty()) {
|
||||
// Allow the user to specify a command to run, similar to Steam's launch options.
|
||||
// In this case, Godot will no longer be run directly; it's up to the underlying command
|
||||
// to run it. For instance, this can be used on Linux to force a running project
|
||||
// to use Optimus using `prime-run` or similar.
|
||||
// Example: `prime-run %command% --time-scale 0.5`
|
||||
const int placeholder_pos = p_custom_args.find("%command%");
|
||||
const int placeholder_pos = raw_custom_args.find("%command%");
|
||||
|
||||
Vector<String> custom_args;
|
||||
|
||||
if (placeholder_pos != -1) {
|
||||
// Prepend executable-specific custom arguments.
|
||||
// If nothing is placed before `%command%`, behave as if no placeholder was specified.
|
||||
Vector<String> exec_args = p_custom_args.substr(0, placeholder_pos).split(" ", false);
|
||||
Vector<String> exec_args = raw_custom_args.substr(0, placeholder_pos).split(" ", false);
|
||||
if (exec_args.size() >= 1) {
|
||||
exec = exec_args[0];
|
||||
exec_args.remove_at(0);
|
||||
|
|
@ -214,13 +216,13 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
|
|||
}
|
||||
|
||||
// Append Godot-specific custom arguments.
|
||||
custom_args = p_custom_args.substr(placeholder_pos + String("%command%").size()).split(" ", false);
|
||||
custom_args = raw_custom_args.substr(placeholder_pos + String("%command%").size()).split(" ", false);
|
||||
for (int i = 0; i < custom_args.size(); i++) {
|
||||
args.push_back(custom_args[i].replace(" ", "%20"));
|
||||
}
|
||||
} else {
|
||||
// Append Godot-specific custom arguments.
|
||||
custom_args = p_custom_args.split(" ", false);
|
||||
custom_args = raw_custom_args.split(" ", false);
|
||||
for (int i = 0; i < custom_args.size(); i++) {
|
||||
args.push_back(custom_args[i].replace(" ", "%20"));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue