summaryrefslogtreecommitdiff
path: root/dev-cpp/tinygltf/tinygltf-2.9.6.ebuild
blob: 85301c5c2f854e98454fc39a328470d554d9c507 (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
# Copyright 2024-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{12..14} )
inherit cmake edo python-any-r1

DESCRIPTION="Header only C++11 tiny glTF 2.0 library"
HOMEPAGE="https://github.com/syoyo/tinygltf"

SAMPLE_MODELS="d7a3cc8e51d7c573771ae77a57f16b0662a905c6"
SRC_URI="
	https://github.com/syoyo/tinygltf/archive/refs/tags/v${PV}.tar.gz
		-> ${P}.tar.gz
	test? (
		https://github.com/KhronosGroup/glTF-Sample-Models/archive/${SAMPLE_MODELS}.tar.gz
			-> glTF-Sample-Models-${SAMPLE_MODELS}.tar.gz
	)
"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"

IUSE="examples test"

RESTRICT="!test? ( test )"

PATCHES=(
	"${FILESDIR}/0001-Use-nlohmann-and-stb-packages-instead-of-bundled-one.patch"
)

RDEPEND="
	dev-libs/stb
	dev-cpp/nlohmann_json
	examples? (
		media-libs/glew:=
		media-libs/glfw
		media-libs/glu
		virtual/opengl
	)
"
DEPEND="
	${RDEPEND}
"
BDEPEND="
	test? (
		${PYTHON_DEPS}
	)
"

pkg_setup() {
	use test && python-any-r1_pkg_setup
}

src_prepare() {
	cmake_src_prepare

	if use test; then
		mv -T "${WORKDIR}/glTF-Sample-Models-${SAMPLE_MODELS}" "${WORKDIR}/glTF-Sample-Models" || die
	fi

	sed -i -e 's/clang++/$(CXX)/' tests/Makefile || die
	sed -i \
		-e "s|^sample_model_dir = \".*\"|sample_model_dir = \"${WORKDIR}/glTF-Sample-Models\"|" \
		-e "s|\"./loader_example\"|\"${BUILD_DIR}/loader_example\"|" \
		test_runner.py || die
}

src_configure() {
	local mycmakeargs=(
		-DTINYGLTF_BUILD_LOADER_EXAMPLE=$(usex test)
		-DTINYGLTF_BUILD_GL_EXAMPLES=$(usex examples)
		-DTINYGLTF_BUILD_VALIDATOR_EXAMPLE=$(usex examples)
		-DTINYGLTF_BUILD_BUILDER_EXAMPLE=$(usex examples)
		-DTINYGLTF_HEADER_ONLY=OFF
		-DTINYGLTF_INSTALL=ON
		-DTINYGLTF_INSTALL_VENDOR=OFF
	)
	#use examples && mycmakeargs+=( -DOpenGL_GL_PREFERENCE=GLVND )
	cmake_src_configure
}

src_test() {
	# unit tests
	pushd tests >/dev/null || die
	emake
	edo ./tester
	edo ./tester_noexcept
	popd >/dev/null || die

	# glTF parsing tests
	edo "${EPYTHON}" test_runner.py
}