commit 6091c4f69b4f726ffbe3a890867fd17f9aee5c39 Author: EnumDev Date: Thu May 8 17:18:58 2025 +0300 Initial Commit diff --git a/pkg.info b/pkg.info new file mode 100644 index 0000000..56a2553 --- /dev/null +++ b/pkg.info @@ -0,0 +1,14 @@ +name: tree-sitter +description: An incremental parsing system for programming tools +version: 0.25.3 +url: https://github.com/tree-sitter/tree-sitter +license: MIT +architecture: any +make_depends: ["cmake","rustc"] +type: source +split_packages: + - name: tree-sitter + - name: tree-sitter-cli + description: CLI tool for tree-sitter + depends: ["gcc"] + optional_depends: ["nodejs"] diff --git a/source.sh b/source.sh new file mode 100644 index 0000000..269ebe5 --- /dev/null +++ b/source.sh @@ -0,0 +1,50 @@ +# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package +# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE +# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT + +DOWNLOAD="https://github.com/tree-sitter/tree-sitter/archive/refs/tags/v${BPM_PKG_VERSION}.tar.gz" +FILENAME="${DOWNLOAD##*/}" + +# The prepare function is executed in the root of the temp directory +# This function is used for downloading files and putting them into the correct location +prepare() { + wget "$DOWNLOAD" + tar -xvf "$FILENAME" --strip-components=1 -C "$BPM_SOURCE" +} + +# The build function is executed in the source directory +# This function is used to compile the source code +build() { + # Build library + mkdir lib/build + cd lib/build + + cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON .. + make + + # Build command-line interface + cd "$BPM_SOURCE"/cli + + cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')" + cargo build --release --locked --offline +} + +# Function for packaging the main tree sitter library +package_tree-sitter() { + cd lib/build + + make DESTDIR="$BPM_OUTPUT" install + + # Install package license + install -Dm644 "$BPM_SOURCE"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/tree-sitter/LICENSE +} + +# Function for packaging the tree sitter cli tools +package_tree-sitter-cli() { + cd cli + + install -D "$BPM_SOURCE"/target/release/tree-sitter "$BPM_OUTPUT"/usr/bin/tree-sitter + + # Install package license + install -Dm644 "$BPM_SOURCE"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/tree-sitter/LICENSE +}