summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2022-03-12 02:04:14 +0100
committerHugo Locurcio <hugo.locurcio@hugo.pro>2024-02-27 20:39:17 +0100
commit67e9ccdbc4909b975099ea73fc5ca92a28ce1e6a (patch)
tree638f6f3de2318295e2633f3482c212d752b5ea55 /main
parent8f3e2a61130232e089f1da6062ebf53f986779b4 (diff)
downloadredot-engine-67e9ccdbc4909b975099ea73fc5ca92a28ce1e6a.tar.gz
Display the build date in the editor and when starting the engine
This can be used to quickly see how recent a development build is, without having to look up the commit date manually. When juggling around with various builds (e.g. for benchmarking), this can also be used to ensure that you're actually running the binary you intended to run. The date stored is the date of the Git commit that is built, not the current date at the time of building the binary. This ensures binaries can remain reproducible. The version timestamp can be accessed using the `timestamp` key of the `Engine.get_version_info()` return value.
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp23
-rw-r--r--main/main.h1
2 files changed, 21 insertions, 3 deletions
diff --git a/main/main.cpp b/main/main.cpp
index c520ebecd3..91ccbe6766 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -393,6 +393,23 @@ void finalize_theme_db() {
#define MAIN_PRINT(m_txt)
#endif
+void Main::print_header(bool p_rich) {
+ if (VERSION_TIMESTAMP > 0) {
+ // Version timestamp available.
+ if (p_rich) {
+ print_line_rich("\u001b[38;5;39m" + String(VERSION_NAME) + "\u001b[0m v" + get_full_version_string() + " (" + Time::get_singleton()->get_datetime_string_from_unix_time(VERSION_TIMESTAMP, true) + " UTC) - \u001b[4m" + String(VERSION_WEBSITE));
+ } else {
+ print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " (" + Time::get_singleton()->get_datetime_string_from_unix_time(VERSION_TIMESTAMP, true) + " UTC) - " + String(VERSION_WEBSITE));
+ }
+ } else {
+ if (p_rich) {
+ print_line_rich("\u001b[38;5;39m" + String(VERSION_NAME) + "\u001b[0m v" + get_full_version_string() + " - \u001b[4m" + String(VERSION_WEBSITE));
+ } else {
+ print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " - " + String(VERSION_WEBSITE));
+ }
+ }
+}
+
/**
* Prints a copyright notice in the command-line help with colored text. A newline is
* automatically added at the end.
@@ -463,7 +480,7 @@ void Main::print_help_option(const char *p_option, const char *p_description, CL
}
void Main::print_help(const char *p_binary) {
- print_line("\u001b[38;5;39m" + String(VERSION_NAME) + "\u001b[0m v" + get_full_version_string() + " - \u001b[4m" + String(VERSION_WEBSITE) + "\u001b[0m");
+ print_header(true);
print_help_copyright("Free and open source software under the terms of the MIT license.");
print_help_copyright("(c) 2014-present Godot Engine contributors. (c) 2007-present Juan Linietsky, Ariel Manzur.");
@@ -2468,8 +2485,8 @@ Error Main::setup2() {
Thread::make_main_thread(); // Make whatever thread call this the main thread.
set_current_thread_safe_for_nodes(true);
- // Print engine name and version
- Engine::get_singleton()->print_header(String(VERSION_NAME) + " v" + get_full_version_string() + " - " + String(VERSION_WEBSITE));
+ // Don't use rich formatting to prevent ANSI escape codes from being written to log files.
+ print_header(false);
#ifdef TOOLS_ENABLED
if (editor || project_manager || cmdline_tool) {
diff --git a/main/main.h b/main/main.h
index 09cc0feae6..062af73d57 100644
--- a/main/main.h
+++ b/main/main.h
@@ -46,6 +46,7 @@ class Main {
CLI_OPTION_AVAILABILITY_HIDDEN,
};
+ static void print_header(bool p_rich);
static void print_help_copyright(const char *p_notice);
static void print_help_title(const char *p_title);
static void print_help_option(const char *p_option, const char *p_description, CLIOptionAvailability p_availability = CLI_OPTION_AVAILABILITY_TEMPLATE_RELEASE);