aboutsummaryrefslogtreecommitdiff
blob: 143d64e7950252550d48ee0de23169b6a97cd7b1 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="Toolchain for the Bluespec Hardware Definition Language"
HOMEPAGE="https://github.com/B-Lang-org/bsc"

if [[ ${PV} == "9999" ]] ; then
	EGIT_REPO_URI="https://github.com/B-Lang-org/bsc.git"
	inherit git-r3
else
	SRC_URI="
		https://github.com/B-Lang-org/bsc/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz
		https://github.com/SRI-CSL/yices2/archive/refs/tags/Yices-2.6.4.tar.gz -> yices-2.6.4.tar.gz
	"
	S="${WORKDIR}/bsc-${PV}"
	S_YICES="${WORKDIR}/yices2-Yices-2.6.4"
	KEYWORDS="~amd64 ~x86"
fi

LICENSE="BSD GPL-3+ MIT"
SLOT="${PV}"
IUSE="doc test"
RESTRICT="!test? ( test )"

RDEPEND="
	app-eselect/eselect-bluespec
	app-shells/tcsh
	dev-haskell/old-time:0=
	dev-haskell/regex-compat:0=
	dev-haskell/split:0=
	dev-haskell/syb:0=
	dev-lang/tcl
"

DEPEND="
	${RDEPEND}
	test? (
		dev-util/dejagnu
		sci-electronics/iverilog
		sci-electronics/systemc
		sys-process/time
	)
"

BDEPEND="
	dev-haskell/cabal:0=
	dev-lang/ghc:0=
	dev-lang/perl
	dev-util/gperf
	doc? (
		dev-ruby/asciidoctor
		dev-ruby/asciidoctor-pdf
		dev-texlive/texlive-bibtexextra
		dev-texlive/texlive-fontsextra
		dev-texlive/texlive-fontutils
		dev-texlive/texlive-latex
		dev-texlive/texlive-latexextra
		dev-texlive/texlive-latexrecommended
		dev-texlive/texlive-plaingeneric
	)
	sys-apps/coreutils
	sys-devel/autoconf
	sys-devel/bison
	sys-devel/flex
	virtual/pkgconfig
"

PATCHES=(
	"${FILESDIR}"/${PN}-2022.01-libstp-stub-makefile.patch
)

# Do not complain about CFLAGS etc since we don't use them
QA_FLAGS_IGNORED="
	usr/share/bsc/bsc-${PV}/bin/core/.*
	usr/share/bsc/bsc-${PV}/lib/SAT/.*
	usr/share/bsc/bsc-${PV}/lib/VPI/.*
"

src_prepare() {
	if [[ ${PV} != "9999" ]] ; then
		rm -r "${S}"/src/vendor/yices/v2.6/yices2 || die
		ln -s "${S_YICES}" "${S}"/src/vendor/yices/v2.6/yices2 || die
	fi

	default
}

src_compile() {
	# NO_DEPS_CHECKS=1: skip the subrepo check (this deriviation uses yices.src instead of the subrepo)
	# LDCONFIG=ldconfig: https://github.com/B-Lang-org/bsc/pull/43
	# STP_STUB=1: https://github.com/B-Lang-org/bsc/pull/278
	emake \
		"NO_DEPS_CHECKS=1" \
		"LDCONFIG=ldconfig" \
		"STP_STUB=1" \
		$(usex doc "" "NOASCIIDOCTOR=1") \
		$(usex doc "install-doc" "") \
		$(usex doc "install-release" "") \
		install-src \
		$(usex doc "release" "")
	emake -C src/comp \
		install-extra
}

src_test() {
	emake check-smoke
	emake -C testsuite check
}

# Call eselect vi update with --if-unset
# to respect user's choice
eselect_bluespec_update() {
	ebegin "Calling eselect bluespec update"
	eselect bluespec update --if-unset
	eend $?
}

src_install() {
	# From https://github.com/B-Lang-org/bsc/blob/main/INSTALL.md,
	# upstream recommend placing the inst directory at
	# the path /usr/share/bsc/bsc-<VERSION> for multi-version.
	local INSTALL_PATH=/usr/share/bsc/bsc-"${PV}"
	local ED_INSTALL_PATH="${ED}${INSTALL_PATH}"
	mkdir -p "${ED_INSTALL_PATH}" || die
	local f
	for f in "${S}"/inst/bin/*; do
		if [[ ! -d "${f}" ]] ; then
			local b=$(basename ${f})
			sed -i "s|ABSNAME=.*\$|ABSNAME=\$(readlink -f -- \"\$0\")|g" "${f}" || die
		fi
	done
	cp -dr --preserve=mode,timestamp "${S}"/inst/* "${ED_INSTALL_PATH}"/ || die
	insinto "${INSTALL_PATH}"/vimfiles
	doins -r "${S}"/util/vim/{ftdetect,indent,syntax}
}

pkg_postinst() {
	eselect_bluespec_update
}

pkg_postrm() {
	eselect_bluespec_update
}