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] multibuild.eclass: supporting introspecting all layers of nested multibuild
Date: Thu, 04 Sep 2014 13:44:22
Message-Id: 1409838243-18349-1-git-send-email-mgorny@gentoo.org
1 Transform MULTIBUILD_VARIANT, MULTIBUILD_ID and BUILD_DIR into arrays
2 preserving values for each nested multibuild layer. For example, if you
3 do something like:
4
5 MULTIBUILD_VARIANTS=( a b c )
6 multibuild_foreach_variant multilib_foreach_abi python_foreach_impl ..
7
8 then the function called last would have:
9
10 MULTIBUILD_VARIANT=( python2.7 abi_x86_64.amd64 a )
11 MULTIBUILD_ID=( a-abi_x86_64.amd64-python2.7 a-abi_x86_64.amd64 a )
12
13 and BUILD_DIR alike it. Which means that using ${MULTIBUILD_VARIANT[2]}
14 you can get your initial 'a' without having to copy intermediate values.
15
16 Of course, if you want to nest multibuild you still need to ensure to
17 set proper MULTIBUILD_VARIANTS in the scope of multibuild_foreach*
18 invocation.
19
20 And before you start to worry, this is fully backwards-compatible.
21 In bash, ${MULTIBUILD_VARIANT} is equivalent to ${MULTIBUILD_VARIANT[0]}
22 in context of an array, and since index 0 stores deepmost value ---
23 nothing changes :).
24
25 Fixes: https://bugs.gentoo.org/show_bug.cgi?id=483758
26 ---
27 eclass/multibuild.eclass | 18 +++++++++++++++---
28 1 file changed, 15 insertions(+), 3 deletions(-)
29
30 diff --git a/eclass/multibuild.eclass b/eclass/multibuild.eclass
31 index de5804d..c8a9591 100644
32 --- a/eclass/multibuild.eclass
33 +++ b/eclass/multibuild.eclass
34 @@ -48,6 +48,10 @@ inherit multiprocessing
35 # @DESCRIPTION:
36 # The current variant which the function was executed for.
37 #
38 +# If nested multibuilds are used, this value can be an array. In that
39 +# case, the first element will name the deepest multibuild, and the next
40 +# elements will go outwards.
41 +#
42 # Example value:
43 # @CODE
44 # python2_6
45 @@ -61,6 +65,10 @@ inherit multiprocessing
46 #
47 # It can be used to create variant-unique directories and files.
48 #
49 +# If nested multibuilds are used, this value can be an array. In that
50 +# case, the first element will name the deepest multibuild, and the next
51 +# elements will go outwards.
52 +#
53 # Example value:
54 # @CODE
55 # amd64-double
56 @@ -75,6 +83,10 @@ inherit multiprocessing
57 # to variant-specific build directories based on the initial value
58 # of BUILD_DIR.
59 #
60 +# If nested multibuilds are used, this value can be an array. In that
61 +# case, the first element will name the deepest multibuild, and the next
62 +# elements will go outwards.
63 +#
64 # Example value:
65 # @CODE
66 # ${WORKDIR}/foo-1.3-python2_6
67 @@ -110,9 +122,9 @@ multibuild_foreach_variant() {
68 debug-print "${FUNCNAME}: initial build_dir = ${bdir}"
69
70 for v in "${MULTIBUILD_VARIANTS[@]}"; do
71 - local MULTIBUILD_VARIANT=${v}
72 - local MULTIBUILD_ID=${prev_id}${v}
73 - local BUILD_DIR=${bdir%%/}-${v}
74 + local MULTIBUILD_VARIANT=( "${v}" "${MULTIBUILD_VARIANT[@]}" )
75 + local MULTIBUILD_ID=( "${prev_id}${v}" "${MULTIBUILD_ID[@]}" )
76 + local BUILD_DIR=( "${bdir%%/}-${v}" "${BUILD_DIR[@]}" )
77
78 _multibuild_run() {
79 # find the first non-private command
80 --
81 2.1.0