Gentoo Archives: gentoo-dev

From: Matt Turner <mattst88@g.o>
To: gentoo-dev@l.g.o
Cc: Matt Turner <mattst88@g.o>
Subject: [gentoo-dev] [PATCH 2/2] meson-multilib.eclass: Add new eclass
Date: Wed, 02 Jun 2021 01:39:42
Message-Id: 20210602013847.1398499-3-mattst88@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/2] New meson-multilib eclass by Matt Turner
1 Signed-off-by: Matt Turner <mattst88@g.o>
2 ---
3 eclass/meson-multilib.eclass | 126 +++++++++++++++++++++++++++++++++++
4 1 file changed, 126 insertions(+)
5 create mode 100644 eclass/meson-multilib.eclass
6
7 diff --git a/eclass/meson-multilib.eclass b/eclass/meson-multilib.eclass
8 new file mode 100644
9 index 00000000000..4a46661d695
10 --- /dev/null
11 +++ b/eclass/meson-multilib.eclass
12 @@ -0,0 +1,126 @@
13 +# Copyright 1999-2021 Gentoo Authors
14 +# Distributed under the terms of the GNU General Public License v2
15 +
16 +# @ECLASS: meson-multilib.eclass
17 +# @MAINTAINER:
18 +# gx86-multilib team <multilib@g.o>
19 +# @AUTHOR:
20 +# Author: Michał Górny <mgorny@g.o>
21 +# Author: Matt Turner <mattst88@g.o>
22 +# @SUPPORTED_EAPIS: 7
23 +# @BLURB: meson wrapper for multilib builds
24 +# @DESCRIPTION:
25 +# The meson-multilib.eclass provides a glue between meson.eclass(5)
26 +# and multilib-minimal.eclass(5), aiming to provide a convenient way
27 +# to build packages using meson for multiple ABIs.
28 +#
29 +# Inheriting this eclass sets IUSE and exports default multilib_src_*()
30 +# sub-phases that call meson phase functions for each ABI enabled.
31 +# The multilib_src_*() functions can be defined in ebuild just like
32 +# in multilib-minimal, yet they ought to call appropriate meson
33 +# phase rather than 'default'.
34 +
35 +case ${EAPI:-0} in
36 + 7) ;;
37 + *) die "EAPI=${EAPI} is not supported" ;;
38 +esac
39 +
40 +inherit meson multilib-minimal
41 +
42 +EXPORT_FUNCTIONS src_configure src_compile src_test src_install
43 +
44 +# @FUNCTION: meson_native_bool
45 +# @USAGE: <USE flag> [option name]
46 +# @DESCRIPTION:
47 +# Given a USE flag and a meson project option, output a string like:
48 +#
49 +# -Doption=true
50 +# -Doption=false
51 +#
52 +# if building for the native ABI (multilib_is_native_abi is true). Otherwise,
53 +# output -Doption=false. If the project option is unspecified, it defaults
54 +# to the USE flag.
55 +meson_native_bool() {
56 + multilib_native_usex "${1}" "-D${2-${1}}=true" "-D${2-${1}}=false"
57 +}
58 +
59 +# @FUNCTION: meson_native_feature
60 +# @USAGE: <USE flag> [option name]
61 +# @DESCRIPTION:
62 +# Given a USE flag and a meson project option, output a string like:
63 +#
64 +# -Doption=enabled
65 +# -Doption=disabled
66 +#
67 +# if building for the native ABI (multilib_is_native_abi is true). Otherwise,
68 +# output -Doption=disabled. If the project option is unspecified, it defaults
69 +# to the USE flag.
70 +meson_native_feature() {
71 + multilib_native_usex "${1}" "-D${2-${1}}=enabled" "-D${2-${1}}=disabled"
72 +}
73 +
74 +# @FUNCTION: meson_native_enabled
75 +# @USAGE: <option name>
76 +# @DESCRIPTION:
77 +# Output -Doption=enabled option if executables are being built
78 +# (multilib_is_native_abi is true). Otherwise, output -Doption=disabled option.
79 +meson_native_enabled() {
80 + if multilib_is_native_abi; then
81 + echo "-D${1}=enabled"
82 + else
83 + echo "-D${1}=disabled"
84 + fi
85 +}
86 +
87 +# @FUNCTION: meson_native_true
88 +# @USAGE: <option name>
89 +# @DESCRIPTION:
90 +# Output -Doption=true option if executables are being built
91 +# (multilib_is_native_abi is true). Otherwise, output -Doption=false option.
92 +meson_native_true() {
93 + if multilib_is_native_abi; then
94 + echo "-D${1}=true"
95 + else
96 + echo "-D${1}=false"
97 + fi
98 +}
99 +
100 +meson-multilib_src_configure() {
101 + local _meson_args=( "${@}" )
102 +
103 + multilib-minimal_src_configure
104 +}
105 +
106 +multilib_src_configure() {
107 + meson_src_configure "${_meson_args[@]}"
108 +}
109 +
110 +meson-multilib_src_compile() {
111 + local _meson_args=( "${@}" )
112 +
113 + multilib-minimal_src_compile
114 +}
115 +
116 +multilib_src_compile() {
117 + meson_src_compile "${_meson_args[@]}"
118 +}
119 +
120 +meson-multilib_src_test() {
121 + local _meson_args=( "${@}" )
122 +
123 + multilib-minimal_src_test
124 +}
125 +
126 +multilib_src_test() {
127 + meson_src_test "${_meson_args[@]}"
128 +}
129 +
130 +meson-multilib_src_install() {
131 + local _meson_args=( "${@}" )
132 +
133 + multilib-minimal_src_install
134 +}
135 +
136 +multilib_src_install() {
137 + meson_src_install "${_meson_args[@]}"
138 +}
139 --
140 2.26.3