Currently, python_foreach_impl() enters BUILD_DIR which is not really
clean nor expected by users. It's better to have that in distutils-r1
directly where it is used with quasi-phase functions.
---
 gx86/eclass/distutils-r1.eclass | 33 +++++++++++++++++++++++----------
 gx86/eclass/python-r1.eclass    | 10 ----------
 2 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index fdbd20b..6a6109d 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -286,6 +286,19 @@ distutils-r1_python_install_all() {
        done
 }
 
+# @FUNCTION: distutils-r1_run_phase
+# @USAGE: [<argv>...]
+# @INTERNAL
+# @DESCRIPTION:
+# Run the given command in BUILD_DIR.
+distutils-r1_run_phase() {
+       debug-print-function ${FUNCNAME} "${@}"
+
+       pushd "${BUILD_DIR}" &>/dev/null || die
+       "${@}" || die "${1} failed."
+       popd &>/dev/null || die
+}
+
 distutils-r1_src_prepare() {
        debug-print-function ${FUNCNAME} "${@}"
 
@@ -297,17 +310,17 @@ distutils-r1_src_prepare() {
        fi
 
        if declare -f python_prepare >/dev/null; then
-               python_foreach_impl python_prepare
+               python_foreach_impl distutils-r1_run_phase python_prepare
        else
-               python_foreach_impl distutils-r1_python_prepare
+               python_foreach_impl distutils-r1_run_phase 
distutils-r1_python_prepare
        fi
 }
 
 distutils-r1_src_configure() {
        if declare -f python_configure >/dev/null; then
-               python_foreach_impl python_configure
+               python_foreach_impl distutils-r1_run_phase python_configure
        else
-               python_foreach_impl distutils-r1_python_configure
+               python_foreach_impl distutils-r1_run_phase 
distutils-r1_python_configure
        fi
 
        if declare -f python_configure_all >/dev/null; then
@@ -319,9 +332,9 @@ distutils-r1_src_compile() {
        debug-print-function ${FUNCNAME} "${@}"
 
        if declare -f python_compile >/dev/null; then
-               python_foreach_impl python_compile
+               python_foreach_impl distutils-r1_run_phase python_compile
        else
-               python_foreach_impl distutils-r1_python_compile
+               python_foreach_impl distutils-r1_run_phase 
distutils-r1_python_compile
        fi
 
        if declare -f python_compile_all >/dev/null; then
@@ -333,9 +346,9 @@ distutils-r1_src_test() {
        debug-print-function ${FUNCNAME} "${@}"
 
        if declare -f python_test >/dev/null; then
-               python_foreach_impl python_test
+               python_foreach_impl distutils-r1_run_phase python_test
        else
-               python_foreach_impl distutils-r1_python_test
+               python_foreach_impl distutils-r1_run_phase 
distutils-r1_python_test
        fi
 
        if declare -f python_test_all >/dev/null; then
@@ -347,9 +360,9 @@ distutils-r1_src_install() {
        debug-print-function ${FUNCNAME} "${@}"
 
        if declare -f python_install >/dev/null; then
-               python_foreach_impl python_install
+               python_foreach_impl distutils-r1_run_phase python_install
        else
-               python_foreach_impl distutils-r1_python_install
+               python_foreach_impl distutils-r1_run_phase 
distutils-r1_python_install
        fi
 
        if declare -f python_install_all >/dev/null; then
diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
index d015cf2..43b1365 100644
--- a/gx86/eclass/python-r1.eclass
+++ b/gx86/eclass/python-r1.eclass
@@ -330,11 +330,6 @@ python_copy_sources() {
 #
 # For each command being run, EPYTHON, PYTHON and BUILD_DIR are set
 # locally, and the former two are exported to the command environment.
-#
-# The command is run inside the build directory. If it doesn't exist
-# yet, it is created (as an empty directory!). If your build system does
-# not support out-of-source builds, you will likely want to use
-# python_copy_sources first.
 python_foreach_impl() {
        debug-print-function ${FUNCNAME} "${@}"
 
@@ -350,13 +345,8 @@ python_foreach_impl() {
                        local BUILD_DIR=${bdir%%/}-${impl}
                        export EPYTHON PYTHON
 
-                       debug-print "${FUNCNAME}: [${impl}] build_dir = 
${BUILD_DIR}"
-
-                       mkdir -p "${BUILD_DIR}" || die
-                       pushd "${BUILD_DIR}" &>/dev/null || die
                        einfo "${EPYTHON}: running ${@}"
                        "${@}" || die "${EPYTHON}: ${1} failed"
-                       popd &>/dev/null || die
                fi
        done
 }
-- 
1.7.12.4


Reply via email to