You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-04 17:04:49 +00:00
Merge pull request #111909 from bruvzg/mods_are_bad_they_make_you_mad
Disable some unsafe CLI arguments in template builds by default.
This commit is contained in:
138
main/main.cpp
138
main/main.cpp
@@ -487,6 +487,9 @@ void Main::print_help_option(const char *p_option, const char *p_description, CL
|
||||
case CLI_OPTION_AVAILABILITY_TEMPLATE_DEBUG:
|
||||
availability_badge = "\u001b[1;94mD";
|
||||
break;
|
||||
case CLI_OPTION_AVAILABILITY_TEMPLATE_UNSAFE:
|
||||
availability_badge = "\u001b[1;93mX";
|
||||
break;
|
||||
case CLI_OPTION_AVAILABILITY_TEMPLATE_RELEASE:
|
||||
availability_badge = "\u001b[1;92mR";
|
||||
break;
|
||||
@@ -529,6 +532,9 @@ void Main::print_help(const char *p_binary) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
OS::get_singleton()->print(" \u001b[1;94mD\u001b[0m Available in editor builds and debug export templates only.\n");
|
||||
#endif
|
||||
#if defined(OVERRIDE_PATH_ENABLED)
|
||||
OS::get_singleton()->print(" \u001b[1;93mX\u001b[0m Only available in editor builds, and export templates compiled with `disable_path_overrides=false`.\n");
|
||||
#endif
|
||||
#ifdef TOOLS_ENABLED
|
||||
OS::get_singleton()->print(" \u001b[1;91mE\u001b[0m Only available in editor builds.\n");
|
||||
#endif
|
||||
@@ -555,21 +561,20 @@ void Main::print_help(const char *p_binary) {
|
||||
print_help_option("--quit", "Quit after the first iteration.\n");
|
||||
print_help_option("--quit-after <int>", "Quit after the given number of iterations. Set to 0 to disable.\n");
|
||||
print_help_option("-l, --language <locale>", "Use a specific locale (<locale> being a two-letter code).\n");
|
||||
print_help_option("--path <directory>", "Path to a project (<directory> must contain a \"project.godot\" file).\n");
|
||||
#ifdef OVERRIDE_ENABLED
|
||||
print_help_option("--scene <path>", "Path or UID of a scene in the project that should be started.\n");
|
||||
print_help_option("-u, --upwards", "Scan folders upwards for project.godot file.\n");
|
||||
print_help_option("--main-pack <file>", "Path to a pack (.pck) file to load.\n");
|
||||
#endif // OVERRIDE_ENABLED
|
||||
#if defined(OVERRIDE_PATH_ENABLED)
|
||||
print_help_option("--path <directory>", "Path to a project (<directory> must contain a \"project.godot\" file).\n", CLI_OPTION_AVAILABILITY_TEMPLATE_UNSAFE);
|
||||
print_help_option("--scene <path>", "Path or UID of a scene in the project that should be started.\n", CLI_OPTION_AVAILABILITY_TEMPLATE_UNSAFE);
|
||||
print_help_option("--main-pack <file>", "Path to a pack (.pck) file to load.\n", CLI_OPTION_AVAILABILITY_TEMPLATE_UNSAFE);
|
||||
#endif // defined(OVERRIDE_PATH_ENABLED)
|
||||
#ifdef DISABLE_DEPRECATED
|
||||
print_help_option("--render-thread <mode>", "Render thread mode (\"safe\", \"separate\").\n");
|
||||
#else
|
||||
print_help_option("--render-thread <mode>", "Render thread mode (\"unsafe\" [deprecated], \"safe\", \"separate\").\n");
|
||||
#endif // DISABLE_DEPRECATED
|
||||
#ifdef OVERRIDE_ENABLED
|
||||
print_help_option("--remote-fs <address>", "Remote filesystem (<host/IP>[:<port>] address).\n");
|
||||
print_help_option("--remote-fs-password <password>", "Password for remote filesystem.\n");
|
||||
#endif // OVERRIDE_ENABLED
|
||||
#if defined(DEBUG_ENABLED) || defined(TOOLS_ENABLED)
|
||||
print_help_option("--remote-fs <address>", "Remote filesystem (<host/IP>[:<port>] address).\n", CLI_OPTION_AVAILABILITY_TEMPLATE_DEBUG);
|
||||
print_help_option("--remote-fs-password <password>", "Password for remote filesystem.\n", CLI_OPTION_AVAILABILITY_TEMPLATE_DEBUG);
|
||||
#endif // defined(DEBUG_ENABLED) || defined (TOOLS_ENABLED)
|
||||
|
||||
print_help_option("--audio-driver <driver>", "Audio driver [");
|
||||
for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) {
|
||||
@@ -642,9 +647,11 @@ void Main::print_help(const char *p_binary) {
|
||||
print_help_option("--extra-gpu-memory-tracking", "Enables additional memory tracking (see class reference for `RenderingDevice.get_driver_and_device_memory_report()` and linked methods). Currently only implemented for Vulkan. Enabling this feature may cause crashes on some systems due to buggy drivers or bugs in the Vulkan Loader. See https://github.com/godotengine/godot/issues/95967\n");
|
||||
print_help_option("--accurate-breadcrumbs", "Force barriers between breadcrumbs. Useful for narrowing down a command causing GPU resets. Currently only implemented for Vulkan.\n");
|
||||
#endif
|
||||
#if defined(DEBUG_ENABLED) || defined(TOOLS_ENABLED)
|
||||
print_help_option("--remote-debug <uri>", "Remote debug (<protocol>://<host/IP>[:<port>], e.g. tcp://127.0.0.1:6007).\n");
|
||||
#endif
|
||||
print_help_option("--single-threaded-scene", "Force scene tree to run in single-threaded mode. Sub-thread groups are disabled and run on the main thread.\n");
|
||||
#if defined(DEBUG_ENABLED)
|
||||
#ifdef DEBUG_ENABLED
|
||||
print_help_option("--debug-collisions", "Show collision shapes when running the scene.\n", CLI_OPTION_AVAILABILITY_TEMPLATE_DEBUG);
|
||||
print_help_option("--debug-paths", "Show path lines when running the scene.\n", CLI_OPTION_AVAILABILITY_TEMPLATE_DEBUG);
|
||||
print_help_option("--debug-navigation", "Show navigation polygons when running the scene.\n", CLI_OPTION_AVAILABILITY_TEMPLATE_DEBUG);
|
||||
@@ -666,12 +673,14 @@ void Main::print_help(const char *p_binary) {
|
||||
print_help_option("--editor-pseudolocalization", "Enable pseudolocalization for the editor and the project manager.\n", CLI_OPTION_AVAILABILITY_EDITOR);
|
||||
#endif
|
||||
|
||||
#ifdef OVERRIDE_ENABLED
|
||||
#if defined(OVERRIDE_PATH_ENABLED) || defined(TESTS_ENABLED)
|
||||
print_help_title("Standalone tools");
|
||||
print_help_option("-s, --script <script>", "Run a script.\n");
|
||||
print_help_option("--main-loop <main_loop_name>", "Run a MainLoop specified by its global class name.\n");
|
||||
print_help_option("--check-only", "Only parse for errors and quit (use with --script).\n");
|
||||
#endif // OVERRIDE_ENABLED
|
||||
#endif // defined(OVERRIDE_PATH_ENABLED) || defined(TESTS_ENABLED)
|
||||
#if defined(OVERRIDE_PATH_ENABLED)
|
||||
print_help_option("-s, --script <script>", "Run a script.\n", CLI_OPTION_AVAILABILITY_TEMPLATE_UNSAFE);
|
||||
print_help_option("--main-loop <main_loop_name>", "Run a MainLoop specified by its global class name.\n", CLI_OPTION_AVAILABILITY_TEMPLATE_UNSAFE);
|
||||
print_help_option("--check-only", "Only parse for errors and quit (use with --script).\n", CLI_OPTION_AVAILABILITY_TEMPLATE_UNSAFE);
|
||||
#endif // defined(OVERRIDE_PATH_ENABLED)
|
||||
#ifdef TOOLS_ENABLED
|
||||
print_help_option("--import", "Starts the editor, waits for any resources to be imported, and then quits.\n", CLI_OPTION_AVAILABILITY_EDITOR);
|
||||
print_help_option("--export-release <preset> <path>", "Export the project in release mode using the given preset and output path. The preset name should match one defined in \"export_presets.cfg\".\n", CLI_OPTION_AVAILABILITY_EDITOR);
|
||||
@@ -980,6 +989,20 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
|
||||
OS::get_singleton()->initialize();
|
||||
|
||||
#if !defined(OVERRIDE_PATH_ENABLED) && !defined(TOOLS_ENABLED)
|
||||
#ifdef MACOS_ENABLED
|
||||
String new_cwd = OS::get_singleton()->get_bundle_resource_dir();
|
||||
if (new_cwd.is_empty() || !new_cwd.is_absolute_path()) {
|
||||
new_cwd = OS::get_singleton()->get_executable_path().get_base_dir();
|
||||
}
|
||||
#else
|
||||
String new_cwd = OS::get_singleton()->get_executable_path().get_base_dir();
|
||||
#endif
|
||||
if (!new_cwd.is_empty()) {
|
||||
OS::get_singleton()->set_cwd(new_cwd);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Benchmark tracking must be done after `OS::get_singleton()->initialize()` as on some
|
||||
// platforms, it's used to set up the time utilities.
|
||||
OS::get_singleton()->benchmark_begin_measure("Startup", "Main::Setup");
|
||||
@@ -1036,7 +1059,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
|
||||
String audio_driver = "";
|
||||
String project_path = ".";
|
||||
bool upwards = false;
|
||||
String debug_uri = "";
|
||||
#if defined(TOOLS_ENABLED) && (defined(WINDOWS_ENABLED) || defined(LINUXBSD_ENABLED))
|
||||
bool test_rd_creation = false;
|
||||
@@ -1447,9 +1469,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
OS::get_singleton()->print("Missing language argument, aborting.\n");
|
||||
goto error;
|
||||
}
|
||||
#ifdef OVERRIDE_ENABLED
|
||||
} else if (arg == "--remote-fs") { // remote filesystem
|
||||
|
||||
#if defined(DEBUG_ENABLED) || defined(TOOLS_ENABLED)
|
||||
if (N) {
|
||||
remotefs = N->get();
|
||||
N = N->next();
|
||||
@@ -1457,8 +1479,14 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
OS::get_singleton()->print("Missing remote filesystem address, aborting.\n");
|
||||
goto error;
|
||||
}
|
||||
#else
|
||||
ERR_PRINT(
|
||||
"`--remote-fs` was specified on the command line, but this Godot binary was compiled without debug. Aborting.\n"
|
||||
"To be able to use it, use the `target=template_debug` SCons option when compiling Godot.\n");
|
||||
#endif // defined(DEBUG_ENABLED) || defined (TOOLS_ENABLED)
|
||||
} else if (arg == "--remote-fs-password") { // remote filesystem password
|
||||
|
||||
#if defined(DEBUG_ENABLED) || defined(TOOLS_ENABLED)
|
||||
if (N) {
|
||||
remotefs_pass = N->get();
|
||||
N = N->next();
|
||||
@@ -1466,7 +1494,12 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
OS::get_singleton()->print("Missing remote filesystem password, aborting.\n");
|
||||
goto error;
|
||||
}
|
||||
#endif // OVERRIDE_ENABLED
|
||||
#else
|
||||
ERR_PRINT(
|
||||
"`--remote-fs-password` was specified on the command line, but this Godot binary was compiled without debug. Aborting.\n"
|
||||
"To be able to use it, use the `target=template_debug` SCons option when compiling Godot.\n");
|
||||
goto error;
|
||||
#endif // defined(DEBUG_ENABLED) || defined (TOOLS_ENABLED)
|
||||
} else if (arg == "--render-thread") { // render thread mode
|
||||
|
||||
if (N) {
|
||||
@@ -1654,8 +1687,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
}
|
||||
#endif // MODULE_GDSCRIPT_ENABLED
|
||||
#endif // TOOLS_ENABLED
|
||||
} else if (arg == "--path") { // set path of project to start or edit
|
||||
|
||||
} else if (arg == "--path") { // set path of project to start or edit
|
||||
#if defined(OVERRIDE_PATH_ENABLED)
|
||||
if (N) {
|
||||
String p = N->get();
|
||||
if (OS::get_singleton()->set_cwd(p) != OK) {
|
||||
@@ -1667,10 +1701,12 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
OS::get_singleton()->print("Missing relative or absolute path, aborting.\n");
|
||||
goto error;
|
||||
}
|
||||
#ifdef OVERRIDE_ENABLED
|
||||
} else if (arg == "-u" || arg == "--upwards") { // scan folders upwards
|
||||
upwards = true;
|
||||
#endif // OVERRIDE_ENABLED
|
||||
#else
|
||||
ERR_PRINT(
|
||||
"`--path` was specified on the command line, but this Godot binary was compiled without support for path overrides. Aborting.\n"
|
||||
"To be able to use it, use the `disable_path_overrides=no` SCons option when compiling Godot.\n");
|
||||
goto error;
|
||||
#endif // defined(OVERRIDE_PATH_ENABLED)
|
||||
} else if (arg == "--quit") { // Auto quit at the end of the first main loop iteration
|
||||
quit_after = 1;
|
||||
#ifdef TOOLS_ENABLED
|
||||
@@ -1685,6 +1721,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
goto error;
|
||||
}
|
||||
} else if (arg.ends_with("project.godot")) {
|
||||
#if defined(OVERRIDE_PATH_ENABLED)
|
||||
String path;
|
||||
String file = arg;
|
||||
int sep = MAX(file.rfind_char('/'), file.rfind_char('\\'));
|
||||
@@ -1701,6 +1738,12 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
#ifdef TOOLS_ENABLED
|
||||
editor = true;
|
||||
#endif
|
||||
#else
|
||||
ERR_PRINT(
|
||||
"`project.godot` path was specified on the command line, but this Godot binary was compiled without support for path overrides. Aborting.\n"
|
||||
"To be able to use it, use the `disable_path_overrides=no` SCons option when compiling Godot.\n");
|
||||
goto error;
|
||||
#endif // defined(OVERRIDE_PATH_ENABLED)
|
||||
} else if (arg == "-b" || arg == "--breakpoints") { // add breakpoints
|
||||
|
||||
if (N) {
|
||||
@@ -1741,8 +1784,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
OS::get_singleton()->print("Missing time scale argument, aborting.\n");
|
||||
goto error;
|
||||
}
|
||||
#ifdef OVERRIDE_ENABLED
|
||||
} else if (arg == "--main-pack") {
|
||||
#if defined(OVERRIDE_PATH_ENABLED) || defined(WEB_ENABLED) // Note: main-pack is always used on web and can't be disabled.
|
||||
if (N) {
|
||||
main_pack = N->get();
|
||||
N = N->next();
|
||||
@@ -1750,7 +1793,13 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
OS::get_singleton()->print("Missing path to main pack file, aborting.\n");
|
||||
goto error;
|
||||
}
|
||||
#endif // OVERRIDE_ENABLED
|
||||
#else
|
||||
ERR_PRINT(
|
||||
"`--main-pack` was specified on the command line, but this Godot binary was compiled without support for path overrides. Aborting.\n"
|
||||
"To be able to use it, use the `disable_path_overrides=no` SCons option when compiling Godot.\n");
|
||||
goto error;
|
||||
#endif // defined(OVERRIDE_PATH_ENABLED) || defined(WEB_ENABLED)
|
||||
|
||||
} else if (arg == "-d" || arg == "--debug") {
|
||||
debug_uri = "local://";
|
||||
OS::get_singleton()->_debug_stdout = true;
|
||||
@@ -1769,14 +1818,15 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
StringName::set_debug_stringnames(true);
|
||||
} else if (arg == "--debug-mute-audio") {
|
||||
debug_mute_audio = true;
|
||||
#endif
|
||||
#endif // defined(DEBUG_ENABLED)
|
||||
#if defined(TOOLS_ENABLED) && (defined(WINDOWS_ENABLED) || defined(LINUXBSD_ENABLED))
|
||||
} else if (arg == "--test-rd-support") {
|
||||
test_rd_support = true;
|
||||
} else if (arg == "--test-rd-creation") {
|
||||
test_rd_creation = true;
|
||||
#endif
|
||||
#endif // defined(TOOLS_ENABLED) && (defined(WINDOWS_ENABLED) || defined(LINUXBSD_ENABLED))
|
||||
} else if (arg == "--remote-debug") {
|
||||
#if defined(DEBUG_ENABLED) || defined(TOOLS_ENABLED)
|
||||
if (N) {
|
||||
debug_uri = N->get();
|
||||
if (!debug_uri.contains("://")) { // wrong address
|
||||
@@ -1789,6 +1839,12 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
OS::get_singleton()->print("Missing remote debug host address, aborting.\n");
|
||||
goto error;
|
||||
}
|
||||
#else
|
||||
ERR_PRINT(
|
||||
"`--remote-debug` was specified on the command line, but this Godot binary was compiled without debug. Aborting.\n"
|
||||
"To be able to use it, use the `target=template_debug` SCons option when compiling Godot.\n");
|
||||
goto error;
|
||||
#endif // defined(DEBUG_ENABLED) || defined (TOOLS_ENABLED)
|
||||
} else if (arg == "--editor-pid") { // not exposed to user
|
||||
if (N) {
|
||||
editor_pid = N->get().to_int();
|
||||
@@ -1931,7 +1987,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef OVERRIDE_ENABLED
|
||||
#if defined(DEBUG_ENABLED) || defined(TOOLS_ENABLED)
|
||||
// Network file system needs to be configured before globals, since globals are based on the
|
||||
// 'project.godot' file which will only be available through the network if this is enabled
|
||||
if (!remotefs.is_empty()) {
|
||||
@@ -1949,10 +2005,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
#endif // OVERRIDE_ENABLED
|
||||
#endif // defined(DEBUG_ENABLED) || defined (TOOLS_ENABLED)
|
||||
|
||||
OS::get_singleton()->_in_editor = editor;
|
||||
if (globals->setup(project_path, main_pack, upwards, editor) == OK) {
|
||||
if (globals->setup(project_path, main_pack, false, editor) == OK) {
|
||||
#ifdef TOOLS_ENABLED
|
||||
found_project = true;
|
||||
#endif
|
||||
@@ -3843,15 +3899,22 @@ int Main::start() {
|
||||
} else if (E->get() == "--install-android-build-template") {
|
||||
install_android_build_template = true;
|
||||
#endif // TOOLS_ENABLED
|
||||
#ifdef OVERRIDE_ENABLED
|
||||
} else if (E->get() == "--scene") {
|
||||
#if defined(OVERRIDE_PATH_ENABLED)
|
||||
E = E->next();
|
||||
if (E) {
|
||||
game_path = ResourceUID::ensure_path(E->get());
|
||||
} else {
|
||||
ERR_FAIL_V_MSG(EXIT_FAILURE, "Missing scene path, aborting.");
|
||||
}
|
||||
#else
|
||||
ERR_PRINT(
|
||||
"`--scene` was specified on the command line, but this Godot binary was compiled without support for path overrides. Aborting.\n"
|
||||
"To be able to use it, use the `disable_path_overrides=no` SCons option when compiling Godot.\n");
|
||||
return EXIT_FAILURE;
|
||||
#endif // defined(OVERRIDE_PATH_ENABLED)
|
||||
} else if (E->get().length() && E->get()[0] != '-' && positional_arg.is_empty() && game_path.is_empty()) {
|
||||
#if defined(OVERRIDE_PATH_ENABLED)
|
||||
positional_arg = E->get();
|
||||
|
||||
String scene_path = ResourceUID::ensure_path(E->get());
|
||||
@@ -3868,7 +3931,12 @@ int Main::start() {
|
||||
// for non-game applications.
|
||||
game_path = scene_path;
|
||||
}
|
||||
#endif // OVERRIDE_ENABLED
|
||||
#else
|
||||
ERR_PRINT(
|
||||
"Scene path was specified on the command line, but this Godot binary was compiled without support for path overrides. Aborting.\n"
|
||||
"To be able to use it, use the `disable_path_overrides=no` SCons option when compiling Godot.\n");
|
||||
return EXIT_FAILURE;
|
||||
#endif // defined(OVERRIDE_PATH_ENABLED)
|
||||
}
|
||||
// Then parameters that have an argument to the right.
|
||||
else if (E->next()) {
|
||||
@@ -4073,7 +4141,7 @@ int Main::start() {
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
#ifdef OVERRIDE_ENABLED
|
||||
#if defined(OVERRIDE_PATH_ENABLED)
|
||||
bool disable_override = GLOBAL_GET("application/config/disable_project_settings_override");
|
||||
if (disable_override) {
|
||||
script = String();
|
||||
@@ -4084,7 +4152,7 @@ int Main::start() {
|
||||
script = String();
|
||||
game_path = String();
|
||||
main_loop_type = String();
|
||||
#endif // OVERRIDE_ENABLED
|
||||
#endif // defined(OVERRIDE_PATH_ENABLED)
|
||||
|
||||
if (script.is_empty() && game_path.is_empty()) {
|
||||
const String main_scene = GLOBAL_GET("application/run/main_scene");
|
||||
|
||||
Reference in New Issue
Block a user