Allow documentation to build in parallel
authorPaul Bauer <paul.bauer.q@gmail.com>
Fri, 31 Aug 2018 12:53:52 +0000 (14:53 +0200)
committerMagnus Lundborg <magnus.lundborg@scilifelab.se>
Mon, 3 Sep 2018 12:38:00 +0000 (14:38 +0200)
Resolved some CMake dependency issues that prevented the documentation
build to run in parallel.

Also changed the admin documentation build script to use parallel
builds.

Change-Id: Ieda390886bdebf50771d9efd91328b27e81150c1

admin/builds/documentation.py
docs/SphinxMacros.cmake
docs/doxygen/CMakeLists.txt

index 2214e35661b915196ded772f6438db5cdf94a651..2d52ae8213f8ec8d09ce6da8840be234b012a6dc 100644 (file)
@@ -63,7 +63,7 @@ def do_build(context):
     context.build_target(target='gmx', parallel=True,
             continue_on_failure=True)
 
-    context.build_target(target='manual', parallel=False,
+    context.build_target(target='manual', parallel=True,
             target_descr='PDF manual', continue_on_failure=True)
     logfile = os.path.join(context.workspace.build_dir, 'docs/manual/gromacs.log')
     if os.path.isfile(logfile):
@@ -77,9 +77,9 @@ def do_build(context):
     # separately causes many of the Doxygen targets to get built twice if run
     # from a tarball.
     if not release:
-        context.build_target(target='doxygen-all', parallel=False,
+        context.build_target(target='doxygen-all', parallel=True,
                 target_descr='Doxygen documentation', continue_on_failure=True)
-        context.build_target(target='check-source', parallel=False,
+        context.build_target(target='check-source', parallel=True,
                 failure_string='check-source failed to run', continue_on_failure=True)
         logs = []
         for target in ('check-source', 'doxygen-xml', 'doxygen-user',
@@ -93,10 +93,10 @@ def do_build(context):
         if context.failed:
             return
 
-    context.build_target(target='sphinx-input', parallel=False,
+    context.build_target(target='sphinx-input', parallel=True,
             failure_string='Generating Sphinx input failed',
             continue_on_failure=True)
-    context.build_target(target='sphinx-programs', parallel=False,
+    context.build_target(target='sphinx-programs', parallel=True,
             failure_string='Running gmx help -export rst failed',
             continue_on_failure=True)
     if context.failed:
@@ -110,7 +110,7 @@ def do_build(context):
             ))
     logs = []
     for target, log, descr in sphinx_targets:
-        context.build_target(target=target, parallel=False,
+        context.build_target(target=target, parallel=True,
                 failure_string='Sphinx: {0} generation failed'.format(descr),
                 continue_on_failure=True)
         logfile = os.path.join(context.workspace.build_dir,
@@ -122,7 +122,7 @@ def do_build(context):
     if context.failed:
         return
 
-    context.build_target(target='webpage', parallel=False)
+    context.build_target(target='webpage', parallel=True)
     if context.failed:
         return
 
index 5e90ceb0b9ac26767c9eb10bfe25e36f1e6e1352..0adc9291454f9570cab6c80bc151aac0ac7ce5c2 100644 (file)
@@ -55,11 +55,19 @@ function(gmx_add_sphinx_source_files)
     endif()
     foreach(_file ${ARG_FILES})
         set(_source ${ARG_FROM}/${_file})
+        get_filename_component(_filepath ${_file} DIRECTORY)
+        get_filename_component(_filename ${_source} NAME)
+        set(_targetdir ${_SPHINX_INPUT_ROOT}/${ARG_TO}/${_filepath})
+        set(_result ${_targetdir}/${_filename})
         set(_target ${_SPHINX_INPUT_ROOT}/${ARG_TO}${_file})
+        add_custom_command(
+            OUTPUT ${_targetdir}
+            COMMAND ${CMAKE_COMMAND} -E make_directory ${_targetdir}
+            )
         add_custom_command(
             OUTPUT  ${_target}
             COMMAND ${CMAKE_COMMAND} -E copy ${_source} ${_target}
-            DEPENDS ${_source}
+            DEPENDS ${_source} ${_targetdir}
             COMMENT "Copying Sphinx input file ${ARG_PREFIX}${_file}"
             VERBATIM)
         list(APPEND _SPHINX_INPUT_FILES ${_target})
@@ -95,12 +103,19 @@ function(gmx_add_sphinx_image_conversion_files)
     endif()
     foreach(_file ${ARG_FILES})
         set(_source ${ARG_FROM}/${_file})
-        string(REGEX REPLACE "pdf" "png" _tmp ${_file})
-        set(_target ${_SPHINX_INPUT_ROOT}/${ARG_TO}${_tmp})
+        get_filename_component(_filepath ${_file} DIRECTORY)
+        get_filename_component(_filename ${_source} NAME)
+        string(REGEX REPLACE "pdf" "png" _tmp ${_filename})
+        set(_targetdir ${_SPHINX_INPUT_ROOT}/${ARG_TO}/${_filepath})
+        set(_target ${_targetdir}/${_tmp})
+        add_custom_command(
+            OUTPUT ${_targetdir}
+            COMMAND ${CMAKE_COMMAND} -E make_directory ${_targetdir}
+            )
         add_custom_command(
             OUTPUT  ${_target}
             COMMAND convert ${_source} -antialias -quality 03 -quiet -pointsize 12 -density 1200 -units PixelsPerInch  ${_target}
-            DEPENDS ${_source}
+            DEPENDS ${_source} ${_targetdir}
             COMMENT "Converting Sphinx input graphics file ${_file} to png"
             VERBATIM)
         list(APPEND _SPHINX_IMAGE_CONVERSION_FILES ${_target})
index 17e2de5ccb15787e06785e9035e68b105cd61fb0..91c73f44f06275e83b24787310412742ff79d6c3 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+# Copyright (c) 2012,2013,2014,2015,2016,2017,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.
@@ -133,12 +133,17 @@ if (DOXYGEN_FOUND)
         set(_deps doxygen-source-timestamp doxygen-version
             ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-${TYPE})
         set(_fast_arg "")
-        if ("${ARGN}" STREQUAL "DEPGRAPHS")
+        list (FIND ARGN "DEPGRAPHS" _index)
+        if (${_index} GREATER -1)
             set(_fast_arg "ADD_FAST_TARGET")
             if (TARGET dep-graphs-dot)
                 list(APPEND _deps dep-graphs-dot)
             endif()
         endif()
+        list (FIND ARGN "DEPGRAPHS" _index)
+        if (${_index} GREATER -1)
+            list(APPEND _deps doxygen-xml)
+        endif()
         gmx_add_custom_output_target(${TARGET} OUTPUT STAMP ${_fast_arg}
             # Ensure the directory exists to avoid spurious warnings
             COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPGRAPH_DIR}
@@ -191,10 +196,10 @@ if (DOXYGEN_FOUND)
     endif()
 
     # Create the actual targets to build the documentation.
-    add_doxygen_target(doxygen-full full "Generating full documentation with Doxygen" DEPGRAPHS)
-    add_doxygen_target(doxygen-lib  lib  "Generating library documentation with Doxygen" DEPGRAPHS)
-    add_doxygen_target(doxygen-user user "Generating public API documentation with Doxygen")
-    add_doxygen_target(doxygen-dev dev "Generating verbose developer docs with Doxygen" DEPGRAPHS)
+    add_doxygen_target(doxygen-full full "Generating full documentation with Doxygen" DEPGRAPHS DEPXML)
+    add_doxygen_target(doxygen-lib  lib  "Generating library documentation with Doxygen" DEPGRAPHS DEPXML)
+    add_doxygen_target(doxygen-user user "Generating public API documentation with Doxygen" DEPXML)
+    add_doxygen_target(doxygen-dev dev "Generating verbose developer docs with Doxygen" DEPGRAPHS DEPXML)
     # Convenience targets to build all the documentation flavors.
     add_custom_target(doxygen-all)
     add_custom_target(doxygen-all-fast)