summaryrefslogtreecommitdiff
blob: 4a8b270ac71ea1a85507ffb65a8a313e3b33eef2 (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
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

LUA_COMPAT=( lua5-{1,3,4} luajit )
inherit cmake lua

DESCRIPTION="Header-only C++ <-> Lua API wrapper"
HOMEPAGE="https://github.com/ThePhD/sol2"
SRC_URI="
	https://github.com/ThePhD/sol2/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	https://github.com/ThePhD/sol2/commit/e5e6466e09b632677d24a8f204d6a0ea0a8862b1.patch -> ${P}-gcc11.patch
"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="test"
REQUIRED_USE="test? ( ${LUA_REQUIRED_USE} )"
RESTRICT="!test? ( test )"

DEPEND="
	test? (
		${LUA_DEPS}
		dev-cpp/catch:0
	)
"
BDEPEND="
	test? (
		virtual/pkgconfig
	)
"

PATCHES=(
	"${DISTDIR}"/${P}-gcc11.patch
	"${FILESDIR}"/${P}-luajit-pkgconf.patch
	"${FILESDIR}"/${P}-catch-depend.patch
)

src_prepare() {
	# TODO: remove this sed on next bump
	sed -i -e 's/-Werror//' \
		tests/runtime_tests/CMakeLists.txt \
		tests/regression_tests/1011/CMakeLists.txt \
		tests/config_tests/function_pointers/CMakeLists.txt \
		examples/customization/CMakeLists.txt \
		examples/CMakeLists.txt || die

	cmake_src_prepare
}

src_configure() {
	cmake_src_configure

	if use test; then
		sol2_configure_wrapper() {
			local mycmakeargs=(
				-DSOL2_BUILD_LUA=no
				-DSOL2_TESTS=yes
				-DSOL2_LUA_VERSION="${ELUA}"
				-DCATCH_INC_DIR="${ESYSROOT}/usr/include/catch2"
			)
			cmake_src_configure
		}
		lua_foreach_impl sol2_configure_wrapper
	fi
}

src_compile() {
	use test && lua_foreach_impl cmake_src_compile
}

src_test() {
	sol2_test_wrapper() {
		if [[ ${ELUA} == luajit ]]; then
			einfo "Skipping test due to https://github.com/ThePhD/sol2/issues/1221"
		else
			cmake_src_test
		fi
	}
	lua_foreach_impl sol2_test_wrapper
}