1 |
commit: bd38be65c80afe2e7ec56e4cc05b5e8388170fa3 |
2 |
Author: Anna (cybertailor) Vyalkova <cyber+gentoo <AT> sysrq <DOT> in> |
3 |
AuthorDate: Thu Mar 31 01:56:33 2022 +0000 |
4 |
Commit: Anna Vyalkova <cyber+gentoo <AT> sysrq <DOT> in> |
5 |
CommitDate: Thu Mar 31 01:57:38 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=bd38be65 |
7 |
|
8 |
qbs.eclass: new eclass |
9 |
|
10 |
Signed-off-by: Anna (cybertailor) Vyalkova <cyber+gentoo <AT> sysrq.in> |
11 |
|
12 |
eclass/qbs.eclass | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
13 |
1 file changed, 186 insertions(+) |
14 |
|
15 |
diff --git a/eclass/qbs.eclass b/eclass/qbs.eclass |
16 |
new file mode 100644 |
17 |
index 000000000..6c3f06310 |
18 |
--- /dev/null |
19 |
+++ b/eclass/qbs.eclass |
20 |
@@ -0,0 +1,186 @@ |
21 |
+# Copyright 2022 Gentoo Authors |
22 |
+# Distributed under the terms of the GNU General Public License v2 |
23 |
+ |
24 |
+# @ECLASS: qbs.eclass |
25 |
+# @AUTHOR: |
26 |
+# Anna Vyalkova <cyber+gentoo@×××××.in> |
27 |
+# @MAINTAINER: |
28 |
+# Anna Vyalkova <cyber+gentoo@×××××.in> |
29 |
+# @SUPPORTED_EAPIS: 8 |
30 |
+# @PROVIDES: qmake-utils |
31 |
+# @BLURB: eclass to build qbs-based packages |
32 |
+# @DESCRIPTION: |
33 |
+# Utility eclass providing wrapper functions for Qbs build system. |
34 |
+ |
35 |
+if [[ ! ${_QBS_ECLASS} ]]; then |
36 |
+ |
37 |
+case ${EAPI} in |
38 |
+ 8) ;; |
39 |
+ *) die "${ECLASS}: EAPI ${EAPI} unsupported." |
40 |
+esac |
41 |
+ |
42 |
+inherit multiprocessing toolchain-funcs qmake-utils |
43 |
+ |
44 |
+# @ECLASS-VARIABLE: QBS_COMMAND_ECHO_MODE |
45 |
+# @USER_VARIABLE |
46 |
+# @DESCRIPTION: |
47 |
+# Determines what kind of output to show when executing commands. Possible |
48 |
+# values are: |
49 |
+# |
50 |
+# - silent |
51 |
+# |
52 |
+# - summary |
53 |
+# |
54 |
+# - command-line (the default) |
55 |
+# |
56 |
+# - command-line-with-environment |
57 |
+: ${QBS_COMMAND_ECHO_MODE:=command-line} |
58 |
+ |
59 |
+BDEPEND="dev-util/qbs" |
60 |
+ |
61 |
+EXPORT_FUNCTIONS src_configure src_compile src_install |
62 |
+ |
63 |
+# @FUNCTION: eqbs |
64 |
+# @USAGE: [<qbs args>...] |
65 |
+# @DESCRIPTION: |
66 |
+# Run Qbs. This command dies on failure. |
67 |
+eqbs() { |
68 |
+ debug-print-function ${FUNCNAME} "${@}" |
69 |
+ |
70 |
+ set -- qbs "${@}" |
71 |
+ einfo "${@}" |
72 |
+ "${@}" || die -n |
73 |
+ |
74 |
+ local ret=${?} |
75 |
+ return ${ret} |
76 |
+} |
77 |
+ |
78 |
+# @FUNCTION: _flags_to_js_array |
79 |
+# @INTERNAL |
80 |
+# @USAGE: [<flags>...] |
81 |
+# @RETURN: arguments quoted and separated by comma |
82 |
+_flags_to_js_array() { |
83 |
+ if [[ ! ${@} ]]; then |
84 |
+ echo "[]" |
85 |
+ else |
86 |
+ local -a array |
87 |
+ printf -v array "'%s', " "${@}" |
88 |
+ echo "[${array%, }]" |
89 |
+ fi |
90 |
+} |
91 |
+ |
92 |
+# @FUNCTION: _filter_ldflags |
93 |
+# @INTERNAL |
94 |
+# @USAGE: [<ldflags>...] |
95 |
+# @RETURN: flags for the linker (with -Wl and -Xlinker removed) |
96 |
+_filter_ldflags() { |
97 |
+ local -a flags |
98 |
+ while [[ ${@} ]]; do |
99 |
+ if [[ ${1} == -Wl,* ]]; then |
100 |
+ IFS=, read -ra flags <<< "${1#-Wl,}" |
101 |
+ printf "%s " "${flags[@]}" |
102 |
+ elif [[ ${1} == -Xlinker ]]; then |
103 |
+ shift |
104 |
+ printf "%s " "${1}" |
105 |
+ fi |
106 |
+ shift |
107 |
+ done |
108 |
+} |
109 |
+ |
110 |
+# @FUNCTION: qbs_src_configure |
111 |
+# @DESCRIPTION: |
112 |
+# Setup toolchain and Qt for the "gentoo" profile. |
113 |
+# Set Qbs preferences to match user settings. Configure build flags and |
114 |
+# installation prefix. |
115 |
+qbs_src_configure() { |
116 |
+ debug-print-function ${FUNCNAME} "${@}" |
117 |
+ |
118 |
+ eqbs setup-toolchains "$(tc-getCC)" gentooToolchain |
119 |
+ eqbs config profiles.gentooToolchain.archiverPath "$(tc-getAR)" |
120 |
+ eqbs config profiles.gentooToolchain.assemblerPath "$(tc-getAS)" |
121 |
+ eqbs config profiles.gentooToolchain.nmPath "$(tc-getNM)" |
122 |
+ eqbs config profiles.gentooToolchain.objcopyPath "$(tc-getOBJCOPY)" |
123 |
+ eqbs config profiles.gentooToolchain.stripPath "$(tc-getSTRIP)" |
124 |
+ |
125 |
+ eqbs setup-qt "$(qt5_get_bindir)/qmake" gentoo |
126 |
+ qbs_config baseProfile gentooToolchain |
127 |
+ |
128 |
+ qbs_config preferences.jobs "$(makeopts_jobs)" |
129 |
+ if [[ "${NOCOLOR}" == true || "${NOCOLOR}" == yes ]]; then |
130 |
+ qbs_config preferences.useColoredOutput false |
131 |
+ fi |
132 |
+ |
133 |
+ qbs_config qbs.installPrefix "${EPREFIX}/usr" |
134 |
+ qbs_config qbs.sysroot "${ESYSROOT}" |
135 |
+ qbs_config qbs.optimization "" # don't add unwanted flags |
136 |
+ |
137 |
+ qbs_config cpp.cFlags "$(_flags_to_js_array ${CFLAGS})" |
138 |
+ qbs_config cpp.cppFlags "$(_flags_to_js_array ${CPPFLAGS})" |
139 |
+ qbs_config cpp.cxxFlags "$(_flags_to_js_array ${CXXFLAGS})" |
140 |
+ qbs_config cpp.linkerFlags "$(_flags_to_js_array $(_filter_ldflags ${LDFLAGS}))" |
141 |
+} |
142 |
+ |
143 |
+# @FUNCTION: qbs_config |
144 |
+# @USAGE: <key> <value> |
145 |
+# @DESCRIPTION: |
146 |
+# Set a preference for the "gentoo" profile. |
147 |
+qbs_config() { |
148 |
+ debug-print-function ${FUNCNAME} "${@}" |
149 |
+ |
150 |
+ (( $# == 2 )) || \ |
151 |
+ die "${FUNCNAME} takes exactly two arguments" |
152 |
+ |
153 |
+ local key=${1} |
154 |
+ local value=${2} |
155 |
+ |
156 |
+ eqbs config "profiles.gentoo.${key}" "${value}" |
157 |
+} |
158 |
+ |
159 |
+# @FUNCTION: qbs_src_compile |
160 |
+# @USAGE: [<qbs args>...] |
161 |
+# @DESCRIPTION: |
162 |
+# General function for compiling with qbs. All arguments are passed |
163 |
+# to qbs_build. |
164 |
+qbs_src_compile() { |
165 |
+ debug-print-function ${FUNCNAME} "${@}" |
166 |
+ |
167 |
+ qbs_build "${@}" |
168 |
+} |
169 |
+ |
170 |
+# @FUNCTION: qbs_build |
171 |
+# @USAGE: [<qbs args>...] |
172 |
+# @DESCRIPTION: |
173 |
+# Build the package using qbs build. |
174 |
+qbs_build() { |
175 |
+ debug-print-function ${FUNCNAME} "${@}" |
176 |
+ |
177 |
+ local qbsargs=( |
178 |
+ --no-install |
179 |
+ --command-echo-mode "${QBS_COMMAND_ECHO_MODE}" |
180 |
+ profile:gentoo |
181 |
+ config:release |
182 |
+ ) |
183 |
+ |
184 |
+ eqbs build "${@}" "${qbsargs[@]}" |
185 |
+} |
186 |
+ |
187 |
+# @FUNCTION: qbs_src_install |
188 |
+# @USAGE: [<qbs args>...] |
189 |
+# @DESCRIPTION: |
190 |
+# Install the package using qbs install. |
191 |
+qbs_src_install() { |
192 |
+ debug-print-function ${FUNCNAME} "${@}" |
193 |
+ |
194 |
+ local qbsargs=( |
195 |
+ --no-build |
196 |
+ --install-root "${D}" |
197 |
+ --command-echo-mode "${QBS_COMMAND_ECHO_MODE}" |
198 |
+ profile:gentoo |
199 |
+ config:release |
200 |
+ ) |
201 |
+ |
202 |
+ eqbs install "${@}" "${qbsargs[@]}" |
203 |
+} |
204 |
+ |
205 |
+_QBS_ECLASS=1 |
206 |
+fi |