Magellan Linux

Contents of /trunk/include/meson.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 33260 - (show annotations) (download)
Tue Oct 22 12:29:09 2019 UTC (4 years, 6 months ago) by niro
File size: 5362 byte(s)
-use mninja() to respect multilib and this fixes multilib_src_install issues too, removed unused variables and set MESON_ variables local if not globally set
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 [[ -n ${MESON_SRCDIR} ]] || local MESON_SRCDIR
72 [[ -n ${MESON_BUILDDIR} ]] || local MESON_BUILDDIR
73
74 default_opts+=" --buildtype=release"
75 default_opts+=" --prefix=/usr"
76 default_opts+=" --sysconfdir=/etc"
77 default_opts+=" --localstatedir=/var/lib"
78
79 if [[ ${MULTILIB_BUILD} = true ]]
80 then
81 # must be escaped so the mlibdir variable gets evaluated later
82 default_opts+=' --libdir=/usr/$(mlibdir)'
83 default_opts+=' --libexecdir=/usr/$(mlibdir)/${PNAME}'
84 : ${MESON_SRCDIR="${SRCDIR}-$(mabi)/${SRCSUBDIR}"}
85 : ${MESON_BUILDDIR="${BUILDDIR}/build-$(mabi)"}
86 all-abis meson setup ${default_opts} ${configure_opts} ${MESON_SRCDIR} ${MESON_BUILDDIR} || die
87 else
88 # the mlibdir variable gets right now evaluated
89 default_opts+=" --libdir=/usr/$(mlibdir)"
90 default_opts+=" --libexecdir=/usr/$(mlibdir)/${PNAME}"
91 : ${MESON_SRCDIR="${SRCDIR}/${SRCSUBDIR}"}
92 : ${MESON_BUILDDIR="${BUILDDIR}/build"}
93 meson setup ${default_opts} ${configure_opts} ${MESON_SRCDIR} ${MESON_BUILDDIR} || die
94 fi
95 }
96
97 mninja()
98 {
99 local abi
100 local abis_to_run="${MULTILIB_ABIS}"
101 [[ -n ${MESON_SRCDIR} ]] || local MESON_SRCDIR
102 [[ -n ${MESON_BUILDDIR} ]] || local MESON_BUILDDIR
103
104 # respect MULTILIB_ONLY_ABI variable
105 [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
106
107 if [[ ${MULTILIB_BUILD} = true ]]
108 then
109 for abi in ${abis_to_run}
110 do
111 echo -e "${COLBLUE}*** ${COLGREEN}running ninja for ABI -${abi}${COLDEFAULT}"
112 : ${MESON_SRCDIR="${SRCDIR}-$(mabi)/${SRCSUBDIR}"}
113 : ${MESON_BUILDDIR="${BUILDDIR}/build-$(mabi)"}
114 abi-${abi} ninja -C ${MESON_SRCDIR} -C ${MESON_BUILDDIR} -v ${MAKEOPTS} "$@"
115 done
116 else
117 : ${MESON_SRCDIR="${SRCDIR}/${SRCSUBDIR}"}
118 : ${MESON_BUILDDIR="${BUILDDIR}/build"}
119 ninja -C ${MESON_SRCDIR} -C ${MESON_BUILDDIR} -v ${MAKEOPTS} "$@"
120 fi
121 }
122
123 meson_setup_builddir()
124 {
125 local abi
126 local abis_to_run="${MULTILIB_ABIS}"
127 [[ -n ${MESON_BUILDDIR} ]] || local MESON_BUILDDIR
128
129 # respect MULTILIB_ONLY_ABI variable
130 [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
131
132 if [[ ${MULTILIB_BUILD} = true ]]
133 then
134 for abi in ${abis_to_run}
135 do
136 echo -e "${COLBLUE}*** ${COLGREEN}running ninja for ABI -${abi}${COLDEFAULT}"
137 : ${MESON_BUILDDIR="${BUILDDIR}/build-$(mabi)"}
138 abi-${abi} install -d ${MESON_BUILDDIR} || die
139 done
140 else
141 : ${MESON_BUILDDIR="${BUILDDIR}/build"}
142 install -d ${MESON_BUILDDIR} || die
143 fi
144 }
145
146 meson_src_compile()
147 {
148 [[ -n ${MESON_SRCDIR} ]] || local MESON_SRCDIR
149
150 if [[ ${MULTILIB_BUILD} != true ]]
151 then
152 : ${MESON_SRCDIR="${SRCDIR}"}
153 cd ${MESON_SRCDIR}
154 fi
155
156 meson_setup_builddir || die
157 meson_configure "$@" || die
158 mninja || die
159 }
160
161 meson_src_check()
162 {
163 [[ -n ${MESON_BUILDDIR} ]] || local MESON_BUILDDIR
164
165 : ${MESON_BUILDDIR="${BUILDDIR}/build"}
166 meson test -C ${MESON_BUILDDIR} || die
167 }
168
169 meson_multilib_src_check()
170 {
171 local abi
172 local abis_to_run="${MULTILIB_ABIS}"
173 [[ -n ${MESON_BUILDDIR} ]] || local MESON_BUILDDIR
174
175 # respect MULTILIB_ONLY_ABI variable
176 [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
177 for abi in ${abis_to_run}
178 do
179 : ${MESON_BUILDDIR="${BUILDDIR}/build-$(mabi)"}
180 abi-${abi} meson test -C ${MESON_BUILDDIR} || die
181 done
182 }
183
184 meson_src_install()
185 {
186 [[ -n ${MESON_SRCDIR} ]] || local MESON_SRCDIR
187
188 : ${MESON_SRCDIR="${SRCDIR}"}
189
190 DESTDIR=${BINDIR} mninja install || die
191
192 cd ${MESON_SRCDIR}
193 local i
194 for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
195 FAQ LICENSE NEWS README TODO
196 do
197 if [ -f ${MESON_SRCDIR}/${i} ]
198 then
199 minstalldocs ${i} || die
200 fi
201 done
202 }
203
204 meson_multilib_src_install()
205 {
206 local abi
207 local abis_to_run="${MULTILIB_ABIS}"
208 [[ -n ${MESON_SRCDIR} ]] || local MESON_SRCDIR
209
210 DESTDIR=${BINDIR} mninja install || die
211
212 # respect MULTILIB_ONLY_ABI variable
213 [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
214 for abi in ${abis_to_run}
215 do
216 : ${MESON_SRCDIR="${SRCDIR}-$(mabi)"}
217
218 cd ${MESON_SRCDIR}
219 local i
220 for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
221 FAQ LICENSE NEWS README TODO
222 do
223 if [ -f ${MESON_SRCDIR}/${i} ]
224 then
225 minstalldocs ${i} || die
226 fi
227 done
228 done
229 }
230
231 export_inherits meson src_prepare src_compile
232 if [[ ${MULTILIB_BUILD} = true ]]
233 then
234 export_inherits meson_multilib src_check src_install
235 else
236 export_inherits meson src_check src_install
237 fi