1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00
emacs/admin/notes/tree-sitter/build-module/build.sh
Gabriel Santos aade1b707c Add go-work-ts-mode for Go workspace files
* lisp/progmodes/eglot.el (eglot-server-programs): Add go-work-ts-mode.
* lisp/progmodes/go-ts-mode.el
(Commentary): Add the repositories for the grammars.
(go-work-ts-mode--indent-rules, go-work-ts-mode--keywords)
(go-work-ts-mode--font-lock-settings): New variables.
(go-work-ts-mode--directive-matcher, go-work-ts-mode): New functions.
(go-mod-ts-mode--directive-matcher): Rename from
go-mod-ts-mode--in-directive-p.  Be more specific on the directive
location (modules).  Replace mention of nil with function.  Use member
instead of pcase to check node types.

* admin/notes/tree-sitter/build-module/batch.sh
* admin/notes/tree-sitter/build-module/build.sh: Add go-work support.

* test/lisp/progmodes/go-ts-mode-resources/font-lock-package.go:
* test/lisp/progmodes/go-ts-mode-resources/indent-mod.erts:
* test/lisp/progmodes/go-ts-mode-resources/indent-work.erts:
New files for testing indentation and font-locking for Go
module and workspace files.
* test/lisp/progmodes/go-ts-mode-tests.el: Add tests for Go module and
workspace files.  (Bug#74461)

* etc/NEWS: Announce go-work-ts-mode.
2025-02-12 06:46:58 +01:00

100 lines
1.9 KiB
Bash
Executable file

#!/bin/bash
lang=$1
topdir="$PWD"
case $(uname) in
"Darwin")
soext="dylib"
;;
*"MINGW"*)
soext="dll"
;;
*)
soext="so"
;;
esac
echo "Building ${lang}"
### Retrieve sources
org="tree-sitter"
repo="tree-sitter-${lang}"
sourcedir="tree-sitter-${lang}/src"
grammardir="tree-sitter-${lang}"
case "${lang}" in
"dockerfile")
org="camdencheek"
;;
"cmake")
org="uyha"
;;
"elixir")
org="elixir-lang"
;;
"go-mod")
# The parser is called "gomod".
lang="gomod"
org="camdencheek"
;;
"go-work")
# The parser is called "gowork".
lang="gowork"
org="omertuc"
;;
"heex")
org="phoenixframework"
;;
"lua")
org="tree-sitter-grammars"
;;
"typescript")
sourcedir="tree-sitter-typescript/typescript/src"
grammardir="tree-sitter-typescript/typescript"
;;
"tsx")
repo="tree-sitter-typescript"
sourcedir="tree-sitter-typescript/tsx/src"
grammardir="tree-sitter-typescript/tsx"
;;
"yaml")
org="ikatyang"
;;
esac
git clone "https://github.com/${org}/${repo}.git" \
--depth 1 --quiet
cp "${grammardir}"/grammar.js "${sourcedir}"
# We have to go into the source directory to compile, because some
# C files refer to files like "../../common/scanner.h".
cd "${sourcedir}"
### Build
cc -fPIC -c -I. parser.c
# Compile scanner.c.
if test -f scanner.c
then
cc -fPIC -c -I. scanner.c
fi
# Compile scanner.cc.
if test -f scanner.cc
then
c++ -fPIC -I. -c scanner.cc
fi
# Link.
if test -f scanner.cc
then
c++ -fPIC -shared *.o -o "libtree-sitter-${lang}.${soext}"
else
cc -fPIC -shared *.o -o "libtree-sitter-${lang}.${soext}"
fi
### Copy out
mkdir -p "${topdir}/dist"
cp "libtree-sitter-${lang}.${soext}" "${topdir}/dist"
cd "${topdir}"
rm -rf "${repo}"