Skip to content

Commit

Permalink
Revert executable name difference. Properly add version metadata to c…
Browse files Browse the repository at this point in the history
…ode and rc file. Make AE/SE show up under Product Version.
  • Loading branch information
Seally committed Dec 2, 2021
1 parent fd32b76 commit d108f42
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 45 deletions.
20 changes: 5 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,11 @@ set_property(CACHE SKYRIM_VERSION PROPERTY STRINGS "AE" "SE")

# ---- Project ----

if(SKYRIM_VERSION STREQUAL "SE")
project(
YASTM_SE
VERSION 1.8.0
LANGUAGES CXX
)
elseif(SKYRIM_VERSION STREQUAL "AE")
project(
YASTM_AE
VERSION 1.8.0
LANGUAGES CXX
)
else()
message(FATAL_ERROR "Unknown Skyrim version: ${SKYRIM_VERSION}")
endif()
project(
YASTM
VERSION 1.8.0
LANGUAGES CXX
)

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.hpp.in
Expand Down
40 changes: 27 additions & 13 deletions cmake/version.hpp.in
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
#ifndef VERSION_HPP
#define VERSION_HPP

namespace version
{
inline constexpr std::size_t MAJOR = @PROJECT_VERSION_MAJOR@;
inline constexpr std::size_t MINOR = @PROJECT_VERSION_MINOR@;
inline constexpr std::size_t PATCH = @PROJECT_VERSION_PATCH@;
inline constexpr auto NAME = "@PROJECT_VERSION@"sv;
inline constexpr auto PROJECT = "@PROJECT_NAME@"sv;
}

#endif // VERSION_HPP
#ifndef VERSION_HPP
#define VERSION_HPP

#include <string_view>

namespace meta
{
using namespace std::literals;

inline constexpr auto NAME = "@PROJECT_NAME@"sv;

namespace version {
inline constexpr unsigned int MAJOR = @PROJECT_VERSION_MAJOR@;
inline constexpr unsigned int MINOR = @PROJECT_VERSION_MINOR@;
inline constexpr unsigned int PATCH = @PROJECT_VERSION_PATCH@;

inline constexpr auto SKYRIM = "@SKYRIM_VERSION@"sv;

inline constexpr auto STRING = "@PROJECT_VERSION@"sv;
/**
* The full version string including the game version it is built for.
*/
inline constexpr auto FULL_STRING = "@PROJECT_VERSION@-@SKYRIM_VERSION@"sv;
} // namespace version
} // namespace meta

#endif // VERSION_HPP
2 changes: 1 addition & 1 deletion cmake/version.rc.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ BEGIN
VALUE "InternalName", "@PROJECT_NAME@"
VALUE "LegalCopyright", "MIT License"
VALUE "ProductName", "@PROJECT_NAME@"
VALUE "ProductVersion", "@[email protected]"
VALUE "ProductVersion", "@[email protected]-@SKYRIM_VERSION@"
END
END
BLOCK "VarFileInfo"
Expand Down
2 changes: 1 addition & 1 deletion src/global.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@
/* Syntax: VERSION_SPECIFIC(SE_OUTPUT, AE_OUTPUT) */
# define VERSION_SPECIFIC(se, ae) se
#else
# error "SKYRIM_VERSION_<version> is not defined."
# error "SKYRIM_VERSION_<version> is not defined or invalid."
#endif
31 changes: 16 additions & 15 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,19 @@
#include "TrapSoulFix.hpp"
#include "fsutils/FSUtils.hpp"

struct Point {
int x;
int y;
};

bool setUpLogging()
{
using namespace std::literals;
namespace logger = SKSE::log;

Point foo(1, 2);
using namespace meta;

auto path = logger::log_directory();
if (!path.has_value()) {
LOG_ERROR("Could not open log directory.");
return false;
}

*path /= version::PROJECT;
*path /= std::string(meta::NAME) + "_" + std::string(version::SKYRIM);
*path += ".log"sv;
auto sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(
path->string(),
Expand All @@ -48,7 +42,7 @@ bool setUpLogging()
spdlog::set_default_logger(std::move(log));
spdlog::set_pattern("%g(%#): [%^%l%$] %v"s);

LOG_INFO_FMT("{} v{}"sv, version::PROJECT, version::NAME);
LOG_INFO_FMT("Loaded {} v{}"sv, NAME, version::FULL_STRING);

return true;
}
Expand Down Expand Up @@ -109,10 +103,12 @@ bool installPatches(const SKSE::LoadInterface* const skse)
extern "C" DLLEXPORT bool SKSEAPI
SKSEPlugin_Query(const SKSE::QueryInterface* skse, SKSE::PluginInfo* info)
{
using namespace meta;

setUpLogging();

info->infoVersion = SKSE::PluginInfo::kVersion;
info->name = version::PROJECT.data();
info->name = NAME.data();
info->version = version::MAJOR;

if (skse->IsEditor()) {
Expand All @@ -132,19 +128,19 @@ extern "C" DLLEXPORT bool SKSEAPI
extern "C" DLLEXPORT bool SKSEAPI
SKSEPlugin_Load(const SKSE::LoadInterface* skse)
{
LOG_INFO_FMT("Loaded {} v{}", version::PROJECT, version::NAME);

SKSE::Init(skse);

return installPatches(skse);
}
#elif defined(SKYRIM_VERSION_AE)
extern "C" DLLEXPORT constinit auto SKSEPlugin_Version = []() {
using namespace meta;

SKSE::PluginVersionData v;

v.PluginVersion(
REL::Version(version::MAJOR, version::MINOR, version::PATCH));
v.PluginName(version::PROJECT);
v.PluginName(NAME);
v.AuthorName("Seally");
v.UsesAddressLibrary(true);
v.UsesSigScanning(false);
Expand All @@ -155,13 +151,18 @@ extern "C" DLLEXPORT constinit auto SKSEPlugin_Version = []() {

extern "C" DLLEXPORT bool SKSEPlugin_Load(const SKSE::LoadInterface* skse)
{
using namespace meta;
setUpLogging();

LOG_INFO_FMT("Loaded {} v{}", version::PROJECT, version::NAME);
if (skse->IsEditor()) {
LOG_CRITICAL("Loaded in editor, marking as incompatible"sv);
return false;
}

SKSE::Init(skse);

return installPatches(skse);
}
#else
# error "SKYRIM_VERSION_<version> is not defined."
# error "SKYRIM_VERSION_<version> is not defined or invalid."
#endif

0 comments on commit d108f42

Please sign in to comment.