2
0
Эх сурвалжийг харах

Merge pull request #11536 from akien-mga/version-hash

main: Add --version switch and git hash to --help

[ci skip]
Rémi Verschelde 8 жил өмнө
parent
commit
f04821669e
1 өөрчлөгдсөн 18 нэмэгдсэн , 4 устгасан
  1. 18 4
      main/main.cpp

+ 18 - 4
main/main.cpp

@@ -74,6 +74,7 @@
 #include "performance.h"
 #include "translation.h"
 #include "version.h"
+#include "version_hash.gen.h"
 
 static ProjectSettings *globals = NULL;
 static Engine *engine = NULL;
@@ -122,6 +123,14 @@ static String unescape_cmdline(const String &p_str) {
 	return p_str.replace("%20", " ");
 }
 
+static String get_full_version_string() {
+
+	String hash = String(VERSION_HASH);
+	if (hash.length() != 0)
+		hash = "." + hash.left(7);
+	return String(VERSION_MKSTRING) + hash;
+}
+
 //#define DEBUG_INIT
 
 #ifdef DEBUG_INIT
@@ -132,7 +141,7 @@ static String unescape_cmdline(const String &p_str) {
 
 void Main::print_help(const char *p_binary) {
 
-	OS::get_singleton()->print(VERSION_FULL_NAME " - https://godotengine.org\n");
+	print_line(String(_MKSTR(VERSION_NAME)) + " v" + get_full_version_string() + " - https://godotengine.org");
 	OS::get_singleton()->print("(c) 2007-2017 Juan Linietsky, Ariel Manzur.\n");
 	OS::get_singleton()->print("(c) 2014-2017 Godot Engine contributors.\n");
 	OS::get_singleton()->print("\n");
@@ -141,6 +150,7 @@ void Main::print_help(const char *p_binary) {
 
 	OS::get_singleton()->print("General options:\n");
 	OS::get_singleton()->print("  -h, --help                       Display this help message.\n");
+	OS::get_singleton()->print("  --version                        Display the version string.\n");
 	OS::get_singleton()->print("  -v, --verbose                    Use verbose stdout mode.\n");
 	OS::get_singleton()->print("  --quiet                          Quiet mode, silences stdout messages. Errors are still displayed.\n");
 	OS::get_singleton()->print("\n");
@@ -195,7 +205,7 @@ void Main::print_help(const char *p_binary) {
 	OS::get_singleton()->print("  --time-scale <scale>             Force time scale (higher values are faster, 1.0 is normal speed).\n");
 	OS::get_singleton()->print("  --disable-render-loop            Disable render loop so rendering only occurs when called explicitly from script.\n");
 	OS::get_singleton()->print("  --disable-crash-handler          Disable crash handler when supported by the platform code.\n");
-	OS::get_singleton()->print("  --fixed-fps <fps>                Forces a fixed ratio between process and fixed_process timing, for use when precision is required, or when rendering to video files. Setting this will disable real-time syncronization, so that run speed is only capped by performance\n");
+	OS::get_singleton()->print("  --fixed-fps <fps>                Force a fixed number of frames per second. This setting disables real\-time synchronization.\n");
 	OS::get_singleton()->print("\n");
 
 	OS::get_singleton()->print("Standalone tools:\n");
@@ -203,7 +213,7 @@ void Main::print_help(const char *p_binary) {
 #ifdef TOOLS_ENABLED
 	OS::get_singleton()->print("  --export <target>                Export the project using the given export target.\n");
 	OS::get_singleton()->print("  --export-debug                   Use together with --export, enables debug mode for the template.\n");
-	OS::get_singleton()->print("  --doctool <file>                 Dump the whole engine API to <file> in XML format. If <file> exists, it will be merged.\n");
+	OS::get_singleton()->print("  --doctool <path>                 Dump the engine API reference to the given <path> 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");
 #ifdef DEBUG_METHODS_ENABLED
 	OS::get_singleton()->print("  --gdnative-generate-json-api     Generate JSON dump of the Godot API for GDNative bindings.\n");
@@ -268,7 +278,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
 	while (I) {
 
 		I->get() = unescape_cmdline(I->get().strip_escapes());
-		//print_line("CMD: "+I->get());
 		I = I->next();
 	}
 
@@ -318,6 +327,11 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
 			show_help = true;
 			goto error;
 
+		} else if (I->get() == "--version") {
+
+			print_line(get_full_version_string());
+			goto error;
+
 		} else if (I->get() == "--resolution") { // force resolution
 
 			if (I->next()) {