Skip to content

Commit f296051

Browse files
authored
update treesitter (#144)
* update treesitter * regenerate bindings * update CI * update bindings * update bindings * update bindings * bump cargo * update bindings * update bindings
1 parent 02929f0 commit f296051

File tree

29 files changed

+295806
-293175
lines changed

29 files changed

+295806
-293175
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ binding.gyp linguist-vendored
99
setup.py linguist-vendored
1010
Makefile linguist-vendored
1111
Package.swift linguist-vendored
12+
13+
# Zig bindings
14+
build.zig linguist-generated
15+
build.zig.zon linguist-generated

.github/workflows/ci.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
os: [ubuntu-latest, windows-latest, macos-14]
20-
language: [fsharp, fsharp_signature]
2120
steps:
2221
- uses: actions/checkout@v4
2322
- uses: tree-sitter/setup-action/cli@v1
2423
- name: test language
2524
uses: tree-sitter/parser-test-action@v2
2625
with:
26+
generate: false
2727
test-rust: ${{ runner.os == 'Linux' }}
28-
test-node: true
29-
test-python: true
30-
test-go: true
31-
test-swift: ${{ runner.os == 'macOS' }}
28+
test-node: ${{ runner.os == 'Linux' }}
29+
test-c: ${{ runner.os == 'Linux' }}
30+
test-go: false
31+
test-swift: false
32+
test-python: false
3233

3334
parse-examples:
3435
name: Parse examples

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.DS_Store
2+
13
# Rust artifacts
24
/Cargo.lock
35
/target/

CMakeLists.txt

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
3+
project(tree-sitter-fsharp
4+
VERSION "0.1.0"
5+
DESCRIPTION ""
6+
HOMEPAGE_URL "https://github.com/tree-sitter/tree-sitter-fsharp"
7+
LANGUAGES C)
8+
9+
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
10+
option(TREE_SITTER_REUSE_ALLOCATOR "Reuse the library allocator" OFF)
11+
12+
set(TREE_SITTER_ABI_VERSION 15 CACHE STRING "Tree-sitter ABI version")
13+
if(NOT ${TREE_SITTER_ABI_VERSION} MATCHES "^[0-9]+$")
14+
unset(TREE_SITTER_ABI_VERSION CACHE)
15+
message(FATAL_ERROR "TREE_SITTER_ABI_VERSION must be an integer")
16+
endif()
17+
18+
find_program(TREE_SITTER_CLI tree-sitter DOC "Tree-sitter CLI")
19+
20+
add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/parser.c"
21+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/grammar.json"
22+
COMMAND "${TREE_SITTER_CLI}" generate src/grammar.json
23+
--abi=${TREE_SITTER_ABI_VERSION}
24+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
25+
COMMENT "Generating parser.c")
26+
27+
add_library(tree-sitter-fsharp src/parser.c)
28+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scanner.c)
29+
target_sources(tree-sitter-fsharp PRIVATE src/scanner.c)
30+
endif()
31+
target_include_directories(tree-sitter-fsharp
32+
PRIVATE src
33+
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/bindings/c>
34+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
35+
36+
target_compile_definitions(tree-sitter-fsharp PRIVATE
37+
$<$<BOOL:${TREE_SITTER_REUSE_ALLOCATOR}>:TREE_SITTER_REUSE_ALLOCATOR>
38+
$<$<CONFIG:Debug>:TREE_SITTER_DEBUG>)
39+
40+
set_target_properties(tree-sitter-fsharp
41+
PROPERTIES
42+
C_STANDARD 11
43+
POSITION_INDEPENDENT_CODE ON
44+
SOVERSION "${TREE_SITTER_ABI_VERSION}.${PROJECT_VERSION_MAJOR}"
45+
DEFINE_SYMBOL "")
46+
47+
configure_file(bindings/c/tree-sitter-fsharp.pc.in
48+
"${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-fsharp.pc" @ONLY)
49+
50+
include(GNUInstallDirs)
51+
52+
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bindings/c/tree_sitter"
53+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
54+
FILES_MATCHING PATTERN "*.h")
55+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-fsharp.pc"
56+
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig")
57+
install(TARGETS tree-sitter-fsharp
58+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
59+
60+
file(GLOB QUERIES queries/*.scm)
61+
install(FILES ${QUERIES}
62+
DESTINATION "${CMAKE_INSTALL_DATADIR}/tree-sitter/queries/fsharp")
63+
64+
add_custom_target(ts-test "${TREE_SITTER_CLI}" test
65+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
66+
COMMENT "tree-sitter test")

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ include = [
2323
path = "bindings/rust/lib.rs"
2424

2525
[dependencies]
26-
tree-sitter-language = "0.1.0"
26+
tree-sitter-language = "0.1"
2727

2828
[build-dependencies]
29-
cc = "1.0.104"
29+
cc = "1.2"
3030

3131
[dev-dependencies]
32-
tree-sitter = "0.24"
32+
tree-sitter = "0.25.4"

Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ SONAME_MINOR := $(word 2,$(subst ., ,$(VERSION)))
2525

2626
# install directory layout
2727
PREFIX ?= /usr/local
28+
DATADIR ?= $(PREFIX)/share
2829
INCLUDEDIR ?= $(PREFIX)/include
2930
LIBDIR ?= $(PREFIX)/lib
3031
PCLIBDIR ?= $(LIBDIR)/pkgconfig
@@ -48,6 +49,10 @@ else ifeq ($(shell uname),Darwin)
4849
LINKSHARED := $(LINKSHARED)$(ADDITIONAL_LIBS),
4950
endif
5051
LINKSHARED := $(LINKSHARED)-install_name,$(LIBDIR)/lib$(LANGUAGE_NAME).$(SONAME_MAJOR).dylib,-rpath,@executable_path/../Frameworks
52+
else ifneq ($(findstring mingw32,$(shell $(CC) -dumpmachine)),)
53+
SOEXT = dll
54+
LINKSHARED += -s -shared -Wl,--out-implib,$(@:dll=lib)
55+
lib$(LANGUAGE_NAME).lib: lib$(LANGUAGE_NAME).$(SOEXT)
5156
else
5257
SOEXT = so
5358
SOEXTVER_MAJOR = so.$(SONAME_MAJOR)
@@ -90,12 +95,14 @@ $(SIGNATURE_DIR)/src/parser.c: $(FSHARP_DIR)/grammar.js $(SIGNATURE_DIR)/grammar
9095
cd $(SIGNATURE_DIR) && $(TS) generate --no-bindings
9196

9297
install: all
93-
install -Dm644 bindings/c/$(LANGUAGE_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h
94-
install -Dm644 $(LANGUAGE_NAME).pc '$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc
95-
install -Dm755 lib$(LANGUAGE_NAME).a '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a
98+
install -d '$(DESTDIR)$(DATADIR)'/tree-sitter/queries/$(PARSER_NAME) '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter '$(DESTDIR)$(PCLIBDIR)' '$(DESTDIR)$(LIBDIR)'
99+
install -m644 bindings/c/tree_sitter/$(LANGUAGE_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h
100+
install -m644 $(LANGUAGE_NAME).pc '$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc
101+
install -m644 lib$(LANGUAGE_NAME).a '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a
96102
install -m755 lib$(LANGUAGE_NAME).$(SOEXT) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER)
97103
ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR)
98104
ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXT)
105+
install -m644 queries/*.scm '$(DESTDIR)$(DATADIR)'/tree-sitter/queries/$(PARSER_NAME)
99106

100107
uninstall:
101108
$(RM) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a \
@@ -104,9 +111,10 @@ uninstall:
104111
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXT) \
105112
'$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h \
106113
'$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc
114+
$(RM) -r '$(DESTDIR)$(DATADIR)'/tree-sitter/queries/$(PARSER_NAME)
107115

108116
clean:
109-
$(RM) $(OBJS) $(LANGUAGE_NAME).pc lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT)
117+
$(RM) $(OBJS) $(LANGUAGE_NAME).pc lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT) lib$(LANGUAGE_NAME).lib
110118

111119
test:
112120
$(TS) test

Package.swift

Lines changed: 0 additions & 61 deletions
This file was deleted.

bindings/c/tree-sitter-fsharp.h renamed to bindings/c/tree_sitter/tree-sitter-fsharp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ extern "C" {
88
#endif
99

1010
const TSLanguage *tree_sitter_fsharp(void);
11-
const TSLanguage *tree_sitter_fsharp_signature(void);
1211

1312
#ifdef __cplusplus
1413
}

bindings/go/binding_fsharp.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

bindings/go/binding_signature.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)