1 |
mgorny 13/03/04 19:21:27 |
2 |
|
3 |
Modified: ChangeLog |
4 |
Added: multibuild.eclass |
5 |
Log: |
6 |
Introduce multibuild.eclass to handle building multiple variants of the same package in a common manner. |
7 |
|
8 |
Revision Changes Path |
9 |
1.705 eclass/ChangeLog |
10 |
|
11 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.705&view=markup |
12 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.705&content-type=text/plain |
13 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?r1=1.704&r2=1.705 |
14 |
|
15 |
Index: ChangeLog |
16 |
=================================================================== |
17 |
RCS file: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v |
18 |
retrieving revision 1.704 |
19 |
retrieving revision 1.705 |
20 |
diff -u -r1.704 -r1.705 |
21 |
--- ChangeLog 4 Mar 2013 19:10:31 -0000 1.704 |
22 |
+++ ChangeLog 4 Mar 2013 19:21:27 -0000 1.705 |
23 |
@@ -1,6 +1,10 @@ |
24 |
# ChangeLog for eclass directory |
25 |
# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2 |
26 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.704 2013/03/04 19:10:31 robbat2 Exp $ |
27 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.705 2013/03/04 19:21:27 mgorny Exp $ |
28 |
+ |
29 |
+ 04 Mar 2013; Michał Górny <mgorny@g.o> +multibuild.eclass: |
30 |
+ Introduce multibuild.eclass to handle building multiple variants of the same |
31 |
+ package in a common manner. |
32 |
|
33 |
04 Mar 2013; Robin H. Johnson <robbat2@g.o> mysql-cmake.eclass: |
34 |
MySQL 5.6 needs to NOT have -fno-implicit-templates, also support |
35 |
|
36 |
|
37 |
|
38 |
1.1 eclass/multibuild.eclass |
39 |
|
40 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/multibuild.eclass?rev=1.1&view=markup |
41 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/multibuild.eclass?rev=1.1&content-type=text/plain |
42 |
|
43 |
Index: multibuild.eclass |
44 |
=================================================================== |
45 |
# Copyright 1999-2013 Gentoo Foundation |
46 |
# Distributed under the terms of the GNU General Public License v2 |
47 |
# $Header: /var/cvsroot/gentoo-x86/eclass/multibuild.eclass,v 1.1 2013/03/04 19:21:27 mgorny Exp $ |
48 |
|
49 |
# @ECLASS: multibuild |
50 |
# @MAINTAINER: |
51 |
# Michał Górny <mgorny@g.o> |
52 |
# @AUTHOR: |
53 |
# Author: Michał Górny <mgorny@g.o> |
54 |
# @BLURB: A generic eclass for building multiple variants of packages. |
55 |
# @DESCRIPTION: |
56 |
# The multibuild eclass aims to provide a generic framework for building |
57 |
# multiple 'variants' of a package (e.g. multilib, Python |
58 |
# implementations). |
59 |
|
60 |
case "${EAPI:-0}" in |
61 |
0|1|2|3|4) |
62 |
die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" |
63 |
;; |
64 |
5) |
65 |
;; |
66 |
*) |
67 |
die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" |
68 |
;; |
69 |
esac |
70 |
|
71 |
if [[ ! ${_MULTIBUILD} ]]; then |
72 |
|
73 |
inherit multiprocessing |
74 |
|
75 |
# @ECLASS-VARIABLE: MULTIBUILD_VARIANTS |
76 |
# @DESCRIPTION: |
77 |
# An array specifying all enabled variants which multibuild_foreach* |
78 |
# can execute the process for. |
79 |
# |
80 |
# In ebuild, it can be set in global scope. Eclasses should set it |
81 |
# locally in function scope to support nesting properly. |
82 |
# |
83 |
# Example: |
84 |
# @CODE |
85 |
# python_foreach_impl() { |
86 |
# local MULTIBUILD_VARIANTS=( python{2_5,2_6,2_7} ... ) |
87 |
# multibuild_foreach_variant python_compile |
88 |
# } |
89 |
# @CODE |
90 |
|
91 |
# @ECLASS-VARIABLE: MULTIBUILD_VARIANT |
92 |
# @DESCRIPTION: |
93 |
# The current variant which the function was executed for. |
94 |
# |
95 |
# Example value: |
96 |
# @CODE |
97 |
# python2_6 |
98 |
# @CODE |
99 |
|
100 |
# @ECLASS-VARIABLE: MULTIBUILD_ID |
101 |
# @DESCRIPTION: |
102 |
# The unique identifier for a multibuild run. In a simple run, it is |
103 |
# equal to MULTIBUILD_VARIANT. In a nested multibuild environment, it |
104 |
# contains the complete selection tree. |
105 |
# |
106 |
# It can be used to create variant-unique directories and files. |
107 |
# |
108 |
# Example value: |
109 |
# @CODE |
110 |
# amd64-double |
111 |
# @CODE |
112 |
|
113 |
# @ECLASS-VARIABLE: BUILD_DIR |
114 |
# @DESCRIPTION: |
115 |
# The current build directory. In global scope, it is supposed |
116 |
# to contain an 'initial' build directory. If unset, ${S} is used. |
117 |
# |
118 |
# multibuild_foreach_variant() sets BUILD_DIR locally |
119 |
# to variant-specific build directories based on the initial value |
120 |
# of BUILD_DIR. |
121 |
# |
122 |
# Example value: |
123 |
# @CODE |
124 |
# ${WORKDIR}/foo-1.3-python2_6 |
125 |
# @CODE |
126 |
|
127 |
# @FUNCTION: multibuild_foreach_variant |
128 |
# @USAGE: [<argv>...] |
129 |
# @DESCRIPTION: |
130 |
# Run the passed command repeatedly for each of the enabled package |
131 |
# variants. |
132 |
# |
133 |
# Each of the runs will have variant-specific BUILD_DIR set, and output |
134 |
# teed to a separate log in ${T}. |
135 |
# |
136 |
# The function returns 0 if all commands return 0, or the first non-zero |
137 |
# exit status otherwise. However, it performs all the invocations |
138 |
# nevertheless. It is preferred to call 'die' inside of the passed |
139 |
# function. |
140 |
multibuild_foreach_variant() { |
141 |
debug-print-function ${FUNCNAME} "${@}" |
142 |
|
143 |
[[ ${MULTIBUILD_VARIANTS} ]] \ |
144 |
|| die "MULTIBUILD_VARIANTS need to be set" |
145 |
|
146 |
local bdir=${BUILD_DIR:-${S}} |
147 |
|
148 |
# Avoid writing outside WORKDIR if S=${WORKDIR}. |
149 |
[[ ${bdir%%/} == ${WORKDIR%%/} ]] && bdir=${WORKDIR}/build |
150 |
|
151 |
local prev_id=${MULTIBUILD_ID:+${MULTIBUILD_ID}-} |
152 |
local ret=0 lret=0 v |
153 |
|
154 |
debug-print "${FUNCNAME}: initial build_dir = ${bdir}" |
155 |
|
156 |
for v in "${MULTIBUILD_VARIANTS[@]}"; do |
157 |
local MULTIBUILD_VARIANT=${v} |
158 |
local MULTIBUILD_ID=${prev_id}${v} |
159 |
local BUILD_DIR=${bdir%%/}-${v} |
160 |
local log_fd |
161 |
|
162 |
# redirect_alloc_fd accepts files only. so we need to open |
163 |
# a random file and then reuse the fd for logger process. |
164 |
redirect_alloc_fd log_fd /dev/null |
165 |
# bash can't handle ${log_fd} in redirections, |
166 |
# we need to use eval to pass fd numbers directly. |
167 |
eval " |
168 |
exec ${log_fd}> >(exec tee -a \"\${T}/build-\${MULTIBUILD_ID}.log\") |
169 |
einfo \"\${v}: running \${@}\" >&${log_fd} 2>&1 |
170 |
\"\${@}\" >&${log_fd} 2>&1 |
171 |
lret=\${?} |
172 |
exec ${log_fd}>&- |
173 |
" |
174 |
done |
175 |
[[ ${ret} -eq 0 && ${lret} -ne 0 ]] && ret=${lret} |
176 |
|
177 |
return ${ret} |
178 |
} |
179 |
|
180 |
# @FUNCTION: multibuild_parallel_foreach_variant |
181 |
# @USAGE: [<argv>...] |
182 |
# @DESCRIPTION: |
183 |
# Run the passed command repeatedly for each of the enabled package |
184 |
# variants alike multibuild_foreach_variant. Multiple invocations of the command |
185 |
# will be performed in parallel, up to MULTIBUILD_JOBS tasks. |
186 |
# |
187 |
# The function returns 0 if all commands return 0, or the first non-zero |
188 |
# exit status otherwise. However, it performs all the invocations |
189 |
# nevertheless. It is preferred to call 'die' inside of the passed |
190 |
# function. |
191 |
multibuild_parallel_foreach_variant() { |
192 |
debug-print-function ${FUNCNAME} "${@}" |
193 |
|
194 |
local ret lret |
195 |
|
196 |
_multibuild_parallel() { |
197 |
( |
198 |
multijob_child_init |
199 |
"${@}" |
200 |
) & |
201 |
multijob_post_fork |
202 |
} |
203 |
|
204 |
local opts |
205 |
if [[ ${MULTIBUILD_JOBS} ]]; then |
206 |
opts=-j${MULTIBUILD_JOBS} |
207 |
else |
208 |
opts=${MAKEOPTS} |
209 |
fi |
210 |
|
211 |
multijob_init "${opts}" |
212 |
multibuild_foreach_variant _multibuild_parallel "${@}" |
213 |
ret=${?} |
214 |
multijob_finish |
215 |
lret=${?} |
216 |
|
217 |
[[ ${ret} -eq 0 ]] && ret=${lret} |
218 |
return ${ret} |
219 |
} |
220 |
|
221 |
_MULTIBUILD=1 |
222 |
fi |