Include doi strings from zenodo during release
authorPaul Bauer <paul.bauer.q@gmail.com>
Tue, 14 Nov 2017 10:43:31 +0000 (11:43 +0100)
committerMark Abraham <mark.j.abraham@gmail.com>
Wed, 10 Oct 2018 19:15:39 +0000 (21:15 +0200)
Add functionality to include doi strings
gathered from Zenodo into the release build
source code and manual. Actual registration
of the DOI has to be handled somewhere else.

Change-Id: I1ce4c913c313e56e77e031e742367420e25da36d

14 files changed:
cmake/gmxVersionInfo.cmake
docs/CMakeLists.txt
docs/conf-vars.py.cmakein
docs/download.rst
docs/user-guide-old/index.rst
docs/user-guide/index.rst
src/gromacs/CMakeLists.txt
src/gromacs/mdrun/runner.cpp
src/gromacs/utility/baseversion-gen.cpp.cmakein
src/gromacs/utility/baseversion-gen.h
src/gromacs/utility/baseversion.cpp
src/gromacs/utility/baseversion.h
src/gromacs/utility/pleasecite.cpp
src/gromacs/utility/pleasecite.h

index 5c28f3553abe408317604ff3d4df940de4370cb7..c39d4bc21c6db3597e3e86c5d5c84e4573ce5aae 100644 (file)
 #   REGRESSIONTEST_MD5SUM
 #       The MD5 checksum of the regressiontest tarball. Only used when building
 #       from a source package.
+#   GMX_SOURCE_DOI_ID
+#       ID collected from Zenodo connected to the doi for a released version
+#       used to identify the source when building an official released version.
+#       This ID is used for the source code tarball.
+#   GMX_MANUAL_DOI_ID
+#       Same as above, but for the reference manual.
+# Setting and retrieving of those variables is handled in gmxCheckReleaseDOI.cmake
 # They are collected into a single section below.
 # The following variables are set based on these:
 #   GMX_VERSION            String composed from GMX_VERSION_* numeric variables
 # tree is a git, but can be disabled with
 #   GMX_GIT_VERSION_INFO           Advanced CMake variable to disable git
 #                                  version info generation.
+# If the version generation is disabled, then the source and manual doi
+# will be based on the stored values for the ID.
 # The main interface to this machinery is the gmx_configure_version_file()
 # CMake function.  The signature is
 #   gmx_configure_version_file(<input> <output>
@@ -245,6 +254,13 @@ if (CMAKE_SCRIPT_MODE_FILE)
     return()
 endif()
 
+# Set those values only in release versions, after getting the identifiers
+# from Zenodo for the manual and source code
+# Has to be done by hand before every final release
+# Use force to override anything given as a cmake command line input
+set(GMX_MANUAL_DOI "" CACHE INTERNAL "reserved doi for GROMACS manual" FORCE)
+set(GMX_SOURCE_DOI "" CACHE INTERNAL "reserved doi for GROMACS source code" FORCE)
+
 #####################################################################
 # git version info management
 
index 6a773d85e106a077ebbc609bba1972ab6ae2a95c..644b5c3ec65fe7cc6931e53c1609519b6033c82c 100644 (file)
@@ -375,6 +375,31 @@ if (SPHINX_FOUND)
     include(SphinxMacros.cmake)
     gmx_init_sphinx_setup(${SPHINX_INPUT_DIR})
 
+    # set temporary variables for doi inclusion
+    # into the manual, plain string + some wrapping
+    # for release builds, and dummy string for non-release
+    # builds
+    if("${GMX_MANUAL_DOI}" STREQUAL "")
+      # empty string means no doi, set dummy text
+      set(GMX_MANUAL_DOI_STRING "This is not a release build of GROMACS, so please reference")
+      set(GMX_MANUAL_DOI_STRING "${GMX_MANUAL_DOI_STRING} one of the GROMACS papers and the base release of the manual.")
+    else()
+      # release version, set plain old boring string
+      set(GMX_MANUAL_DOI_STRING "Please reference this documentation as https://doi.org/${GMX_MANUAL_DOI}.")
+    endif()
+    # same for source doi, but modify the text
+    if("${GMX_SOURCE_DOI}" STREQUAL "")
+      # empty string means no release build
+      set(GMX_SOURCE_DOI_STRING "This is not a release build of GROMACS. Please reference one of the")
+      set(GMX_SOURCE_DOI_STRING "${GMX_SOURCE_DOI_STRING} GROMACS papers, as well as the base release that this version is built from.")
+      set(GMX_SOURCE_DOI_STRING "${GMX_SOURCE_DOI_STRING} Also, please state what modifcations have been performed or where the version")
+      set(GMX_SOURCE_DOI_STRING "${GMX_SOURCE_DOI_STRING} was sourced from.")
+    else()
+      # release version, give them a doi url string
+      set(GMX_SOURCE_DOI_STRING "To cite the source code for this release, please cite")
+      set(GMX_SOURCE_DOI_STRING "${GMX_SOURCE_DOI_STRING} https://doi.org/${GMX_SOURCE_DOI}.")
+    endif()
+
     set(SPHINX_CONFIG_VARS_FILE ${SPHINX_INPUT_DIR}/conf-vars.py)
     gmx_configure_version_file(conf-vars.py.cmakein ${SPHINX_CONFIG_VARS_FILE}
         EXTRA_VARS
@@ -387,6 +412,8 @@ if (SPHINX_FOUND)
             SOURCE_MD5SUM REGRESSIONTEST_MD5SUM_STRING
             GMX_TNG_MINIMUM_REQUIRED_VERSION
             GMX_LMFIT_REQUIRED_VERSION
+            GMX_MANUAL_DOI_STRING
+            GMX_SOURCE_DOI_STRING
         COMMENT "Configuring Sphinx configuration file")
     gmx_add_sphinx_input_file(${SPHINX_CONFIG_VARS_FILE})
     gmx_add_sphinx_source_files(FILES ${SPHINX_SOURCE_FILES})
