Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build linux arm64 #65

Merged
merged 14 commits into from
Dec 16, 2024
111 changes: 81 additions & 30 deletions .github/workflows/DuckDBNodeBindingsAndAPI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ on:
pull_request:
workflow_dispatch:
inputs:
publish:
description: 'Publish'
type: boolean
required: true
default: false
publish_dry_run:
description: 'Publish Dry Run'
type: boolean
Expand All @@ -13,41 +18,51 @@ on:
type: boolean
required: true
default: false
publish_linux_x64:
description: 'Publish Bindings for Linux x64'
type: boolean
required: true
default: false
publish_bindings:
description: 'Publish Bindings (from Linux x64)'
type: boolean
required: true
default: false
publish_api:
description: 'Publish API (from Linux x64)'
# publish_linux_x64:
# description: 'Publish Bindings for Linux x64'
# type: boolean
# required: true
# default: false
# publish_bindings:
# description: 'Publish Bindings (from Linux x64)'
# type: boolean
# required: true
# default: false
# publish_api:
# description: 'Publish API (from Linux x64)'
# type: boolean
# required: true
# default: false
linux_arm64:
description: 'Run on Linux arm64'
type: boolean
required: true
default: false
# publish_linux_arm64:
# description: 'Publish Bindings for Linux arm64'
# type: boolean
# required: true
# default: false
macos_arm64:
description: 'Run on Mac OS X arm64'
type: boolean
required: true
default: false
publish_darwin_arm64:
description: 'Publish Bindings for Darwin arm64'
type: boolean
required: true
default: false
# publish_darwin_arm64:
# description: 'Publish Bindings for Darwin arm64'
# type: boolean
# required: true
# default: false
windows_x64:
description: 'Run on Windows x64'
type: boolean
required: true
default: false
publish_win32_x64:
description: 'Publish Bindings for Win32 x64'
type: boolean
required: true
default: false
# publish_win32_x64:
# description: 'Publish Bindings for Win32 x64'
# type: boolean
# required: true
# default: false
repository_dispatch:

concurrency:
Expand Down Expand Up @@ -87,30 +102,66 @@ jobs:
run: pnpm test

- name: Git Status
if: ${{ inputs.publish_linux_x64 || inputs.publish_bindings || inputs.publish_api }}
if: ${{ inputs.publish }}
run: git status

- name: Publish - Bindings - Linux x64
if: ${{ inputs.publish_linux_x64 }}
if: ${{ inputs.publish }}
working-directory: bindings/pkgs/@duckdb/node-bindings-linux-x64
run: pnpm publish ${{ inputs.publish_dry_run && '--dry-run' || '' }} --publish-branch ${{ github.ref_name }} --access public
env:
NPM_AUTH_TOKEN: ${{ secrets.DUCKDB_NPM_TOKEN }}

- name: Publish - Bindings
if: ${{ inputs.publish_bindings }}
if: ${{ inputs.publish }}
working-directory: bindings/pkgs/@duckdb/node-bindings
run: pnpm publish ${{ inputs.publish_dry_run && '--dry-run' || '' }} --publish-branch ${{ github.ref_name }} --access public
env:
NPM_AUTH_TOKEN: ${{ secrets.DUCKDB_NPM_TOKEN }}

- name: Publish - API
if: ${{ inputs.publish_api }}
if: ${{ inputs.publish }}
working-directory: api/pkgs/@duckdb/node-api
run: pnpm publish ${{ inputs.publish_dry_run && '--dry-run' || '' }} --publish-branch ${{ github.ref_name }} --access public
env:
NPM_AUTH_TOKEN: ${{ secrets.DUCKDB_NPM_TOKEN }}

linux_arm64:
name: Linux arm64
runs-on: ubuntu-latest
if: ${{ github.event_name != 'workflow_dispatch' || inputs.linux_arm64 }}
env:
TARGET_ARCH: arm64
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
steps:
- name: Install aarch64 compilers
run: sudo apt install binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu

- uses: actions/checkout@v4

- uses: pnpm/action-setup@v3
with:
version: 9

- name: Workspace - Install
run: pnpm install --ignore-scripts

- name: Bindings - Build
working-directory: bindings
run: pnpm run build

- name: Git Status
if: ${{ inputs.publish }}
run: git status

- name: Publish - Bindings - Linux arm64
if: ${{ inputs.publish }}
working-directory: bindings/pkgs/@duckdb/node-bindings-linux-arm64
run: pnpm publish ${{ inputs.publish_dry_run && '--dry-run' || '' }} --publish-branch ${{ github.ref_name }} --access public
env:
NPM_AUTH_TOKEN: ${{ secrets.DUCKDB_NPM_TOKEN }}

