Skip to content

Commit

Permalink
actions: build node addon using zig, add aarch64 linux
Browse files Browse the repository at this point in the history
  • Loading branch information
eilvelia committed May 28, 2024
1 parent 5e8b782 commit c31959d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 32 deletions.
52 changes: 22 additions & 30 deletions .github/workflows/publish-tdl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,36 @@ jobs:
with:
node-version: lts/*
cache: npm
- uses: goto-bus-stop/setup-zig@v2
if: runner.os == 'Linux'
- 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
ldd packages/tdl/prebuilds/*/*.node
du -hs packages/tdl/prebuilds/*/*.node
- name: Prebuildify
CC="zig cc -target x86_64-linux-gnu.2.17" CXX="zig c++ -target x86_64-linux-gnu.2.17 -s" \
npm run make-prebuild -w tdl -- --arch x64 --tag-libc --strip
CC="zig cc -target aarch64-linux-gnu.2.17" CXX="zig c++ -target aarch64-linux-gnu.2.17 -s" \
npm run make-prebuild -w tdl -- --arch arm64 --armv 8 --tag-armv --tag-libc
ldd packages/tdl/prebuilds/*-x64/*.node
file packages/tdl/prebuilds/*/*.node
du -hsc packages/tdl/prebuilds/*/*.node
- name: Prebuildify (x86_64 only)
if: runner.os != 'Linux'
run: npm run make-prebuild -w tdl
run: npm run make-prebuild -w tdl -- --arch x64 --strip
- 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 --strip
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
- uses: actions/upload-artifact@v4
with:
name: tdl-prebuilds
name: tdl-prebuilds-${{ matrix.os }}
path: packages/tdl/prebuilds

publish:
Expand All @@ -83,10 +74,11 @@ jobs:
run: python3 -m pip install packaging
- name: Install dependencies
run: npm install
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: tdl-prebuilds
pattern: tdl-prebuilds-*
path: packages/tdl/prebuilds
merge-multiple: true
- run: tree packages/tdl/prebuilds
- name: Ensure prebuilts exist
run: (( $(ls packages/tdl/prebuilds | wc -l) > 3 ))
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. Only Linux binaries are statically linked against libstdc++.

<a name="installation"></a>
## Installation
Expand Down
2 changes: 1 addition & 1 deletion packages/tdl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build:lib": "tsc",
"build:addon": "node-gyp rebuild",
"build": "tsc && node scripts/copy-readme.js && node scripts/generate-flow.js && node-gyp rebuild",
"make-prebuild": "prebuildify --napi -t 18.20.2 --strip",
"make-prebuild": "prebuildify --napi -t 18.20.2",
"clean": "node-gyp clean",
"install": "node-gyp-build"
},
Expand Down

0 comments on commit c31959d

Please sign in to comment.