1 |
A parallel variant of python_foreach_impl. Also, move DISTUTILS_JOBS to |
2 |
python-r1 then. |
3 |
--- |
4 |
gx86/eclass/distutils-r1.eclass | 8 ------ |
5 |
gx86/eclass/python-r1.eclass | 54 +++++++++++++++++++++++++++++++++++++++++ |
6 |
2 files changed, 54 insertions(+), 8 deletions(-) |
7 |
|
8 |
diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass |
9 |
index e662fa2..8457fd2 100644 |
10 |
--- a/gx86/eclass/distutils-r1.eclass |
11 |
+++ b/gx86/eclass/distutils-r1.eclass |
12 |
@@ -100,14 +100,6 @@ if [[ ! ${DISTUTILS_OPTIONAL} ]]; then |
13 |
DEPEND=${PYTHON_DEPS} |
14 |
fi |
15 |
|
16 |
-# @ECLASS-VARIABLE: DISTUTILS_JOBS |
17 |
-# @DEFAULT_UNSET |
18 |
-# @DESCRIPTION: |
19 |
-# The number of parallel jobs to run for distutils-r1 parallel builds. |
20 |
-# If unset, the job-count in ${MAKEOPTS} will be used. |
21 |
-# |
22 |
-# This variable is intended to be set in make.conf. |
23 |
- |
24 |
# @ECLASS-VARIABLE: PATCHES |
25 |
# @DEFAULT_UNSET |
26 |
# @DESCRIPTION: |
27 |
diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass |
28 |
index 083157c..09e6417 100644 |
29 |
--- a/gx86/eclass/python-r1.eclass |
30 |
+++ b/gx86/eclass/python-r1.eclass |
31 |
@@ -173,6 +173,14 @@ _python_set_globals() { |
32 |
} |
33 |
_python_set_globals |
34 |
|
35 |
+# @ECLASS-VARIABLE: DISTUTILS_JOBS |
36 |
+# @DEFAULT_UNSET |
37 |
+# @DESCRIPTION: |
38 |
+# The number of parallel jobs to run for distutils-r1 parallel builds. |
39 |
+# If unset, the job-count in ${MAKEOPTS} will be used. |
40 |
+# |
41 |
+# This variable is intended to be set in make.conf. |
42 |
+ |
43 |
# @FUNCTION: _python_validate_useflags |
44 |
# @INTERNAL |
45 |
# @DESCRIPTION: |
46 |
@@ -623,6 +631,52 @@ python_foreach_impl() { |
47 |
return ${ret} |
48 |
} |
49 |
|
50 |
+# @FUNCTION: python_parallel_foreach_impl |
51 |
+# @USAGE: <command> [<args>...] |
52 |
+# @DESCRIPTION: |
53 |
+# Run the given command for each of the enabled Python implementations. |
54 |
+# If additional parameters are passed, they will be passed through |
55 |
+# to the command. |
56 |
+# |
57 |
+# The function will return 0 status if all invocations succeed. |
58 |
+# Otherwise, the return code from first failing invocation will |
59 |
+# be returned. |
60 |
+# |
61 |
+# For each command being run, EPYTHON, PYTHON and BUILD_DIR are set |
62 |
+# locally, and the former two are exported to the command environment. |
63 |
+# |
64 |
+# Multiple invocations of the command will be run in parallel, up to |
65 |
+# DISTUTILS_JOBS (defaulting to '-j' option argument from MAKEOPTS). |
66 |
+python_parallel_foreach_impl() { |
67 |
+ debug-print-function ${FUNCNAME} "${@}" |
68 |
+ |
69 |
+ local ret lret |
70 |
+ |
71 |
+ _python_parallel() { |
72 |
+ ( |
73 |
+ multijob_child_init |
74 |
+ "${@}" |
75 |
+ ) & |
76 |
+ multijob_post_fork |
77 |
+ } |
78 |
+ |
79 |
+ local opts |
80 |
+ if [[ ${DISTUTILS_JOBS} ]]; then |
81 |
+ opts=-j${DISTUTILS_JOBS} |
82 |
+ else |
83 |
+ opts=${MAKEOPTS} |
84 |
+ fi |
85 |
+ |
86 |
+ multijob_init "${opts}" |
87 |
+ python_foreach_impl _python_parallel "${@}" |
88 |
+ ret=${?} |
89 |
+ multijob_finish |
90 |
+ lret=${?} |
91 |
+ |
92 |
+ [[ ${ret} -eq 0 ]] && ret=${lret} |
93 |
+ return ${ret} |
94 |
+} |
95 |
+ |
96 |
# @FUNCTION: python_export_best |
97 |
# @USAGE: [<variable>...] |
98 |
# @DESCRIPTION: |
99 |
-- |
100 |
1.8.1.2 |