mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
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.
This commit is contained in:
parent
8f3e2a6113
commit
67e9ccdbc4
9 changed files with 69 additions and 7 deletions
13
methods.py
13
methods.py
|
@ -209,6 +209,18 @@ def get_version_info(module_version_string="", silent=False):
|
|||
githash = head
|
||||
|
||||
version_info["git_hash"] = githash
|
||||
# Fallback to 0 as a timestamp (will be treated as "unknown" in the engine).
|
||||
version_info["git_timestamp"] = 0
|
||||
|
||||
# Get the UNIX timestamp of the build commit.
|
||||
if os.path.exists(".git"):
|
||||
try:
|
||||
version_info["git_timestamp"] = subprocess.check_output(
|
||||
["git", "log", "-1", "--pretty=format:%ct", githash]
|
||||
).decode("utf-8")
|
||||
except (subprocess.CalledProcessError, OSError):
|
||||
# `git` not found in PATH.
|
||||
pass
|
||||
|
||||
return version_info
|
||||
|
||||
|
@ -246,6 +258,7 @@ def generate_version_header(module_version_string=""):
|
|||
"""/* THIS FILE IS GENERATED DO NOT EDIT */
|
||||
#include "core/version.h"
|
||||
const char *const VERSION_HASH = "{git_hash}";
|
||||
const uint64_t VERSION_TIMESTAMP = {git_timestamp};
|
||||
""".format(
|
||||
**version_info
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue