Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: python@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 6/8] Convert python-r1 to use multibuild.
Date: Wed, 27 Feb 2013 21:46:12
Message-Id: 1362001405-25636-6-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-dev] [RFC] multibuild.eclass -- a generic pluggable framework to handle multi-variant builds by "Michał Górny"
1 ---
2 gx86/eclass/python-r1.eclass | 74 +++++++++++++-------------------------------
3 1 file changed, 21 insertions(+), 53 deletions(-)
4
5 diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
6 index a1d9228..fb9032e 100644
7 --- a/gx86/eclass/python-r1.eclass
8 +++ b/gx86/eclass/python-r1.eclass
9 @@ -48,7 +48,7 @@ elif [[ ${_PYTHON_ANY_R1} ]]; then
10 die 'python-r1.eclass can not be used with python-any-r1.eclass.'
11 fi
12
13 -inherit python-utils-r1
14 +inherit multibuild python-utils-r1
15
16 # @ECLASS-VARIABLE: PYTHON_COMPAT
17 # @REQUIRED
18 @@ -602,6 +602,21 @@ _python_obtain_impls() {
19 done
20 }
21
22 +# @FUNCTION: _python_multibuild_wrapper
23 +# @USAGE: <command> [<args>...]
24 +# @INTERNAL
25 +# @DESCRIPTION:
26 +# Initialize the environment for Python implementation selected
27 +# for multibuild.
28 +_python_multibuild_wrapper() {
29 + debug-print-function ${FUNCNAME} "${@}"
30 +
31 + local -x EPYTHON PYTHON
32 + python_export "${MULTIBUILD_VARIANT}" EPYTHON PYTHON
33 +
34 + "${@}"
35 +}
36 +
37 # @FUNCTION: python_foreach_impl
38 # @USAGE: <command> [<args>...]
39 # @DESCRIPTION:
40 @@ -621,36 +636,10 @@ python_foreach_impl() {
41 _python_validate_useflags
42 _python_check_USE_PYTHON
43
44 - local impl
45 - local bdir=${BUILD_DIR:-${S}}
46 - local ret=0 lret=0
47 local MULTIBUILD_VARIANTS
48 -
49 - debug-print "${FUNCNAME}: bdir = ${bdir}"
50 _python_obtain_impls
51 - for impl in "${MULTIBUILD_VARIANTS[@]}"; do
52 - local EPYTHON PYTHON
53 - python_export "${impl}" EPYTHON PYTHON
54 - local BUILD_DIR=${bdir%%/}-${impl}
55 - export EPYTHON PYTHON
56 -
57 - einfo "${EPYTHON}: running ${@}" \
58 - | tee -a "${T}/build-${EPYTHON}.log"
59 -
60 - # _python_parallel() does redirection internally.
61 - # note: this is a hidden API to avoid writing python_foreach_impl
62 - # twice. do *not* even think of using it anywhere else.
63 - if [[ ${1} == _python_parallel ]]; then
64 - "${@}"
65 - else
66 - "${@}" 2>&1 | tee -a "${T}/build-${EPYTHON}.log"
67 - fi
68 - lret=${?}
69
70 - [[ ${ret} -eq 0 && ${lret} -ne 0 ]] && ret=${lret}
71 - done
72 -
73 - return ${ret}
74 + multibuild_foreach _python_multibuild_wrapper "${@}"
75 }
76
77 # @FUNCTION: python_parallel_foreach_impl
78 @@ -672,32 +661,11 @@ python_foreach_impl() {
79 python_parallel_foreach_impl() {
80 debug-print-function ${FUNCNAME} "${@}"
81
82 - local ret lret
83 -
84 - _python_parallel() {
85 - (
86 - multijob_child_init
87 - "${@}" 2>&1 | tee -a "${T}/build-${EPYTHON}.log"
88 - exit ${PIPESTATUS[0]}
89 - ) &
90 - multijob_post_fork
91 - }
92 -
93 - local opts
94 - if [[ ${DISTUTILS_JOBS} ]]; then
95 - opts=-j${DISTUTILS_JOBS}
96 - else
97 - opts=${MAKEOPTS}
98 - fi
99 -
100 - multijob_init "${opts}"
101 - python_foreach_impl _python_parallel "${@}"
102 - ret=${?}
103 - multijob_finish
104 - lret=${?}
105 + local MULTIBUILD_JOBS=${MULTIBUILD_JOBS:-${DISTUTILS_JOBS}}
106 + local MULTIBUILD_VARIANTS
107 + _python_obtain_impls
108
109 - [[ ${ret} -eq 0 ]] && ret=${lret}
110 - return ${ret}
111 + multibuild_parallel_foreach _python_multibuild_wrapper "${@}"
112 }
113
114 # @FUNCTION: python_export_best
115 --
116 1.8.1.4