summaryrefslogtreecommitdiff
blob: e6de260d88b549c9b6ccc994ab9dba03a543a464 (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

PYTHON_COMPAT=( python3_{8..10} )
inherit python-any-r1 meson cmake

SDP="systemd-stable-251.4"
MUSL_PATCHSET="251.2"

DESCRIPTION="High-level C++ D-Bus library"
HOMEPAGE="https://github.com/Kistler-Group/sdbus-cpp"
SRC_URI="https://github.com/Kistler-Group/sdbus-cpp/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	!systemd? (
		https://github.com/systemd/${SDP%-*}/archive/v${SDP##*-}/${SDP}.tar.gz
		elibc_musl? (
			https://dev.gentoo.org/~floppym/distfiles/systemd-musl-patches-${MUSL_PATCHSET}.tar.gz
			https://dev.gentoo.org/~gyakovlev/distfiles/systemd-musl-patches-${MUSL_PATCHSET}.tar.gz
			https://dev.gentoo.org/~soap/distfiles/systemd-musl-patches-${MUSL_PATCHSET}.tar.gz
		)
	)"
LICENSE="LGPL-2.1+ Nokia-Qt-LGPL-Exception-1.1" # Nothing to do with Qt but exception text is exactly the same.
SLOT="0/1"
KEYWORDS="~amd64"
IUSE="doc systemd test tools"
RESTRICT="!test? ( test )"

RDEPEND="
	!systemd? ( sys-libs/libcap )
	systemd? ( >=sys-apps/systemd-236:= )
	tools? ( dev-libs/expat )
"

# util-linux is needed for libmount when building libsystemd, but sdbus-c++
# doesn't need it when subsequently linking libsystemd statically.

DEPEND="
	${RDEPEND}
	!systemd? ( sys-apps/util-linux )
	test? ( >=dev-cpp/gtest-1.10.0 )
"

BDEPEND="
	virtual/pkgconfig
	doc? ( app-doc/doxygen[dot] )
	!systemd? (
		${PYTHON_DEPS}
		$(python_gen_any_dep 'dev-python/jinja[${PYTHON_USEDEP}]')
	)
"

python_check_deps() {
	has_version -b "dev-python/jinja[${PYTHON_USEDEP}]"
}

S="${WORKDIR}/sdbus-cpp-${PV}"
SDS="${WORKDIR}/${SDP}"
SDB="${WORKDIR}/systemd-build"

PATCHES=(
	"${FILESDIR}"/${PN}-pc-reqs.patch
)

pkg_setup() {
	use systemd || python-any-r1_pkg_setup
}

src_prepare() {
	if ! use systemd; then
		pushd "${SDS}" || die
		use elibc_musl && eapply "${WORKDIR}"/musl-patches
		eapply "${FILESDIR}"/${PN}-static-libsystemd.patch
		popd || die
	fi

	cmake_src_prepare
}

src_configure() {
	if ! use systemd; then
		EMESON_SOURCE=${SDS} \
		BUILD_DIR=${SDB} \
		meson_src_configure \
			--prefix "${WORKDIR}" \
			--includedir "${SDP}/src" \
			-Drootlibdir="${SDB}" \
			-Dselinux=false \
			-Dstatic-libsystemd=pic \
			-Dgshadow=false \
			-Dsmack=false \
			-Dutmp=false

		# systemd doesn't generate the needed pkg-config file during configure.
		BUILD_DIR=${SDB} \
		meson_src_compile libsystemd.pc

		# Need this present otherwise CMake generates the wrong linker args.
		touch "${SDB}"/libsystemd.a || die
	fi

	local mycmakeargs=(
		-DBUILD_CODE_GEN=$(usex tools)
		-DBUILD_DOC=yes
		-DBUILD_DOXYGEN_DOC=$(usex doc)
		-DBUILD_LIBSYSTEMD=no
		-DBUILD_TESTS=$(usex test)
	)

	PKG_CONFIG_PATH=${SDB}/src/libsystemd:${PKG_CONFIG_PATH} \
	cmake_src_configure
}

src_compile() {
	if ! use systemd; then
		BUILD_DIR=${SDB} \
		meson_src_compile version.h systemd:static_library
	fi

	cmake_src_compile all $(usev doc)
}

src_test() {
	if ! cmp -s {"${S}"/tests/integrationtests/files,/etc/dbus-1/system.d}/org.sdbuscpp.integrationtests.conf; then
		ewarn "Not running the tests as a D-Bus configuration file has not been"
		ewarn "installed yet or has changed since. The tests can be run after"
		ewarn "the package has been merged."
		return
	elif [[ ! -S /run/dbus/system_bus_socket ]]; then
		ewarn "Not running the tests as the system-wide D-Bus daemon is unavailable."
		return
	fi

	cmake_src_test
}

src_install() {
	cmake_src_install
	rm -v "${ED}"/usr/share/doc/${PF}/COPYING || die

	if use test; then
		# Delete installed test binaries.
		rm -rv "${ED}"/opt || die
	fi
}