summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2013-02-26 14:33:45 +0000
committerMichał Górny <mgorny@gentoo.org>2013-02-26 14:33:45 +0000
commit78b2ea573430ecbc4e40db626b9ce1d9a4061ef6 (patch)
tree81ed7395cddf924e2b4ccbad7918470cfcc65cf9 /eclass/python-r1.eclass
parentMake python_foreach_impl() non-fatal, expect explicit die inside or outside. (diff)
downloadhistorical-78b2ea573430ecbc4e40db626b9ce1d9a4061ef6.tar.gz
historical-78b2ea573430ecbc4e40db626b9ce1d9a4061ef6.tar.bz2
historical-78b2ea573430ecbc4e40db626b9ce1d9a4061ef6.zip
Introduce the parallel variant of python_foreach_impl().
Diffstat (limited to 'eclass/python-r1.eclass')
-rw-r--r--eclass/python-r1.eclass56
1 files changed, 55 insertions, 1 deletions
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 5b2e8b6b4da1..ec75d4ab8331 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.41 2013/02/26 14:32:49 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.42 2013/02/26 14:33:45 mgorny Exp $
# @ECLASS: python-r1
# @MAINTAINER:
@@ -173,6 +173,14 @@ _python_set_globals() {
}
_python_set_globals
+# @ECLASS-VARIABLE: DISTUTILS_JOBS
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# The number of parallel jobs to run for distutils-r1 parallel builds.
+# If unset, the job-count in ${MAKEOPTS} will be used.
+#
+# This variable is intended to be set in make.conf.
+
# @FUNCTION: _python_validate_useflags
# @INTERNAL
# @DESCRIPTION:
@@ -623,6 +631,52 @@ python_foreach_impl() {
return ${ret}
}
+# @FUNCTION: python_parallel_foreach_impl
+# @USAGE: <command> [<args>...]
+# @DESCRIPTION:
+# Run the given command for each of the enabled Python implementations.
+# If additional parameters are passed, they will be passed through
+# to the command.
+#
+# The function will return 0 status if all invocations succeed.
+# Otherwise, the return code from first failing invocation will
+# be returned.
+#
+# For each command being run, EPYTHON, PYTHON and BUILD_DIR are set
+# locally, and the former two are exported to the command environment.
+#
+# Multiple invocations of the command will be run in parallel, up to
+# DISTUTILS_JOBS (defaulting to '-j' option argument from MAKEOPTS).
+python_parallel_foreach_impl() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local ret lret
+
+ _python_parallel() {
+ (
+ multijob_child_init
+ "${@}"
+ ) &
+ multijob_post_fork
+ }
+
+ local opts
+ if [[ ${DISTUTILS_JOBS} ]]; then
+ opts=-j${DISTUTILS_JOBS}
+ else
+ opts=${MAKEOPTS}
+ fi
+
+ multijob_init "${opts}"
+ python_foreach_impl _python_parallel "${@}"
+ ret=${?}
+ multijob_finish
+ lret=${?}
+
+ [[ ${ret} -eq 0 ]] && ret=${lret}
+ return ${ret}
+}
+
# @FUNCTION: python_export_best
# @USAGE: [<variable>...]
# @DESCRIPTION: