changelog shortlog graph tags branches files raw help

Mercurial > infra / changeset: edit tree-sitter-langs

changeset 298: 4b7478f58f15
parent 297: 06131ebff5cd
child 299: ad9493172356
author: Richard Westhaver <ellis@rwest.io>
date: Wed, 19 Jun 2024 19:45:37 -0400
files: bootstrap.sh scripts/tree-sitter-install-langs.sh scripts/tree-sitter-langs.sh skelfile
description: edit tree-sitter-langs
     1.1--- a/bootstrap.sh	Wed Jun 19 19:27:24 2024 -0400
     1.2+++ b/bootstrap.sh	Wed Jun 19 19:45:37 2024 -0400
     1.3@@ -62,11 +62,11 @@
     1.4   # cp -rf rocksdb/*.so lib/
     1.5 
     1.6   if [ ! -f "bin/skel" ]; then
     1.7-  ensure download "$_core_url" "${_core_pack}" "$_arch"
     1.8-  unzstd "${_core_pack}"
     1.9-  tar -xf "core.tar"
    1.10-  cp -rf core/bin/* bin/
    1.11-  cp -rf core/share/* share/
    1.12+  ensure download "$_core_url" "tmp/${_core_pack}" "$_arch"
    1.13+  unzstd "tmp/${_core_pack}"
    1.14+  tar -xf "tmp/core.tar"
    1.15+  cp -rf tmp/core/bin/* bin/
    1.16+  cp -rf tmp/core/share/* share/
    1.17   fi
    1.18 
    1.19   if [ ! -f "share/lisp/$_infra_core" ]; then
     2.1--- a/scripts/tree-sitter-install-langs.sh	Wed Jun 19 19:27:24 2024 -0400
     2.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3@@ -1,56 +0,0 @@
     2.4-#!/usr/bin/env bash
     2.5-
     2.6-# based on https://github.com/GrammaTech/sel/blob/master/tools/tree-sitter-install.sh
     2.7-set -eux
     2.8-
     2.9-declare -ar default_langs=(
    2.10-  commonlisp bash c cpp css go html java javascript jsdoc json python regex rust
    2.11-  typescript/tsx typescript/typescript yaml
    2.12-) 
    2.13-# see https://tree-sitter.github.io/tree-sitter/#parsers for a
    2.14-# complete list of parsers available
    2.15-TARGETDIR="${1:-.stash/src/tree-sitter-langs}"
    2.16-PREFIX=${PREFIX:-/usr/local}
    2.17-CC=${CC:-clang}
    2.18-CXX=${CXX:-clang++}
    2.19-if [ $(uname) == "Darwin" ];then
    2.20-   EXT=dylib;
    2.21-else
    2.22-   EXT=so
    2.23-fi
    2.24-
    2.25-declare -A repos
    2.26-repos[commonlisp]=https://github.com/theHamsta/tree-sitter-commonlisp.git
    2.27-repos[yaml]=https://github.com/ikatyang/tree-sitter-yaml.git
    2.28-repos[cpp]=https://github.com/ruricolist/tree-sitter-cpp.git
    2.29-
    2.30-declare -a langs
    2.31-if [ -z "${2:-}" ]; then
    2.32-  langs=(${default_langs[@]})
    2.33-else
    2.34-  langs=($@)
    2.35-fi
    2.36-
    2.37-mkdir -pv $TARGETDIR
    2.38-pushd $TARGETDIR
    2.39-for lang in "${langs[@]}";do
    2.40-  [ -d "tree-sitter-${lang%/*}" ] || git clone ${repos[$lang]:-https://github.com/tree-sitter/tree-sitter-${lang%/*}};
    2.41-  # subshell
    2.42-  (
    2.43-    cd "tree-sitter-${lang}/src";
    2.44-    if test -f "scanner.cc"; then
    2.45-      ${CXX} -I. -fPIC scanner.cc -c -lstdc++;
    2.46-      ${CC} -I. -std=c99 -fPIC parser.c -c;
    2.47-      ${CXX} -shared scanner.o parser.o -o ${PREFIX}/lib/libtree-sitter-"${lang//\//-}.${EXT}";
    2.48-    elif test -f "scanner.c"; then
    2.49-      ${CC} -I. -std=c99 -fPIC scanner.c -c;
    2.50-      ${CC} -I. -std=c99 -fPIC parser.c -c;
    2.51-      ${CC} -shared scanner.o parser.o -o ${PREFIX}/lib/libtree-sitter-"${lang//\//-}.${EXT}";
    2.52-    else
    2.53-      ${CC} -I. -std=c99 -fPIC parser.c -c;
    2.54-      ${CC} -shared parser.o -o ${PREFIX}/lib/libtree-sitter-"${lang//\//-}.${EXT}";
    2.55-    fi;
    2.56-    mkdir -p "${PREFIX}/share/tree-sitter/${lang}/";
    2.57-    cp grammar.json node-types.json "${PREFIX}/share/tree-sitter/${lang}";
    2.58-  )
    2.59-done
     3.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2+++ b/scripts/tree-sitter-langs.sh	Wed Jun 19 19:45:37 2024 -0400
     3.3@@ -0,0 +1,57 @@
     3.4+#!/usr/bin/env bash
     3.5+
     3.6+# based on https://github.com/GrammaTech/sel/blob/master/tools/tree-sitter-install.sh
     3.7+set -eux
     3.8+
     3.9+declare -ar default_langs=(
    3.10+  commonlisp bash c cpp css go html java javascript jsdoc json python regex rust
    3.11+  typescript/tsx typescript/typescript yaml
    3.12+) 
    3.13+# see https://tree-sitter.github.io/tree-sitter/#parsers for a
    3.14+# complete list of parsers available
    3.15+TARGETDIR="${1:-.stash/src/tree-sitter-langs}"
    3.16+
    3.17+PREFIX=$(realpath "${PREFIX:-/usr/local}")
    3.18+CC=${CC:-clang}
    3.19+CXX=${CXX:-clang++}
    3.20+if [ $(uname) == "Darwin" ];then
    3.21+   EXT=dylib;
    3.22+else
    3.23+   EXT=so
    3.24+fi
    3.25+
    3.26+declare -A repos
    3.27+repos[commonlisp]=https://github.com/theHamsta/tree-sitter-commonlisp.git
    3.28+repos[yaml]=https://github.com/ikatyang/tree-sitter-yaml.git
    3.29+repos[cpp]=https://github.com/ruricolist/tree-sitter-cpp.git
    3.30+
    3.31+declare -a langs
    3.32+if [ -z "${2:-}" ]; then
    3.33+  langs=(${default_langs[@]})
    3.34+else
    3.35+  langs=($@)
    3.36+fi
    3.37+
    3.38+mkdir -pv $TARGETDIR
    3.39+cd $TARGETDIR
    3.40+for lang in "${langs[@]}";do
    3.41+  [ -d "tree-sitter-${lang%/*}" ] || git clone ${repos[$lang]:-https://github.com/tree-sitter/tree-sitter-${lang%/*}};
    3.42+  # subshell
    3.43+  (
    3.44+    cd "tree-sitter-${lang}/src";
    3.45+    if test -f "scanner.cc"; then
    3.46+      ${CXX} -I. -fPIC scanner.cc -c -lstdc++;
    3.47+      ${CC} -I. -std=c99 -fPIC parser.c -c;
    3.48+      ${CXX} -shared scanner.o parser.o -o ${PREFIX}/lib/libtree-sitter-"${lang//\//-}.${EXT}";
    3.49+    elif test -f "scanner.c"; then
    3.50+      ${CC} -I. -std=c99 -fPIC scanner.c -c;
    3.51+      ${CC} -I. -std=c99 -fPIC parser.c -c;
    3.52+      ${CC} -shared scanner.o parser.o -o ${PREFIX}/lib/libtree-sitter-"${lang//\//-}.${EXT}";
    3.53+    else
    3.54+      ${CC} -I. -std=c99 -fPIC parser.c -c;
    3.55+      ${CC} -shared parser.o -o ${PREFIX}/lib/libtree-sitter-"${lang//\//-}.${EXT}";
    3.56+    fi;
    3.57+    mkdir -p "${PREFIX}/share/tree-sitter/${lang}/";
    3.58+    cp grammar.json node-types.json "${PREFIX}/share/tree-sitter/${lang}";
    3.59+  )
    3.60+done
     4.1--- a/skelfile	Wed Jun 19 19:27:24 2024 -0400
     4.2+++ b/skelfile	Wed Jun 19 19:45:37 2024 -0400
     4.3@@ -83,7 +83,7 @@
     4.4          blake3_avx512_x86-64_unix.S$#)
     4.5  (blake3-install () #$cd .stash/src/blake3/c && cp libblake3.so /usr/local/lib/ && cp blake3.h /usr/local/include/$#)
     4.6  ;; install
     4.7- (tree-sitter-langs (src) #$./scripts/tree-sitter-install-langs.sh$#)
     4.8+ (tree-sitter-langs (src) #$PREFIX=.stash ./scripts/tree-sitter-langs.sh$#)
     4.9  (cargo-tools () #$scripts/install-cargo-tools.sh$#)
    4.10  (rustup () #$curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y$#)
    4.11  (sbcl-install () #$cd .stash/src/sbcl && INSTALL_ROOT=/usr/local sh install.sh$#)