Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,29 @@ env.Prepend(LIBS=godot_env["LIBS"])

SConscript("extension/deps/SCsub", "env")

def version_git_info_builder(target, source, env):
with open(str(target[0]), "wt", encoding="utf-8", newline="\n") as file:
file.write("/* THIS FILE IS GENERATED. EDITS WILL BE LOST. */\n\n")
file.write(
"""\
#pragma once

#include <cstdint>
#include <string_view>

namespace OpenVic {{
static constexpr std::string_view GAME_TAG = "{git_tag}";
static constexpr std::string_view GAME_RELEASE = "{git_release}";
static constexpr std::string_view GAME_COMMIT_HASH = "{git_hash}";
static constexpr const uint64_t GAME_COMMIT_TIMESTAMP = {git_timestamp}ull;
}}
""".format(**source[0].read())
)

result = env.Command("extension/src/gen/git_info.gen.hpp", env.Value(env.get_git_info()), env.Action(version_git_info_builder, "$GENCOMSTR"))
env.NoCache(result)
Default(result)

# For the reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags
Expand Down
29 changes: 29 additions & 0 deletions extension/doc_classes/GitInfo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GitInfo" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<members>
<member name="commit_hash" type="StringName" setter="" getter="get_commit_hash">
The full Git commit hash the extension was compiled from as a [StringName].
If the Git commit hash was not found returns "0000000000000000000000000000000000000000"
</member>
<member name="commit_timestamp" type="int" setter="" getter="get_commit_timestamp">
The Git commit date UNIX timestamp the extension was compiled from, in seconds as an int, or 0 if unavailable.
</member>
<member name="release_name" type="StringName" setter="" getter="get_release_name">
The last Github release/prerelease name found on Github when the extension was compiled, or [member tag] if unavailable.
If [member tag] was not found, returns "&lt;release missing&gt;".
</member>
<member name="short_hash" type="StringName" setter="" getter="get_short_hash">
The 7 string short form of [member commit_hash].
</member>
<member name="tag" type="StringName" setter="" getter="get_tag">
The latest Git tag when the extension was compiled.
If the Git tag was not found returns "&lt;tag missing&gt;".
</member>
</members>
</class>
10 changes: 10 additions & 0 deletions extension/src/openvic-extension/register_types.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "register_types.hpp"

#include <godot_cpp/classes/engine.hpp>
#include <godot_cpp/core/class_db.hpp>

#include "openvic-extension/classes/GFXButtonStateTexture.hpp"
#include "openvic-extension/classes/GFXMaskedFlagTexture.hpp"
Expand All @@ -26,6 +27,7 @@
#include "openvic-extension/singletons/Checksum.hpp"
#include "openvic-extension/singletons/CursorSingleton.hpp"
#include "openvic-extension/singletons/GameSingleton.hpp"
#include "openvic-extension/singletons/GitInfo.hpp"
#include "openvic-extension/singletons/LoadLocalisation.hpp"
#include "openvic-extension/singletons/MapItemSingleton.hpp"
#include "openvic-extension/singletons/MenuSingleton.hpp"
Expand All @@ -36,6 +38,7 @@
using namespace godot;
using namespace OpenVic;

static GitInfo* _git_info_singleton = nullptr;
static Checksum* _checksum_singleton = nullptr;
static CursorSingleton* _cursor_singleton = nullptr;
static LoadLocalisation* _load_localisation = nullptr;
Expand All @@ -52,6 +55,10 @@ void initialize_openvic_types(ModuleInitializationLevel p_level) {
return;
}

ClassDB::register_class<GitInfo>();
_git_info_singleton = memnew(GitInfo);
Engine::get_singleton()->register_singleton("GitInfo", GitInfo::get_singleton());

ClassDB::register_class<Checksum>();
_checksum_singleton = memnew(Checksum);
Engine::get_singleton()->register_singleton("Checksum", Checksum::get_singleton());
Expand Down Expand Up @@ -131,6 +138,9 @@ void uninitialize_openvic_types(ModuleInitializationLevel p_level) {
return;
}

Engine::get_singleton()->unregister_singleton("GitInfo");
memdelete(_git_info_singleton);

Engine::get_singleton()->unregister_singleton("Checksum");
memdelete(_checksum_singleton);

Expand Down
62 changes: 62 additions & 0 deletions extension/src/openvic-extension/singletons/GitInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

#include "GitInfo.hpp"

#include <godot_cpp/classes/global_constants.hpp>
#include <godot_cpp/core/error_macros.hpp>

