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

EAPI=8

inherit cmake edo flag-o-matic

DESCRIPTION="A portable fork of the high-performance regular expression matching library"
HOMEPAGE="
	https://www.vectorcamp.gr/vectorscan/
	https://github.com/VectorCamp/vectorscan
"
SRC_URI="
	https://github.com/VectorCamp/vectorscan/archive/refs/tags/${PN}/${PV}.tar.gz
		-> ${P}.tar.gz
"

S="${WORKDIR}/${PN}-${P}"

LICENSE="BSD"
SLOT="0/5"
KEYWORDS="~amd64"
IUSE="cpu_flags_x86_avx2 cpu_flags_x86_sse4_2"

DEPEND="
	dev-libs/boost:=
"
RDEPEND="
	${DEPEND}
	!dev-libs/hyperscan
"
BDEPEND="
	dev-util/ragel
	virtual/pkgconfig
"

REQUIRED_USE="
	x86? ( cpu_flags_x86_sse4_2 )
	amd64? ( cpu_flags_x86_sse4_2 )
"

src_prepare() {
	local sedargs=(
		# Respect user -m flags (march/mtune)
		-e '/set(ARCH_CX*_FLAG/d'
		# Respect user -O flags
		-e '/set(OPT_CX*_FLAG/d'
	)
	sed -i "${sedargs[@]}" CMakeLists.txt cmake/cflags-x86.cmake || die
	cmake_src_prepare
}

src_configure() {
	use cpu_flags_x86_avx2 && append-flags -mavx2
	use cpu_flags_x86_sse4_2 && append-flags -msse4.2

	local mycmakeargs=(
		-DBUILD_BENCHMARKS=OFF
		-DBUILD_EXAMPLES=OFF
		-DBUILD_SHARED_LIBS=ON

		-DBUILD_AVX2=$(usex cpu_flags_x86_avx2)

		-DUSE_CPU_NATIVE=OFF
	)
	cmake_src_configure
}

src_test() {
	# The unit target cannot be used currently due to a bug in it,
	# see https://github.com/VectorCamp/vectorscan/issues/202
	#cmake_build unit
	edo "${BUILD_DIR}/bin/unit-hyperscan"
}