Skip to content

Commit

Permalink
Load the correct library
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-e committed Nov 27, 2024
1 parent 747734c commit 16f22e1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_parsers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
- name: Commit changes
if: steps.changes.outputs.changes == 'true'
run: |
git commit -m "Build tree-sitter parsers for ${{ matrix.platform }}-${arch} [skip ci]"
git commit -m "Build tree-sitter parsers for ${{ matrix.platform }}-${arch}"
- name: Push changes
if: steps.changes.outputs.changes == 'true'
Expand Down
28 changes: 25 additions & 3 deletions lib/reaper/ast_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,35 @@ def initialize(language)
@language = language
@current_file_contents = nil

platform = case RUBY_PLATFORM
when /darwin/
'darwin'
when /linux/
'linux'
else
raise "Unsupported platform: #{RUBY_PLATFORM}"
end

arch = case RUBY_PLATFORM
when /x86_64|amd64/
'x86_64'
when /arm64|aarch64/
'arm64'
else
raise "Unsupported architecture: #{RUBY_PLATFORM}"
end

extension = platform == 'darwin' ? 'dylib' : 'so'
parser_file = "libtree-sitter-#{language}-#{platform}-#{arch}.#{extension}"
parser_path = File.join('parsers', parser_file)

case language
when 'swift'
@parser.language = TreeSitter.lang('swift')
@parser.language = TreeSitter.lang('swift', parser_path)
when 'kotlin'
@parser.language = TreeSitter.lang('kotlin')
@parser.language = TreeSitter.lang('kotlin', parser_path)
when 'java'
@parser.language = TreeSitter.lang('java')
@parser.language = TreeSitter.lang('java', parser_path)
else
raise "Unsupported language: #{language}"
end
Expand Down

0 comments on commit 16f22e1

Please sign in to comment.