1 |
On Thu, 2021-12-09 at 10:10 +0700, Vadim Misbakh-Soloviov wrote: |
2 |
> Some grammars packages (like, for example, tree-sitter-agda) uses |
3 |
> different versioning scheme from vast majority of grammars in |
4 |
> tree-sitter github organization. |
5 |
> |
6 |
> Also, third-party grammars doesn't follow tree-sitter versioning. |
7 |
> |
8 |
> Also, some grammars (like tree-sitter-haskell, for example) only had |
9 |
> old release tagged, but having compatible and useful grammars in |
10 |
> current HEAD. |
11 |
> |
12 |
> Also, some grammars like tree-sitter-verilog, even have only v0.0 tag. |
13 |
> |
14 |
> So, instead of assuming grammar ABI version based on ${PV} (ver_test) |
15 |
> we decided to take ABI version drectly from source code. |
16 |
> --- |
17 |
> eclass/tree-sitter-grammar.eclass | 20 ++++++++++---------- |
18 |
> 1 file changed, 10 insertions(+), 10 deletions(-) |
19 |
> |
20 |
> diff --git a/eclass/tree-sitter-grammar.eclass b/eclass/tree-sitter-grammar.eclass |
21 |
> index 46573027f96..939a36ccb8c 100644 |
22 |
> --- a/eclass/tree-sitter-grammar.eclass |
23 |
> +++ b/eclass/tree-sitter-grammar.eclass |
24 |
> @@ -40,15 +40,13 @@ EXPORT_FUNCTIONS src_compile src_install |
25 |
> # @INTERNAL |
26 |
> # @DESCRIPTION: |
27 |
> # This internal function determines the ABI version of a grammar library based |
28 |
> -# on the package version. |
29 |
> +# on a constant in the source file. |
30 |
> _get_tsg_abi_ver() { |
31 |
> - if ver_test -gt 0.21; then |
32 |
> - die "Grammar too new; unknown ABI version" |
33 |
> - elif ver_test -ge 0.19.0; then |
34 |
> - echo 13 |
35 |
> - else |
36 |
> - die "Grammar too old; unknown ABI version" |
37 |
> - fi |
38 |
> + # This sed script finds ABI definition string in parser source file, |
39 |
> + # substitutes all the string until the ABI number, and prints remains |
40 |
> + # (the ABI number itself) |
41 |
> + sed -n '/#define LANGUAGE_VERSION/s/.* //p' "${S}"/parser.c || |
42 |
|
43 |
I think you can do: |
44 |
|
45 |
sed -n 's/#define LANGUAGE_VERSION //p' ... |
46 |
|
47 |
'p' applies only on successful replacement. |
48 |
|
49 |
> + die "Unable to extract ABI version for this grammar" |
50 |
> } |
51 |
> |
52 |
> # @FUNCTION: tree-sitter-grammar_src_compile |
53 |
> @@ -89,8 +87,10 @@ tree-sitter-grammar_src_compile() { |
54 |
> tree-sitter-grammar_src_install() { |
55 |
> debug-print-function ${FUNCNAME} "${@}" |
56 |
> |
57 |
> - dolib.so "${WORKDIR}"/lib${PN}$(get_libname $(_get_tsg_abi_ver)) |
58 |
> - dosym lib${PN}$(get_libname $(_get_tsg_abi_ver)) \ |
59 |
> + local soname=lib${PN}$(get_libname $(_get_tsg_abi_ver)) |
60 |
> + |
61 |
> + dolib.so "${WORKDIR}/${soname}" |
62 |
> + dosym "${soname}" \ |
63 |
> /usr/$(get_libdir)/lib${PN}$(get_libname) |
64 |
> } |
65 |
> fi |
66 |
|
67 |
-- |
68 |
Best regards, |
69 |
Michał Górny |