diff --git a/Makefile b/Makefile index d76391a..cefe153 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,8 @@ gtest: $(GTESTS_TESTDIR)/*.cpp $(GTEST_OBJECTS) %.o:%.cpp $(CXX) ${CXXFLAGS} ${LDFLAGS} ${INCLUDEFLAGS} -c -o $@ $< +version.o:version.cpp + $(CXX) ${CXXFLAGS} ${LDFLAGS} ${INCLUDEFLAGS} -DGITCOMMIT=\"$(shell git rev-parse --short HEAD)\" -c -o $@ $< clean: rm -f $(OBJECTS) $(DEPENDS) diff --git a/qswiki.cpp b/qswiki.cpp index 9d5738e..f34a85c 100644 --- a/qswiki.cpp +++ b/qswiki.cpp @@ -41,6 +41,7 @@ SOFTWARE. #include "cli.h" #include "cliconsole.h" #include "cliserver.h" +#include "version.h" void sigterm_handler(int arg) { @@ -73,11 +74,6 @@ std::unique_ptr createCache(const ConfigVariableResolver &resolver) return std::make_unique(path); } -std::string get_version_string() -{ - return "master"; -} - int main(int argc, char **argv) { diff --git a/version.cpp b/version.cpp new file mode 100644 index 0000000..95490a4 --- /dev/null +++ b/version.cpp @@ -0,0 +1,11 @@ +#include "version.h" + +std::string git_commit_id() +{ + return std::string(GITCOMMIT); +} + +std::string get_version_string() +{ + return git_commit_id() + " Built: " + __DATE__ + " " + __TIME__; +} diff --git a/version.h b/version.h new file mode 100644 index 0000000..b9aa895 --- /dev/null +++ b/version.h @@ -0,0 +1,7 @@ +#ifndef VERSION_H +#define VERSION_H + +#include +std::string git_commit_id(); +std::string get_version_string(); +#endif // VERSION_H