parallel-wrapper.sh 876 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0+
  3. #
  4. # Figure out if we should follow a specific parallelism from the make
  5. # environment (as exported by scripts/jobserver-exec), or fall back to
  6. # the "auto" parallelism when "-jN" is not specified at the top-level
  7. # "make" invocation.
  8. sphinx="$1"
  9. shift || true
  10. parallel="$PARALLELISM"
  11. if [ -z "$parallel" ] ; then
  12. # If no parallelism is specified at the top-level make, then
  13. # fall back to the expected "-jauto" mode that the "htmldocs"
  14. # target has had.
  15. auto=$(perl -e 'open IN,"'"$sphinx"' --version 2>&1 |";
  16. while (<IN>) {
  17. if (m/([\d\.]+)/) {
  18. print "auto" if ($1 >= "1.7")
  19. }
  20. }
  21. close IN')
  22. if [ -n "$auto" ] ; then
  23. parallel="$auto"
  24. fi
  25. fi
  26. # Only if some parallelism has been determined do we add the -jN option.
  27. if [ -n "$parallel" ] ; then
  28. parallel="-j$parallel"
  29. fi
  30. exec "$sphinx" $parallel "$@"