mirror of
https://github.com/gentoo-mirror/guru.git
synced 2026-07-10 15:45:15 -04:00
107 lines
2.4 KiB
Bash
107 lines
2.4 KiB
Bash
# Copyright 2023-2025 Gentoo Authors
|
|
# Distributed under the terms of the GNU General Public License v2
|
|
|
|
EAPI=8
|
|
|
|
inherit eapi9-pipestatus edo toolchain-funcs
|
|
|
|
declare -A COMMITS=(
|
|
[dr_flac]="a1dd66cb680522a753bac7dff306b4a1cfd75e26"
|
|
[testbench]="aa7b0c6cf32994c106ae517a08134c28a96ff5b2"
|
|
)
|
|
|
|
DESCRIPTION="Single-header FLAC audio decoder library"
|
|
HOMEPAGE="https://github.com/mackron/dr_libs/"
|
|
SRC_URI="https://github.com/mackron/dr_libs/archive/${COMMITS[dr_flac]}.tar.gz -> ${P}.gh.tar.gz
|
|
test? ( https://github.com/ietf-wg-cellar/flac-test-files/archive/${COMMITS[testbench]}.tar.gz
|
|
-> flac-test-files-${COMMITS[testbench]}.gh.tar.gz )"
|
|
|
|
S="${WORKDIR}/dr_libs-${COMMITS[dr_flac]}"
|
|
|
|
LICENSE="|| ( MIT-0 public-domain )"
|
|
SLOT="0"
|
|
KEYWORDS="~amd64"
|
|
|
|
IUSE="test"
|
|
RESTRICT="!test? ( test )"
|
|
|
|
BDEPEND="test? ( media-libs/flac )"
|
|
|
|
TESTCASES=(
|
|
dr_flac_seeking.c
|
|
dr_flac_{decoding,test_0}.{c,cpp}
|
|
)
|
|
|
|
src_prepare() {
|
|
if use test; then
|
|
# Sanitize testbench and move to expected location
|
|
find "${WORKDIR}"/flac-test-files-${COMMITS[testbench]}/subset -type f \
|
|
\! -name "*.flac" -delete || die
|
|
mv -T "${WORKDIR}"/flac-test-files-${COMMITS[testbench]}/subset \
|
|
tests/testvectors/flac/testbench || die
|
|
|
|
# Disable profiling tests as they are not relevant downstream.
|
|
for tcase in ${TESTCASES[@]}; do
|
|
sed -i "s/doProfiling = DRFLAC_TRUE/doProfiling = DRFLAC_FALSE/" \
|
|
tests/flac/$tcase || die "sed failed on tests/flac/$tcase"
|
|
done
|
|
|
|
fi
|
|
|
|
awk '/Introduction/,/\*\//' dr_flac.h | sed '$d' > README
|
|
pipestatus || die
|
|
awk '/REVISION HISTORY/,/\*\//' dr_flac.h | sed '$d' > CHANGELOG
|
|
pipestatus || die
|
|
default
|
|
}
|
|
|
|
src_compile() {
|
|
if use test; then
|
|
local MY_{C,CC,CXX,BUILD,FLAGS}
|
|
MY_CC=$(tc-getCC)
|
|
MY_CXX=$(tc-getCXX)
|
|
|
|
pushd tests > /dev/null || die
|
|
for tcase in ${TESTCASES[@]}; do
|
|
case ${tcase} in
|
|
*.cpp)
|
|
MY_C=${MY_CXX}
|
|
MY_FLAGS=${CXXFLAGS}
|
|
;;
|
|
*.c)
|
|
MY_C=${MY_CC}
|
|
MY_FLAGS=${CFLAGS}
|
|
;;
|
|
*)
|
|
die "Unknown test case ${tcase}"
|
|
;;
|
|
esac
|
|
MY_BUILD="${MY_C} flac/${tcase} -o bin/${tcase} ${MY_FLAGS} ${CPPFLAGS}"
|
|
case ${tcase%.*} in
|
|
dr_flac_seeking)
|
|
;&
|
|
dr_flac_decoding)
|
|
MY_BUILD="${MY_BUILD} -lFLAC ${LDFLAGS}"
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
edo ${MY_BUILD}
|
|
done
|
|
popd || die
|
|
fi
|
|
}
|
|
|
|
src_test() {
|
|
pushd tests > /dev/null || die
|
|
for tcase in ${TESTCASES[@]}; do
|
|
edo bin/${tcase}
|
|
done
|
|
popd || die
|
|
}
|
|
|
|
src_install() {
|
|
einstalldocs
|
|
doheader dr_flac.h
|
|
}
|