#include "openvic-extension/utility/ClassBindings.hpp"
#include "openvic-extension/utility/Utilities.hpp"

#include "gen/git_info.gen.hpp"

using namespace godot;
using namespace OpenVic;

GitInfo::GitInfo() {
ERR_FAIL_COND(_singleton != nullptr);
_singleton = this;

commit_hash = Utilities::std_to_godot_string(GAME_COMMIT_HASH);
commit_timestamp = GAME_COMMIT_TIMESTAMP;
short_hash = commit_hash.substr(0, 7);
tag = Utilities::std_to_godot_string(GAME_TAG);
release_name = Utilities::std_to_godot_string(GAME_RELEASE);
}

GitInfo::~GitInfo() {
ERR_FAIL_COND(_singleton != this);
_singleton = nullptr;
}

void GitInfo::_bind_methods() {
OV_BIND_METHOD(GitInfo::get_commit_hash);
OV_BIND_METHOD(GitInfo::get_commit_timestamp);
OV_BIND_METHOD(GitInfo::get_short_hash);
OV_BIND_METHOD(GitInfo::get_tag);
OV_BIND_METHOD(GitInfo::get_release_name);

ADD_PROPERTY(
PropertyInfo(Variant::STRING_NAME, "commit_hash", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), //
"", "get_commit_hash"
);
ADD_PROPERTY(
PropertyInfo(Variant::INT, "commit_timestamp", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), //
"", "get_commit_timestamp"
);
ADD_PROPERTY(
PropertyInfo(Variant::STRING_NAME, "short_hash", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), //
"", "get_short_hash"
);
ADD_PROPERTY(
PropertyInfo(Variant::STRING_NAME, "tag", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), //
"", "get_tag"
);
ADD_PROPERTY(
PropertyInfo(Variant::STRING_NAME, "release_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), //
"", "get_release_name"
);
}

GitInfo* GitInfo::get_singleton() {
return _singleton;
}
30 changes: 30 additions & 0 deletions extension/src/openvic-extension/singletons/GitInfo.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include <godot_cpp/classes/object.hpp>
#include <godot_cpp/classes/wrapped.hpp>
#include <godot_cpp/variant/string_name.hpp>

#include "openvic-simulation/utility/Getters.hpp"

namespace OpenVic {
class GitInfo : public godot::Object {
GDCLASS(GitInfo, Object);

godot::StringName PROPERTY(commit_hash);
uint64_t PROPERTY(commit_timestamp);
godot::StringName PROPERTY(short_hash);
godot::StringName PROPERTY(tag);
godot::StringName PROPERTY(release_name);

static inline GitInfo* _singleton = nullptr;

protected:
static void _bind_methods();

public:
static GitInfo* get_singleton();

GitInfo();
~GitInfo();
};
}
113 changes: 0 additions & 113 deletions game/addons/openvic-plugin/ReleaseExportEditorPlugin.gd

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions game/addons/openvic-plugin/openvic-plugin.gd

This file was deleted.

1 change: 0 additions & 1 deletion game/addons/openvic-plugin/openvic-plugin.gd.uid

This file was deleted.

7 changes: 0 additions & 7 deletions game/addons/openvic-plugin/plugin.cfg

This file was deleted.

Empty file added game/export/.gdignore
Empty file.
2 changes: 1 addition & 1 deletion game/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ window/size/window_height_override.editor=0

[editor_plugins]

enabled=PackedStringArray("res://addons/MusicMetadata/plugin.cfg", "res://addons/keychain/plugin.cfg", "res://addons/openvic-plugin/plugin.cfg")
enabled=PackedStringArray("res://addons/MusicMetadata/plugin.cfg", "res://addons/keychain/plugin.cfg")

[filesystem]

Expand Down
9 changes: 0 additions & 9 deletions game/src/GIT_INFO.gd

This file was deleted.

1 change: 0 additions & 1 deletion game/src/GIT_INFO.gd.uid

This file was deleted.

4 changes: 2 additions & 2 deletions game/src/Game/Autoload/Argument/ArgumentParser.gd
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ func _parse_argument_list(dictionary : Dictionary, arg_list : PackedStringArray,

func _print_help() -> void:
var project_name : StringName = ProjectSettings.get_setting_with_override(&"application/config/name")
var project_version : String = _GIT_INFO_.tag
var project_hash : String = _GIT_INFO_.short_hash
var project_version : String = GitInfo.tag
var project_hash : String = GitInfo.short_hash
var project_website : String = "https://openvic.com"
var project_description : String = ProjectSettings.get_setting_with_override(&"application/config/description")
print_rich(
Expand Down
Loading
Loading