Commit 3f884968 by Maarten L. Hekkelman

export version number of lib

parent e450fee0
......@@ -15,3 +15,4 @@ config.log
libtool
rsrc/lib-version.txt
version-info*.txt
src/revision.hpp
......@@ -132,6 +132,23 @@ $(OBJDIR)/Symmetry.lo: src/SymOpTable_data.cpp
endif
REVISION = $(shell git log --pretty=format:%h --max-count=1)
REVISION_FILE = version-info-$(REVISION).txt
$(REVISION_FILE):
rm -f version-info-*.txt
git describe --match=build --dirty > $@
@ git log --pretty=medium --date=iso8601 -1 >> $@
src/revision.hpp: $(REVISION_FILE)
@ echo 'const char kRevision[] = R"(' > $@
@ cat $? >> $@
@ echo ')";' >> $@
$(OBJDIR)/CifUtils.o: src/revision.hpp
$(OBJDIR)/CifUtils.lo: src/revision.hpp
$(LIB_TARGET): $(OBJECTS)
$(CXXLINK) -rpath $(libdir) $(OBJECTS) $(LIBS)
......
......@@ -54,6 +54,12 @@ extern const char gResourceName[];
namespace cif
{
// the git 'build' number
std::string get_version_nr();
// std::string get_version_date();
// --------------------------------------------------------------------
// some basic utilities: Since we're using ASCII input only, we define for optimisation
// our own case conversion routines.
......
......@@ -37,6 +37,7 @@
#include <fstream>
#include <map>
#include <chrono>
#include <regex>
#if defined(_MSC_VER)
#define TERM_WIDTH 80
......@@ -58,6 +59,40 @@ namespace cif
extern int VERBOSE;
// --------------------------------------------------------------------
std::string get_version_nr()
{
const std::regex
rxVersionNr(R"(build-(\d+)-g[0-9a-f]{7}(-dirty)?)");
#include "revision.hpp"
struct membuf : public std::streambuf
{
membuf(char* data, size_t length) { this->setg(data, data, data + length); }
} buffer(const_cast<char*>(kRevision), sizeof(kRevision));
std::istream is(&buffer);
std::string line, result;
while (getline(is, line))
{
std::smatch m;
if (std::regex_match(line, m, rxVersionNr))
{
result = m[1];
if (m[2].matched)
result += '*';
break;
}
}
return result;
}
// --------------------------------------------------------------------
// This really makes a difference, having our own tolower routines
const uint8_t kCharToLowerMap[256] =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment