Subject: bug#61849: 29.0.60; Unable to use treesit-install-language-grammar because repo doesn't have parser.c

From: Eli Zaretskii <[email-masked]>
Date: Mon, 27 Feb 2023 22:00:48 +0200

> From: Misha Zharov <[email-masked]>
> Date: Sun, 26 Feb 2023 23:34:57 -0800
> 
> Add (sql "https://github.com/m-novikov/tree-sitter-sql") to
> treesit-language-source-alist. Then use
> treesit-install-language-grammar. The following error occurs:
> 
>     Error encountered when installing language grammar: (treesit-error
>     Command: cc -fPIC -c -I. parser.c Error output: cc1: fatal error:
>     parser.c: No such file or directory compilation terminated.)
> 
> This error occurs because we need to run a configuration step on the
> repo to generate parser.c. I believe this is because we need to either
> run `npm run generate` or `tree-sitter generate` to generate the
> `src/parser.c` file. It would be nice if we could implement a patch to:
> 
>   1. Allow users to specify a configuration step to configure the repo
>      before searching for parser.c (like passing a lambda into
>      `treesit-language-source-alist`)
>   2. Allow users to specify a git hash that should be checked out before
>      the configuration step is run. I know currently different branches
>      are supported, but not all projects have release branches.
>   3. Alternatively this function can be split into 2 function, the first one
>       would clone and configure the repository, and well as find the
>       required files. The second function would simply compile the required
>       files into the shared libraries, and move them to the appropriate location

I'm not sure we should incorporate in Emacs so much of this
specialized stuff.  treesit-install-language-grammar is meant for
doing the simple steps of compiling C/C++ sources in a boilerplate
repository into a shared library.  Anything significantly more complex
should IMO be left to manual procedures by people who know what they
are doing, especially if that requires to have specialized tools
installed.

(Btw, why not use https://github.com/DerekStride/tree-sitter-sql
instead?)