From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 2ED5D15802F for ; Thu, 9 Mar 2023 14:14:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B13F5E08FA; Thu, 9 Mar 2023 14:14:08 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 7FF81E08FA for ; Thu, 9 Mar 2023 14:14:08 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 185483404AD for ; Thu, 9 Mar 2023 14:14:07 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C8B758D4 for ; Thu, 9 Mar 2023 14:14:04 +0000 (UTC) From: "Eric Joldasov" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Eric Joldasov" Message-ID: <1678371215.e8354425d475c98040823f67ac2faa3800d81870.bratishkaerik@gentoo> Subject: [gentoo-commits] repo/proj/guru:dev commit in: dev-zig/zls/ X-VCS-Repository: repo/proj/guru X-VCS-Files: dev-zig/zls/zls-9999.ebuild X-VCS-Directories: dev-zig/zls/ X-VCS-Committer: bratishkaerik X-VCS-Committer-Name: Eric Joldasov X-VCS-Revision: e8354425d475c98040823f67ac2faa3800d81870 X-VCS-Branch: dev Date: Thu, 9 Mar 2023 14:14:04 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: e7ada210-b731-4b01-83d5-a6ab4302933b X-Archives-Hash: a2f2d4cc199dcc2d5dd884b20112d8f5 commit: e8354425d475c98040823f67ac2faa3800d81870 Author: Eric Joldasov getgoogleoff me> AuthorDate: Thu Mar 9 14:13:14 2023 +0000 Commit: Eric Joldasov getgoogleoff me> CommitDate: Thu Mar 9 14:13:35 2023 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=e8354425 dev-zig/zls: adjust ebuild (9999) for slotted Zig Signed-off-by: Eric Joldasov getgoogleoff.me> dev-zig/zls/zls-9999.ebuild | 99 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 91 insertions(+), 8 deletions(-) diff --git a/dev-zig/zls/zls-9999.ebuild b/dev-zig/zls/zls-9999.ebuild index 267e3221a..f38e48ae0 100644 --- a/dev-zig/zls/zls-9999.ebuild +++ b/dev-zig/zls/zls-9999.ebuild @@ -1,42 +1,125 @@ -# Copyright 2022 Gentoo Authors +# Copyright 2022-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 -inherit git-r3 +inherit edo git-r3 EGIT_REPO_URI="https://github.com/zigtools/zls" -HOMEPAGE="https://github.com/zigtools/zls" DESCRIPTION="The officially unofficial Ziglang language server" +HOMEPAGE="https://github.com/zigtools/zls" LICENSE="MIT" SLOT="0" -DEPEND="~dev-lang/zig-9999" +EZIG_MIN="9999" +EZIG_MAX_EXCLUSIVE="99991" + +DEPEND="dev-lang/zig:${EZIG_MIN}" RDEPEND="${DEPEND}" # see https://github.com/ziglang/zig/issues/3382 # For now, Zig Build System doesn't support CFLAGS/LDFLAGS/etc. QA_FLAGS_IGNORED="usr/bin/zls" +# : copied from sys-fs/ncdu : +# 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 candidates candidate selected selected_ver + + candidates=$(compgen -c zig-) + + for candidate in ${candidates}; do + if [[ ! ${candidate} =~ zig(-bin)?-([.0-9]+) ]]; then + continue + fi + + local ver + if (( ${#BASH_REMATCH[@]} == 3 )); then + ver="${BASH_REMATCH[2]}" + else + ver="${BASH_REMATCH[1]}" + fi + + 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 PATH" + fi + + export EZIG="${selected}" + export EZIG_VER="${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_src_unpack cd "${S}" || die # "zig build" doesn't have "fetch" subcommand yet - zig build --help || die "Fetching Zig modules failed" + ezig build --help || die "Fetching Zig modules failed" } src_compile() { - zig build -Doptimize=ReleaseSafe -Ddata_version=master --verbose || die + ezig build -Doptimize=ReleaseSafe -Ddata_version=master --verbose || die } src_test() { - zig build test -Doptimize=ReleaseSafe -Ddata_version=master --verbose || die + ezig build test -Doptimize=ReleaseSafe -Ddata_version=master --verbose || die } src_install() { - DESTDIR="${ED}" zig build install --prefix /usr -Doptimize=ReleaseSafe -Ddata_version=master --verbose || die + DESTDIR="${ED}" ezig build install --prefix /usr -Doptimize=ReleaseSafe -Ddata_version=master --verbose || die dodoc README.md }