blob: 002b08c6e02f0a58805420a2bf9fef9c97f91576 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# Copyright 2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: build2.eclass
# @MAINTAINER:
# Anna Vyalkova <cyber+gentoo@sysrq.in>
# @AUTHOR:
# Anna Vyalkova <cyber+gentoo@sysrq.in>
# @SUPPORTED_EAPIS: 8
# @BLURB: eclass for packages using build2
# @DESCRIPTION:
# Utility eclass providing wrapper functions for the build2 build system along
# with default phase functions.
case ${EAPI:-0} in
8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} unsupported."
esac
if [[ ! ${_BUILD2_ECLASS} ]]; then
inherit edo multiprocessing toolchain-funcs
fi
EXPORT_FUNCTIONS src_configure src_compile src_test src_install
if [[ ! ${_BUILD2_ECLASS} ]]; then
# @ECLASS_VARIABLE: BUILD2_VERBOSITY
# @USER_VARIABLE
# @DESCRIPTION:
# Determines what kind of output to show when executing commands. All possible
# options are listed in b(1).
: ${BUILD2_VERBOSITY:=2}
BDEPEND="dev-util/build2"
# @FUNCTION: build2_src_configure
# @DESCRIPTION:
# Set build2 preferences to match user settings. Configure toolchain, build
# flags and installation prefix.
build2_src_configure() {
debug-print-function ${FUNCNAME} "${@}"
[[ -z ${mybargs} ]] && declare -a mybargs=()
local mybargstype=$(declare -p mybargs 2>&-)
if [[ "${mybargstype}" != "declare -a mybargs="* ]]; then
die "mybargs must be declared as array"
fi
local bargs=(
config.cxx="$(tc-getCXX)"
config.cxx.coptions="${CXXFLAGS}"
config.cxx.loptions="${LDFLAGS}"
config.c="$(tc-getCC)"
config.cc.coptions="${CFLAGS}"
config.cc.loptions="${LDFLAGS}"
config.bin.ar="$(tc-getAR)"
config.bin.ranlib="$(tc-getRANLIB)"
config.bin.lib=shared
config.install.root="${EPREFIX}"/usr
config.install.lib="${EPREFIX}"/usr/$(get_libdir)
config.install.doc="${EPREFIX}"/usr/share/doc/${PF}
"${mybargs[@]}"
--jobs $(makeopts_jobs)
--verbose "${BUILD2_VERBOSITY}"
)
edo b configure "${bargs[@]}"
}
# @FUNCTION: build2_src_compile
# @USAGE: [<b args>...]
# @DESCRIPTION:
# General function for compiling with build2. Tests are built conditionally.
build2_src_compile() {
debug-print-function ${FUNCNAME} "${@}"
local build_tests=no
local bargs=(
"${@}"
--jobs $(makeopts_jobs)
--verbose "${BUILD2_VERBOSITY}"
)
edo b update-for-install "${bargs[@]}"
has test ${FEATURES} && edo b update-for-test "${bargs[@]}"
}
# @FUNCTION: build2_src_test
# @USAGE: [<b args>...]
# @DESCRIPTION:
# Test the package using "b test".
build2_src_test() {
debug-print-function ${FUNCNAME} "${@}"
local bargs=(
"${@}"
--jobs $(makeopts_jobs)
--verbose "${BUILD2_VERBOSITY}"
)
edo b test "${bargs[@]}"
}
# @FUNCTION: build2_src_install
# @USAGE: [<b args>...]
# @DESCRIPTION:
# Install the package using "b install".
build2_src_install() {
debug-print-function ${FUNCNAME} "${@}"
local bargs=(
config.install.chroot="${D}"
"${@}"
--jobs $(makeopts_jobs)
--verbose "${BUILD2_VERBOSITY}"
)
edo b install "${bargs[@]}"
einstalldocs
}
# @FUNCTION: build2_pkg_die
# @INTERNAL
# @DESCRIPTION:
# EBUILD_DEATH_HOOK function to display a warning if ccache is enabled.
if ! has build2_pkg_die ${EBUILD_DEATH_HOOKS}; then
EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} build2_pkg_die"
fi
build2_pkg_die() {
if [[ "${EBUILD_PHASE}" != "compile" ]]; then
return
fi
if has ccache ${FEATURES}; then
# build2 doesn't support ccache:
# https://github.com/build2/build2/issues/86#issuecomment-647401742
ewarn
ewarn "!!! You have enabled ccache. Please try disabling ccache"
ewarn "!!! before reporting a bug."
ewarn
fi
}
_BUILD2_ECLASS=1
fi
|