macos_arm64:
name: Mac OS X arm64
runs-on: macos-latest
Expand Down Expand Up @@ -142,11 +193,11 @@ jobs:
run: pnpm test

- name: Git Status
if: ${{ inputs.publish_darwin_arm64 }}
if: ${{ inputs.publish }}
run: git status

- name: Publish - Bindings - Darwin arm64
if: ${{ inputs.publish_darwin_arm64 }}
if: ${{ inputs.publish }}
working-directory: bindings/pkgs/@duckdb/node-bindings-darwin-arm64
run: pnpm publish ${{ inputs.publish_dry_run && '--dry-run' || '' }} --publish-branch ${{ github.ref_name }} --access public
env:
Expand Down Expand Up @@ -183,11 +234,11 @@ jobs:
run: pnpm test

- name: Git Status
if: ${{ inputs.publish_win32_x64 }}
if: ${{ inputs.publish }}
run: git status

- name: Publish - Bindings - Win32 x64
if: ${{ inputs.publish_win32_x64 }}
if: ${{ inputs.publish }}
working-directory: bindings/pkgs/@duckdb/node-bindings-win32-x64
run: pnpm publish ${{ inputs.publish_dry_run && '--dry-run' || '' }} --publish-branch ${{ github.ref_name }} --access public
env:
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [@duckdb/node-api](api/pkgs/@duckdb/node-api/README.md)
- [@duckdb/node-bindings](bindings/pkgs/@duckdb/node-bindings/README.md)
- [@duckdb/node-bindings-darwin-arm64](bindings/pkgs/@duckdb/node-bindings-darwin-arm64/README.md)
- [@duckdb/node-bindings-linux-arm64](bindings/pkgs/@duckdb/node-bindings-linux-x64/README.md)
- [@duckdb/node-bindings-linux-x64](bindings/pkgs/@duckdb/node-bindings-linux-x64/README.md)
- [@duckdb/node-bindings-win32-x64](bindings/pkgs/@duckdb/node-bindings-win32-x64/README.md)

Expand All @@ -17,6 +18,7 @@
- [@duckdb/node-api](https://www.npmjs.com/package/@duckdb/node-api)
- [@duckdb/node-bindings](https://www.npmjs.com/package/@duckdb/node-bindings)
- [@duckdb/node-bindings-darwin-arm64](https://www.npmjs.com/package/@duckdb/node-bindings-darwin-arm64)
- [@duckdb/node-bindings-linux-arm64](https://www.npmjs.com/package/@duckdb/node-bindings-linux-x64)
- [@duckdb/node-bindings-linux-x64](https://www.npmjs.com/package/@duckdb/node-bindings-linux-x64)
- [@duckdb/node-bindings-win32-x64](https://www.npmjs.com/package/@duckdb/node-bindings-win32-x64)

Expand Down Expand Up @@ -46,12 +48,14 @@ Change version in:
- `api/pkgs/@duckdb/node-api/package.json`
- `bindings/pkgs/@duckdb/node-bindings/package.json`
- `bindings/pkgs/@duckdb/node-bindings-darwin-arm64/package.json`
- `bindings/pkgs/@duckdb/node-bindings-linux-arm64/package.json`
- `bindings/pkgs/@duckdb/node-bindings-linux-x64/package.json`
- `bindings/pkgs/@duckdb/node-bindings-win32-x64/package.json`

### Upgrade DuckDB Version

Change version in:
- `bindings/scripts/fetch_libduckdb_linux_aarch64.py`
- `bindings/scripts/fetch_libduckdb_linux_amd64.py`
- `bindings/scripts/fetch_libduckdb_osx_universal.py`
- `bindings/scripts/fetch_libduckdb_windows_amd64.py`
Expand Down
1 change: 1 addition & 0 deletions api/pkgs/@duckdb/node-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Some features are not yet complete:

### Supported Platforms

- Linux arm64 (experimental)
- Linux x64
- Mac OS X (Darwin) arm64 (Apple Silicon)
- Windows (Win32) x64
Expand Down
28 changes: 28 additions & 0 deletions bindings/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
'script_path': '<(module_root_dir)/scripts/fetch_libduckdb_linux_amd64.py',
},
}],
['OS=="linux" and target_arch=="arm64"', {
'variables': {
'script_path': '<(module_root_dir)/scripts/fetch_libduckdb_linux_aarch64.py',
},
}],
['OS=="mac"', {
'variables': {
'script_path': '<(module_root_dir)/scripts/fetch_libduckdb_osx_universal.py',
Expand Down Expand Up @@ -54,6 +59,21 @@
},
],
}],
['OS=="linux" and target_arch=="arm64"', {
'link_settings': {
'libraries': [
'-lduckdb',
'-L<(module_root_dir)/libduckdb',
'-Wl,-rpath,\'$$ORIGIN\'',
],
},
'copies': [
{
'files': ['<(module_root_dir)/libduckdb/libduckdb.so'],
'destination': '<(module_root_dir)/pkgs/@duckdb/node-bindings-linux-arm64',
},
],
}],
['OS=="mac"', {
'cflags+': ['-fvisibility=hidden'],
'xcode_settings': {
Expand Down Expand Up @@ -101,6 +121,14 @@
},
],
}],
['OS=="linux" and target_arch=="arm64"', {
'copies': [
{
'files': ['<(module_root_dir)/build/Release/duckdb.node'],
'destination': '<(module_root_dir)/pkgs/@duckdb/node-bindings-linux-arm64',
},
],
}],
['OS=="mac"', {
'copies': [
{
Expand Down
3 changes: 2 additions & 1 deletion bindings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"scripts": {
"build": "npm run build:package && npm run build:test",
"build:package": "node-gyp configure && node-gyp build",
"build:package": "cross-replace node-gyp configure --verbose --arch=$TARGET_ARCH && node-gyp build --verbose --arch=$TARGET_ARCH",
"build:test": "tsc -b test",
"clean": "npm run clean:gyp && npm run clean:libduckdb && npm run clean:package",
"clean:gyp": "node-gyp clean",
Expand All @@ -13,6 +13,7 @@
},
"dependencies": {
"@duckdb/node-bindings": "workspace:*",
"cross-replace": "^0.2.0",
"node-addon-api": "^8.3.0",
"node-gyp": "^10.3.1",
"rimraf": "^5.0.10",
Expand Down
1 change: 1 addition & 0 deletions bindings/pkgs/@duckdb/node-bindings-linux-arm64/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}
5 changes: 5 additions & 0 deletions bindings/pkgs/@duckdb/node-bindings-linux-arm64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# DuckDB Node Bindings: Linux arm64 (experimental)

Binaries supporting [Node](https://nodejs.org/) bindings to the [DuckDB C API](https://duckdb.org/docs/api/c/overview) for Linux arm64. These are experimental; they are not fully tested.

See [@duckdb/node-bindings](https://www.npmjs.com/package/@duckdb/node-bindings) for a low-level API that uses these binaries, or [@duckdb/node-api](https://www.npmjs.com/package/@duckdb/node-api) for a high-level API built on those bindings.
14 changes: 14 additions & 0 deletions bindings/pkgs/@duckdb/node-bindings-linux-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@duckdb/node-bindings-linux-arm64",
"version": "1.1.3-alpha.6",
"os": [
"linux"
],
"cpu": [
"arm64"
],
"repository": {
"type": "git",
"url": "https://github.com/duckdb/duckdb-node-neo.git"
}
}
1 change: 1 addition & 0 deletions bindings/pkgs/@duckdb/node-bindings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ See [@duckdb/node-api](https://www.npmjs.com/package/@duckdb/node-api) for a hig

### Supported Platforms

- Linux arm64 (experimental)
- Linux x64
- Mac OS X (Darwin) arm64 (Apple Silicon)
- Windows (Win32) x64
1 change: 1 addition & 0 deletions bindings/pkgs/@duckdb/node-bindings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"types": "./duckdb.d.ts",
"optionalDependencies": {
"@duckdb/node-bindings-darwin-arm64": "workspace:*",
"@duckdb/node-bindings-linux-arm64": "workspace:*",
"@duckdb/node-bindings-linux-x64": "workspace:*",
"@duckdb/node-bindings-win32-x64": "workspace:*"
},
Expand Down
11 changes: 11 additions & 0 deletions bindings/scripts/fetch_libduckdb_linux_aarch64.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os
from fetch_libduckdb import fetch_libduckdb

zip_url = "https://github.com/duckdb/duckdb/releases/download/v1.1.3/libduckdb-linux-aarch64.zip"
output_dir = os.path.join(os.path.dirname(__file__), "..", "libduckdb")
files = [
"duckdb.h",
"libduckdb.so",
]

fetch_libduckdb(zip_url, output_dir, files)
16 changes: 16 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading