From 52f22a65eb7153aca6563372425c4c79a84242b9 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 6 Apr 2023 14:24:19 +0200 Subject: [PATCH] cicd: build CLI for macos-arm64 --- .github/workflows/build.yml | 12 +++++++++--- cli/npm/install.js | 8 ++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cf3628a1..d4a68a06 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,7 @@ env: CROSS_DEBUG: 1 on: + workflow_dispatch: workflow_call: inputs: ref: @@ -27,6 +28,7 @@ jobs: - { name: windows-x64 , target: x86_64-pc-windows-msvc , os: windows-latest } - { name: windows-x86 , target: i686-pc-windows-msvc , os: windows-latest } - { name: macos-x64 , target: x86_64-apple-darwin , os: macos-latest } + - { name: macos-arm64 , target: aarch64-apple-darwin , os: macos-latest } env: BUILD_CMD: cargo @@ -125,30 +127,34 @@ jobs: run: make.sh CFLAGS="-Werror" -j - name: Build wasm library + if: ${{ !matrix.job.use-cross && matrix.job.name != 'macos-arm64' }} # Not used run: script/build-wasm - name: Build CLI run: $BUILD_CMD build --release --target=${{ matrix.job.target }} - name: Fetch fixtures + if: ${{ matrix.job.name != 'macos-arm64' }} # Not used run: script/fetch-fixtures - name: Generate fixtures + if: ${{ matrix.job.name != 'macos-arm64' }} # Can't run CLI on host run: script/generate-fixtures - name: Generate WASM fixtures - if: "!matrix.job.use-cross" + if: ${{ !matrix.job.use-cross && matrix.job.name != 'macos-arm64' }} # Not used run: script/generate-fixtures-wasm - name: Run main tests + if: ${{ matrix.job.name != 'macos-arm64' }} # Can't run CLI on host run: $BUILD_CMD test --target=${{ matrix.job.target }} - name: Run wasm tests - if: "!matrix.job.use-cross" # TODO: Install Emscripten into custom cross images + if: ${{ !matrix.job.use-cross && matrix.job.name != 'macos-arm64' }} # Not used run: script/test-wasm - name: Run benchmarks - if: "!matrix.job.use-cross" # It doesn't make sense to benchmark something in an emulator + if: ${{ !matrix.job.use-cross && matrix.job.name != 'macos-arm64' }} # Cross-compiled benchmarks make no sense run: $BUILD_CMD bench benchmark -p tree-sitter-cli --target=${{ matrix.job.target }} - name: Upload CLI artifact diff --git a/cli/npm/install.js b/cli/npm/install.js index 2790b47d..9e572c3a 100755 --- a/cli/npm/install.js +++ b/cli/npm/install.js @@ -16,14 +16,10 @@ const platformName = { let archName = { 'x64': 'x64', 'x86': 'x86', - 'ia32': 'x86' + 'ia32': 'x86', + 'arm64': 'arm64' }[process.arch]; -// ARM macs can run x64 binaries via Rosetta. Rely on that for now. -if (platformName === 'macos' && process.arch === 'arm64') { - archName = 'x64'; -} - if (!platformName || !archName) { console.error( `Cannot install tree-sitter-cli for platform ${process.platform}, architecture ${process.arch}`