index 038014a7398cf78d9593f43623a7220107e2a042..e1c8b531c8c4fa6d5fd8c07c581c02e8dad89304 100644 (file)
@@ -48,5 +48,7 @@ variables = [
         ('SOURCE_MD5SUM', '@SOURCE_MD5SUM@'),
         ('REGRESSIONTEST_MD5SUM', '@REGRESSIONTEST_MD5SUM_STRING@'),
         ('GMX_TNG_MINIMUM_REQUIRED_VERSION', '@GMX_TNG_MINIMUM_REQUIRED_VERSION@'),
-        ('GMX_LMFIT_REQUIRED_VERSION', '@GMX_LMFIT_REQUIRED_VERSION@')
+        ('GMX_LMFIT_REQUIRED_VERSION', '@GMX_LMFIT_REQUIRED_VERSION@'),
+        ('GMX_MANUAL_DOI_STRING', '@GMX_MANUAL_DOI_STRING@'),
+        ('GMX_SOURCE_DOI_STRING', '@GMX_SOURCE_DOI_STRING@')
     ]
index c77ef35aa36670d6b0ed16a7688969004845cc27..8586bd89fc2b33e68da2956f5d2d94ce557006cb 100644 (file)
@@ -3,6 +3,10 @@
 Downloads
 =========
 
+|GMX_MANUAL_DOI_STRING|
+
+|GMX_SOURCE_DOI_STRING|
+
 Source code
 -----------
 * |gmx-source-package-ftp|
index 636c85f7c0f2dd07b3d70b9e679d47c7476f3f16..0890011729baaf7232931f30671c65cd059e6604 100644 (file)
@@ -16,6 +16,10 @@ For getting, building and installing |Gromacs|, see the
 For background on algorithms and implementations, see the
 `reference manual`_.
 
+|GMX_MANUAL_DOI_STRING|
+
+|GMX_SOURCE_DOI_STRING|
+
 .. _reference manual: gmx-manual-parent-dir_
 
 .. toctree::
index 3c7ae2186549b20203a1fdd7f565b225e909ae81..036a5aecf4bdefb395392ee659505e65fad2d994 100644 (file)
@@ -16,6 +16,10 @@ For getting, building and installing |Gromacs|, see the
 For background on algorithms and implementations, see the
 :ref:`reference manual part <gmx-reference-manual-rst>` of the documentation.
 
+|GMX_MANUAL_DOI_STRING|
+
+|GMX_SOURCE_DOI_STRING|
+
 .. TODO This is going to require more organization now that
    we are getting more content available.
 
index b305b92326bf45e85b5baac028c4ba3d9d0080a9..5f9ad79b925affacb6c4ef1088d64e985382bf55 100644 (file)
@@ -171,7 +171,10 @@ gmx_install_headers(
 set(GENERATED_VERSION_FILE utility/baseversion-gen.cpp)
 gmx_configure_version_file(
     utility/baseversion-gen.cpp.cmakein ${GENERATED_VERSION_FILE}
-    REMOTE_HASH)
+    REMOTE_HASH
+    EXTRA_VARS
+        GMX_SOURCE_DOI
+    )
 list(APPEND LIBGROMACS_SOURCES ${GENERATED_VERSION_FILE}
      $<TARGET_OBJECTS:libgromacs_external>
      $<TARGET_OBJECTS:libgromacs_generated>)
