Skip to content

Commit 978a2db

Browse files
authored
Merge pull request tree-sitter#2178 from clason/master
ci: build CLI for macos-arm64
2 parents bbcf1e3 + 71f32a2 commit 978a2db

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
- { name: linux-x86 , target: i686-unknown-linux-gnu , os: ubuntu-latest , use-cross: true }
2727
- { name: windows-x64 , target: x86_64-pc-windows-msvc , os: windows-latest }
2828
- { name: windows-x86 , target: i686-pc-windows-msvc , os: windows-latest }
29+
- { name: macos-arm64 , target: aarch64-apple-darwin , os: macos-latest }
2930
- { name: macos-x64 , target: x86_64-apple-darwin , os: macos-latest }
3031

3132
env:
@@ -121,34 +122,38 @@ jobs:
121122
esac
122123
123124
- name: Build C library
124-
if: "!contains(matrix.job.os, 'windows')" # Requires an additional adapted Makefile for `cl.exe` compiler
125+
if: ${{ !contains(matrix.job.os, 'windows') }} # Requires an additional adapted Makefile for `cl.exe` compiler
125126
run: make.sh CFLAGS="-Werror" -j
126127

127128
- name: Build wasm library
129+
if: ${{ !matrix.job.use-cross && matrix.job.name != 'macos-arm64' }} # Not used
128130
run: script/build-wasm
129131

130132
- name: Build CLI
131133
run: $BUILD_CMD build --release --target=${{ matrix.job.target }}
132134

133135
- name: Fetch fixtures
136+
if: ${{ matrix.job.name != 'macos-arm64' }} # Not used
134137
run: script/fetch-fixtures
135138

136139
- name: Generate fixtures
140+
if: ${{ matrix.job.name != 'macos-arm64' }} # Can't natively run CLI on runner's host
137141
run: script/generate-fixtures
138142

139143
- name: Generate WASM fixtures
140-
if: "!matrix.job.use-cross"
144+
if: ${{ !matrix.job.use-cross && matrix.job.name != 'macos-arm64' }} # Not used
141145
run: script/generate-fixtures-wasm
142146

143147
- name: Run main tests
148+
if: ${{ matrix.job.name != 'macos-arm64' }} # Can't natively run CLI on runner's host
144149
run: $BUILD_CMD test --target=${{ matrix.job.target }}
145150

146151
- name: Run wasm tests
147-
if: "!matrix.job.use-cross" # TODO: Install Emscripten into custom cross images
152+
if: ${{ !matrix.job.use-cross && matrix.job.name != 'macos-arm64' }} # Not used
148153
run: script/test-wasm
149154

150155
- name: Run benchmarks
151-
if: "!matrix.job.use-cross" # It doesn't make sense to benchmark something in an emulator
156+
if: ${{ !matrix.job.use-cross && matrix.job.name != 'macos-arm64' }} # Cross-compiled benchmarks make no sense
152157
run: $BUILD_CMD bench benchmark -p tree-sitter-cli --target=${{ matrix.job.target }}
153158

154159
- name: Upload CLI artifact

cli/npm/install.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,10 @@ const platformName = {
1616
let archName = {
1717
'x64': 'x64',
1818
'x86': 'x86',
19-
'ia32': 'x86'
19+
'ia32': 'x86',
20+
'arm64': 'arm64'
2021
}[process.arch];
2122

22-
// ARM macs can run x64 binaries via Rosetta. Rely on that for now.
23-
if (platformName === 'macos' && process.arch === 'arm64') {
24-
archName = 'x64';
25-
}
26-
2723
if (!platformName || !archName) {
2824
console.error(
2925
`Cannot install tree-sitter-cli for platform ${process.platform}, architecture ${process.arch}`

0 commit comments

Comments
 (0)