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
Randy Taylor 8f49137c9b
Add dockerfile-ts-mode (Bug#59894)
* admin/notes/tree-sitter/build-module/batch.sh: Add dockerfile support.
* admin/notes/tree-sitter/build-module/build.sh: Support different
namespaces and add dockerfile support.
* etc/NEWS: Mention it.
* lisp/progmodes/dockerfile-ts-mode.el: New major mode with
tree-sitter support.
* lisp/progmodes/eglot.el (eglot-server-programs): Add it.
2022-12-09 16:46:01 -08:00

70 lines
1.4 KiB
Bash
Executable file

#!/bin/bash
lang=$1
topdir="$PWD"
if [ $(uname) == "Darwin" ]
then
soext="dylib"
else
soext="so"
fi
echo "Building ${lang}"
### Retrieve sources
namespace="tree-sitter"
repo="tree-sitter-${lang}"
sourcedir="tree-sitter-${lang}/src"
grammardir="tree-sitter-${lang}"
case "${lang}" in
"dockerfile")
namespace="camdencheek"
;;
"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"
;;
esac
git clone "https://github.com/${namespace}/${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 -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}"