summaryrefslogtreecommitdiffstats
path: root/libversion
diff options
context:
space:
mode:
authoralbert-github <albert.tests@gmail.com>2019-05-31 18:03:45 (GMT)
committeralbert-github <albert.tests@gmail.com>2019-05-31 18:03:45 (GMT)
commit4ad23e5d18fc294e00844fd8557f8c5dd6254d6e (patch)
tree54add50b60dc75b677dc62afc84aad4014b0d9a2 /libversion
parentfa9dda01e6c013c7fe9be99b21d8bbf3c95c0482 (diff)
downloadDoxygen-4ad23e5d18fc294e00844fd8557f8c5dd6254d6e.zip
Doxygen-4ad23e5d18fc294e00844fd8557f8c5dd6254d6e.tar.gz
Doxygen-4ad23e5d18fc294e00844fd8557f8c5dd6254d6e.tar.bz2
Show git version information
The original version has as features: - getting the git version number for usage in doxygen - making the doxygen version number inclusion dependent on the VERSION file The disadvantage of the chosen methodology was that an extra correction step was necessary, by defining getter methods to retrieve the values this correction can be hidden. The information is coming from different sources: - the VERSION file - the git "repository and build system (when present) Furthermore there are a couple of places where the version information is used (a.o. doxygen and doxywizard executable, though the doxygenwizard was only done "half hearted") The handling of the VERSION file has been made in such a way that it is comparable with the generation of the git version changes. For a better abstraction the version handling is all done in a separate directory.
Diffstat (limited to 'libversion')
-rw-r--r--libversion/CMakeLists.txt27
-rw-r--r--libversion/doxyversion.cpp.in7
-rw-r--r--libversion/gitversion.cpp.in16
-rw-r--r--libversion/version.h22
4 files changed, 72 insertions, 0 deletions
diff --git a/libversion/CMakeLists.txt b/libversion/CMakeLists.txt
new file mode 100644
index 0000000..1a430fd
--- /dev/null
+++ b/libversion/CMakeLists.txt
@@ -0,0 +1,27 @@
+# vim:ts=4:sw=4:expandtab:autoindent:
+
+# setup information for doxygen version handling
+set(PRE_CONFIGURE_DOXYGEN_VERSION_FILE "${CMAKE_SOURCE_DIR}/libversion/doxyversion.cpp.in")
+set(POST_CONFIGURE_DOXYGEN_VERSION_FILE "${GENERATED_SRC}/doxyversion.cpp")
+
+# setup information for git version handling
+set(PRE_CONFIGURE_GIT_VERSION_FILE "${CMAKE_SOURCE_DIR}/libversion/gitversion.cpp.in")
+set(POST_CONFIGURE_GIT_VERSION_FILE "${GENERATED_SRC}/gitversion.cpp")
+
+include(${CMAKE_SOURCE_DIR}/cmake/git_watcher.cmake)
+include(${CMAKE_SOURCE_DIR}/cmake/doxygen_version.cmake)
+
+include_directories(
+ .
+)
+
+add_library(version STATIC
+ ${POST_CONFIGURE_DOXYGEN_VERSION_FILE}
+ ${POST_CONFIGURE_GIT_VERSION_FILE}
+)
+
+add_dependencies( version check_git_repository )
+add_dependencies( version check_doxygen_version )
+
+set_source_files_properties(${POST_CONFIGURE_GIT_VERSION_FILE} PROPERTIES GENERATED 1)
+set_source_files_properties(${POST_CONFIGURE_DOXYGEN_VERSION_FILE} PROPERTIES GENERATED 1)
diff --git a/libversion/doxyversion.cpp.in b/libversion/doxyversion.cpp.in
new file mode 100644
index 0000000..11bca8d
--- /dev/null
+++ b/libversion/doxyversion.cpp.in
@@ -0,0 +1,7 @@
+#include "version.h"
+
+char *getVersion(void)
+{
+ static char versionString[] = "@DOXYGEN_VERSION@";
+ return versionString;
+}
diff --git a/libversion/gitversion.cpp.in b/libversion/gitversion.cpp.in
new file mode 100644
index 0000000..164b50b
--- /dev/null
+++ b/libversion/gitversion.cpp.in
@@ -0,0 +1,16 @@
+#include <string.h>
+#include <version.h>
+
+/* - On some systems git is not installed or
+ * installed on a place where FindGit.cmake cannot find it
+ * - No git information is present (no .git directory)
+ * in those cases clear the gitVersionString (would have string GIT-NOTFOUND).
+ */
+char *getGitVersion(void)
+{
+ static char gitVersionString[100];
+ strcpy(gitVersionString,"@GIT_HEAD_SHA1@");
+ strcat(gitVersionString,!strcmp("@GIT_IS_DIRTY@","true")?"*":"");
+ if (!strcmp("@GIT_HEAD_SHA1@", "GIT-NOTFOUND")) gitVersionString[0] = '\0';
+ return gitVersionString;
+}
diff --git a/libversion/version.h b/libversion/version.h
new file mode 100644
index 0000000..a656e74
--- /dev/null
+++ b/libversion/version.h
@@ -0,0 +1,22 @@
+/******************************************************************************
+ *
+ *
+ *
+ * Copyright (C) 1997-2015 by Dimitri van Heesch.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied warranty.
+ * See the GNU General Public License for more details.
+ *
+ * Documents produced by Doxygen are derivative works derived from the
+ * input used in their production; they are not affected by this license.
+ *
+ */
+
+#ifndef VERSION_H
+#define VERSION_H
+char *getVersion(void);
+char *getGitVersion(void);
+#endif