Skip to content

Commit

Permalink
build: use tsdl
Browse files Browse the repository at this point in the history
  • Loading branch information
stackmystack committed Sep 5, 2024
1 parent b7eccf4 commit 1e9e35e
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 319 deletions.
33 changes: 25 additions & 8 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,38 @@ on:

jobs:
build:
name: ${{ matrix.platform }} (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
target:
- { os: ubuntu-latest, platform: linux-x64 }
- { os: macos-latest, platform: macos-arm64 }
runs-on: ${{ matrix.target.os }}
platform:
# - linux-arm
# - linux-arm64
- linux-x64
# - linux-x86
- macos-arm64
# - macos-x64

include:
# - { platform: linux-arm , os: ubuntu-latest }
# - { platform: linux-arm64 , os: ubuntu-latest }
- { platform: linux-x64, os: ubuntu-latest }
# - { platform: linux-x86 , os: ubuntu-latest }
- { platform: macos-arm64, os: macos-14 }
# - { platform: macos-x64 , os: macos-12 }
runs-on: ${{ matrix.os }}
env:
PLATFORM: ${{ matrix.target.platform }}
TREE_SITTER_VERSION: 0.22.6
PLATFORM: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- name: Build for ${{ matrix.target.platform }}
- name: Download tsdl
run: |
curl -o tsdl.gz -L "https://github.com/stackmystack/tsdl/releases/latest/download/tsdl-${{ matrix.platform }}.gz"
gunzip tsdl.gz
chmod +x tsdl
- name: Build
run: |
./lang d
./tsdl build --out-dir lib/${{ matrix.platform}}
- name: Prepare git # To get tags from `git describe`
run: |
git fetch --prune --unshallow
Expand Down
65 changes: 2 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,6 @@

[![cd](https://github.com/Faveod/tree-sitter-parsers/actions/workflows/cd.yml/badge.svg)](https://github.com/Faveod/tree-sitter-parsers/actions/workflows/cd.yml)

This repository contains a script to create your favourite shared library
`tree-sitter-{parser}`.
Some parsers built with [tsdl](httsp://github.com/stackmystack/tsdl).

The official repositories don't have a `Makefile` for generated parsers, so this
is like a special `Makefile`.

We also have the libraries pushed as artifacts through CI/CD. Check
[Releases](https://github.com/Faveod/tree-sitter-parsers/releases).

This repository was created for
[`ruby-tree-sitter`](https://github.com/Faveod/ruby-tree-sitter).
## Usage

``` console
./lang javascript
./lang java ruby php
```

## Tree-Sitter version

The script will clone `tree-sitter` and then checkout some tag (I will try to
keep it updated to latest). But if it finds a `tree-sitter` dir, it will not do
anything to it. **so if you want to build agains a specific tag or commit, just
`cd` into `tree-sitter` and do yout thing**.

## Parser versions

Instead of defaulting to cloning parsers and building them from `HEAD`, or from
the latest release tag, the script `lang` will look for a file `ref` where
parser commit `SHA1` is specified. Actually anything you can pass to `git
checkout` will be accepted.

If `ref` was not found, `lang` will use `HEAD`.

The releases will contain a copy of the used `ref`.

## Artefacts

The output of `./lang LANGUAGE` is in `lib/libtree-sitter-LANGUAGE.{dylib, so}`.

# Supported Archs

This is not true as of now, please refer to the releases. They should be
available once more in the future.

## Linux

- x86_64-linux-gnu
- arm-linux-gnueabi
- arm-linux-gnueabihf
- aarch64-linux-gnu
- mipsel-linux-gnu
- powerpc64le-linux-gnu

## Macos

- x86_64-intel

NO SUPPORT FOR ARM (M1, M2, etc). Will land sometime soon, maybe. This requres a
patch to `tree-sitter`'s makefile itself.

## Windows

no.
Check [Releases](https://github.com/Faveod/tree-sitter-parsers/releases).
45 changes: 0 additions & 45 deletions clean

This file was deleted.

162 changes: 0 additions & 162 deletions lang

This file was deleted.

8 changes: 1 addition & 7 deletions package/deb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ debian="$pkg/DEBIAN"
mkdir -p "$debian"

dst="$pkg/usr/local/lib"
dst_escaped=$(printf '%s\n' "$dst" | sed -e 's/[\/&]/\\&/g')
mkdir -p "$dst"

cat <<-EOF > "$debian/control"
Expand All @@ -29,10 +28,5 @@ cat <<-EOF > "$debian/control"
Description: A bunch of tree-sitter parsers.
EOF

for i in lib/*-"$PLATFORM".so
do
cp $i $(echo $i | sed -E "s/^(lib\/)(.*)-$PLATFORM(\.so)$/$dst_escaped\/\2\3/")
done

cp "lib/$PLATFORM/*.so" "$dst"
dpkg-deb -Z none --build "$pkg" "lib/$pkg_name.deb"

10 changes: 3 additions & 7 deletions package/zip
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ pkg_name="$pkg-$version_num-$PLATFORM"
rm -rf "$pkg"

dst=$pkg
dst_escaped=$(printf '%s\n' "$dst" | sed -e 's/[\/&]/\\&/g')
mkdir "$dst"

for i in lib/*-"$PLATFORM"."$ext"
do
cp $i $(echo $i | sed -E "s/^(lib\/)(.*)-$PLATFORM(\.$ext)$/$dst_escaped\/\2\3/")
done
cp "lib/$PLATFORM/*.so" "$dst"

zip "lib/$pkg_name.zip" "$dst"/*
tar -cvzf "lib/$pkg_name.tar.gz" "$dst"/*
zip "lib/$pkg_name.zip" "$dst/*"
tar -cvzf "lib/$pkg_name.tar.gz" "$dst/*"
15 changes: 15 additions & 0 deletions parsers.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
tree-sitter-version = "0.22.6"

[parsers]
bash = "7331995b19b8f8aba2d5e26deb51d2195c18bc94"
c = "212a80f86452bb1316324fa0db730cf52f29e05a"
cobol = { ref = "c7a36d749e7f1db021588259f2b1b765e59d0c12", from = "https://github.com/yutaro-sakamoto/tree-sitter-cobol" }
embedded-template = "203f7bd3c1bbfbd98fc19add4b8fcb213c059205"
html = "949b78051835564bca937565241e5e337d838502"
java = "953abfc8bb3eb2f578e1f461edba4a9885f974b8"
javascript = "4928d3d18019a848906855476fde2dc8be030217"
json = "3fef30de8aee74600f25ec2e319b62a1a870d51e"
php = "575a0801f430c8672db70b73493c033a9dcfc328"
python = "82f5c9937fe4300b4bec3ee0e788d642c77aab2c"
ruby = "788a63ca1b7619288980aaafd37d890ee2469421"
rust = "9c84af007b0f144954adb26b3f336495cbb320a7"
12 changes: 0 additions & 12 deletions ref

This file was deleted.

Loading

0 comments on commit 1e9e35e

Please sign in to comment.