# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 inherit edo git-r3 DESCRIPTION="Ghostty is a fast, feature-rich, and cross-platform terminal emulator that uses platform-native UI and GPU acceleration." HOMEPAGE="ghostty.org" EGIT_REPO_URI="https://github.com/ghostty-org/ghostty.git" LICENSE="MIT" SLOT="0" EZIG_MIN="0.13" EZIG_MAX_EXCLUSIVE="0.14" # RDEPEND="${DEPEND}" BDEPEND=" gui-libs/gtk[X] " QA_FLAGS_IGNORED="usr/bin/ghostty" # S="${WORKDIR}/${PN}" # Many thanks to Florian Schmaus (Flowdalic)! # Adapted from https://github.com/gentoo/gentoo/pull/28986 # Set the EZIG environment variable. zig-set_EZIG() { [[ -n ${EZIG} ]] && return if [[ -n ${EZIG_OVERWRITE} ]]; then export EZIG="${EZIG_OVERWRITE}" return fi local candidate selected selected_ver ver for candidate in "${BROOT}"/usr/bin/zig-*; do if [[ ! -L ${candidate} || ${candidate} != */zig?(-bin)-+([0-9.]) ]]; then continue fi ver=${candidate##*-} if [[ -n ${EZIG_EXACT_VER} ]]; then ver_test "${ver}" -ne "${EZIG_EXACT_VER}" && continue selected="${candidate}" selected_ver="${ver}" break fi if [[ -n ${EZIG_MIN} ]] \ && ver_test "${ver}" -lt "${EZIG_MIN}"; then # Candidate does not satisfy EZIG_MIN condition. continue fi if [[ -n ${EZIG_MAX_EXCLUSIVE} ]] \ && ver_test "${ver}" -ge "${EZIG_MAX_EXCLUSIVE}"; then # Candidate does not satisfy EZIG_MAX_EXCLUSIVE condition. continue fi if [[ -n ${selected_ver} ]] \ && ver_test "${selected_ver}" -gt "${ver}"; then # Candidate is older than the currently selected candidate. continue fi selected="${candidate}" selected_ver="${ver}" done if [[ -z ${selected} ]]; then die "Could not find (suitable) zig installation in ${BROOT}/usr/bin" fi export EZIG="${selected}" export EZIG_VER="${selected_ver}" } # Invoke zig with the optionally provided arguments. ezig() { zig-set_EZIG # Unfortunately, we cannot add more args here, since syntax is different # for every subcommands. Yes, even target/cpu :( f.i. : # -target/-mcpu for zig build-exe vs -Dtarget/-Dcpu for zig build- # -OReleaseSafe for zig build-exe vs -DReleaseSafe for zig build # (or even none, if hardcoded by upstream so choice is -Drelease=true/false) # Ofc we can patch this, but still... edo "${EZIG}" "${@}" } src_unpack() { git-r3_fetch git-r3_checkout cd ${S} || return zig build --fetch 2>/dev/null zig build --fetch 2>/dev/null zig build --fetch 2>/dev/null } src_configure() { zig-set_EZIG export ZIG=${EZIG} } src_compile() { ezig build -Doptimize=ReleaseFast } src_test() { ezig build test -Doptimize=ReleaseFast } src_install() { ezig build -p "${ED}"/usr -Doptimize=ReleaseFast }