Skip to content

Commit 2bdc76a

Browse files
ObserverOfTimeamaanq
authored andcommitted
build: switch to prebuildify
1 parent 245510c commit 2bdc76a

File tree

4 files changed

+86
-89
lines changed

4 files changed

+86
-89
lines changed

.github/workflows/build.yml

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ on:
44
push:
55
branches:
66
- master
7+
tags:
8+
- v*
79
pull_request:
810
branches:
911
- master
10-
release:
11-
types:
12-
- released
1312

14-
env:
15-
PREBUILD_CMD: npx prebuild -r napi --all --strip -u ${{ secrets.GH_TOKEN }}
13+
concurrency:
14+
group: ${{github.workflow}}-${{github.ref}}
15+
cancel-in-progress: true
1616

17-
jobs:
1817

18+
jobs:
1919
test:
2020
strategy:
2121
matrix:
2222
os:
23-
- windows-2019
23+
- windows-2022
2424
- macos-14
25-
- ubuntu-20.04
25+
- ubuntu-22.04
2626
node:
2727
- 18
2828
- 20
@@ -37,15 +37,23 @@ jobs:
3737
- uses: actions/setup-node@v4
3838
with:
3939
node-version: ${{ matrix.node }}
40-
4140
- run: npm install
41+
- run: npm run build -- --arch x64
42+
- if: runner.os == 'macOS'
43+
run: npm run build -- --arch arm64
4244
- run: npm test
45+
- uses: actions/upload-artifact@v4
46+
if: github.ref_type == 'tag' && matrix.node == 20
47+
with:
48+
path: prebuilds/**
49+
name: prebuilds-${{matrix.os}}
50+
retention-days: 2
4351

4452
publish:
45-
if: ${{ github.event_name == 'release' }}
53+
if: github.ref_type == 'tag'
4654
name: Publish to npm
47-
runs-on: ubuntu-20.04
48-
needs: test
55+
runs-on: ubuntu-22.04
56+
needs: [test]
4957
steps:
5058
- uses: actions/checkout@v4
5159
with:
@@ -55,31 +63,13 @@ jobs:
5563
with:
5664
node-version: 20
5765
registry-url: https://registry.npmjs.org
66+
- uses: actions/download-artifact@v4
67+
with:
68+
path: prebuilds
69+
pattern: prebuilds-*
70+
merge-multiple: true
71+
- run: tree prebuilds
5872
- run: npm install
59-
- run: npm publish --access public
73+
- run: npm publish
6074
env:
6175
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
62-
63-
prebuild:
64-
strategy:
65-
matrix:
66-
os:
67-
- windows-2019
68-
- macos-14
69-
- ubuntu-20.04
70-
fail-fast: false
71-
name: Prebuild for ${{ matrix.os }}
72-
runs-on: ${{ matrix.os }}
73-
needs: publish
74-
steps:
75-
- uses: actions/checkout@v4
76-
with:
77-
submodules: true
78-
fetch-depth: 0
79-
- uses: actions/setup-node@v4
80-
with:
81-
node-version: 20
82-
- run: npm install
83-
- run: ${{ env.PREBUILD_CMD }}
84-
- if: runner.os == 'macOS'
85-
run: ${{ env.PREBUILD_CMD }} --arch arm64

binding.gyp

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"targets": [
33
{
44
"target_name": "tree_sitter_runtime_binding",
5-
"dependencies": ["tree_sitter", "<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except"],
5+
"dependencies": [
6+
"tree_sitter",
7+
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
8+
],
69
"sources": [
710
"src/binding.cc",
811
"src/conversions.cc",
@@ -21,40 +24,40 @@
2124
"defines": [
2225
"NAPI_VERSION=<(napi_build_version)",
2326
],
24-
'cflags': [
25-
'-std=c++17'
27+
"cflags": [
28+
"-std=c++17"
2629
],
27-
'cflags_cc': [
28-
'-std=c++17'
30+
"cflags_cc": [
31+
"-std=c++17"
2932
],
30-
'conditions': [
31-
['OS=="mac"', {
32-
'xcode_settings': {
33-
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
34-
'CLANG_CXX_LANGUAGE_STANDARD': 'c++17',
35-
'MACOSX_DEPLOYMENT_TARGET': '10.9',
33+
"conditions": [
34+
["OS=='mac'", {
35+
"xcode_settings": {
36+
"GCC_SYMBOLS_PRIVATE_EXTERN": "YES", # -fvisibility=hidden
37+
"CLANG_CXX_LANGUAGE_STANDARD": "c++17",
38+
"MACOSX_DEPLOYMENT_TARGET": "10.9",
3639
},
3740
}],
38-
['OS=="win"', {
39-
'msvs_settings': {
40-
'VCCLCompilerTool': {
41-
'AdditionalOptions': [
42-
'/std:c++17',
41+
["OS=='win'", {
42+
"msvs_settings": {
43+
"VCCLCompilerTool": {
44+
"AdditionalOptions": [
45+
"/std:c++17",
4346
],
44-
'RuntimeLibrary': 0,
47+
"RuntimeLibrary": 0,
4548
},
4649
},
4750
}],
48-
['OS == "linux"', {
49-
'cflags_cc': [
50-
'-Wno-cast-function-type'
51+
["OS == 'linux'", {
52+
"cflags_cc": [
53+
"-Wno-cast-function-type"
5154
]
5255
}],
5356
]
5457
},
5558
{
5659
"target_name": "tree_sitter",
57-
'type': 'static_library',
60+
"type": "static_library",
5861
"sources": [
5962
"vendor/tree-sitter/lib/src/lib.c"
6063
],
@@ -63,14 +66,14 @@
6366
"vendor/tree-sitter/lib/include",
6467
],
6568
"cflags": [
66-
"-std=c99"
69+
"-std=c11"
6770
]
6871
}
6972
],
70-
'variables': {
71-
'runtime%': 'node',
72-
'openssl_fips': '',
73-
'v8_enable_pointer_compression%': 0,
74-
'v8_enable_31bit_smis_on_64bit_arch%': 0,
73+
"variables": {
74+
"runtime%": "node",
75+
"openssl_fips": "",
76+
"v8_enable_pointer_compression%": 0,
77+
"v8_enable_31bit_smis_on_64bit_arch%": 0,
7578
}
7679
}

index.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
let binding;
2-
try {
3-
binding = require('./build/Release/tree_sitter_runtime_binding');
4-
} catch (e) {
5-
try {
6-
binding = require('./build/Debug/tree_sitter_runtime_binding');
7-
} catch (_) {
8-
throw e;
9-
}
10-
}
11-
12-
const util = require('util')
1+
const binding = require('node-gyp-build')(__dirname);
132
const {Query, Parser, NodeMethods, Tree, TreeCursor, LookaheadIterator} = binding;
143

4+
const util = require('util');
5+
156
/*
167
* Tree
178
*/

