Skip to content

Commit ac80b76

Browse files
tree-sitter-cli: add new package
Tree-sitter CLI allows you to develop, test, and use Tree-sitter grammars from the command line. Signed-off-by: Valeriy Kosikhin <[email protected]>
1 parent 37bfd2b commit ac80b76

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

utils/tree-sitter-cli/Makefile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
include $(TOPDIR)/rules.mk
2+
3+
PKG_NAME:=tree-sitter-cli
4+
PKG_VERSION:=0.25.10
5+
PKG_RELEASE:=1
6+
7+
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
8+
PKG_SOURCE_URL:=https://codeload.github.com/tree-sitter/tree-sitter/tar.gz/v$(PKG_VERSION)?
9+
PKG_HASH:=ad5040537537012b16ef6e1210a572b927c7cdc2b99d1ee88d44a7dcdc3ff44c
10+
11+
PKG_MAINTAINER:=Valeriy Kosikhin <[email protected]>
12+
PKG_LICENSE:=MIT
13+
PKG_LICENSE_FILES:=LICENSE
14+
15+
PKG_BUILD_DEPENDS:=rust/host
16+
PKG_BUILD_PARALLEL:=1
17+
18+
include $(INCLUDE_DIR)/package.mk
19+
include ../../lang/rust/rust-package.mk
20+
21+
define Package/tree-sitter-cli
22+
SECTION:=utils
23+
CATEGORY:=Utilities
24+
TITLE:=CLI tool for creating and testing Tree-sitter parsers
25+
URL:=https://tree-sitter.github.io/
26+
DEPENDS:=$(RUST_ARCH_DEPENDS)
27+
endef
28+
29+
define Package/tree-sitter-cli/description
30+
Tree-sitter CLI allows you to develop, test, and use Tree-sitter grammars from the command line.
31+
endef
32+
33+
TAR_OPTIONS+= --strip-components 1
34+
TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
35+
MAKE_PATH:=cli
36+
37+
define Package/tree-sitter-cli/install
38+
$(INSTALL_DIR) $(1)/usr/bin
39+
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/tree-sitter $(1)/usr/bin
40+
endef
41+
42+
$(eval $(call RustBinPackage,tree-sitter-cli))
43+
$(eval $(call BuildPackage,tree-sitter-cli))
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--- a/cli/loader/src/lib.rs
2+
+++ b/cli/loader/src/lib.rs
3+
@@ -303,7 +303,6 @@ impl Config {
4+
}
5+
6+
const BUILD_TARGET: &str = env!("BUILD_TARGET");
7+
-const BUILD_HOST: &str = env!("BUILD_HOST");
8+
9+
pub struct LanguageConfiguration<'a> {
10+
pub scope: Option<String>,
11+
@@ -821,7 +820,7 @@ impl Loader {
12+
.cargo_metadata(false)
13+
.cargo_warnings(false)
14+
.target(BUILD_TARGET)
15+
- .host(BUILD_HOST)
16+
+ .host(BUILD_TARGET)
17+
.debug(self.debug_build)
18+
.file(&config.parser_path)
19+
.includes(&config.header_paths)

0 commit comments

Comments
 (0)