[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-dev
Subject:    [gentoo-dev] [PATCH 6/8] Convert python-r1 to use multibuild.
From:       Michał Górny <mgorny () gentoo ! org>
Date:       2013-02-27 21:43:23
Message-ID: 1362001405-25636-6-git-send-email-mgorny () gentoo ! org
[Download RAW message or body]

---
 gx86/eclass/python-r1.eclass | 74 +++++++++++++-------------------------------
 1 file changed, 21 insertions(+), 53 deletions(-)

diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
index a1d9228..fb9032e 100644
--- a/gx86/eclass/python-r1.eclass
+++ b/gx86/eclass/python-r1.eclass
@@ -48,7 +48,7 @@ elif [[ ${_PYTHON_ANY_R1} ]]; then
 	die 'python-r1.eclass can not be used with python-any-r1.eclass.'
 fi
 
-inherit python-utils-r1
+inherit multibuild python-utils-r1
 
 # @ECLASS-VARIABLE: PYTHON_COMPAT
 # @REQUIRED
@@ -602,6 +602,21 @@ _python_obtain_impls() {
 	done
 }
 
+# @FUNCTION: _python_multibuild_wrapper
+# @USAGE: <command> [<args>...]
+# @INTERNAL
+# @DESCRIPTION:
+# Initialize the environment for Python implementation selected
+# for multibuild.
+_python_multibuild_wrapper() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local -x EPYTHON PYTHON
+	python_export "${MULTIBUILD_VARIANT}" EPYTHON PYTHON
+
+	"${@}"
+}
+
 # @FUNCTION: python_foreach_impl
 # @USAGE: <command> [<args>...]
 # @DESCRIPTION:
@@ -621,36 +636,10 @@ python_foreach_impl() {
 	_python_validate_useflags
 	_python_check_USE_PYTHON
 
-	local impl
-	local bdir=${BUILD_DIR:-${S}}
-	local ret=0 lret=0
 	local MULTIBUILD_VARIANTS
-
-	debug-print "${FUNCNAME}: bdir = ${bdir}"
 	_python_obtain_impls
-	for impl in "${MULTIBUILD_VARIANTS[@]}"; do
-		local EPYTHON PYTHON
-		python_export "${impl}" EPYTHON PYTHON
-		local BUILD_DIR=${bdir%%/}-${impl}
-		export EPYTHON PYTHON
-
-		einfo "${EPYTHON}: running ${@}" \
-			| tee -a "${T}/build-${EPYTHON}.log"
-
-		# _python_parallel() does redirection internally.
-		# note: this is a hidden API to avoid writing python_foreach_impl
-		# twice. do *not* even think of using it anywhere else.
-		if [[ ${1} == _python_parallel ]]; then
-			"${@}"
-		else
-			"${@}" 2>&1 | tee -a "${T}/build-${EPYTHON}.log"
-		fi
-		lret=${?}
 
-		[[ ${ret} -eq 0 && ${lret} -ne 0 ]] && ret=${lret}
-	done
-
-	return ${ret}
+	multibuild_foreach _python_multibuild_wrapper "${@}"
 }
 
 # @FUNCTION: python_parallel_foreach_impl
@@ -672,32 +661,11 @@ python_foreach_impl() {
 python_parallel_foreach_impl() {
 	debug-print-function ${FUNCNAME} "${@}"
 
-	local ret lret
-
-	_python_parallel() {
-		(
-			multijob_child_init
-			"${@}" 2>&1 | tee -a "${T}/build-${EPYTHON}.log"
-			exit ${PIPESTATUS[0]}
-		) &
-		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=${?}
+	local MULTIBUILD_JOBS=${MULTIBUILD_JOBS:-${DISTUTILS_JOBS}}
+	local MULTIBUILD_VARIANTS
+	_python_obtain_impls
 
-	[[ ${ret} -eq 0 ]] && ret=${lret}
-	return ${ret}
+	multibuild_parallel_foreach _python_multibuild_wrapper "${@}"
 }
 
 # @FUNCTION: python_export_best
-- 
1.8.1.4


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic