From f1a376d44bf899356a87870be7889e6b2173d1b4 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sun, 13 Oct 2019 05:54:20 +0200 Subject: [PATCH] cmake: Add commit to version.hpp template Switches out the `const uint16_t` for actual defines, which are easier to deal with and work in C out of the box. --- cmake/version.hpp.in | 25 +++++++++++++------------ source/filters/filter-blur.cpp | 4 ++-- source/plugin.cpp | 6 ++---- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/cmake/version.hpp.in b/cmake/version.hpp.in index a63453aa..efc6de86 100644 --- a/cmake/version.hpp.in +++ b/cmake/version.hpp.in @@ -17,19 +17,20 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#ifndef STREAMEFFECTS_VERSION_HPP +#define STREAMEFFECTS_VERSION_HPP + #pragma once -#include +#include -#define MAKE_VERSION(major,minor,patch,tweak) ((uint64_t(major) & 0xFFFFull) << 48ull) | ((uint64_t(minor) & 0xFFFFull) << 32ull) | ((uint64_t(patch) & 0xFFFFull) << 16ull) | ((uint64_t(patch) & 0xFFFFull)) +#define STREAMEFFECTS_MAKE_VERSION(major,minor,patch,tweak) ((uint64_t(major) & 0xFFFFull) << 48ull) | ((uint64_t(minor) & 0xFFFFull) << 32ull) | ((uint64_t(patch) & 0xFFFFull) << 16ull) | ((uint64_t(patch) & 0xFFFFull)) -const uint16_t PROJECT_VERSION_MAJOR = @PROJECT_VERSION_MAJOR@; -const uint16_t PROJECT_VERSION_MINOR = @PROJECT_VERSION_MINOR@; -const uint16_t PROJECT_VERSION_PATCH = @PROJECT_VERSION_PATCH@; -const uint16_t PROJECT_VERSION_TWEAK = @PROJECT_VERSION_TWEAK@; -const uint64_t PROJECT_VERSION = MAKE_VERSION(PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR, PROJECT_VERSION_PATCH, PROJECT_VERSION_TWEAK); +#define STREAMEFFECTS_COMMIT "@PROJECT_COMMIT@" +#define STREAMEFFECTS_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define STREAMEFFECTS_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define STREAMEFFECTS_VERSION_PATCH @PROJECT_VERSION_PATCH@ +#define STREAMEFFECTS_VERSION_BUILD @PROJECT_VERSION_TWEAK@ +#define STREAMEFFECTS_VERSION STREAMEFFECTS_MAKE_VERSION(STREAMEFFECTS_VERSION_MAJOR, STREAMEFFECTS_VERSION_MINOR, STREAMEFFECTS_VERSION_PATCH, STREAMEFFECTS_VERSION_BUILD) +#define STREAMEFFECTS_VERSION_STRING "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.@PROJECT_VERSION_TWEAK@-@PROJECT_COMMIT@" -const uint16_t PLUGIN_VERSION_MAJOR = @PROJECT_VERSION_MAJOR@; -const uint16_t PLUGIN_VERSION_MINOR = @PROJECT_VERSION_MINOR@; -const uint16_t PLUGIN_VERSION_PATCH = @PROJECT_VERSION_PATCH@; -const uint16_t PLUGIN_VERSION_TWEAK = @PROJECT_VERSION_TWEAK@; -const uint64_t PLUGIN_VERSION_FULL = (((uint64_t)(PLUGIN_VERSION_MAJOR & 0xFFFF) << 48ull) | ((uint64_t)(PLUGIN_VERSION_MINOR & 0xFFFF) << 32ull) | ((uint64_t)(PLUGIN_VERSION_PATCH) & 0xFFFFFFFF)); +#endif STREAMEFFECTS_VERSION_HPP diff --git a/source/filters/filter-blur.cpp b/source/filters/filter-blur.cpp index 47e56e4d..f8aa6ad2 100644 --- a/source/filters/filter-blur.cpp +++ b/source/filters/filter-blur.cpp @@ -562,7 +562,7 @@ void filter::blur::blur_instance::translate_old_settings(obs_data_t* settings) int64_t version = obs_data_get_int(settings, S_VERSION); // If it's the same as the current version, return. - if (version == PROJECT_VERSION) { + if (version == STREAMEFFECTS_VERSION) { return; } @@ -601,7 +601,7 @@ void filter::blur::blur_instance::translate_old_settings(obs_data_t* settings) obs_data_unset_user_value(settings, "Filter.Blur.Directional.Angle"); } - obs_data_set_int(settings, S_VERSION, PROJECT_VERSION); + obs_data_set_int(settings, S_VERSION, STREAMEFFECTS_VERSION); } obs_properties_t* filter::blur::blur_instance::get_properties() diff --git a/source/plugin.cpp b/source/plugin.cpp index fb73b6b0..83386208 100644 --- a/source/plugin.cpp +++ b/source/plugin.cpp @@ -31,8 +31,7 @@ #include "sources/source-shader.hpp" MODULE_EXPORT bool obs_module_load(void) try { - P_LOG_INFO("Loading Version %u.%u.%u (Build %u)", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR, - PROJECT_VERSION_PATCH, PROJECT_VERSION_TWEAK); + P_LOG_INFO("Loading Version %s", STREAMEFFECTS_VERSION_STRING); // Initialize Source Tracker obs::source_tracker::initialize(); @@ -57,8 +56,7 @@ MODULE_EXPORT bool obs_module_load(void) try { } MODULE_EXPORT void obs_module_unload(void) try { - P_LOG_INFO("Unloading Version %u.%u.%u (Build %u)", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR, - PROJECT_VERSION_PATCH, PROJECT_VERSION_TWEAK); + P_LOG_INFO("Unloading Version %s", STREAMEFFECTS_VERSION_STRING); // Clean up Sources source::mirror::mirror_factory::finalize();