From 93f070ec6b6efd2319eff5d8164dafbdaed4a006 Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Tue, 13 Oct 2015 22:25:52 +0200 Subject: [PATCH] doc-tools: Build in parallel with NUMBER_OF_CORES processes Change-Id: I7f820d80069f2b98c35f6f0cc1d2dbe9ed2b2cc7 --- bin/doc-tools-build-rst | 14 ++++++++++---- bin/doc-tools-check-languages | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/bin/doc-tools-build-rst b/bin/doc-tools-build-rst index 99bb0232..9cc9be80 100755 --- a/bin/doc-tools-build-rst +++ b/bin/doc-tools-build-rst @@ -32,6 +32,12 @@ TAG_OPT="" BUILD="" LINKCHECK="" +if [ -x "$(command -v getconf)" ]; then + NUMBER_OF_CORES=$(getconf _NPROCESSORS_ONLN) +else + NUMBER_OF_CORES=2 +fi + while [[ $# > 0 ]] ; do option="$1" case $option in @@ -85,14 +91,14 @@ fi if [ "$LINKCHECK" = "1" ] ; then # Show sphinx-build invocation for easy reproduction set -x - sphinx-build -E -W -d $DOCTREES -b linkcheck $TAG_OPT \ - $DIRECTORY/source $BUILD_DIR + sphinx-build -j $NUMBER_OF_CORES -E -W -d $DOCTREES -b linkcheck \ + $TAG_OPT $DIRECTORY/source $BUILD_DIR set +x else # Show sphinx-build invocation for easy reproduction set -x - sphinx-build -E -W -d $DOCTREES -b html $TAG_OPT \ - $DIRECTORY/source $BUILD_DIR + sphinx-build -j $NUMBER_OF_CORES -E -W -d $DOCTREES -b html \ + $TAG_OPT $DIRECTORY/source $BUILD_DIR set +x # Copy RST diff --git a/bin/doc-tools-check-languages b/bin/doc-tools-check-languages index db4e0a36..b6c4a689 100755 --- a/bin/doc-tools-check-languages +++ b/bin/doc-tools-check-languages @@ -14,6 +14,12 @@ BUILD_FAIL=0 +if [ -x "$(command -v getconf)" ]; then + NUMBER_OF_CORES=$(getconf _NPROCESSORS_ONLN) +else + NUMBER_OF_CORES=2 +fi + function setup_directories { language=$1 for directory in ${DIRECTORIES["$language"]} ; do @@ -51,7 +57,7 @@ function build_rst { if [ ${book} = "install-guide" ] ; then TAG="-t obs -t rdo -t ubuntu -t debian" fi - tox -evenv "sphinx-build -q -E -W -b gettext $TAG ${DOC_DIR}${book}/source/ \ + tox -evenv "sphinx-build -j $NUMBER_OF_CORES -q -E -W -b gettext $TAG ${DOC_DIR}${book}/source/ \ ${DOC_DIR}${book}/source/locale/" # Merge the common-rst po file in @@ -82,7 +88,7 @@ function build_rst { if [ ${book} = "firstapp" ] ; then # Firstapp has several variations, build all of them for tag in libcloud dotnet fog pkgcloud shade; do - tox -evenv "sphinx-build -q -E -t $tag -D language=${language} \ + tox -evenv "sphinx-build -j $NUMBER_OF_CORES -q -E -t $tag -D language=${language} \ ${DOC_DIR}${book}/source/ \ ${DOC_DIR}${book}/build-${tag}/html" mkdir -p publish-docs/${language}/${book}-${tag} @@ -103,7 +109,7 @@ function build_rst { sed -n 4p | sed -e 's/^ *//g') sed -i -e "s/\.\. title::.*/.. title:: ${title}/" \ ${DOC_DIR}${book}/source/index.rst - tox -evenv "sphinx-build -q -E -t $tag -D language=${language} \ + tox -evenv "sphinx-build -j $NUMBER_OF_CORES -q -E -t $tag -D language=${language} \ ${DOC_DIR}${book}/source/ \ ${DOC_DIR}${book}/build-${tag}/html" mkdir -p publish-docs/${language}/${book}-${tag} @@ -117,7 +123,7 @@ function build_rst { ${INSTALL_DEBIAN}/index.html fi else - tox -evenv "sphinx-build -q -E -D language=${language} \ + tox -evenv "sphinx-build -j $NUMBER_OF_CORES -q -E -D language=${language} \ ${DOC_DIR}${book}/source/ \ ${DOC_DIR}${book}/build/html" mkdir -p publish-docs/${language}/${book}/