forked from teamnwah/openmw-tes3coop
Move OpenMW version information to a textfile instead of compiling it in
Now we don't need to recompile 3 .cpp files and re-link whenever the current git HEAD changes.sceneinput
parent
c783b50a83
commit
f09e4620b6
@ -0,0 +1,41 @@
|
||||
#include "version.hpp"
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
namespace Version
|
||||
{
|
||||
|
||||
Version getOpenmwVersion(const std::string &resourcePath)
|
||||
{
|
||||
boost::filesystem::path path (resourcePath + "/version");
|
||||
|
||||
boost::filesystem::ifstream stream (path);
|
||||
|
||||
Version v;
|
||||
std::getline(stream, v.mVersion);
|
||||
std::getline(stream, v.mCommitHash);
|
||||
std::getline(stream, v.mTagHash);
|
||||
return v;
|
||||
}
|
||||
|
||||
std::string Version::describe()
|
||||
{
|
||||
std::string str = "OpenMW version " + mVersion;
|
||||
std::string rev = mCommitHash;
|
||||
std::string tag = mTagHash;
|
||||
if (!rev.empty() && !tag.empty())
|
||||
{
|
||||
rev = rev.substr(0, 10);
|
||||
str += "\nRevision: " + rev;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string getOpenmwVersionDescription(const std::string &resourcePath)
|
||||
{
|
||||
Version v = getOpenmwVersion(resourcePath);
|
||||
return v.describe();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
#ifndef VERSION_HPP
|
||||
#define VERSION_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Version
|
||||
{
|
||||
|
||||
struct Version
|
||||
{
|
||||
std::string mVersion;
|
||||
std::string mCommitHash;
|
||||
std::string mTagHash;
|
||||
|
||||
std::string describe();
|
||||
};
|
||||
|
||||
/// Read OpenMW version from the version file located in resourcePath.
|
||||
Version getOpenmwVersion(const std::string& resourcePath);
|
||||
|
||||
/// Helper function to getOpenmwVersion and describe() it
|
||||
std::string getOpenmwVersionDescription(const std::string& resourcePath);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // VERSION_HPP
|
||||
|
@ -1,13 +0,0 @@
|
||||
#ifndef VERSION_HPP
|
||||
#define VERSION_HPP
|
||||
|
||||
#define OPENMW_VERSION_MAJOR @OPENMW_VERSION_MAJOR@
|
||||
#define OPENMW_VERSION_MINOR @OPENMW_VERSION_MINOR@
|
||||
#define OPENMW_VERSION_RELEASE @OPENMW_VERSION_RELEASE@
|
||||
#define OPENMW_VERSION "@OPENMW_VERSION@"
|
||||
|
||||
#define OPENMW_VERSION_COMMITHASH "@OPENMW_VERSION_COMMITHASH@"
|
||||
#define OPENMW_VERSION_TAGHASH "@OPENMW_VERSION_TAGHASH@"
|
||||
|
||||
#endif // VERSION_HPP
|
||||
|
@ -0,0 +1,3 @@
|
||||
@OPENMW_VERSION@
|
||||
@OPENMW_VERSION_COMMITHASH@
|
||||
@OPENMW_VERSION_TAGHASH@
|
Loading…
Reference in New Issue