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 22fb42c
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 332 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
19 changes: 7 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
*.gz
*.so
*.dylib

tsdl

lib/
tree-sitter*/
bash/
c/
embedded-template/
html/
java/
javascript/
json/
php/
python/
ruby/
rust/
tmp/
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.

10 changes: 2 additions & 8 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

dpkg-deb -Z none --build "$pkg" "lib/$pkg_name.deb"

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"/*."$ext" "$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"/*
Loading

0 comments on commit 22fb42c

Please sign in to comment.