Skip to content

Commit

Permalink
actions: build node addon for aarch linux via zig
Browse files Browse the repository at this point in the history
  • Loading branch information
eilvelia committed May 27, 2024
1 parent 5e8b782 commit cf22745
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
37 changes: 13 additions & 24 deletions .github/workflows/publish-tdl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,30 @@ jobs:
with:
node-version: lts/*
cache: npm
- uses: goto-bus-stop/setup-zig@v2
- name: Install dependencies
run: npm install
- name: Clean old binaries
run: npm run clean -w tdl
- name: Prebuildify in docker
- name: Prebuildify (Linux via zig)
if: runner.os == 'Linux'
run: |
# docker run -u root -v $(pwd):/app ghcr.io/prebuild/centos7-devtoolset7:2 \
# npm run make-prebuild -w tdl -- --tag-libc
cat > prebuilt-node-addon.sh <<EOF
set -ex
yum update -y
yum install -y centos-release-scl
yum install -y devtoolset-9 make python3
yum install https://rpm.nodesource.com/pub_16.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y
yum install nodejs -y --setopt=nodesource-nodejs.module_hotfixes=1
source /opt/rh/devtoolset-9/enable
gcc --version
ldd --version
cd /app
npm run make-prebuild -w tdl -- --tag-libc
EOF
docker run -v $(pwd):/app centos:7 \
bash /app/prebuilt-node-addon.sh
CC="zig cc -target x86_64-linux-gnu.2.17" CXX="zig c++ -target x86_64-linux-gnu.2.17" \
npm run make-prebuild -w tdl -- --arch x64 --tag-libc
CC="zig cc -target aarch64-linux-gnu.2.17" CXX="zig c++ -target aarch64-linux-gnu.2.17" \
npm run make-prebuild -w tdl -- --arch arm64 --armv 8 --tag-armv --tag-libc
ldd packages/tdl/prebuilds/*/*.node
du -hs packages/tdl/prebuilds/*/*.node
du -hsc packages/tdl/prebuilds/*/*.node
- name: Prebuildify
if: runner.os != 'Linux'
run: npm run make-prebuild -w tdl
run: npm run make-prebuild -w tdl -- --arch x64
- name: "Prebuildify: Crosscompile to arm64 Apple Silicon"
if: runner.os == 'macOS'
run: npm run make-prebuild -w tdl -- --arch arm64
- name: Install prebuilt-tdlib for TDLib v1.8.0
run: npm i -D [email protected]
- name: Run tests
run: |
npm run make-prebuild -w tdl -- --arch arm64
file packages/tdl/prebuilds/*/*.node
du -hsc packages/tdl/prebuilds/*/*.node
- name: Run tests (unit tests + integration tests)
run: npm run test:all
- uses: actions/upload-artifact@v3
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
is removed and replaced with `UnknownError`.
- Changed the default verbosity level from 2 to 1.
- Added `client.isClosed()`.
- Pre-built node addons now support aarch64 GNU/Linux.
- Removed deprecated client options: `receiveTimeout`, `useDefaultVerbosityLevel`,
`disableAuth`, `useMutableRename`, `verbosityLevel`.
- Removed the `bare` client option. `tdl.createBareClient(): Client` is added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ TDLib version 1.8.0 or newer is required.
- The tdjson shared library (`libtdjson.so` on Linux, `libtdjson.dylib` on macOS, `tdjson.dll` on Windows)
- In some cases, a C++ compiler and Python installed to build the node addon[^1]

[^1]: `tdl` is packaged with pre-built addons for Windows (x86_64), GNU/Linux (x86_64; glibc >= 2.17), and macOS (x86_64, aarch64; v10.14+). If a pre-built binary is not available for your system, then the node addon will be built using node-gyp, requiring Python and a C++ toolchain (C++14 is required) to be installed (on Windows, MSVS or Build Tools). Pass `--build-from-source` to never use the pre-built binaries. Note that macOS aarch64 binaries aren't tested.
[^1]: `tdl` is packaged with pre-built addons for Windows (x86_64), GNU/Linux (x86_64, arm64; glibc >= 2.17), and macOS (x86_64, arm64; v10.14+). If a pre-built binary is not available for your system, then the node addon will be built using node-gyp, requiring Python and a C++ toolchain (C++14 is required) to be installed (on Windows, MSVS or Build Tools). Pass `--build-from-source` to never use the pre-built binaries. arm64 binaries are not tested in the CI.

<a name="installation"></a>
## Installation
Expand Down

0 comments on commit cf22745

Please sign in to comment.