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

EAPI=6

inherit cmake-multilib flag-o-matic llvm eapi7-ver

MY_PN="SPIRV-LLVM-Translator"
MY_PV="$(ver_rs 3 -)"
MY_P="${MY_PN}-${MY_PV}"

DESCRIPTION="Bi-directional translator between SPIR-V and LLVM IR"
HOMEPAGE="https://github.com/KhronosGroup/SPIRV-LLVM-Translator"
SRC_URI="https://github.com/KhronosGroup/${MY_PN}/archive/v${MY_PV}.tar.gz -> ${P}.tar.gz
	https://dev.gentoo.org/~marecki/dists/${PN}/${PN}-8.0.0.1-LowerOpenCL_new_block_representation.patch.xz"

LICENSE="UoI-NCSA"
SLOT="8"
KEYWORDS="~amd64"
IUSE="test"

S="${WORKDIR}/${MY_P}"

COMMON="sys-devel/llvm:8=[${MULTILIB_USEDEP}]"
DEPEND="${COMMON}
	test? ( dev-python/lit )"
RDEPEND="${COMMON}"

LLVM_MAX_SLOT=8

PATCHES=(
	"${WORKDIR}"/${PN}-8.0.0.1-LowerOpenCL_new_block_representation.patch
	"${FILESDIR}"/${PN}-8.0.0.1-no_pkgconfig_files.patch
)

src_prepare() {
	append-flags -fPIC
	cmake-utils_src_prepare
}

multilib_src_configure() {
	local mycmakeargs=(
		-DCMAKE_INSTALL_PREFIX="$(get_llvm_prefix)"
		$(usex test "-DLLVM_INCLUDE_TESTS=ON" "")
	)
	cmake-utils_src_configure
}

multilib_src_compile() {
	cmake-utils_src_compile llvm-spirv
}

multilib_src_install() {
	cmake-utils_src_install
	# CMake does not install the executable so do it by hand
	if multilib_is_native_abi; then
		exeinto "$(get_llvm_prefix)"/bin
		doexe "${BUILD_DIR}"/tools/llvm-spirv/llvm-spirv
	fi
}

multilib_src_test() {
	# TODO: figure out why some tests fail on amd64 when ABI==x86
	if multilib_is_native_abi; then
		lit "${BUILD_DIR}/test" || die "Error running tests for ABI ${ABI}"
	fi
}