mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-26 13:47:12 +01:00
SCons: Add methods.get_version_info()
method returning a Dict
This makes it possible to retrieve all relevant versioning info used to generate `core/version_generated.gen.h` in the buildsystem. Notably it makes the custom logic parsing the `GODOT_VERSION_STATUS` environment variable to override status easy to reuse. (cherry picked from commit d432fe38a9a65b9e84964a7393c9fe4ce22361a3)
This commit is contained in:
parent
b97535aead
commit
36356df17e
@ -614,7 +614,7 @@ if selected_platform in platform_list:
|
|||||||
env.module_list = modules_enabled
|
env.module_list = modules_enabled
|
||||||
methods.sort_module_list(env)
|
methods.sort_module_list(env)
|
||||||
|
|
||||||
methods.update_version(env.module_version_string)
|
methods.generate_version_header(env.module_version_string)
|
||||||
|
|
||||||
env["PROGSUFFIX"] = suffix + env.module_version_string + env["PROGSUFFIX"]
|
env["PROGSUFFIX"] = suffix + env.module_version_string + env["PROGSUFFIX"]
|
||||||
env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"]
|
env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"]
|
||||||
|
91
methods.py
91
methods.py
@ -63,40 +63,39 @@ def add_module_version_string(self, s):
|
|||||||
self.module_version_string += "." + s
|
self.module_version_string += "." + s
|
||||||
|
|
||||||
|
|
||||||
def update_version(module_version_string=""):
|
def get_version_info(module_version_string="", silent=False):
|
||||||
build_name = "custom_build"
|
build_name = "custom_build"
|
||||||
if os.getenv("BUILD_NAME") != None:
|
if os.getenv("BUILD_NAME") != None:
|
||||||
build_name = str(os.getenv("BUILD_NAME"))
|
build_name = str(os.getenv("BUILD_NAME"))
|
||||||
print("Using custom build name: " + build_name)
|
if not silent:
|
||||||
|
print("Using custom build name: '{}'.".format(build_name))
|
||||||
|
|
||||||
import version
|
import version
|
||||||
|
|
||||||
# NOTE: It is safe to generate this file here, since this is still executed serially
|
version_info = {
|
||||||
f = open("core/version_generated.gen.h", "w")
|
"short_name": str(version.short_name),
|
||||||
f.write('#define VERSION_SHORT_NAME "' + str(version.short_name) + '"\n')
|
"name": str(version.name),
|
||||||
f.write('#define VERSION_NAME "' + str(version.name) + '"\n')
|
"major": int(version.major),
|
||||||
f.write("#define VERSION_MAJOR " + str(version.major) + "\n")
|
"minor": int(version.minor),
|
||||||
f.write("#define VERSION_MINOR " + str(version.minor) + "\n")
|
"patch": int(version.patch),
|
||||||
f.write("#define VERSION_PATCH " + str(version.patch) + "\n")
|
"status": str(version.status),
|
||||||
|
"build": str(build_name),
|
||||||
|
"module_config": str(version.module_config) + module_version_string,
|
||||||
|
"year": int(version.year),
|
||||||
|
"website": str(version.website),
|
||||||
|
"docs_branch": str(version.docs),
|
||||||
|
}
|
||||||
|
|
||||||
# For dev snapshots (alpha, beta, RC, etc.) we do not commit status change to Git,
|
# For dev snapshots (alpha, beta, RC, etc.) we do not commit status change to Git,
|
||||||
# so this define provides a way to override it without having to modify the source.
|
# so this define provides a way to override it without having to modify the source.
|
||||||
pandemonium_status = str(version.status)
|
|
||||||
if os.getenv("PANDEMONIUM_VERSION_STATUS") != None:
|
if os.getenv("PANDEMONIUM_VERSION_STATUS") != None:
|
||||||
pandemonium_status = str(os.getenv("PANDEMONIUM_VERSION_STATUS"))
|
version_info["status"] = str(os.getenv("PANDEMONIUM_VERSION_STATUS"))
|
||||||
print("Using version status '{}', overriding the original '{}'.".format(pandemonium_status, str(version.status)))
|
if not silent:
|
||||||
f.write('#define VERSION_STATUS "' + pandemonium_status + '"\n')
|
print(
|
||||||
f.write('#define VERSION_BUILD "' + str(build_name) + '"\n')
|
"Using version status '{}', overriding the original '{}'.".format(version_info.status, version.status)
|
||||||
f.write('#define VERSION_MODULE_CONFIG "' + str(version.module_config) + module_version_string + '"\n')
|
)
|
||||||
f.write("#define VERSION_YEAR " + str(version.year) + "\n")
|
|
||||||
f.write('#define VERSION_WEBSITE "' + str(version.website) + '"\n')
|
|
||||||
f.write('#define VERSION_DOCS_BRANCH "' + str(version.docs) + '"\n')
|
|
||||||
f.write('#define VERSION_DOCS_URL "https://docs.godotengine.org/en/" VERSION_DOCS_BRANCH\n')
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
# NOTE: It is safe to generate this file here, since this is still executed serially
|
# Parse Git hash if we're in a Git repo.
|
||||||
fhash = open("core/version_hash.gen.cpp", "w")
|
|
||||||
fhash.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
|
|
||||||
fhash.write('#include "core/version.h"\n')
|
|
||||||
githash = ""
|
githash = ""
|
||||||
gitfolder = ".git"
|
gitfolder = ".git"
|
||||||
|
|
||||||
@ -126,7 +125,49 @@ def update_version(module_version_string=""):
|
|||||||
else:
|
else:
|
||||||
githash = head
|
githash = head
|
||||||
|
|
||||||
fhash.write('const char *const VERSION_HASH = "' + githash + '";\n')
|
version_info["git_hash"] = githash
|
||||||
|
|
||||||
|
return version_info
|
||||||
|
|
||||||
|
|
||||||
|
def generate_version_header(module_version_string=""):
|
||||||
|
version_info = get_version_info(module_version_string)
|
||||||
|
|
||||||
|
# NOTE: It is safe to generate these files here, since this is still executed serially.
|
||||||
|
|
||||||
|
f = open("core/version_generated.gen.h", "w")
|
||||||
|
f.write(
|
||||||
|
"""/* THIS FILE IS GENERATED DO NOT EDIT */
|
||||||
|
#ifndef VERSION_GENERATED_GEN_H
|
||||||
|
#define VERSION_GENERATED_GEN_H
|
||||||
|
#define VERSION_SHORT_NAME "{short_name}"
|
||||||
|
#define VERSION_NAME "{name}"
|
||||||
|
#define VERSION_MAJOR {major}
|
||||||
|
#define VERSION_MINOR {minor}
|
||||||
|
#define VERSION_PATCH {patch}
|
||||||
|
#define VERSION_STATUS "{status}"
|
||||||
|
#define VERSION_BUILD "{build}"
|
||||||
|
#define VERSION_MODULE_CONFIG "{module_config}"
|
||||||
|
#define VERSION_YEAR {year}
|
||||||
|
#define VERSION_WEBSITE "{website}"
|
||||||
|
#define VERSION_DOCS_BRANCH "{docs_branch}"
|
||||||
|
#define VERSION_DOCS_URL "https://docs.godotengine.org/en/" VERSION_DOCS_BRANCH
|
||||||
|
#endif // VERSION_GENERATED_GEN_H
|
||||||
|
""".format(
|
||||||
|
**version_info
|
||||||
|
)
|
||||||
|
)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
fhash = open("core/version_hash.gen.cpp", "w")
|
||||||
|
fhash.write(
|
||||||
|
"""/* THIS FILE IS GENERATED DO NOT EDIT */
|
||||||
|
#include "core/version.h"
|
||||||
|
const char *const VERSION_HASH = "{git_hash}";
|
||||||
|
""".format(
|
||||||
|
**version_info
|
||||||
|
)
|
||||||
|
)
|
||||||
fhash.close()
|
fhash.close()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user