Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scripts and instructions for switching between tree-sitter versions #81

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

mjambon
Copy link
Member

@mjambon mjambon commented Sep 11, 2024

Motivation

This will facilitate regenerating grammar code using the old tree-sitter (0.20.6) as required by many target languages in ocaml-tree-sitter-semgrep. I need to regenerate them because I'm changing the format of the parse results to accommodate the so-called extras.

Changes

  • The default tree-sitter version to use is now kept in the file tree-sitter-version.default instead of being in a script.
  • The actual tree-sitter version being used is in the file tree-sitter-version.
  • We provide a script ./scripts/switch-tree-sitter-version for developers of ocaml-tree-sitter-semgrep who need to switch back and forth between tree-sitter versions (without having to recompile everything).

Compatibility

Building and installing the tree-sitter and ocaml-tree-sitter runtime libraries - as needed by semgrep - is unchanged. The default destination folder of the tree-sitter binaries and libraries is still tree-sitter (except that it's now a symlink).

Tests

Test for the default tree-sitter version (0.22.6):

make setup && make && make install && make test
cat tree-sitter-version  # should be 0.22.6

Test for the older tree-sitter version (0.20.6):

./scripts/switch-tree-sitter-version 0.20.6
cat tree-sitter-version  # should be 0.20.6
make setup && make && make install && make test

Check that re-running make setup is faster the second time around for a given tree-sitter version.

Documentation

This situation is temporary and hopefully won't happen again. This is due to the recent tree-sitter no longer supporting C++ scanners. I added a minimal paragraph about version management to the readme.

Security

  • Change has no security implications (otherwise, ping the security team)

@mjambon mjambon requested a review from nmote September 11, 2024 21:44
@aryx aryx merged commit e74ffc6 into main Sep 12, 2024
2 checks passed
@aryx aryx deleted the martin/manage-versions branch September 12, 2024 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants