Skip to content

Commit d96efc0

Browse files
committed
Adding support to yaml
1 parent 611d78f commit d96efc0

2 files changed

Lines changed: 166 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
Class {
2+
#name : 'TSLibrariesCommandLinesYAML',
3+
#superclass : 'TSLibrariesCommandLines',
4+
#category : 'TreeSitter-Libraries',
5+
#package : 'TreeSitter-Libraries'
6+
}
7+
8+
{ #category : 'as yet unclassified' }
9+
TSLibrariesCommandLinesYAML >> cmdLinuxTreeSitterYAML [
10+
11+
"^ self tsBuildCommandForMacAndLinux: '/tree-sitter-yaml'"
12+
13+
| path command |
14+
path := TSLibraries new originalLibrariesDirectory , '/tree-sitter-yaml'.
15+
command := 'cd ' , path, String lf.
16+
command := command , String lf,
17+
'clang -O3 -fPIC -Isrc -c src/parser.c -o parser.o', String lf,
18+
'clang++ -O3 -fPIC -Isrc -c src/scanner.cc -o scanner.o', String lf,
19+
'clang++ -shared -o libtree-sitter-yaml.so parser.o scanner.o'.
20+
21+
^ command.
22+
]
23+
24+
{ #category : 'as yet unclassified' }
25+
TSLibrariesCommandLinesYAML >> cmdMacTreeSitterYAML [
26+
27+
"^ self tsBuildCommandForMacAndLinux: '/tree-sitter-yaml'"
28+
29+
30+
| path command |
31+
path := TSLibraries new originalLibrariesDirectory , '/tree-sitter-yaml'.
32+
command := 'cd ' , path, String lf.
33+
command := command , String lf,
34+
'clang -O3 -fPIC -Isrc -c src/parser.c -o parser.o', String lf,
35+
'clang++ -O3 -fPIC -Isrc -c src/scanner.cc -o scanner.o', String lf,
36+
'clang++ -dynamiclib -o libtree-sitter-yaml.dylib parser.o scanner.o'.
37+
38+
^ command.
39+
]
40+
41+
{ #category : 'as yet unclassified' }
42+
TSLibrariesCommandLinesYAML >> cmdWindowsTreeSitterYAML [
43+
44+
| path command |
45+
path := TSLibraries new originalLibrariesDirectory , '/tree-sitter-yaml'.
46+
command := 'cd ' , path.
47+
"command := command
48+
,
49+
'&& gcc -shared -o libtree-sitter-yaml.dll src/parser.c'."
50+
51+
^ command := command , '&& clang -O3 -Isrc -c src/parser.c -o parser.o', String lf,
52+
'clang++ -O3 -Isrc -c src/scanner.cc -o scanner.o', String lf,
53+
'clang++ -shared -o tree-sitter-yaml.dll parser.o scanner.o'.
54+
55+
^ command
56+
]
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
Class {
2+
#name : 'TSLibrariesYAML',
3+
#superclass : 'TSLibraries',
4+
#category : 'TreeSitter-Libraries',
5+
#package : 'TreeSitter-Libraries'
6+
}
7+
8+
{ #category : 'as yet unclassified' }
9+
TSLibrariesYAML >> cloneTreeSitterYAML [
10+
11+
| clonePath cloneCommand status lastReleasedVersion|
12+
"Construct clone path"
13+
clonePath := self originalLibrariesDirectory , '/tree-sitter-yaml'.
14+
15+
"before cloning get the latest release"
16+
"lastReleasedVersion := self class gitBranchToUse ifNil: [ self latestReleaseTagForOwner: 'ikatyang' repo: 'tree-sitter-yaml' ]."
17+
18+
"Execute clone command"
19+
cloneCommand := 'git clone https://github.com/ikatyang/tree-sitter-yaml.git '
20+
, clonePath.
21+
"cloneCommand := 'git clone --branch ', lastReleasedVersion ,' --depth 1 https://github.com/ikatyang/tree-sitter-yaml.git '
22+
, clonePath."
23+
24+
self logInTranscript:
25+
'Start cloning Tree-Sitter-YAML in' , clonePath.
26+
27+
"Run the command"
28+
status := LibC uniqueInstance system: cloneCommand.
29+
30+
"Verify success"
31+
status = 0
32+
ifTrue: [
33+
self logInTranscript:
34+
'Tree Sitter YAML successfully cloned to: ' , clonePath ]
35+
ifFalse: [
36+
self logInTranscript:
37+
'Tree Sitter YAML clone failed with exit code: '
38+
, status asString ]
39+
]
40+
41+
{ #category : 'as yet unclassified' }
42+
TSLibrariesYAML >> ensureYAMLLibraryExists [
43+
44+
self yamlLibraryExists ifFalse: [
45+
self yamlLibraryExistsInDocuments ifFalse: [
46+
self
47+
cloneTreeSitterYAML ;
48+
generateTreeSitterYAMLLibraries ].
49+
self moveYAMLLibraryToPharoVM ]
50+
]
51+
52+
{ #category : 'as yet unclassified' }
53+
TSLibrariesYAML >> generateTreeSitterYAMLLibraries [
54+
55+
| command status cmdLines |
56+
cmdLines := TSLibrariesCommandLinesYAML new.
57+
self isMacOS
58+
ifTrue: [ command := cmdLines cmdMacTreeSitterYAML ]
59+
ifFalse: [
60+
self isWindows
61+
ifTrue: [ command := cmdLines cmdWindowsTreeSitterYAML ]
62+
ifFalse: [ command := cmdLines cmdLinuxTreeSitterYAML ] ].
63+
64+
self logInTranscript: 'Start generating Tree Sitter YAML library'.
65+
66+
"Run the command"
67+
status := LibC uniqueInstance system: command.
68+
69+
self logInTranscript:
70+
'Tree Sitter YAML library generation command is finished'.
71+
72+
"Verify success"
73+
status = 0
74+
ifTrue: [
75+
self logInTranscript:
76+
'Tree Sitter YAML library generated successfully' ]
77+
ifFalse: [
78+
Error signal:
79+
'Tree Sitter YAML library was not generated successfully' ].
80+
81+
status := 0.
82+
83+
^ status
84+
]
85+
86+
{ #category : 'as yet unclassified' }
87+
TSLibrariesYAML >> moveYAMLLibraryToPharoVM [
88+
89+
self moveLibrary: self yamlLibraryName from: '/tree-sitter-YAML/'
90+
]
91+
92+
{ #category : 'as yet unclassified' }
93+
TSLibrariesYAML >> yamlLibraryExists [
94+
95+
^ (self vmLibrariesDirectory / self yamlLibraryName)
96+
asFileReference exists
97+
]
98+
99+
{ #category : 'as yet unclassified' }
100+
TSLibrariesYAML >> yamlLibraryExistsInDocuments [
101+
102+
^ (self originalLibrariesDirectory asFileReference / self yamlLibraryName)
103+
asFileReference exists
104+
]
105+
106+
{ #category : 'as yet unclassified' }
107+
TSLibrariesYAML >> yamlLibraryName [
108+
109+
^ self libraryName: 'libtree-sitter-yaml'.
110+
]

0 commit comments

Comments
 (0)