package.json

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,43 @@
11
{
22
"name": "tree-sitter",
3-
"version": "0.20.6",
3+
"version": "0.21.0",
44
"description": "Incremental parsers for node",
55
"author": "Max Brunsfeld",
6+
"contributors": [
7+
"Segev Finer",
8+
"Boris Verkhovskiy",
9+
"Amaan Qureshi"
10+
],
611
"license": "MIT",
712
"repository": {
813
"type": "git",
914
"url": "http://github.com/tree-sitter/node-tree-sitter.git"
1015
},
1116
"keywords": [
12-
"parser",
13-
"lexer"
17+
"incremental",
18+
"parsing",
19+
"tree-sitter"
1420
],
1521
"main": "index.js",
1622
"types": "tree-sitter.d.ts",
23+
"files": [
24+
"binding.gyp",
25+
"tree-sitter.d.ts",
26+
"prebuilds/*",
27+
"src/*",
28+
"vendor/tree-sitter/lib/include/*",
29+
"vendor/tree-sitter/lib/src/*"
30+
],
1731
"dependencies": {
1832
"node-addon-api": "^7.1.0",
19-
"prebuild-install": "^7.1.1"
33+
"node-gyp-build": "^4.8.0"
2034
},
2135
"devDependencies": {
2236
"@types/node": "^20.11.16",
2337
"chai": "^4.3.10",
2438
"mocha": "^8.4.0",
2539
"node-gyp": "^10.0.1",
26-
"prebuild": "^13.0.0",
40+
"prebuildify": "^6.0.0",
2741
"tmp": "^0.2.1",
2842
"tree-sitter-c": "github:amaanq/tree-sitter-c#napi",
2943
"tree-sitter-embedded-template": "github:tree-sitter/tree-sitter-embedded-template#napi",
@@ -32,17 +46,16 @@
3246
"tree-sitter-javascript": "github:amaanq/tree-sitter-javascript#napi",
3347
"tree-sitter-json": "github:tree-sitter/tree-sitter-json#napi",
3448
"tree-sitter-python": "github:amaanq/tree-sitter-python#napi",
35-
"tree-sitter-rust": "github:amaanq/tree-sitter-rust#napi",
36-
"tree-sitter-ruby": "github:tree-sitter/tree-sitter-ruby#napi"
49+
"tree-sitter-ruby": "github:tree-sitter/tree-sitter-ruby#napi",
50+
"tree-sitter-rust": "github:amaanq/tree-sitter-rust#napi"
3751
},
3852
"scripts": {
39-
"install": "prebuild-install -r napi || node-gyp rebuild",
40-
"build": "node-gyp build",
53+
"install": "node-gyp-build",
54+
"build": "prebuildify --napi --strip",
55+
"rebuild": "node-gyp rebuild",
4156
"test": "mocha"
4257
},
43-
"binary": {
44-
"napi_versions": [
45-
8
46-
]
58+
"publishConfig": {
59+
"access": "public"
4760
}
4861
}

0 commit comments

Comments
 (0)