Skip to content

Commit be47627

Browse files
refactor(lib)!: build using cmake
1 parent 82b255b commit be47627

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
name: Generate parser
3131
runs-on: ubuntu-latest
3232
steps:
33-
- uses: tree-sitter/setup-action@v1
33+
- uses: tree-sitter/setup-action@v2
3434
with:
3535
install-lib: false
3636
- run: tree-sitter generate

lib/action.yml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ inputs:
55
tree-sitter-ref:
66
description: A tree-sitter commit, tag, or branch
77
default: latest
8+
wasmtime:
9+
description: Enable wasmtime
10+
default: "false"
811

912
runs:
1013
using: composite
@@ -34,18 +37,39 @@ runs:
3437
working-directory: ${{runner.temp}}
3538
shell: bash
3639
run: |-
37-
printf '::group::Installing the tree-sitter library\n'
40+
printf '::group::Cloning tree-sitter\n'
41+
3842
git clone "$TREE_SITTER_REPO" tree-sitter -q --filter=blob:none
3943
cd tree-sitter && git checkout "$TREE_SITTER_REF"
40-
make PREFIX="$RUNNER_TOOL_CACHE/tree-sitter/lib"
41-
make PREFIX="$RUNNER_TOOL_CACHE/tree-sitter/lib" install
44+
45+
cmake -S lib -B build -G Ninja \
46+
-DBUILD_SHARED_LIBS=OFF \
47+
-DCMAKE_INSTALL_PREFIX="$TREE_SITTER_LIB"
48+
cmake --build build && cmake --install build
49+
50+
cmake -S lib -B build -G Ninja \
51+
-DBUILD_SHARED_LIBS=ON \
52+
-DCMAKE_INSTALL_PREFIX="$RUNNER_TOOL_CACHE/tree-sitter/lib"
53+
cmake --build build && cmake --install build
54+
4255
printf '::endgroup::\n'
4356
- name: Set up library paths
4457
shell: sh
4558
run: |-
46-
printf '%s\n' >> "$GITHUB_ENV" \
47-
"LD_LIBRARY_PATH=$RUNNER_TOOL_CACHE/tree-sitter/lib/lib" \
48-
"PKG_CONFIG_PATH=$RUNNER_TOOL_CACHE/tree-sitter/lib/lib/pkgconfig"
59+
PREFIX="$RUNNER_TOOL_CACHE/tree-sitter/lib"
60+
printf 'PKG_CONFIG_PATH=%s/lib/pkgconfig\n' >> "$GITHUB_ENV" \
61+
"${PKG_CONFIG_PATH}${PKG_CONFIG_PATH+:}${PREFIX}"
62+
if [[ $RUNNER_OS == Linux ]]; then
63+
printf 'LD_LIBRARY_PATH=%s/lib\n' >> "$GITHUB_ENV" \
64+
"${LD_LIBRARY_PATH}${LD_LIBRARY_PATH+:}${PREFIX}"
65+
else if [[ $RUNNER_OS == macOS ]]; then
66+
printf 'DYLD_LIBRARY_PATH=%s/lib\n' >> "$GITHUB_ENV" \
67+
"${DYLD_LIBRARY_PATH}${DYLD_LIBRARY_PATH+:}${PREFIX}"
68+
else
69+
printf '%s/lib\n' "$PREFIX" >> "$GITHUB_PATH"
70+
fi
71+
env:
72+
PATH_SEP: ${{runner.os != 'Windows' && ':' || ';'}}
4973
- name: Save tree-sitter library to cache
5074
uses: actions/cache/save@v4
5175
if: >-

0 commit comments

Comments
 (0)