summaryrefslogtreecommitdiff
path: root/app-shells/fish/fish-4.6.0.ebuild
blob: ff460868af8356d993669c5633d554ad21480ae4 (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
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CRATES=""

if [[ ${PV} != 9999 ]]; then
	declare -A GIT_CRATES=(
		[pcre2-sys]='https://github.com/fish-shell/rust-pcre2;85b7afba1a9d9bd445779800e5bcafeb732e4421;rust-pcre2-%commit%/pcre2-sys'
		[pcre2]='https://github.com/fish-shell/rust-pcre2;85b7afba1a9d9bd445779800e5bcafeb732e4421;rust-pcre2-%commit%'
	)
fi

RUST_MIN_VER="1.85.0"

PYTHON_COMPAT=( python3_{11..14} )

inherit cargo cmake python-any-r1 readme.gentoo-r1 xdg

DESCRIPTION="Friendly Interactive SHell"
HOMEPAGE="https://fishshell.com/"

MY_PV="${PV/_beta/b}"
MY_P="${PN}-${MY_PV}"

if [[ ${PV} == 9999 ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/fish-shell/fish-shell.git"
else
	SRC_URI="
		https://github.com/fish-shell/fish-shell/releases/download/${MY_PV}/${MY_P}.tar.xz
		https://github.com/gentoo-crate-dist/fish-shell/releases/download/${MY_PV}/fish-shell-${MY_PV}-crates.tar.xz
		${CARGO_CRATE_URIS}
	"
	KEYWORDS="~amd64 ~arm64 ~loong ppc64 ~riscv ~x64-macos"
fi

S="${WORKDIR}/${MY_P}"

LICENSE="GPL-2 BSD BSD-2 CC0-1.0 GPL-2+ ISC LGPL-2+ MIT PSF-2 ZLIB"
# Dependent crate licenses
LICENSE+=" Apache-2.0 MIT MPL-2.0 Unicode-3.0 ZLIB"
SLOT="0"
IUSE="+doc nls test"

RESTRICT="!test? ( test )"

BDEPEND="
	virtual/pkgconfig
	${PYTHON_USEDEP}
	doc? ( $(python_gen_any_dep 'dev-python/sphinx[${PYTHON_USEDEP}]') )
	nls? ( sys-devel/gettext )
	test? (
		app-misc/tmux
		dev-vcs/git
		sys-apps/less
		$(python_gen_any_dep 'dev-python/pexpect[${PYTHON_USEDEP}]')
	)
"
DEPEND="dev-libs/libpcre2[pcre32]"
RDEPEND="${DEPEND}"

QA_FLAGS_IGNORED="usr/bin/.*"

python_check_deps() {
	if use doc; then
		python_has_version "dev-python/sphinx[${PYTHON_USEDEP}]" || return 1
	fi
	if use test; then
		python_has_version "dev-python/pexpect[${PYTHON_USEDEP}]" || return 1
	fi
}

pkg_setup() {
	if use doc || use test; then
		python-any-r1_pkg_setup
	fi
	rust_pkg_setup

	export PKG_CONFIG_ALLOW_CROSS=1
}

src_prepare() {
	# Bug: https://bugs.gentoo.org/952080
	sed -e '/^lto = /d' -i Cargo.toml || die "Failed to remove LTO from cargo package"

	cmake_src_prepare
}

src_unpack() {
	if [[ ${PV} == 9999 ]]; then
		git-r3_src_unpack
		cargo_live_src_unpack
	else
		cargo_src_unpack
	fi
}

src_configure() {
	local mycmakeargs=(
		-DCMAKE_INSTALL_SYSCONFDIR="${EPREFIX}/etc"
		-DCMAKE_INSTALL_DATADIR="${EPREFIX}/usr/share"
		-DWITH_DOCS="$(usex doc ON OFF)"
		-DWITH_MESSAGE_LOCALIZATION="$(usex nls ON OFF)"
		-DRust_CARGO="${CARGO}"
		-DRust_COMPILER="${RUSTC}"
	)
	local -x CMAKE_BUILD_TYPE="$(usex debug Debug Release)"
	cargo_env cmake_src_configure
}

src_compile() {
	local -x CARGO_TERM_COLOR=always
	cargo_env cmake_src_compile
}

src_test() {
	# Very fragile tests, don't seem to work in sandboxed environment.
	# No die to allow repeating tests.
	rm -v \
		tests/checks/tmux-pager.fish \
		tests/checks/tmux-wrapping.fish \
		tests/checks/tmux-commandline.fish \
		tests/checks/tmux-prompt.fish \
		tests/pexpects/terminal.py \
		|| :

	cargo_env cmake_build fish_run_tests
}

src_install() {
	cargo_env cmake_src_install
	keepdir /usr/share/fish/vendor_{completions,conf,functions}.d
	readme.gentoo_create_doc
}

pkg_postinst() {
	readme.gentoo_print_elog
	xdg_pkg_postinst
}