mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 11:26:42 +00:00 
			
		
		
		
	Now we don't need to recompile 3 .cpp files and re-link whenever the current git HEAD changes.
		
			
				
	
	
		
			41 lines
		
	
	
	
		
			888 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
	
		
			888 B
		
	
	
	
		
			C++
		
	
	
	
	
	
#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();
 | 
						|
}
 | 
						|
 | 
						|
}
 |