Gentoo Archives: gentoo-commits

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