summaryrefslogtreecommitdiff
path: root/media-libs/tg_owt/tg_owt-0_pre20210422.ebuild
blob: 3e8e01ec1d262d4dddcfc303d02cf936ec43b542 (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
# Copyright 2020-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit cmake

TG_OWT_COMMIT="18cb4cd9bb4c2f5f5f5e760ec808f74c302bc1bf"
LIBYUV_COMMIT="ad890067f661dc747a975bc55ba3767fe30d4452"

DESCRIPTION="WebRTC build for Telegram"
HOMEPAGE="https://github.com/desktop-app/tg_owt"
SRC_URI="https://github.com/desktop-app/tg_owt/archive/${TG_OWT_COMMIT}.tar.gz -> ${P}.tar.gz
	https://archive.org/download/libyuv-${LIBYUV_COMMIT}.tar/libyuv-${LIBYUV_COMMIT}.tar.gz"
# Fetch libyuv archive from: https://chromium.googlesource.com/libyuv/libyuv/+archive/${LIBYUV_COMMIT}.tar.gz

LICENSE="BSD"
SLOT="0"
KEYWORDS="amd64 ~ppc64"

# Bundled libs:
# - libyuv (no stable versioning, www-client/chromium and media-libs/libvpx bundle it)
# - libsrtp (project uses private APIs)
# - pffft (no stable versioning, patched)
# media-libs/libjpeg-turbo is required for libyuv
DEPEND="
	dev-cpp/abseil-cpp:=[cxx17(+)]
	dev-libs/libevent:=
	dev-libs/openssl:=
	dev-libs/protobuf:=
	media-libs/libjpeg-turbo:=
	>=media-libs/libvpx-1.10.0:=
	media-libs/openh264:=
	media-libs/opus
	media-video/ffmpeg:=
	net-libs/usrsctp
"
RDEPEND="${DEPEND}"
BDEPEND="virtual/pkgconfig"

S="${WORKDIR}/${PN}-${TG_OWT_COMMIT}"

src_unpack() {
	unpack "${P}.tar.gz"
	cd "${S}/src/third_party/libyuv" || die
	unpack "libyuv-${LIBYUV_COMMIT}.tar.gz"
}

src_prepare() {
	# https://github.com/desktop-app/tg_owt/pull/55
	eapply "${FILESDIR}/Allow-using-packaged-third_party.patch"

	# We aren't installing any third_party headers
	sed -i '/third_party\/libyuv/d' cmake/libyuv.cmake || die

	# libvpx source files aren't included in the repository
	sed -i '/include(cmake\/libvpx.cmake)/d' CMakeLists.txt || die

	# Remove screen_drawer files that cause linking errors
	# (not used right now I don't think, maybe in a future version)
	# https://github.com/desktop-app/tg_owt/issues/58
	sed -i -e '/desktop_capture\/screen_drawer\.cc/d' \
		-e '/desktop_capture\/screen_drawer_lock_posix\.cc/d' CMakeLists.txt || die

	# HACK
	# build/headers don't have ppc64 condition and force SSE2.
	# sed it out and force C version on ppc64
	# without this linking tdesktop will fail with undef reference to `webrtc::VectorDifference_SSE2_W32
	if use ppc64; then
		sed -i 's/VectorDifference_SSE2_W.*/VectorDifference_C;/g' src/modules/desktop_capture/differ_block.cc || die
	fi

	cmake_src_prepare
}

src_configure() {
	# Defined by -DCMAKE_BUILD_TYPE=Release, avoids crashes
	# see https://bugs.gentoo.org/754012
	append-cppflags '-DNDEBUG'
	cmake_src_configure
}

src_install() {
	cmake_src_install

	# Save about 15MB of useless headers
	rm -r "${ED}/usr/include/tg_owt/third_party" || die
}