Skip to content

Commit

Permalink
fix: regenerate bindings (and update config file)
Browse files Browse the repository at this point in the history
  • Loading branch information
ribru17 committed Oct 7, 2024
1 parent f767fb0 commit 31fad2b
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 20 deletions.
60 changes: 60 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
cmake_minimum_required(VERSION 3.13)

project(tree-sitter-query
VERSION "0.4.0"
DESCRIPTION "TS query grammar for tree-sitter"
HOMEPAGE_URL "https://github.com/tree-sitter-grammars/tree-sitter-query"
LANGUAGES C)

option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
option(TREE_SITTER_REUSE_ALLOCATOR "Reuse the library allocator" OFF)

set(TREE_SITTER_ABI_VERSION 14 CACHE STRING "Tree-sitter ABI version")
if(NOT ${TREE_SITTER_ABI_VERSION} MATCHES "^[0-9]+$")
unset(TREE_SITTER_ABI_VERSION CACHE)
message(FATAL_ERROR "TREE_SITTER_ABI_VERSION must be an integer")
endif()

find_program(TREE_SITTER_CLI tree-sitter DOC "Tree-sitter CLI")

add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/parser.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/grammar.json"
COMMAND "${TREE_SITTER_CLI}" generate src/grammar.json
--abi=${TREE_SITTER_ABI_VERSION}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Generating parser.c")

add_library(tree-sitter-query src/parser.c)
if(EXISTS src/scanner.c)
target_sources(tree-sitter-query PRIVATE src/scanner.c)
endif()
target_include_directories(tree-sitter-query PRIVATE src)

target_compile_definitions(tree-sitter-query PRIVATE
$<$<BOOL:${TREE_SITTER_REUSE_ALLOCATOR}>:TREE_SITTER_REUSE_ALLOCATOR>
$<$<CONFIG:Debug>:TREE_SITTER_DEBUG>)

set_target_properties(tree-sitter-query
PROPERTIES
C_STANDARD 11
POSITION_INDEPENDENT_CODE ON
SOVERSION "${TREE_SITTER_ABI_VERSION}.${PROJECT_VERSION_MAJOR}"
DEFINE_SYMBOL "")

configure_file(bindings/c/tree-sitter-query.pc.in
"${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-query.pc" @ONLY)

include(GNUInstallDirs)

install(FILES bindings/c/tree-sitter-query.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/tree_sitter")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-query.pc"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig")
install(TARGETS tree-sitter-query
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

add_custom_target(test "${TREE_SITTER_CLI}" test
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "tree-sitter test")

# vim:ft=cmake:
1 change: 1 addition & 0 deletions bindings/go/binding.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bindings/go/binding_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions bindings/go/go.mod

This file was deleted.

9 changes: 9 additions & 0 deletions bindings/node/binding_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions bindings/python/tests/test_binding.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions bindings/swift/TreeSitterQueryTests/TreeSitterQueryTests.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/tree-sitter-grammars/tree-sitter-query

go 1.22

require github.com/tree-sitter/go-tree-sitter v0.23.1
15 changes: 2 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,5 @@
"test": "make test",
"version": "make -s update",
"prebuildify": "prebuildify --napi --strip"
},
"tree-sitter": [
{
"scope": "source.query",
"injection-regex": "^query$",
"highlights": "queries/query/highlights.scm",
"injections": "queries/query/injections.scm",
"file-types": [
"scm"
]
}
]
}
}
}
40 changes: 40 additions & 0 deletions tree-sitter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"grammars": [
{
"name": "query",
"camelcase": "Query",
"scope": "source.query",
"path": ".",
"file-types": [
"scm"
],
"highlights": "queries/query/highlights.scm",
"injections": "queries/query/injections.scm",
"injection-regex": "^query$"
}
],
"metadata": {
"version": "0.4.0",
"license": "Apache-2.0",
"description": "TS query grammar for tree-sitter",
"authors": [
{
"name": "Steven Sojka"
},
{
"name": "Stephan Seitz"
}
],
"links": {
"repository": "https://github.com/tree-sitter-grammars/tree-sitter-query"
}
},
"bindings": {
"c": true,
"go": true,
"node": true,
"python": true,
"rust": true,
"swift": true
}
}

0 comments on commit 31fad2b

Please sign in to comment.