Contents of /trunk/include/meson.sminc
Parent Directory | Revision Log
Revision 33239 -
(show annotations)
(download)
Mon Oct 21 09:58:50 2019 UTC (4 years, 7 months ago) by niro
File size: 4984 byte(s)
Mon Oct 21 09:58:50 2019 UTC (4 years, 7 months ago) by niro
File size: 4984 byte(s)
-make mesons builddir and srcdir configurable
1 | # $Id$ |
2 | # meson config tools |
3 | |
4 | SDEPEND="${SDEPEND} |
5 | >= dev-util/meson-0.43 |
6 | >= dev-util/ninja-1.8" |
7 | |
8 | # enables features like --enable-blah with make |
9 | meson_enable() |
10 | { |
11 | local feature="$1" |
12 | local option="$2" |
13 | [[ -z ${option} ]] && option="true" |
14 | |
15 | echo "-Denable-${feature}=${option}" |
16 | } |
17 | |
18 | # disables features like --disable-blah with make |
19 | meson_disable() |
20 | { |
21 | local feature="$1" |
22 | echo "-Denable-${feature}=false" |
23 | } |
24 | |
25 | # enables features like --with-blah with make |
26 | meson_with() |
27 | { |
28 | local feature="$1" |
29 | local option="$2" |
30 | [[ -z ${option} ]] && option="true" |
31 | |
32 | echo "-Dwith-${feature}=${option}" |
33 | } |
34 | |
35 | # enables features like --with-blah with make |
36 | meson_without() |
37 | { |
38 | local feature="$1" |
39 | echo "-Dwith-${feature}=false" |
40 | } |
41 | |
42 | meson_bool_true() |
43 | { |
44 | local feature="$1" |
45 | meson_opt "${feature}" "true" |
46 | } |
47 | |
48 | meson_bool_false() |
49 | { |
50 | local feature="$1" |
51 | meson_opt "${feature}" "false" |
52 | } |
53 | |
54 | # generic meson opts |
55 | meson_opt() |
56 | { |
57 | local feature="$1" |
58 | local option="$2" |
59 | echo "-D${feature}=${option}" |
60 | } |
61 | |
62 | meson_src_prepare() |
63 | { |
64 | munpack ${SRCFILE} || die |
65 | } |
66 | |
67 | meson_configure() |
68 | { |
69 | local configure_opts="$@" |
70 | local default_opts |
71 | |
72 | default_opts+=" --buildtype=release" |
73 | default_opts+=" --prefix=/usr" |
74 | default_opts+=" --sysconfdir=/etc" |
75 | default_opts+=" --localstatedir=/var/lib" |
76 | |
77 | if [[ ${MULTILIB_BUILD} = true ]] |
78 | then |
79 | # must be escaped so the mlibdir variable gets evaluated later |
80 | default_opts+=' --libdir=/usr/$(mlibdir)' |
81 | default_opts+=' --libexecdir=/usr/$(mlibdir)/${PNAME}' |
82 | : ${MESON_SRCDIR="${SRCDIR}-$(mabi)/${SRCSUBDIR}"} |
83 | : ${MESON_BUILDDIR="${BUILDDIR}/build-$(mabi)"} |
84 | all-abis meson setup ${default_opts} ${configure_opts} ${MESON_SRCDIR} ${MESON_BUILDDIR} || die |
85 | else |
86 | # the mlibdir variable gets right now evaluated |
87 | default_opts+=" --libdir=/usr/$(mlibdir)" |
88 | default_opts+=" --libexecdir=/usr/$(mlibdir)/${PNAME}" |
89 | : ${MESON_SRCDIR="${SRCDIR}/${SRCSUBDIR}"} |
90 | : ${MESON_BUILDDIR="${BUILDDIR}/build"} |
91 | meson setup ${default_opts} ${configure_opts} ${MESON_SRCDIR} ${MESON_BUILDDIR} || die |
92 | fi |
93 | } |
94 | |
95 | mninja() |
96 | { |
97 | local abi |
98 | local abis_to_run="${MULTILIB_ABIS}" |
99 | |
100 | # respect MULTILIB_ONLY_ABI variable |
101 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" |
102 | |
103 | if [[ ${MULTILIB_BUILD} = true ]] |
104 | then |
105 | for abi in ${abis_to_run} |
106 | do |
107 | echo -e "${COLBLUE}*** ${COLGREEN}running ninja for ABI -${abi}${COLDEFAULT}" |
108 | : ${MESON_SRCDIR="${SRCDIR}-$(mabi)/${SRCSUBDIR}"} |
109 | : ${MESON_BUILDDIR="${BUILDDIR}/build-$(mabi)"} |
110 | abi-${abi} ninja -C ${MESON_SRCDIR} -C ${MESON_BUILDDIR} -v ${MAKEOPTS} "$@" |
111 | done |
112 | else |
113 | : ${MESON_SRCDIR="${SRCDIR}/${SRCSUBDIR}"} |
114 | : ${MESON_BUILDDIR="${BUILDDIR}/build"} |
115 | ninja -C ${MESON_SRCDIR} -C ${MESON_BUILDDIR} -v ${MAKEOPTS} "$@" |
116 | fi |
117 | } |
118 | |
119 | meson_setup_builddir() |
120 | { |
121 | local abi |
122 | local abis_to_run="${MULTILIB_ABIS}" |
123 | |
124 | # respect MULTILIB_ONLY_ABI variable |
125 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" |
126 | |
127 | if [[ ${MULTILIB_BUILD} = true ]] |
128 | then |
129 | for abi in ${abis_to_run} |
130 | do |
131 | echo -e "${COLBLUE}*** ${COLGREEN}running ninja for ABI -${abi}${COLDEFAULT}" |
132 | : ${MESON_BUILDDIR="${BUILDDIR}/build-$(mabi)"} |
133 | abi-${abi} install -d ${MESON_BUILDDIR} || die |
134 | done |
135 | else |
136 | : ${MESON_BUILDDIR="${BUILDDIR}/build"} |
137 | install -d ${MESON_BUILDDIR} || die |
138 | fi |
139 | } |
140 | |
141 | meson_src_compile() |
142 | { |
143 | if [[ ${MULTILIB_BUILD} != true ]] |
144 | then |
145 | : ${MESON_SRCDIR="${SRCDIR}"} |
146 | cd ${MESON_SRCDIR} |
147 | fi |
148 | |
149 | meson_setup_builddir || die |
150 | meson_configure "$@" || die |
151 | mninja || die |
152 | } |
153 | |
154 | meson_src_check() |
155 | { |
156 | : ${MESON_BUILDDIR="${BUILDDIR}/build"} |
157 | cd ${MESON_BUILDDIR} |
158 | meson test || die |
159 | } |
160 | |
161 | meson_multilib_src_check() |
162 | { |
163 | local abi |
164 | local abis_to_run="${MULTILIB_ABIS}" |
165 | |
166 | # respect MULTILIB_ONLY_ABI variable |
167 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" |
168 | for abi in ${abis_to_run} |
169 | do |
170 | : ${MESON_BUILDDIR="${BUILDDIR}/build-${abi}"} |
171 | cd ${MESON_BUILDDIR} |
172 | meson test || die |
173 | done |
174 | } |
175 | |
176 | meson_src_install() |
177 | { |
178 | : ${MESON_SRCDIR="${SRCDIR}"} |
179 | : ${MESON_BUILDDIR="${BUILDDIR}/build"} |
180 | |
181 | cd ${MESON_BUILDDIR} |
182 | DESTDIR=${BINDIR} ninja install || die |
183 | |
184 | cd ${MESON_SRCDIR} |
185 | local i |
186 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
187 | FAQ LICENSE NEWS README TODO |
188 | do |
189 | if [ -f ${MESON_SRCDIR}/${i} ] |
190 | then |
191 | minstalldocs ${i} || die |
192 | fi |
193 | done |
194 | } |
195 | |
196 | meson_multilib_src_install() |
197 | { |
198 | local abi |
199 | local abis_to_run="${MULTILIB_ABIS}" |
200 | |
201 | # respect MULTILIB_ONLY_ABI variable |
202 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" |
203 | for abi in ${abis_to_run} |
204 | do |
205 | : ${MESON_SRCDIR="${SRCDIR}-${abi}"} |
206 | : ${MESON_BUILDDIR="${BUILDDIR}/build-${abi}"} |
207 | |
208 | cd ${MESON_BUILDDIR} |
209 | DESTDIR=${BINDIR} ninja install || die |
210 | |
211 | cd ${MESON_SRCDIR} |
212 | local i |
213 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
214 | FAQ LICENSE NEWS README TODO |
215 | do |
216 | if [ -f ${MESON_SRCDIR}/${i} ] |
217 | then |
218 | minstalldocs ${i} || die |
219 | fi |
220 | done |
221 | done |
222 | } |
223 | |
224 | export_inherits meson src_prepare src_compile |
225 | if [[ ${MULTILIB_BUILD} = true ]] |
226 | then |
227 | export_inherits meson_multilib src_check src_install |
228 | else |
229 | export_inherits meson src_check src_install |
230 | fi |