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 86BC5158086 for ; Thu, 9 Dec 2021 07:26:58 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1E14B2BC028; Thu, 9 Dec 2021 07:26:54 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 pigeon.gentoo.org (Postfix) with ESMTPS id 0346A2BC007 for ; Thu, 9 Dec 2021 07:26:53 +0000 (UTC) Message-ID: Subject: Re: [gentoo-dev] [PATCH] eclass/tree-sitter-grammar: fix ABI autodetecton From: =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: sarnex@gentoo.org, matt@offtopica.uk, Vadim Misbakh-Soloviov Date: Thu, 09 Dec 2021 08:26:48 +0100 In-Reply-To: <20211209031042.885672-1-mva@gentoo.org> References: <20211209031042.885672-1-mva@gentoo.org> Organization: Gentoo Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.1 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: 5400e1b5-1d26-4d68-8f46-143646ac614a X-Archives-Hash: 646d6f0616920a38e129e233b0b6e422 On Thu, 2021-12-09 at 10:10 +0700, Vadim Misbakh-Soloviov wrote: > Some grammars packages (like, for example, tree-sitter-agda) uses > different versioning scheme from vast majority of grammars in > tree-sitter github organization. > > Also, third-party grammars doesn't follow tree-sitter versioning. > > Also, some grammars (like tree-sitter-haskell, for example) only had > old release tagged, but having compatible and useful grammars in > current HEAD. > > Also, some grammars like tree-sitter-verilog, even have only v0.0 tag. > > So, instead of assuming grammar ABI version based on ${PV} (ver_test) > we decided to take ABI version drectly from source code. > --- > eclass/tree-sitter-grammar.eclass | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) > > diff --git a/eclass/tree-sitter-grammar.eclass b/eclass/tree-sitter-grammar.eclass > index 46573027f96..939a36ccb8c 100644 > --- a/eclass/tree-sitter-grammar.eclass > +++ b/eclass/tree-sitter-grammar.eclass > @@ -40,15 +40,13 @@ EXPORT_FUNCTIONS src_compile src_install > # @INTERNAL > # @DESCRIPTION: > # This internal function determines the ABI version of a grammar library based > -# on the package version. > +# on a constant in the source file. > _get_tsg_abi_ver() { > - if ver_test -gt 0.21; then > - die "Grammar too new; unknown ABI version" > - elif ver_test -ge 0.19.0; then > - echo 13 > - else > - die "Grammar too old; unknown ABI version" > - fi > + # This sed script finds ABI definition string in parser source file, > + # substitutes all the string until the ABI number, and prints remains > + # (the ABI number itself) > + sed -n '/#define LANGUAGE_VERSION/s/.* //p' "${S}"/parser.c || I think you can do: sed -n 's/#define LANGUAGE_VERSION //p' ... 'p' applies only on successful replacement. > + die "Unable to extract ABI version for this grammar" > } > > # @FUNCTION: tree-sitter-grammar_src_compile > @@ -89,8 +87,10 @@ tree-sitter-grammar_src_compile() { > tree-sitter-grammar_src_install() { > debug-print-function ${FUNCNAME} "${@}" > > - dolib.so "${WORKDIR}"/lib${PN}$(get_libname $(_get_tsg_abi_ver)) > - dosym lib${PN}$(get_libname $(_get_tsg_abi_ver)) \ > + local soname=lib${PN}$(get_libname $(_get_tsg_abi_ver)) > + > + dolib.so "${WORKDIR}/${soname}" > + dosym "${soname}" \ > /usr/$(get_libdir)/lib${PN}$(get_libname) > } > fi -- Best regards, Michał Górny