index 8b9d48d79571ebbea4729ce8369a8b7560ee5a67..1e8c85149a16fa63e59775fe6b9cdf9a952c2b28 100644 (file)
@@ -525,6 +525,7 @@ int Mdrunner::mdrunner()
         please_cite(fplog, "Spoel2005a");
         please_cite(fplog, "Lindahl2001a");
         please_cite(fplog, "Berendsen95a");
+        writeSourceDoi(fplog);
     }
 
     std::unique_ptr<t_state> globalState;
index b4c80730e3ae2c6ce6a4da819f8672426b30343f..441cefebd35f1d642c95773446a2ee9255eefc12 100644 (file)
@@ -37,3 +37,4 @@
 const char _gmx_ver_string[] = "@GMX_VERSION_STRING_FULL@";
 const char _gmx_full_git_hash[] = "@GMX_VERSION_FULL_HASH@";
 const char _gmx_central_base_hash[] = "@GMX_VERSION_CENTRAL_BASE_HASH@";
+const char gmxSourceDoiString[] = "@GMX_SOURCE_DOI@";
index d7a0392731aeb7da44c0ef1d56ff0bedabb5bcef..1efca7a64e7c1eb7bb22b83219378f9f14c8b585 100644 (file)
@@ -52,6 +52,15 @@ extern const char _gmx_ver_string[];
 extern const char _gmx_full_git_hash[];
 //! Full git hash of the latest commit in a central \Gromacs repository.
 extern const char _gmx_central_base_hash[];
+/*! \brief
+ *  DOI string for the \Gromacs source code populated by CMake.
+ *
+ *  The variable is populated with the generated DOI string
+ *  by CMake when the build of a release version is
+ *  requested by Jenkins. Allows identification and
+ *  referencing of different \Gromacs releases.
+ */
+extern const char gmxSourceDoiString[];
 
 //! \}
 //! \endcond
index 05d1c18f82cbafdd1954129b8cc699589ab77603..1cf7cc0652fe6b7d4b5daa472ef3d6e65e5b8e14 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -55,6 +55,11 @@ const char *gmx_version_git_central_base_hash()
     return _gmx_central_base_hash;
 }
 
+const char *gmxDOI()
+{
+    return gmxSourceDoiString;
+}
+
 #if GMX_DOUBLE
 void gmx_is_double_precision()
 {
index 545517186828cdaf643cb14bd6482bc1777a76cb..b4e7fc4a74219f1e0a4c1ca5d33361b5873a95cc 100644 (file)
@@ -96,4 +96,9 @@ void gmx_is_single_precision();
 /*! \brief Return a string describing what kind of GPU suport was configured in the build. */
 const char *getGpuImplementationString();
 
+/*! \brief
+ * DOI string, or empty when not a release build.
+ */
+const char *gmxDOI();
+
 #endif
index f3664822f9a00f698efccbb13369d7d3955c5b7f..261d733b5b7b0abde00fbef2e4417b62f9886808 100644 (file)
@@ -41,6 +41,7 @@
 #include <cstring>
 
 #include "gromacs/utility/arraysize.h"
+#include "gromacs/utility/baseversion.h"
 #include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/smalloc.h"
 
@@ -419,3 +420,28 @@ void please_cite(FILE *fp, const char *key)
     fprintf(fp, "-------- -------- --- Thank You --- -------- --------\n\n");
     fflush(fp);
 }
+
+void
+writeSourceDoi(FILE *fp)
+{
+    /* Check if we are in release mode or not.
+     * TODO The check should properly target something else than
+     * the string being empty
+     */
+    if (strlen(gmxDOI()) == 0)
+    {
+        /* Not a release build, return without printing anything */
+        return;
+    }
+
+    const char *doiString = wrap_lines(gmxDOI(), LINE_WIDTH, 0, FALSE);
+
+    if (fp == nullptr)
+    {
+        return;
+    }
+    fprintf(fp, "\n++++ PLEASE CITE THE DOI FOR THIS VERSION OF GROMACS ++++\n");
+    fprintf(fp, "%s%s\n", "https://doi.org/", doiString);
+    fprintf(fp, "-------- -------- --- Thank You --- -------- --------\n\n");
+    fflush(fp);
+}
index 1ae9e7fdb3fc219dd38189de34598eb101a8c8a5..3257f03dd0932a80a419db7255ac065f34223306 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -37,6 +37,7 @@
 /*! \libinternal \file
  * \brief
  * Declares please_cite() for printing out literature references.
+ * Declares writeSourceDoi for printing of source code DOI.
  *
  * \inlibraryapi
  * \ingroup module_utility
@@ -50,4 +51,8 @@
 void
 please_cite(FILE *fp, const char *key);
 
+//! Write a message to \c fp to request citation also of the source-code DOI.
+void
+writeSourceDoi(FILE *fp);
+
 #endif