-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scripts and instructions for switching between tree-sitter versions
- Loading branch information
Showing
9 changed files
with
102 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#! /usr/bin/env bash | ||
# | ||
# Change the tree-sitter version used for local development and rebuild | ||
# what's necessary. | ||
# | ||
set -eu | ||
|
||
error() { | ||
( | ||
echo "[$0] Error: $*" | ||
echo "Supported versions: 0.20.6 0.22.6" | ||
) | ||
exit 1 | ||
} | ||
|
||
if [[ $# -ne 1 ]]; then | ||
error "Exactly one argument is expected, the tree-sitter version ID" | ||
fi | ||
|
||
version='' | ||
case "$1" in | ||
0.20.6) | ||
version=0.20.6 | ||
;; | ||
0.22.6) | ||
version=0.22.6 | ||
;; | ||
*) | ||
error "Unsupported version '$1'" | ||
esac | ||
|
||
echo "$version" > tree-sitter-version | ||
./scripts/update-version-symlinks | ||
|
||
echo "You can now run 'make setup' to download and build tree-sitter $version." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#! /usr/bin/env bash | ||
# | ||
# Run this script to update local symlinks after changing the tree-sitter | ||
# version in the file 'tree-sitter-version'. | ||
# | ||
# This facilitates development that requires switching between different | ||
# tree-sitter versions. The compiled tree-sitter libraries and binaries | ||
# go into a versioned folder e.g. tree-sitter-0.22.6 and are therefore | ||
# preserved when switching back and forth between versions. | ||
# | ||
# If the user wishes to install the tree-sitter CLI or runtime library | ||
# elsewhere than the default 'tree-sitter/', they can do so by passing the | ||
# '--prefix' option. In this case, the symlinks we create here become | ||
# irrelevant. | ||
# | ||
set -eu | ||
|
||
version=$(cat tree-sitter-version) | ||
|
||
echo "Updating symlinks 'downloads/tree-sitter' and 'tree-sitter'" | ||
|
||
( | ||
cd downloads | ||
rm -f tree-sitter | ||
ln -s tree-sitter-"$version" tree-sitter | ||
) | ||
|
||
if [[ -d tree-sitter ]] && [[ ! -L tree-sitter ]]; then | ||
# The issue is that we want to be able to use two different versions of | ||
# the tree-sitter CLI. To make this convenient, the 'tree-sitter' folder | ||
# is now a symlink to the versioned folder name. | ||
echo "*** Your tree-sitter installation is old. Removing it." | ||
rm -rf tree-sitter | ||
fi | ||
|
||
# Remove the symlink and set it to the new install folder. | ||
# It allows us to use this script to switch tree-sitter versions without | ||
# rebuilding everything. | ||
rm -f tree-sitter | ||
ln -s tree-sitter-"$version" tree-sitter | ||
mkdir -p tree-sitter-"$version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.22.6 |