1 |
11.11.2013 19:32, Sergey Popov пишет: |
2 |
> Some work on splitting these helper functions was done earlier, and then |
3 |
> we have got request(bug #479744), so, with ACK from pesa, i would like |
4 |
> to propose this new eclass here and some times after - another proposal |
5 |
> with making qt4-r2 eclass depends on this one to prevent code duplication. |
6 |
> |
7 |
> So, here it is(directly from qt overlay): |
8 |
> |
9 |
> |
10 |
> |
11 |
> # Copyright 1999-2013 Gentoo Foundation |
12 |
> # Distributed under the terms of the GNU General Public License v2 |
13 |
> # $Header: $ |
14 |
> |
15 |
> # @ECLASS: qmake-utils.eclass |
16 |
> # @MAINTAINER: |
17 |
> # Qt herd <qt@g.o> |
18 |
> # @AUTHOR: |
19 |
> # Davide Pesavento <pesa@g.o> |
20 |
> # @BLURB: Common functions for qmake-based packages. |
21 |
> # @DESCRIPTION: |
22 |
> # Utility eclass providing wrapper functions for Qt4 and Qt5 qmake. |
23 |
> |
24 |
> if [[ ${___ECLASS_ONCE_QMAKE_UTILS} != "recur -_+^+_- spank" ]]; then |
25 |
> ___ECLASS_ONCE_QMAKE_UTILS="recur -_+^+_- spank" |
26 |
> |
27 |
> inherit eutils multilib toolchain-funcs |
28 |
> |
29 |
> # @FUNCTION: qmake-utils_find_pro_file |
30 |
> # @RETURN: zero or one qmake .pro file names |
31 |
> # @INTERNAL |
32 |
> # @DESCRIPTION: |
33 |
> # Outputs a project file name that can be passed to eqmake. |
34 |
> # 0 *.pro files found --> outputs null string; |
35 |
> # 1 *.pro file found --> outputs its name; |
36 |
> # 2 or more *.pro files found --> if "${PN}.pro" or |
37 |
> # "$(basename ${S}).pro" are there, outputs one of them. |
38 |
> qmake-utils_find_pro_file() { |
39 |
> local dir_name=$(basename "${S}") |
40 |
> |
41 |
> # set nullglob to avoid expanding *.pro to the literal |
42 |
> # string "*.pro" when there are no matching files |
43 |
> eshopts_push -s nullglob |
44 |
> local pro_files=(*.pro) |
45 |
> eshopts_pop |
46 |
> |
47 |
> case ${#pro_files[@]} in |
48 |
> 0) |
49 |
> : ;; |
50 |
> 1) |
51 |
> echo "${pro_files}" |
52 |
> ;; |
53 |
> *) |
54 |
> for pro_file in "${pro_files[@]}"; do |
55 |
> if [[ ${pro_file%.pro} == ${dir_name} || ${pro_file%.pro} == ${PN} |
56 |
> ]]; then |
57 |
> echo "${pro_file}" |
58 |
> break |
59 |
> fi |
60 |
> done |
61 |
> ;; |
62 |
> esac |
63 |
> } |
64 |
> |
65 |
> # @VARIABLE: EQMAKE4_EXCLUDE |
66 |
> # @DEFAULT_UNSET |
67 |
> # @DESCRIPTION: |
68 |
> # List of files to be excluded from eqmake4 CONFIG processing. |
69 |
> # Paths are relative to the current working directory (usually ${S}). |
70 |
> # |
71 |
> # Example: EQMAKE4_EXCLUDE="ignore/me.pro foo/*" |
72 |
> |
73 |
> # @FUNCTION: eqmake4 |
74 |
> # @USAGE: [project_file] [parameters to qmake] |
75 |
> # @DESCRIPTION: |
76 |
> # Wrapper for Qt4's qmake. If project_file isn't specified, eqmake4 will |
77 |
> # look for it in the current directory (${S}, non-recursively). If more |
78 |
> # than one project file are found, then ${PN}.pro is processed, provided |
79 |
> # that it exists. Otherwise eqmake4 fails. |
80 |
> # |
81 |
> # All other arguments are appended unmodified to qmake command line. |
82 |
> # |
83 |
> # For recursive build systems, i.e. those based on the subdirs template, |
84 |
> # you should run eqmake4 on the top-level project file only, unless you |
85 |
> # have a valid reason to do otherwise. During the building, qmake will |
86 |
> # be automatically re-invoked with the right arguments on every directory |
87 |
> # specified inside the top-level project file. |
88 |
> eqmake4() { |
89 |
> debug-print-function ${FUNCNAME} "$@" |
90 |
> |
91 |
> has "${EAPI:-0}" 0 1 2 && use !prefix && EPREFIX= |
92 |
> |
93 |
> ebegin "Running qmake" |
94 |
> |
95 |
> local qmake_args=("$@") |
96 |
> |
97 |
> # check if project file was passed as a first argument |
98 |
> # if not, then search for it |
99 |
> local regexp='.*\.pro' |
100 |
> if ! [[ ${1} =~ ${regexp} ]]; then |
101 |
> local project_file=$(qmake-utils_find_pro_file) |
102 |
> if [[ -z ${project_file} ]]; then |
103 |
> echo |
104 |
> eerror "No project files found in '${PWD}'!" |
105 |
> eerror "This shouldn't happen - please send a bug report to |
106 |
> https://bugs.gentoo.org/" |
107 |
> echo |
108 |
> die "eqmake4 failed" |
109 |
> fi |
110 |
> qmake_args+=("${project_file}") |
111 |
> fi |
112 |
> |
113 |
> # make sure CONFIG variable is correctly set |
114 |
> # for both release and debug builds |
115 |
> local config_add="release" |
116 |
> local config_remove="debug" |
117 |
> if has debug ${IUSE} && use debug; then |
118 |
> config_add="debug" |
119 |
> config_remove="release" |
120 |
> fi |
121 |
> |
122 |
> local awkscript='BEGIN { |
123 |
> printf "### eqmake4 was here ###\n" > file; |
124 |
> printf "CONFIG -= debug_and_release %s\n", remove >> file; |
125 |
> printf "CONFIG += %s\n\n", add >> file; |
126 |
> fixed=0; |
127 |
> } |
128 |
> /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ { |
129 |
> if (gsub("\\<((" remove ")|(debug_and_release))\\>", "") > 0) { |
130 |
> fixed=1; |
131 |
> } |
132 |
> } |
133 |
> /^[[:blank:]]*CONFIG[[:blank:]]*-=/ { |
134 |
> if (gsub("\\<" add "\\>", "") > 0) { |
135 |
> fixed=1; |
136 |
> } |
137 |
> } |
138 |
> { |
139 |
> print >> file; |
140 |
> } |
141 |
> END { |
142 |
> print fixed; |
143 |
> }' |
144 |
> |
145 |
> [[ -n ${EQMAKE4_EXCLUDE} ]] && eshopts_push -o noglob |
146 |
> |
147 |
> local file |
148 |
> while read file; do |
149 |
> local excl |
150 |
> for excl in ${EQMAKE4_EXCLUDE}; do |
151 |
> [[ ${file} == ${excl} ]] && continue 2 |
152 |
> done |
153 |
> grep -q '^### eqmake4 was here ###$' "${file}" && continue |
154 |
> |
155 |
> local retval=$({ |
156 |
> rm -f "${file}" || echo FAIL |
157 |
> awk -v file="${file}" \ |
158 |
> -v add=${config_add} \ |
159 |
> -v remove=${config_remove} \ |
160 |
> -- "${awkscript}" || echo FAIL |
161 |
> } < "${file}") |
162 |
> |
163 |
> if [[ ${retval} == 1 ]]; then |
164 |
> einfo " - fixed CONFIG in ${file}" |
165 |
> elif [[ ${retval} != 0 ]]; then |
166 |
> eerror " - error while processing ${file}" |
167 |
> die "eqmake4 failed to process ${file}" |
168 |
> fi |
169 |
> done < <(find . -type f -name '*.pr[io]' -printf '%P\n' 2>/dev/null) |
170 |
> |
171 |
> [[ -n ${EQMAKE4_EXCLUDE} ]] && eshopts_pop |
172 |
> |
173 |
> "${EPREFIX}"/usr/bin/qmake \ |
174 |
> -makefile \ |
175 |
> QTDIR="${EPREFIX}"/usr/$(get_libdir) \ |
176 |
> QMAKE="${EPREFIX}"/usr/bin/qmake \ |
177 |
> QMAKE_AR="$(tc-getAR) cqs" \ |
178 |
> QMAKE_CC="$(tc-getCC)" \ |
179 |
> QMAKE_CXX="$(tc-getCXX)" \ |
180 |
> QMAKE_LINK="$(tc-getCXX)" \ |
181 |
> QMAKE_LINK_C="$(tc-getCC)" \ |
182 |
> QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \ |
183 |
> QMAKE_RANLIB= \ |
184 |
> QMAKE_STRIP= \ |
185 |
> QMAKE_CFLAGS="${CFLAGS}" \ |
186 |
> QMAKE_CFLAGS_RELEASE= \ |
187 |
> QMAKE_CFLAGS_DEBUG= \ |
188 |
> QMAKE_CXXFLAGS="${CXXFLAGS}" \ |
189 |
> QMAKE_CXXFLAGS_RELEASE= \ |
190 |
> QMAKE_CXXFLAGS_DEBUG= \ |
191 |
> QMAKE_LFLAGS="${LDFLAGS}" \ |
192 |
> QMAKE_LFLAGS_RELEASE= \ |
193 |
> QMAKE_LFLAGS_DEBUG= \ |
194 |
> QMAKE_LIBDIR_QT="${EPREFIX}"/usr/$(get_libdir)/qt4 \ |
195 |
> QMAKE_LIBDIR_X11="${EPREFIX}"/usr/$(get_libdir) \ |
196 |
> QMAKE_LIBDIR_OPENGL="${EPREFIX}"/usr/$(get_libdir) \ |
197 |
> "${qmake_args[@]}" |
198 |
> |
199 |
> # was qmake successful? |
200 |
> if ! eend $? ; then |
201 |
> echo |
202 |
> eerror "Running qmake has failed! (see above for details)" |
203 |
> eerror "This shouldn't happen - please send a bug report to |
204 |
> https://bugs.gentoo.org/" |
205 |
> echo |
206 |
> die "eqmake4 failed" |
207 |
> fi |
208 |
> } |
209 |
> |
210 |
> # @FUNCTION: eqmake5 |
211 |
> # @USAGE: [arguments for qmake] |
212 |
> # @DESCRIPTION: |
213 |
> # Wrapper for Qt5's qmake. All arguments are passed to qmake. |
214 |
> # |
215 |
> # For recursive build systems, i.e. those based on the subdirs template, |
216 |
> # you should run eqmake5 on the top-level project file only, unless you |
217 |
> # have a valid reason to do otherwise. During the building, qmake will |
218 |
> # be automatically re-invoked with the right arguments on every directory |
219 |
> # specified inside the top-level project file. |
220 |
> eqmake5() { |
221 |
> debug-print-function ${FUNCNAME} "$@" |
222 |
> |
223 |
> has "${EAPI:-0}" 0 1 2 && use !prefix && EPREFIX= |
224 |
> |
225 |
> ebegin "Running qmake" |
226 |
> |
227 |
> "${EPREFIX}"/usr/$(get_libdir)/qt5/bin/qmake \ |
228 |
> -makefile \ |
229 |
> QMAKE_AR="$(tc-getAR) cqs" \ |
230 |
> QMAKE_CC="$(tc-getCC)" \ |
231 |
> QMAKE_CXX="$(tc-getCXX)" \ |
232 |
> QMAKE_LINK="$(tc-getCXX)" \ |
233 |
> QMAKE_LINK_C="$(tc-getCC)" \ |
234 |
> QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \ |
235 |
> QMAKE_RANLIB= \ |
236 |
> QMAKE_STRIP= \ |
237 |
> QMAKE_CFLAGS="${CFLAGS}" \ |
238 |
> QMAKE_CFLAGS_RELEASE= \ |
239 |
> QMAKE_CFLAGS_DEBUG= \ |
240 |
> QMAKE_CXXFLAGS="${CXXFLAGS}" \ |
241 |
> QMAKE_CXXFLAGS_RELEASE= \ |
242 |
> QMAKE_CXXFLAGS_DEBUG= \ |
243 |
> QMAKE_LFLAGS="${LDFLAGS}" \ |
244 |
> QMAKE_LFLAGS_RELEASE= \ |
245 |
> QMAKE_LFLAGS_DEBUG= \ |
246 |
> "$@" |
247 |
> |
248 |
> # was qmake successful? |
249 |
> if ! eend $? ; then |
250 |
> echo |
251 |
> eerror "Running qmake has failed! (see above for details)" |
252 |
> eerror "This shouldn't happen - please send a bug report to |
253 |
> https://bugs.gentoo.org/" |
254 |
> echo |
255 |
> die "eqmake5 failed" |
256 |
> fi |
257 |
> } |
258 |
> |
259 |
> fi |
260 |
> |
261 |
> |
262 |
|
263 |
Ok, no objections/comments for more than 3 weeks. I committed it. Later |
264 |
i will post diff for qt4-r2 eclass. |
265 |
|
266 |
-- |
267 |
Best regards, Sergey Popov |
268 |
Gentoo developer |
269 |
Gentoo Desktop Effects project lead |
270 |
Gentoo Qt project lead |
271 |
Gentoo Proxy maintainers project lead |