Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 3/3] Support out-of-source builds.
Date: Sun, 28 Oct 2012 15:58:35
Message-Id: 1351439877-9025-3-git-send-email-mgorny@gentoo.org
1 ---
2 gx86/eclass/distutils-r1.eclass | 50 ++++++++++++++++++++++++++++++++++++-----
3 1 file changed, 45 insertions(+), 5 deletions(-)
4
5 diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
6 index 6bec5bb..cce47a7 100644
7 --- a/gx86/eclass/distutils-r1.eclass
8 +++ b/gx86/eclass/distutils-r1.eclass
9 @@ -105,6 +105,22 @@ DEPEND=${PYTHON_DEPS}
10 # HTML_DOCS=( doc/html/ )
11 # @CODE
12
13 +# @ECLASS-VARIABLE: DISTUTILS_IN_SOURCE_BUILD
14 +# @DEFAULT_UNSET
15 +# @DESCRIPTION:
16 +# If set to a non-null value, in-source builds will be enabled.
17 +# If unset, the default is to use in-source builds when python_prepare()
18 +# is declared, and out-of-source builds otherwise.
19 +#
20 +# If in-source builds are used, the eclass will create a copy of package
21 +# sources for each Python implementation in python_prepare_all(),
22 +# and work on that copy afterwards.
23 +#
24 +# If out-of-source builds are used, the eclass will instead work
25 +# on the sources directly, prepending setup.py arguments with
26 +# 'build --build-base ${BUILD_DIR}' to enforce keeping & using built
27 +# files in the specific root.
28 +
29 # @ECLASS-VARIABLE: myesetuppyargs
30 # @DEFAULT_UNSET
31 # @DESCRIPTION:
32 @@ -130,7 +146,16 @@ DEPEND=${PYTHON_DEPS}
33 esetuppy() {
34 debug-print-function ${FUNCNAME} "${@}"
35
36 - set -- "${PYTHON:-python}" setup.py \
37 + local args=()
38 + if [[ ! ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
39 + if [[ ! ${BUILD_DIR} ]]; then
40 + die 'Out-of-source build requested, yet BUILD_DIR unset.'
41 + fi
42 +
43 + args+=( build --build-base "${BUILD_DIR}" )
44 + fi
45 +
46 + set -- "${PYTHON:-python}" setup.py "${args[@]}" \
47 "${myesetuppyargs[@]}" "${@}"
48
49 echo "${@}" >&2
50 @@ -152,8 +177,17 @@ distutils-r1_python_prepare_all() {
51
52 epatch_user
53
54 - # create source copies for each implementation
55 - python_copy_sources
56 + # by default, use in-source build if python_prepare() is used
57 + if [[ ! ${DISTUTILS_IN_SOURCE_BUILD+1} ]]; then
58 + if declare -f python_prepare >/dev/null; then
59 + DISTUTILS_IN_SOURCE_BUILD=1
60 + fi
61 + fi
62 +
63 + if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
64 + # create source copies for each implementation
65 + python_copy_sources
66 + fi
67 }
68
69 # @FUNCTION: distutils-r1_python_prepare
70 @@ -297,9 +331,15 @@ distutils-r1_python_install_all() {
71 distutils-r1_run_phase() {
72 debug-print-function ${FUNCNAME} "${@}"
73
74 - pushd "${BUILD_DIR}" &>/dev/null || die
75 + if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
76 + pushd "${BUILD_DIR}" &>/dev/null || die
77 + fi
78 +
79 "${@}" || die "${1} failed."
80 - popd &>/dev/null || die
81 +
82 + if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
83 + popd &>/dev/null || die
84 + fi
85 }
86
87 distutils-r1_src_prepare() {
88 --
89 1.7.12.4