summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2012-10-29 13:34:02 +0000
committerMichał Górny <mgorny@gentoo.org>2012-10-29 13:34:02 +0000
commit74f8b12e0bd3825f47542f5151789c41a141b492 (patch)
tree8c002c4656310bd733ecdd72c08f5d3d1014a108 /eclass
parentIntroduce an esetup.py wrapper function and mydistutilsargs=() for it. (diff)
downloadgentoo-2-74f8b12e0bd3825f47542f5151789c41a141b492.tar.gz
gentoo-2-74f8b12e0bd3825f47542f5151789c41a141b492.tar.bz2
gentoo-2-74f8b12e0bd3825f47542f5151789c41a141b492.zip
Support and use out-of-source builds by default.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/ChangeLog5
-rw-r--r--eclass/distutils-r1.eclass52
2 files changed, 50 insertions, 7 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index e3cee6611977..4cdc4617f4e7 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,9 @@
# ChangeLog for eclass directory
# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.483 2012/10/29 13:30:48 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.484 2012/10/29 13:34:02 mgorny Exp $
+
+ 29 Oct 2012; Michał Górny <mgorny@gentoo.org> distutils-r1.eclass:
+ Support and use out-of-source builds by default.
29 Oct 2012; Michał Górny <mgorny@gentoo.org> distutils-r1.eclass:
Introduce an esetup.py wrapper function and mydistutilsargs=() for it.
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 9b427f669a6e..172cc70f39da 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.13 2012/10/29 13:30:48 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.14 2012/10/29 13:34:02 mgorny Exp $
# @ECLASS: distutils-r1
# @MAINTAINER:
@@ -105,6 +105,22 @@ DEPEND=${PYTHON_DEPS}
# HTML_DOCS=( doc/html/ )
# @CODE
+# @ECLASS-VARIABLE: DISTUTILS_IN_SOURCE_BUILD
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set to a non-null value, in-source builds will be enabled.
+# If unset, the default is to use in-source builds when python_prepare()
+# is declared, and out-of-source builds otherwise.
+#
+# If in-source builds are used, the eclass will create a copy of package
+# sources for each Python implementation in python_prepare_all(),
+# and work on that copy afterwards.
+#
+# If out-of-source builds are used, the eclass will instead work
+# on the sources directly, prepending setup.py arguments with
+# 'build --build-base ${BUILD_DIR}' to enforce keeping & using built
+# files in the specific root.
+
# @ECLASS-VARIABLE: mydistutilsargs
# @DEFAULT_UNSET
# @DESCRIPTION:
@@ -129,8 +145,17 @@ DEPEND=${PYTHON_DEPS}
esetup.py() {
debug-print-function ${FUNCNAME} "${@}"
+ local args=()
+ if [[ ! ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
+ if [[ ! ${BUILD_DIR} ]]; then
+ die 'Out-of-source build requested, yet BUILD_DIR unset.'
+ fi
+
+ args+=( build --build-base "${BUILD_DIR}" )
+ fi
+
set -- "${PYTHON:-python}" setup.py \
- "${mydistutilsargs[@]}" "${@}"
+ "${args[@]}" "${mydistutilsargs[@]}" "${@}"
echo "${@}" >&2
"${@}" || die
@@ -151,8 +176,17 @@ distutils-r1_python_prepare_all() {
epatch_user
- # create source copies for each implementation
- python_copy_sources
+ # by default, use in-source build if python_prepare() is used
+ if [[ ! ${DISTUTILS_IN_SOURCE_BUILD+1} ]]; then
+ if declare -f python_prepare >/dev/null; then
+ DISTUTILS_IN_SOURCE_BUILD=1
+ fi
+ fi
+
+ if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
+ # create source copies for each implementation
+ python_copy_sources
+ fi
}
# @FUNCTION: distutils-r1_python_prepare
@@ -296,9 +330,15 @@ distutils-r1_python_install_all() {
distutils-r1_run_phase() {
debug-print-function ${FUNCNAME} "${@}"
- pushd "${BUILD_DIR}" &>/dev/null || die
+ if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
+ pushd "${BUILD_DIR}" &>/dev/null || die
+ fi
+
"${@}" || die "${1} failed."
- popd &>/dev/null || die
+
+ if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
+ popd &>/dev/null || die
+ fi
}
distutils-r1_src_prepare() {