-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from limbonaut/show-version
Show version info in the editor
- Loading branch information
Showing
8 changed files
with
143 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Edit the following variables to change version info | ||
|
||
major = 1 | ||
minor = 1 | ||
patch = 0 | ||
status = "dev" | ||
doc_branch = "latest" | ||
|
||
# Code that generates version header | ||
|
||
def _git_hash(short: bool = False): | ||
import subprocess | ||
ret = "unknown" | ||
try: | ||
if short: | ||
cmd = ["git", "rev-parse", "--short", "HEAD"] | ||
else: | ||
cmd = ["git", "rev-parse", "HEAD"] | ||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) | ||
ret = proc.communicate()[0].strip().decode("utf-8") | ||
except: | ||
pass | ||
return ret | ||
|
||
|
||
def _get_version_info(): | ||
return { | ||
"major": major, | ||
"minor": minor, | ||
"patch": patch, | ||
"status": status, | ||
"doc_branch": doc_branch, | ||
"git_short_hash": _git_hash(short=True), | ||
"git_hash": _git_hash(short=False) | ||
} | ||
|
||
|
||
def generate_module_version_header(): | ||
version_info = _get_version_info() | ||
f = open("util/limboai_version.gen.h", "w") | ||
f.write( | ||
"""/* THIS FILE IS GENERATED DO NOT EDIT */ | ||
#ifndef LIMBOAI_VERSION_GEN_H | ||
#define LIMBOAI_VERSION_GEN_H | ||
#define LIMBOAI_VERSION_MAJOR {major} | ||
#define LIMBOAI_VERSION_MINOR {minor} | ||
#define LIMBOAI_VERSION_PATCH {patch} | ||
#define LIMBOAI_VERSION_STATUS "{status}" | ||
#define LIMBOAI_VERSION_HASH "{git_hash}" | ||
#define LIMBOAI_VERSION_SHORT_HASH "{git_short_hash}" | ||
#define LIMBOAI_VERSION_DOC_BRANCH "{doc_branch}" | ||
#define LIMBOAI_VERSION_DOC_URL "https://limboai.readthedocs.io/en/" LIMBOAI_VERSION_DOC_BRANCH "/" | ||
#endif // LIMBOAI_VERSION_GEN_H | ||
""".format(**version_info)) | ||
f.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* limboai_version.h | ||
* ============================================================================= | ||
* Copyright 2021-2024 Serhii Snitsaruk | ||
* | ||
* Use of this source code is governed by an MIT-style | ||
* license that can be found in the LICENSE file or at | ||
* https://opensource.org/licenses/MIT. | ||
* ============================================================================= | ||
*/ | ||
|
||
#ifndef LIMBOAI_VERSION_H | ||
#define LIMBOAI_VERSION_H | ||
|
||
#include "limboai_version.gen.h" | ||
|
||
#ifdef LIMBOAI_MODULE | ||
#include "core/string/ustring.h" | ||
#elif LIMBOAI_GDEXTENSION | ||
#include <godot_cpp/variant/string.hpp> | ||
#endif | ||
|
||
inline String GET_LIMBOAI_VERSION() { | ||
String version = itos(LIMBOAI_VERSION_MAJOR) + "." + itos(LIMBOAI_VERSION_MINOR); | ||
if (LIMBOAI_VERSION_PATCH != 0) { | ||
version += "." + itos(LIMBOAI_VERSION_PATCH); | ||
} | ||
if (strlen(LIMBOAI_VERSION_STATUS) > 0) { | ||
version += "-" + String(LIMBOAI_VERSION_STATUS); | ||
} | ||
return version; | ||
} | ||
|
||
#define GET_LIMBOAI_FULL_VERSION() GET_LIMBOAI_VERSION() + " [" + LIMBOAI_VERSION_SHORT_HASH + "]" | ||
|
||
#endif // LIMBOAI_VERSION_H |