summaryrefslogtreecommitdiff
path: root/dev-ada/gpr/gpr-26.0.0.ebuild
blob: b25dec925198cec8d8edcf7684200b2ee9f19f70 (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
# Copyright 2022-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

ADA_COMPAT=( gcc_{14..16} )
PYTHON_COMPAT=( python3_{13..14} )

inherit ada python-any-r1 multiprocessing

DESCRIPTION="LibGPR2 - Parser for GPR Project files"
HOMEPAGE="https://github.com/AdaCore/gpr"
SRC_URI="https://github.com/AdaCore/${PN}/archive/refs/tags/v${PV}.tar.gz
	-> ${P}.tar.gz"

LICENSE="Apache-2.0"
SLOT="0/${PV}"
KEYWORDS="~amd64 ~arm64 ~x86"
IUSE="static-libs static-pic test"
REQUIRED_USE="${ADA_REQUIRED_USE}"
RESTRICT="!test? ( test )"

RDEPEND="${ADA_DEPS}
	dev-ada/xmlada[${ADA_USEDEP},shared,static-libs?,static-pic?]
	>=dev-ada/gnatcoll-core-26[${ADA_USEDEP},shared,static-libs?,static-pic?]
	dev-ada/gnatcoll-bindings[${ADA_USEDEP},shared,static-libs?,static-pic?,iconv(+),gmp]
"

DEPEND="${RDEPEND}
	dev-ada/gprconfig_kb[${ADA_USEDEP}]
	dev-ada/gprbuild[${ADA_USEDEP}]"
BDEPEND="test? (
	$(python_gen_any_dep '
		dev-ada/e3-testsuite[${PYTHON_USEDEP}]
	')
	dev-ada/gnatmem
)"

PATCHES=( "${FILESDIR}"/${P}-gcc16.patch )

python_check_deps() {
	use test || return 0
	python_has_version "dev-ada/e3-testsuite[${PYTHON_USEDEP}]"
}

pkg_setup() {
	use test && python-any-r1_pkg_setup
	ada_pkg_setup
}

src_prepare() {
	default
	cd testsuite/tests
	rm -r \
		abstract-importing-non-abstract aggregate ali_parser attribute \
		autoconf build-actions build_db build_makefile_parser \
		callgraph-install c-closure check-has-value check-mem \
		check-shared-lib-import command_line config \
		custom_attr_no_pack default-target disable_warnings display-version \
		empty_attribute_support explicit-target executable-directory \
		excluded_source_dirs externals-in-configuration-project \
		ignore_source_sub_dirs installed_asm_object \
		invalid-project invalid-project-2 invalid-trace-file kb \
		library load-preinstalled \
		multi-unit-3 nested-case nested-externals no-naming-package-in-config \
		options package-extension package-renaming parent-var-visible \
		parser-no-value prj-syntax-error process_manager runtime \
		self-project-attribute source subdirs target-checks tools \
		types-import unknown-var-config unit_filename_generator view_builder \
		build_db_dag/actions_signature tooling/source_dirs || die
}

src_compile() {
	local BUILD_ROOT=.build
	local KB_BUILD_DIR=${BUILD_ROOT}/kb
	mkdir -p ${KB_BUILD_DIR} || die
	cp kb/gpr2-kb-embedded.ads ${KB_BUILD_DIR} || die
	gprbuild -p -P kb/collect_kb.gpr -v -largs ${LDFLAGS} -cargs ${ADAFLAGS} \
		|| die
	.build/kb/collect_kb -o .build/kb /usr/share/gprconfig || die

	build () {
		gprbuild -j$(get_makeopts_jobs) -m -p -v -XLIBRARY_TYPE=$1 \
			-XGPR2_BUILD=release -XXMLADA_BUILD=$1 gpr2.gpr \
			-largs ${LDFLAGS} \
			-cargs ${ADAFLAGS} || die "gprbuild failed"
	}
	build relocatable
	if use static-libs; then
		build static
	fi
	if use static-pic; then
		build static-pic
	fi

	gprbuild -p -m -v -j$(get_makeopts_jobs) -aP . -XGPR2_BUILD=release \
		-XLIBRARY_TYPE=relocatable -XXMLADA_BUILD=relocatable tools/gpr2_tools.gpr \
		-largs ${LDFLAGS} -cargs ${ADAFLAGS} || die
}

src_test() {
	cd testsuite
	rm -rf tests/extension/all-with-imports || die
	rm -rf tests/extension/extending-add-body || die
	rm -rf tests/extension/extending-interface-in-extended-project || die
	./testsuite.py |& tee test.log
	grep -w FAIL test.log && die
}

src_install() {
	build () {
		gprinstall -XLIBRARY_TYPE=$1 -f -p -v -XGPR2_BUILD=release \
			--prefix="${D}/usr" -XXMLADA_BUILD=$1 \
			--build-name=$1 --build-var=LIBRARY_TYPE \
			--build-var=GPR2_LIBRARY_TYPE gpr2.gpr || die
	}
	build relocatable
	if use static-libs; then
		build static
	fi
	if use static-pic; then
		build static-pic
	fi

	gprinstall -p -f -v --prefix="${D}/usr" -XGPR2_BUILD=release \
		-XLIBRARY_TYPE=relocatable -XXMLADA_BUILD=relocatable \
		--build-name=relocatable --mode=usage tools/gpr2_tools.gpr || die

	sed -i \
		-e 's|"gpr2.build.view_tables.update_sources_list", ||g' \
		-e 's|"gpr2.tree_internal.load_autoconf", ||g' \
		"${D}"/usr/share/gpr/gpr2.gpr \
		|| die

	einstalldocs

	rm "${D}"/usr/bin/gprconfig || die
	rm "${D}"/usr/bin/gprbuild || die
	rm "${D}"/usr/bin/gprclean || die
	rm "${D}"/usr/bin/gprinstall || die

	rm -r "${D}"/usr/share/gpr/manifests || die
}