1 |
commit: 708b16c5bb904fd2f07a47982c9632c767580fb0 |
2 |
Author: Anna (cybertailor) Vyalkova <cyber+gentoo <AT> sysrq <DOT> in> |
3 |
AuthorDate: Thu Jul 22 08:10:46 2021 +0000 |
4 |
Commit: Anna Vyalkova <cyber+gentoo <AT> sysrq <DOT> in> |
5 |
CommitDate: Thu Jul 22 08:27:39 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=708b16c5 |
7 |
|
8 |
boinc.eclass: new eclass |
9 |
|
10 |
Signed-off-by: Anna (cybertailor) Vyalkova <cyber+gentoo <AT> sysrq.in> |
11 |
|
12 |
eclass/boinc.eclass | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++++ |
13 |
1 file changed, 200 insertions(+) |
14 |
|
15 |
diff --git a/eclass/boinc.eclass b/eclass/boinc.eclass |
16 |
new file mode 100644 |
17 |
index 000000000..d16d6e250 |
18 |
--- /dev/null |
19 |
+++ b/eclass/boinc.eclass |
20 |
@@ -0,0 +1,200 @@ |
21 |
+# Copyright 2021 Gentoo Authors |
22 |
+# Distributed under the terms of the GNU General Public License v2 |
23 |
+ |
24 |
+# @ECLASS: boinc.eclass |
25 |
+# @MAINTAINER: |
26 |
+# Anna Vyalkova <cyber+gentoo@×××××.in> |
27 |
+# @SUPPORTED_EAPIS: 8 |
28 |
+# @BLURB: An eclass to build BOINC applications and libraries. |
29 |
+# @DESCRIPTION: |
30 |
+# This eclass provides helper functions to build BOINC applications and libraries. |
31 |
+ |
32 |
+inherit toolchain-funcs |
33 |
+ |
34 |
+case ${EAPI} in |
35 |
+ 8) ;; |
36 |
+ *) die "${ECLASS}: EAPI ${EAPI} unsupported." |
37 |
+esac |
38 |
+ |
39 |
+# @ECLASS-VARIABLE: BOINC_SUBMODULE |
40 |
+# @PRE_INHERIT |
41 |
+# @DEFAULT_UNSET |
42 |
+# @DESCRIPTION: |
43 |
+# Set this variable to a subdirectory relative to BOINC source repository, |
44 |
+# if software cannot be built outside it (for example, if some required |
45 |
+# headers are missing in sci-misc/boinc). |
46 |
+# |
47 |
+# If unset, no functions will be exported. |
48 |
+ |
49 |
+# @ECLASS-VARIABLE: BOINC_S |
50 |
+# @DEFAULT_UNSET |
51 |
+# @DESCRIPTION: |
52 |
+# If defined this variable determines the source directory name after |
53 |
+# unpacking. This defaults to package name and version. Note that this |
54 |
+# variable supports a wildcard mechanism to help with github tarballs |
55 |
+# that contain the commit hash as part of the directory name. |
56 |
+ |
57 |
+if [[ ${BOINC_SUBMODULE} ]]; then |
58 |
+ EXPORT_FUNCTIONS src_unpack src_prepare src_configure |
59 |
+fi |
60 |
+ |
61 |
+if [[ ! ${_BOINC_ECLASS} ]]; then |
62 |
+ |
63 |
+# @FUNCTION: get_boinc_src |
64 |
+# @USAGE: <SRC_URI|S> <release> [client|server] |
65 |
+# @RETURN: SRC_URI snippet or temporary build directory for given BOINC release |
66 |
+get_boinc_src() { |
67 |
+ local query_var=${1} |
68 |
+ local RELEASE_PATCH=${2} |
69 |
+ local RELEASE_MINOR=$(ver_cut 1-2 ${RELEASE_PATCH}) |
70 |
+ local RELEASE_TYPE=${3:-client} |
71 |
+ |
72 |
+ local SUFFIX= |
73 |
+ case ${RELEASE_TYPE} in |
74 |
+ server) SUFFIX="-server" ;; |
75 |
+ client) ;; |
76 |
+ *) die "${FUNCNAME}: unknown release type '${RELEASE_TYPE}'" |
77 |
+ esac |
78 |
+ |
79 |
+ local _SRC_URI="https://github.com/BOINC/boinc/archive" |
80 |
+ _SRC_URI+="${RELEASE_TYPE}_release/${RELEASE_MINOR}/${RELEASE_PATCH}.tar.gz" |
81 |
+ _SRC_URI+=" -> boinc${SUFFIX}-${RELEASE_PATCH}.tar.gz" |
82 |
+ |
83 |
+ local _S="${WORKDIR}/boinc-${RELEASE_TYPE}_release-${RELEASE_MINOR}-${RELEASE_PATCH}" |
84 |
+ |
85 |
+ case ${query_var} in |
86 |
+ SRC_URI) echo "${_SRC_URI}" ;; |
87 |
+ S) echo "${_S}" ;; |
88 |
+ *) die "${FUNCNAME}: unknown variable to query (${query_var})" |
89 |
+ esac |
90 |
+ |
91 |
+} |
92 |
+ |
93 |
+# @ECLASS-VARIABLE: BOINC_BUILD_DIR |
94 |
+# @OUTPUT_VARIABLE |
95 |
+# @DESCRIPTION: |
96 |
+# Temporary build directory, where BOINC sources are located. |
97 |
+ |
98 |
+# @FUNCTION: boinc_require_source |
99 |
+# @USAGE: [boinc version] [client|server] |
100 |
+# @DESCRIPTION: |
101 |
+# Set up SRC_URI and S for building application within BOINC source tree. |
102 |
+# |
103 |
+# This function must be called in global scope, after BOINC_SUBMODULE |
104 |
+# and SRC_URI have been declared. Take care not to overwrite the variables |
105 |
+# set by it. |
106 |
+# |
107 |
+# If no BOINC version is given, this function assumes it equal to client |
108 |
+# release $PV. |
109 |
+boinc_require_source() { |
110 |
+ local boinc_version=${1:-${PV}} |
111 |
+ SRC_URI+=" $(get_boinc_src SRC_URI ${boinc_version} ${2})" |
112 |
+ |
113 |
+ readonly BOINC_BUILD_DIR="$(get_boinc_src S ${boinc_version} ${2})" |
114 |
+ S="${BOINC_BUILD_DIR}/${BOINC_SUBMODULE}" |
115 |
+} |
116 |
+ |
117 |
+# @FUNCTION: boinc_enable_autotools |
118 |
+# @USAGE: [econf args...] |
119 |
+# @DESCRIPTION: |
120 |
+# Configure BOINC source tree using autotools. |
121 |
+# |
122 |
+# If no arguments are given, econf will be called |
123 |
+# with --enable-pkg-devel flag. |
124 |
+# |
125 |
+# This function must be called in global scope. |
126 |
+boinc_enable_autotools() { |
127 |
+ inherit autotools |
128 |
+ _BOINC_RUN_AUTOTOOLS=1 |
129 |
+ _BOINC_ECONF_ARGS=${@:---enable-pkg-devel} |
130 |
+} |
131 |
+ |
132 |
+# @FUNCTION: boinc_override_config |
133 |
+# @USAGE: <config.h> |
134 |
+# @DESCRIPTION: |
135 |
+# Some applications do not need autotools to build but |
136 |
+# use a few HAVE_* defines. |
137 |
+ |
138 |
+# If you want to save ~40 seconds and really know what |
139 |
+# to do, pass prepared config.h to this function. |
140 |
+# |
141 |
+# This function must be called in global scope. |
142 |
+boinc_override_config() { |
143 |
+ _BOINC_CONFIG_OVERRIDE="${1}" |
144 |
+} |
145 |
+ |
146 |
+# @FUNCTION: boinc_builddir_check |
147 |
+# @USAGE: |
148 |
+# @DESCRIPTION: |
149 |
+# Make sure BOINC_BUILD_DIR has a value. |
150 |
+boinc_builddir_check() { |
151 |
+ if [[ ! ${BOINC_BUILD_DIR} ]]; then |
152 |
+ eerror "BOINC_BUILD_DIR is not set." |
153 |
+ die "Did you forget to call boinc_require_source?" |
154 |
+ fi |
155 |
+ |
156 |
+ mkdir -p ${BOINC_BUILD_DIR} || die |
157 |
+} |
158 |
+ |
159 |
+boinc_src_unpack() { |
160 |
+ default_src_unpack |
161 |
+ boinc_builddir_check |
162 |
+ |
163 |
+ [[ -d ${S} ]] && \ |
164 |
+ return |
165 |
+ |
166 |
+ # Special case, for the always-lovely GitHub fetches. With this, |
167 |
+ # we allow the star glob to just expand to whatever directory it's |
168 |
+ # called. |
169 |
+ if [[ "${BOINC_S:=${P}}" = *"*"* ]]; then |
170 |
+ pushd "${WORKDIR}" >/dev/null || die |
171 |
+ local shopt_save=$(shopt -p nullglob) |
172 |
+ shopt -s nullglob |
173 |
+ |
174 |
+ # use an array to trigger filename expansion |
175 |
+ BOINC_S=( ${BOINC_S} ) |
176 |
+ if [[ ${#BOINC_S[@]} -gt 1 ]]; then |
177 |
+ die "BOINC_S did expand to multiple paths: ${BOINC_S[*]}" |
178 |
+ fi |
179 |
+ |
180 |
+ ${shopt_save} |
181 |
+ popd >/dev/null || die |
182 |
+ fi |
183 |
+ |
184 |
+ mkdir -p "$(dirname "${S}")" || die |
185 |
+ mv "${WORKDIR}/${BOINC_S}" "${S}" || die |
186 |
+} |
187 |
+ |
188 |
+boinc_src_prepare() { |
189 |
+ boinc_builddir_check |
190 |
+ default_src_prepare |
191 |
+ |
192 |
+ if [[ ${_BOINC_RUN_AUTOTOOLS} ]]; then |
193 |
+ pushd "${BOINC_BUILD_DIR}" >/dev/null || die |
194 |
+ eautoreconf |
195 |
+ popd >/dev/null || die |
196 |
+ fi |
197 |
+} |
198 |
+ |
199 |
+boinc_src_configure() { |
200 |
+ boinc_builddir_check |
201 |
+ pushd "${BOINC_BUILD_DIR}" >/dev/null || die |
202 |
+ |
203 |
+ bash ./generate_svn_version.sh || \ |
204 |
+ die "generating svn_version.h failed" |
205 |
+ |
206 |
+ if [[ ${_BOINC_RUN_AUTOTOOLS} ]]; then |
207 |
+ econf "${_BOINC_ECONF_ARGS[@]}" |
208 |
+ else |
209 |
+ tc-export AR CC CPP CXX LD OBJDUMP RANLIB |
210 |
+ fi |
211 |
+ |
212 |
+ if [[ ${_BOINC_CONFIG_OVERRIDE} ]]; then |
213 |
+ cp "${_BOINC_CONFIG_OVERRIDE}" config.h || die |
214 |
+ fi |
215 |
+ |
216 |
+ popd >/dev/null || die |
217 |
+} |
218 |
+ |
219 |
+_BOINC_ECLASS=1 |
220 |
+fi |