summaryrefslogtreecommitdiff
blob: b1e812e6a7a1f88089834e455a6d32210b9d3384 (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
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=5

SUPPORT_PYTHON_ABIS="1"
PYTHON_DEPEND="*"
PYTHON_EXPORT_PHASE_FUNCTIONS="1"

inherit git-2 python

DESCRIPTION="GCC Python plugin for static analysis"
HOMEPAGE="https://fedorahosted.org/gcc-python-plugin"
EGIT_REPO_URI="git://git.fedorahosted.org/gcc-python-plugin.git"
LICENSE="GPL-3"
SLOT="0"
KEYWORDS=""
IUSE="doc"

DEPEND="${DEPEND}
>=sys-devel/gcc-4.6
dev-python/six
dev-python/pygments
media-gfx/graphviz"

RDEPEND="${DEPEND}"

DEPEND="${DEPEND}
dev-python/sphinx
doc? (
dev-python/pycairo
)"

src_configure() {
	return
}

src_compile() {
	rename_items() {
		PLUGIN_NAME="python$(python_get_version --major)"
		GCC_WITH_PYTHON_SCRIPT_NAME="gcc-with-${PLUGIN_NAME}"

		cp python.so "${PLUGIN_NAME}.so"
		cp gcc-with-python "${GCC_WITH_PYTHON_SCRIPT_NAME}"
		sed -i -e"s|-fplugin=[^ ]*|-fplugin=${PLUGIN_NAME}|" "${GCC_WITH_PYTHON_SCRIPT_NAME}"
		sed -i -e"s|-fplugin-arg-python-script|-fplugin-arg-${PLUGIN_NAME}-script|" "${GCC_WITH_PYTHON_SCRIPT_NAME}"
	}

	python_execute_function -d -s plugin
	python_execute_function -s rename_items

	cd "${WORKDIR}/${P}-$(python_get_version -f)"

	emake man

	if use doc; then
		emake html
	fi
}

src_test() {
	emake testcpybuilder test-suite testcpychecker
}

src_install() {
	GCC_PLUGIN_DIR="$(gcc --print-file-name=plugin)"

	install_plugin_files() {
		dobin "gcc-with-python$(python_get_version --major)"
		insinto "${GCC_PLUGIN_DIR}"
		doins "python$(python_get_version --major).so"
		insinto "$(python_get_sitedir)"
		doins -r gccutils
		doins -r libcpychecker
	}

	python_execute_function -s install_plugin_files
	dobin "${FILESDIR}/gcc-with-python"

	cd "${WORKDIR}/${P}-$(python_get_version -f)"

	doman docs/_build/man/*

	if use doc; then
		dodoc -r examples
		dodoc -r docs/_build/html
	fi
}