public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: python@gentoo.org, "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-dev] [PATCH 6/8] Convert python-r1 to use multibuild.
Date: Wed, 27 Feb 2013 22:43:23 +0100	[thread overview]
Message-ID: <1362001405-25636-6-git-send-email-mgorny@gentoo.org> (raw)
In-Reply-To: <20130227224152.6d1293c9@pomiocik.lan>

---
 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



  parent reply	other threads:[~2013-02-27 21:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-27 21:41 [gentoo-dev] [RFC] multibuild.eclass -- a generic pluggable framework to handle multi-variant builds Michał Górny
2013-02-27 21:43 ` [gentoo-dev] [PATCH 1/8] Initial version of multibuild eclass Michał Górny
2013-02-27 21:43 ` [gentoo-dev] [PATCH 2/8] Use bash redirection to run 'tee' rather than simple pipes Michał Górny
2013-02-28 13:09   ` Alec Warner
2013-02-28 14:53     ` Michał Górny
2013-02-27 21:43 ` [gentoo-dev] [PATCH 3/8] Avoid writing outside WORKDIR if S=${WORKDIR} Michał Górny
2013-02-27 21:43 ` [gentoo-dev] [PATCH 4/8] Convert multilib-build to use multibuild Michał Górny
2013-02-27 21:43 ` [gentoo-dev] [PATCH 5/8] python-r1: calculate final list of enabled impls for foreach Michał Górny
2013-02-27 21:43 ` Michał Górny [this message]
2013-02-27 21:43 ` [gentoo-dev] [PATCH 7/8] Move run_in_build_dir() to multibuild.eclass Michał Górny
2013-02-27 21:43 ` [gentoo-dev] [PATCH 8/8] fftw: example use of multibuild in ebuild Michał Górny
2013-03-02 23:19   ` Christoph Junghans
2013-03-02 21:42 ` [gentoo-dev] Further changes to multibuild.eclass Michał Górny
2013-03-02 21:42   ` [gentoo-dev] [PATCH 1/4] multibuild: print only 'public' part of command-line Michał Górny
2013-03-02 22:52     ` Alec Warner
2013-03-02 23:03       ` Michał Górny
2013-03-02 21:42   ` [gentoo-dev] [PATCH 2/4] multibuild: add multibuild_for_best_variant() Michał Górny
2013-03-02 21:42   ` [gentoo-dev] [PATCH 3/4] multilib-build: introduce multilib_for_best_abi() Michał Górny
2013-03-02 21:42   ` [gentoo-dev] [PATCH 4/4] distutils-r1: reuse multibuild_for_best_variant Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1362001405-25636-6-git-send-email-mgorny@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    --cc=python@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox