summaryrefslogtreecommitdiff
path: root/media-libs/cubeb/cubeb-0.2_p20220922.ebuild
blob: 7624610e5f4b581dcecf12e63af79283e8e1b7e2 (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
# Copyright 2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CARGO_OPTIONAL=1
CRATES="
	bitflags-1.3.2
	cache-padded-1.2.0
	cc-1.0.73
	cmake-0.1.48
	cubeb-backend-0.10.1
	cubeb-core-0.10.1
	cubeb-sys-0.10.1
	libc-0.2.133
	pkg-config-0.3.25
	ringbuf-0.2.8
	semver-1.0.14"
inherit cargo cmake flag-o-matic

HASH_CUBEB=93d1fa3fccdc22da37aa59f67b213591797db369
HASH_PULSERS=f32b3ef708c0bfb2c414c08971d638527353d376

DESCRIPTION="Cross-platform audio library"
HOMEPAGE="https://github.com/mozilla/cubeb/"
SRC_URI="
	https://github.com/mozilla/cubeb/archive/${HASH_CUBEB}.tar.gz -> ${P}.tar.gz
	pulseaudio? ( rust? (
		https://github.com/mozilla/cubeb-pulse-rs/archive/${HASH_PULSERS}.tar.gz -> ${PN}-pulse-rs-${HASH_PULSERS::10}.tar.gz
		$(cargo_crate_uris)
	) )"
S="${WORKDIR}/${PN}-${HASH_CUBEB}"

LICENSE="ISC pulseaudio? ( rust? ( || ( Apache-2.0 MIT ) ) )"
SLOT="0"
KEYWORDS="~amd64 ~arm64 ~x86"
IUSE="alsa doc jack pulseaudio +rust sndio test"
RESTRICT="!test? ( test )"

RDEPEND="
	media-libs/speexdsp
	alsa? ( media-libs/alsa-lib )
	jack? ( virtual/jack )
	pulseaudio? ( media-libs/libpulse )
	sndio? ( media-sound/sndio:= )"
DEPEND="
	${RDEPEND}
	test? ( dev-cpp/gtest )"
BDEPEND="
	doc? ( app-doc/doxygen )
	pulseaudio? ( rust? ( ${RUST_DEPEND} ) )"

PATCHES=(
	"${FILESDIR}"/${PN}-0.2_p20211213-automagic.patch
)

src_unpack() {
	use pulseaudio && use rust && cargo_src_unpack || default
}

src_prepare() {
	if use pulseaudio && use rust; then
		mv ../${PN}-pulse-rs-${HASH_PULSERS} src/${PN}-pulse-rs || die
	fi

	cmake_src_prepare

	use !debug || sed -i 's|/release/|/debug/|' CMakeLists.txt || die
}

src_configure() {
	local mycmakeargs=(
		-DBUILD_RUST_LIBS=$(usex rust)
		-DBUILD_TESTS=$(usex test)
		-DCHECK_ALSA=$(usex alsa)
		-DCHECK_JACK=$(usex jack)
		-DCHECK_PULSE=$(usex pulseaudio)
		-DCHECK_SNDIO=$(usex sndio)
		-DLAZY_LOAD_LIBS=no
		-DUSE_SANITIZERS=no
		$(cmake_use_find_package doc Doxygen)
	)

	if use pulseaudio && use rust; then
		# undefined references with cubeb-core, often need to be filtered for
		# cmake bits as well if combined with rust in case of llvm mismatch
		filter-lto
		cargo_src_configure --manifest-path src/${PN}-pulse-rs/Cargo.toml
	fi

	cmake_src_configure
}

src_compile() {
	use pulseaudio && use rust && cargo_src_compile

	cmake_src_compile
}

src_test() {
	use pulseaudio && use rust && cargo_src_test

	# these tests need access to audio devices and no sandbox
	cmake_src_test -E '(audio|callback_ret|device_changed_callback|devices|duplex|latency|record|sanity|tone)'
}

src_install() {
	cmake_src_install

	use doc && dodoc -r "${BUILD_DIR}"/docs/html

	# the basic test tool users could use to check if audio works is rather
	# limited and has a tendency to segfault if some backends are disabled
	rm "${ED}"/usr/bin/cubeb-test || die
}