Subject: 29.0.60; Fix tree-sitter-build-scripts

From: Theodor Thornhill <[email-masked]>
Date: Thu, 01 Dec 2022 09:49:31 +0100

Hello there!

Attached is a patch to build typescript in addition to tsx.

Theo

>From 077bd1ff9825721bc6023f9e81e379774429bb13 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <[email-masked]>
Date: Thu, 1 Dec 2022 09:39:17 +0100
Subject: [PATCH] Fix tree-sitter build scripts

* admin/notes/tree-sitter/build-module/batch.sh (languages): Add tsx.
* admin/notes/tree-sitter/build-module/build.sh (lang): Make guards to
account for typescript/tsx.  It's a little hacky because of the nested
nature of that particular repository.
---
 admin/notes/tree-sitter/build-module/batch.sh |  1 +
 admin/notes/tree-sitter/build-module/build.sh | 29 ++++++++++++-------
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/admin/notes/tree-sitter/build-module/batch.sh b/admin/notes/tree-sitter/build-module/batch.sh
index deed18978a..d45f37f4b6 100755
--- a/admin/notes/tree-sitter/build-module/batch.sh
+++ b/admin/notes/tree-sitter/build-module/batch.sh
@@ -12,6 +12,7 @@ languages=
     'python'
     'rust'
     'typescript'
+    'tsx'
 )
 
 for language in "${languages[@]}"
diff --git a/admin/notes/tree-sitter/build-module/build.sh b/admin/notes/tree-sitter/build-module/build.sh
index 102ab310fa..02c6ebaf5d 100755
--- a/admin/notes/tree-sitter/build-module/build.sh
+++ b/admin/notes/tree-sitter/build-module/build.sh
@@ -12,20 +12,23 @@ lang=
 echo "Building ${lang}"
 
 # Retrieve sources.
-git clone "https://github.com/tree-sitter/tree-sitter-${lang}.git" \
-    --depth 1 --quiet
-if [ "${lang}" == "typescript" ]
+if [ "${lang}" == "typescript" ] || [ "${lang}" == "tsx" ]
 then
-    lang="typescript/tsx"
+    git clone "https://github.com/tree-sitter/tree-sitter-typescript.git" \
+        --depth 1 --quiet
+
+    lang="typescript/${lang}"
+else
+    git clone "https://github.com/tree-sitter/tree-sitter-${lang}.git" \
+        --depth 1 --quiet
 fi
-cp tree-sitter-lang.in "tree-sitter-${lang}/src"
-cp emacs-module.h "tree-sitter-${lang}/src"
+
 cp "tree-sitter-${lang}/grammar.js" "tree-sitter-${lang}/src"
 cd "tree-sitter-${lang}/src"
 
-if [ "${lang}" == "typescript/tsx" ]
+if [ "${lang}" == "typescript/$1" ]
 then
-    lang="tsx"
+    lang=$1
 fi
 
 # Build.
@@ -50,7 +53,7 @@ lang=
 
 # Copy out.
 
-if [ "${lang}" == "typescript" ]
+if [ "${lang}" == "typescript" ] || [ "${lang}" == "tsx" ]
 then
     cp "libtree-sitter-${lang}.${soext}" ..
     cd ..
@@ -59,4 +62,10 @@ lang=
 mkdir -p ../../dist
 cp "libtree-sitter-${lang}.${soext}" ../../dist
 cd ../../
-rm -rf "tree-sitter-${lang}"
+
+if [ "${lang}" == "typescript" ] || [ "${lang}" == "tsx" ]
+then
+    rm -rf "tree-sitter-typescript"
+else
+    rm -rf "tree-sitter-${lang}"
+fi
-- 
2.34.1