1 |
commit: df4b9919281a430d28e7812e29c2014b50df0693 |
2 |
Author: Davide Pesavento <davidepesa <AT> gmail <DOT> com> |
3 |
AuthorDate: Sun Jun 24 21:00:12 2012 +0000 |
4 |
Commit: Davide Pesavento <pesa <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Jun 24 21:00:12 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/qt.git;a=commit;h=df4b9919 |
7 |
|
8 |
[qt5-build.eclass] Rewrite qconfig.{h,pri} handling and enable it. |
9 |
|
10 |
--- |
11 |
eclass/qt5-build.eclass | 156 +++++++++++++++++++++++------------------------ |
12 |
1 files changed, 76 insertions(+), 80 deletions(-) |
13 |
|
14 |
diff --git a/eclass/qt5-build.eclass b/eclass/qt5-build.eclass |
15 |
index e1c37d5..6d714b6 100644 |
16 |
--- a/eclass/qt5-build.eclass |
17 |
+++ b/eclass/qt5-build.eclass |
18 |
@@ -8,7 +8,6 @@ |
19 |
# @BLURB: Eclass for Qt5 split ebuilds. |
20 |
# @DESCRIPTION: |
21 |
# This eclass contains various functions that are used when building Qt5. |
22 |
-# eutils, flag-o-matic, multilib eclasses are guaranteed to be already inherited. |
23 |
# Requires EAPI 4. |
24 |
|
25 |
case ${EAPI} in |
26 |
@@ -289,6 +288,7 @@ qt5-build_src_test() { |
27 |
# @FUNCTION: qt5-build_src_install |
28 |
# @DESCRIPTION: |
29 |
# Performs the actual installation of target directories. |
30 |
+# TODO: pkgconfig files are installed in the wrong place |
31 |
qt5-build_src_install() { |
32 |
qt5_foreach_target_subdir emake INSTALL_ROOT="${D}" install |
33 |
|
34 |
@@ -296,12 +296,21 @@ qt5-build_src_install() { |
35 |
pushd "${QT5_BUILD_DIR}" >/dev/null || die |
36 |
emake INSTALL_ROOT="${D}" install_{qmake,mkspecs} |
37 |
popd >/dev/null || die |
38 |
+ |
39 |
+ # create an empty Gentoo/gentoo-qconfig.h |
40 |
+ dodir "${D}${QTHEADERDIR}"/Gentoo |
41 |
+ : > "${D}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h |
42 |
+ |
43 |
+ # include gentoo-qconfig.h at the beginning of Qt{,Core}/qconfig.h |
44 |
+ sed -i -e '2a#include <Gentoo/gentoo-qconfig.h>\n' \ |
45 |
+ "${D}${QTHEADERDIR}"/QtCore/qconfig.h \ |
46 |
+ "${D}${QTHEADERDIR}"/Qt/qconfig.h \ |
47 |
+ || die "sed qconfig.h failed" |
48 |
fi |
49 |
|
50 |
- # TODO: install_qconfigs |
51 |
- # TODO: pkgconfig files are installed in the wrong place |
52 |
+ qt5_install_module_qconfigs |
53 |
|
54 |
- # remove .la files since we are building only shared Qt libraries |
55 |
+ # remove .la files since we are building only shared libraries |
56 |
prune_libtool_files |
57 |
} |
58 |
|
59 |
@@ -310,27 +319,25 @@ qt5-build_src_install() { |
60 |
# Regenerate configuration, plus throw a message about possible |
61 |
# breakages and proposed solutions. |
62 |
qt5-build_pkg_postinst() { |
63 |
- # TODO |
64 |
- #generate_qconfigs |
65 |
- : |
66 |
+ qt5_regenerate_global_qconfigs |
67 |
} |
68 |
|
69 |
# @FUNCTION: qt5-build_pkg_postrm |
70 |
# @DESCRIPTION: |
71 |
# Regenerate configuration when the package is completely removed. |
72 |
qt5-build_pkg_postrm() { |
73 |
- # TODO |
74 |
- #generate_qconfigs |
75 |
- : |
76 |
+ if [[ -z ${REPLACED_BY_VERSION} && ${PN} != "qt-core" ]]; then |
77 |
+ qt5_regenerate_global_qconfigs |
78 |
+ fi |
79 |
} |
80 |
|
81 |
# @FUNCTION: qt_use |
82 |
-# @USAGE: < flag > [ feature ] [ enableval ] |
83 |
+# @USAGE: <flag> [feature] [enableval] |
84 |
# @DESCRIPTION: |
85 |
# This will echo "-${enableval}-${feature}" if <flag> is enabled, or |
86 |
-# "-no-${feature}" if it's disabled. If [feature] is not specified, <flag> |
87 |
-# will be used for that. If [enableval] is not specified, it omits the |
88 |
-# "-${enableval}" part. |
89 |
+# "-no-${feature}" if it's disabled. If [feature] is not specified, |
90 |
+# <flag> will be used for that. If [enableval] is not specified, the |
91 |
+# "-${enableval}" prefix is omitted. |
92 |
qt_use() { |
93 |
use "$1" && echo "${3:+-$3}-${2:-$1}" || echo "-no-${2:-$1}" |
94 |
} |
95 |
@@ -386,86 +393,75 @@ qt5_foreach_target_subdir() { |
96 |
done |
97 |
} |
98 |
|
99 |
-# @FUNCTION: install_qconfigs |
100 |
+# @FUNCTION: qt5_install_module_qconfigs |
101 |
# @INTERNAL |
102 |
# @DESCRIPTION: |
103 |
-# Installs gentoo-specific mkspecs configurations. |
104 |
-install_qconfigs() { |
105 |
+# Creates and installs gentoo-specific ${PN}-qconfig.{h,pri} files. |
106 |
+qt5_install_module_qconfigs() { |
107 |
local x |
108 |
|
109 |
- if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} ]]; then |
110 |
- for x in QCONFIG_ADD QCONFIG_REMOVE; do |
111 |
- [[ -n ${!x} ]] && echo ${x}=${!x} >> "${T}"/${PN}-qconfig.pri |
112 |
- done |
113 |
- insinto ${QTDATADIR#${EPREFIX}}/mkspecs/gentoo |
114 |
- doins "${T}"/${PN}-qconfig.pri || die "installing ${PN}-qconfig.pri failed" |
115 |
- fi |
116 |
+ # qconfig.h |
117 |
+ : > "${T}"/${PN}-qconfig.h |
118 |
+ for x in ${QCONFIG_DEFINE}; do |
119 |
+ echo "#define ${x}" >> "${T}"/${PN}-qconfig.h |
120 |
+ done |
121 |
+ [[ -s ${T}/${PN}-qconfig.h ]] && ( |
122 |
+ insinto "${QTHEADERDIR#${EPREFIX}}"/Gentoo |
123 |
+ doins "${T}"/${PN}-qconfig.h |
124 |
+ ) |
125 |
|
126 |
- if [[ -n ${QCONFIG_DEFINE} ]]; then |
127 |
- for x in ${QCONFIG_DEFINE}; do |
128 |
- echo "#define ${x}" >> "${T}"/gentoo-${PN}-qconfig.h |
129 |
- done |
130 |
- insinto ${QTHEADERDIR#${EPREFIX}}/Gentoo |
131 |
- doins "${T}"/gentoo-${PN}-qconfig.h || die "installing ${PN}-qconfig.h failed" |
132 |
- fi |
133 |
+ # qconfig.pri |
134 |
+ : > "${T}"/${PN}-qconfig.pri |
135 |
+ for x in QCONFIG_ADD QCONFIG_REMOVE; do |
136 |
+ [[ -n ${!x} ]] && echo "${x}=${!x}" >> "${T}"/${PN}-qconfig.pri |
137 |
+ done |
138 |
+ [[ -s ${T}/${PN}-qconfig.pri ]] && ( |
139 |
+ insinto "${QTDATADIR#${EPREFIX}}"/mkspecs/gentoo |
140 |
+ doins "${T}"/${PN}-qconfig.pri |
141 |
+ ) |
142 |
} |
143 |
|
144 |
-# @FUNCTION: generate_qconfigs |
145 |
+# @FUNCTION: qt5_regenerate_global_qconfigs |
146 |
# @INTERNAL |
147 |
# @DESCRIPTION: |
148 |
# Generates gentoo-specific qconfig.{h,pri}. |
149 |
-generate_qconfigs() { |
150 |
- if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} ]]; then |
151 |
- local x qconfig_add qconfig_remove qconfig_new |
152 |
- for x in "${ROOT}${QTDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do |
153 |
- [[ -f ${x} ]] || continue |
154 |
+# Don't die here because dying in pkg_post{inst,rm} just makes things worse. |
155 |
+qt5_regenerate_global_qconfigs() { |
156 |
+ einfo "Regenerating gentoo-qconfig.h" |
157 |
+ |
158 |
+ find "${ROOT}${QTHEADERDIR}"/Gentoo -name 'qt-*-qconfig.h' -type f \ |
159 |
+ -exec cat {} + > "${T}"/gentoo-qconfig.h |
160 |
+ if [[ -s ${T}/gentoo-qconfig.h ]]; then |
161 |
+ mv -f "${T}"/gentoo-qconfig.h "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h \ |
162 |
+ || eerror "Failed to install new gentoo-qconfig.h" |
163 |
+ else |
164 |
+ eerror "Generated gentoo-qconfig.h is empty" |
165 |
+ fi |
166 |
+ |
167 |
+ einfo "Fixing QT_CONFIG in qconfig.pri" |
168 |
+ |
169 |
+ if [[ -f ${ROOT}${QTDATADIR}/mkspecs/qconfig.pri ]]; then |
170 |
+ local x qconfig_add= qconfig_remove= |
171 |
+ local qt_config=$(sed -n 's/^QT_CONFIG +=//p' "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri) |
172 |
+ local new_qt_config= |
173 |
+ |
174 |
+ # generate list of QT_CONFIG entries from the existing list, |
175 |
+ # adding QCONFIG_ADD and excluding QCONFIG_REMOVE |
176 |
+ for x in "${ROOT}${QTDATADIR}"/mkspecs/gentoo/qt-*-qconfig.pri; do |
177 |
qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=//p' "${x}")" |
178 |
qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=//p' "${x}")" |
179 |
done |
180 |
- |
181 |
- # these error checks do not use die because dying in pkg_post{inst,rm} |
182 |
- # just makes things worse. |
183 |
- if [[ -e "${ROOT}${QTDATADIR}"/mkspecs/gentoo/qconfig.pri ]]; then |
184 |
- # start with the qconfig.pri that qt-core installed |
185 |
- if ! cp "${ROOT}${QTDATADIR}"/mkspecs/gentoo/qconfig.pri \ |
186 |
- "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri; then |
187 |
- eerror "cp qconfig failed." |
188 |
- return 1 |
189 |
- fi |
190 |
- |
191 |
- # generate list of QT_CONFIG entries from the existing list |
192 |
- # including qconfig_add and excluding qconfig_remove |
193 |
- for x in $(sed -n 's/^QT_CONFIG +=//p' \ |
194 |
- "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri) ${qconfig_add}; do |
195 |
- has ${x} ${qconfig_remove} || qconfig_new+=" ${x}" |
196 |
- done |
197 |
- |
198 |
- # replace the existing QT_CONFIG list with qconfig_new |
199 |
- if ! sed -i -e "s/QT_CONFIG +=.*/QT_CONFIG += ${qconfig_new}/" \ |
200 |
- "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri; then |
201 |
- eerror "Sed for QT_CONFIG failed" |
202 |
- return 1 |
203 |
+ for x in ${qt_config} ${qconfig_add}; do |
204 |
+ if ! has "${x}" ${new_qt_config} ${qconfig_remove}; then |
205 |
+ new_qt_config+=" ${x}" |
206 |
fi |
207 |
+ done |
208 |
|
209 |
- # create Gentoo/qconfig.h |
210 |
- if [[ ! -e ${ROOT}${QTHEADERDIR}/Gentoo ]]; then |
211 |
- if ! mkdir -p "${ROOT}${QTHEADERDIR}"/Gentoo; then |
212 |
- eerror "mkdir ${QTHEADERDIR}/Gentoo failed" |
213 |
- return 1 |
214 |
- fi |
215 |
- fi |
216 |
- : > "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h |
217 |
- for x in "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-*-qconfig.h; do |
218 |
- [[ -f ${x} ]] || continue |
219 |
- cat "${x}" >> "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h |
220 |
- done |
221 |
- else |
222 |
- rm -f "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri |
223 |
- rm -f "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h |
224 |
- rmdir "${ROOT}${QTDATADIR}"/mkspecs \ |
225 |
- "${ROOT}${QTDATADIR}" \ |
226 |
- "${ROOT}${QTHEADERDIR}"/Gentoo \ |
227 |
- "${ROOT}${QTHEADERDIR}" 2>/dev/null |
228 |
- fi |
229 |
+ # now replace the existing QT_CONFIG with the generated list |
230 |
+ sed -i -e "s/^QT_CONFIG +=.*/QT_CONFIG +=${new_qt_config}/" \ |
231 |
+ "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri \ |
232 |
+ || eerror "Failed to sed QT_CONFIG in qconfig.pri" |
233 |
+ else |
234 |
+ eerror "qconfig.pri does not exist or is not a regular file" |
235 |
fi |
236 |
} |