ruby_tree_sitter 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +22 -20
- data/ext/tree_sitter/extconf.rb +8 -8
- data/ext/tree_sitter/repo.rb +17 -10
- data/lib/tree_sitter/mixins/language.rb +1 -0
- data/lib/tree_sitter/version.rb +1 -1
- data/lib/tree_sitter.rb +7 -1
- data/tree_sitter.gemspec +0 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0488c0541ab1295e21de7a53a3af6bbfb0d2e5a2340874803037b00956e16e3
|
4
|
+
data.tar.gz: 9e5b5d202e3857ee5840322c1899684e12aa8469faa3c199f0cb8b1d1d183913
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0d6108292ce09bed1aca0d83899df812019c5689901c762b0b8f54b951f68dc4256495b1e10ad2faf64523f0cfad7262fd07aad7dab1666d599a0453dd40b20
|
7
|
+
data.tar.gz: 6d84ad3d549c81a18a64509d826ae86d12bf90da60cdb0bcff40d5a85008c80ec309afe2d3190707601586d814f8a07ee919887f67c3103ebf352585b69b1e44
|
data/README.md
CHANGED
@@ -68,12 +68,23 @@ TreeStand provides an idiomatic Ruby interface to work with tree-sitter parsers.
|
|
68
68
|
|
69
69
|
## Dependencies
|
70
70
|
|
71
|
-
This gem is a binding for `tree-sitter
|
72
|
-
`tree-sitter`
|
71
|
+
This gem is a binding for `tree-sitter`, and comes with a pre-built version
|
72
|
+
of `tree-sitter` bundled with it, so you can start using it without any
|
73
|
+
special configuration.
|
73
74
|
|
74
|
-
|
75
|
-
|
76
|
-
|
75
|
+
We support the following platforms:
|
76
|
+
|
77
|
+
- `aarch64-linux-gnu`
|
78
|
+
- `aarch64-linux-musl`
|
79
|
+
- `arm-linux-gnu`
|
80
|
+
- `arm-linux-musl`
|
81
|
+
- `x86_64-linux-gnu`
|
82
|
+
- `x86_64-linux-musl`
|
83
|
+
- `x86-linux-musl`
|
84
|
+
- `arm64-darwin`
|
85
|
+
- `x86_64-darwin`
|
86
|
+
|
87
|
+
(see [Build from source](docs/Contributing.md#build-from-source)).
|
77
88
|
|
78
89
|
You can either install `tree-sitter` from source or through your go-to package manager.
|
79
90
|
|
@@ -108,7 +119,7 @@ brew install tree-sitter
|
|
108
119
|
From [rubygems](https://rubygems.org/gems/ruby_tree_sitter), in your `Gemfile`:
|
109
120
|
|
110
121
|
```ruby
|
111
|
-
gem 'ruby_tree_sitter', '~> 1.
|
122
|
+
gem 'ruby_tree_sitter', '~> 1.6'
|
112
123
|
```
|
113
124
|
|
114
125
|
Or manually:
|
@@ -123,18 +134,19 @@ Or from `git` sources, which will compile on installation:
|
|
123
134
|
gem 'ruby_tree_sitter', git: 'https://github.com/Faveod/ruby-tree-sitter'
|
124
135
|
```
|
125
136
|
|
126
|
-
###
|
137
|
+
### Enable system libraries
|
127
138
|
|
128
|
-
To install with `--
|
139
|
+
To install with `--enable-sys-libs`, you can either:
|
129
140
|
|
130
141
|
```sh
|
131
|
-
gem install ruby_tree_sitter -- --
|
142
|
+
gem install ruby_tree_sitter --platform=ruby -- --enable-sys-libs
|
132
143
|
```
|
133
144
|
|
134
145
|
Or via bundle:
|
135
146
|
|
136
147
|
```sh
|
137
|
-
bundle config
|
148
|
+
bundle config force_ruby_platform true
|
149
|
+
bundle config set build.ruby_tree_sitter --enable-sys-libs
|
138
150
|
```
|
139
151
|
|
140
152
|
### No compilation
|
@@ -163,16 +175,6 @@ You will have to install parsers yourself, either by:
|
|
163
175
|
[Faveod/tree-sitter-parsers](https://github.com/Faveod/tree-sitter-parsers)
|
164
176
|
which supports numerous architectures.
|
165
177
|
|
166
|
-
### A note on static vs dynamic linking
|
167
|
-
|
168
|
-
This extension will statically link against a downloaded version of
|
169
|
-
`tree-sitter` when you use the `--disable-sys-lib`. So any installed version of
|
170
|
-
`tree-sitter` will not be loaded.
|
171
|
-
|
172
|
-
The native gems are also statically linked.
|
173
|
-
|
174
|
-
All other methods will dynamically link against the installed `tree-sitter`.
|
175
|
-
|
176
178
|
## Examples
|
177
179
|
|
178
180
|
See `examples` directory.
|
data/ext/tree_sitter/extconf.rb
CHANGED
@@ -15,7 +15,7 @@ cflags = []
|
|
15
15
|
ldflags = []
|
16
16
|
|
17
17
|
def system_tree_sitter?
|
18
|
-
enable_config('sys-libs',
|
18
|
+
enable_config('sys-libs', false)
|
19
19
|
end
|
20
20
|
|
21
21
|
def env_var_on?(var)
|
@@ -26,6 +26,8 @@ end
|
|
26
26
|
# System lib vs Downloaded lib #
|
27
27
|
# ################################## #
|
28
28
|
|
29
|
+
repo = TreeSitter::Repo.new
|
30
|
+
|
29
31
|
dir_include, dir_lib =
|
30
32
|
if system_tree_sitter?
|
31
33
|
[
|
@@ -33,7 +35,6 @@ dir_include, dir_lib =
|
|
33
35
|
%w[/opt/lib /opt/local/lib /usr/lib /usr/local/lib],
|
34
36
|
]
|
35
37
|
else
|
36
|
-
repo = TreeSitter::Repo.new
|
37
38
|
if !repo.download
|
38
39
|
msg = <<~MSG
|
39
40
|
|
@@ -48,19 +49,19 @@ dir_include, dir_lib =
|
|
48
49
|
# We need to make sure we're selecting the proper toolchain.
|
49
50
|
# Especially needed for corss-compilation.
|
50
51
|
ENV.store('CC', RbConfig::CONFIG['CC'])
|
52
|
+
repo.patch
|
51
53
|
repo.compile
|
52
|
-
repo.keep_static_lib
|
53
54
|
repo.include_and_lib_dirs
|
54
55
|
end
|
55
56
|
|
57
|
+
dir_config('tree-sitter', dir_include&.first, dir_lib&.first)
|
58
|
+
|
56
59
|
# ################################## #
|
57
60
|
# Generate Makefile #
|
58
61
|
# ################################## #
|
59
62
|
|
60
|
-
header = find_header('tree_sitter/api.h'
|
61
|
-
library = find_library('tree-sitter',
|
62
|
-
'ts_parser_new', # a symbol
|
63
|
-
*dir_lib)
|
63
|
+
header = find_header('tree_sitter/api.h')
|
64
|
+
library = find_library('tree-sitter', 'ts_parser_new')
|
64
65
|
|
65
66
|
if !header || !library
|
66
67
|
abort <<~MSG
|
@@ -144,6 +145,5 @@ cflags.concat %w[-std=c99 -fPIC -Wall]
|
|
144
145
|
append_cflags(cflags)
|
145
146
|
append_ldflags(ldflags)
|
146
147
|
|
147
|
-
dir_config('tree-sitter')
|
148
148
|
create_header
|
149
149
|
create_makefile('tree_sitter/tree_sitter')
|
data/ext/tree_sitter/repo.rb
CHANGED
@@ -29,7 +29,9 @@ module TreeSitter
|
|
29
29
|
def compile
|
30
30
|
# We need to clean because the same folder is used over and over
|
31
31
|
# by rake-compiler-dock
|
32
|
-
|
32
|
+
ar = RbConfig::MAKEFILE_CONFIG['AR']
|
33
|
+
ar = " AR=#{ar}" if ar
|
34
|
+
sh "cd #{src} && make clean &&#{ar} make libtree-sitter.a"
|
33
35
|
end
|
34
36
|
|
35
37
|
def exe?(name)
|
@@ -59,14 +61,14 @@ module TreeSitter
|
|
59
61
|
end
|
60
62
|
|
61
63
|
def include_and_lib_dirs
|
62
|
-
[[src / 'lib' / 'include'], [src.to_s]]
|
64
|
+
[[(src / 'lib' / 'include').to_s], [src.to_s]]
|
63
65
|
end
|
64
66
|
|
65
|
-
def
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
def patch
|
68
|
+
root = Pathname.new(File.expand_path(__dir__)).realpath.parent.parent
|
69
|
+
patch = root / 'patches' / 'cross-compile.patch'
|
70
|
+
|
71
|
+
sh "patch --forward #{src / 'Makefile'} #{patch}"
|
70
72
|
end
|
71
73
|
|
72
74
|
def sh(cmd)
|
@@ -98,9 +100,14 @@ module TreeSitter
|
|
98
100
|
def sources_from_git
|
99
101
|
return false if !exe?(:git)
|
100
102
|
|
101
|
-
sh
|
102
|
-
|
103
|
-
|
103
|
+
sh <<~SHELL.chomp
|
104
|
+
mkdir #{src} \\
|
105
|
+
&& cd #{src} \\
|
106
|
+
&& git init \\
|
107
|
+
&& git remote add origin "#{url[:git]}" \\
|
108
|
+
&& git fetch origin --depth 1 tags/v#{version} \\
|
109
|
+
&& git reset --hard FETCH_HEAD
|
110
|
+
SHELL
|
104
111
|
true
|
105
112
|
end
|
106
113
|
|
data/lib/tree_sitter/version.rb
CHANGED
data/lib/tree_sitter.rb
CHANGED
@@ -2,7 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'set'
|
4
4
|
|
5
|
-
|
5
|
+
begin
|
6
|
+
RUBY_VERSION =~ /(\d+\.\d+)/
|
7
|
+
require "tree_sitter/#{Regexp.last_match(1)}/tree_sitter"
|
8
|
+
rescue LoadError
|
9
|
+
require 'tree_sitter/tree_sitter'
|
10
|
+
end
|
11
|
+
|
6
12
|
require 'tree_sitter/version'
|
7
13
|
|
8
14
|
require 'tree_sitter/mixins/language'
|
data/tree_sitter.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_tree_sitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firas al-Khalil
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-07
|
12
|
+
date: 2024-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sorbet-runtime
|
@@ -103,7 +103,6 @@ homepage: https://www.github.com/Faveod/ruby-tree-sitter
|
|
103
103
|
licenses:
|
104
104
|
- MIT
|
105
105
|
metadata:
|
106
|
-
allowed_push_host: https://rubygems.org
|
107
106
|
homepage_uri: https://www.github.com/Faveod/ruby-tree-sitter
|
108
107
|
source_code_uri: https://www.github.com/Faveod/ruby-tree-sitter
|
109
108
|
changelog_uri: https://www.github.com/Faveod/ruby-tree-sitter
|
@@ -123,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
122
|
- !ruby/object:Gem::Version
|
124
123
|
version: '0'
|
125
124
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
125
|
+
rubygems_version: 3.3.26
|
127
126
|
signing_key:
|
128
127
|
specification_version: 4
|
129
128
|
summary: Ruby bindings for Tree-Sitter
|