Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ on:

jobs:
build-test:
name: Build & Test (${{ matrix.os }})
name: Build & Test (${{ matrix.os }}${{ matrix.cross && ' xarch' || '' }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-14, windows-2022]
cross: [false, true]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -22,19 +23,43 @@ jobs:
with:
node-version: '22.x'

- name: Set architecture
id: arch
shell: bash
run: |
if [ "${{ runner.os }}" = "macOS" ]; then
echo "arch=${{ matrix.cross && 'x64' || 'arm64' }}" >> $GITHUB_OUTPUT
else
echo "arch=${{ matrix.cross && 'arm64' || 'x64' }}" >> $GITHUB_OUTPUT
fi

- name: Install sysroot
if: runner.os == 'Linux'
run: |
sudo apt-get update -qq
sudo apt-get install -y gcc-10 g++-10
SYSROOT_PATH=$(node scripts/linux/install-sysroot.js x64 | grep "SYSROOT_PATH=" | cut -d= -f2)
if [ "${{ steps.arch.outputs.arch }}" = "arm64" ]; then
sudo apt-get install -y gcc-10-aarch64-linux-gnu g++-10-aarch64-linux-gnu
echo "CC=aarch64-linux-gnu-gcc-10" >> $GITHUB_ENV
echo "CXX=aarch64-linux-gnu-g++-10" >> $GITHUB_ENV
else
sudo apt-get install -y gcc-10 g++-10
echo "CC=gcc-10" >> $GITHUB_ENV
echo "CXX=g++-10" >> $GITHUB_ENV
fi
SYSROOT_PATH=$(node scripts/linux/install-sysroot.js ${{ steps.arch.outputs.arch }} | grep "SYSROOT_PATH=" | cut -d= -f2)
echo "SYSROOT_PATH=$SYSROOT_PATH" >> $GITHUB_ENV
echo "Sysroot path set to: $SYSROOT_PATH"
echo "CC=gcc-10" >> $GITHUB_ENV
echo "CXX=g++-10" >> $GITHUB_ENV

- name: Install dependencies and build
run: npm ci
env:
ARCH: ${{ steps.arch.outputs.arch }}
npm_config_arch: ${{ steps.arch.outputs.arch }}

- name: Debug built files
shell: bash
run: |
ls -lR ./

- name: Verify GLIBC requirements
if: runner.os == 'Linux'
Expand All @@ -45,7 +70,9 @@ jobs:
./scripts/linux/verify-glibc-requirements.sh

- name: Test
if: ${{ !matrix.cross }}
run: npm test

- name: Lint
if: ${{ !matrix.cross }}
run: npm run lint
12 changes: 9 additions & 3 deletions pipelines/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ steps:
- bash: |
if [ "$(uname)" = "Linux" ]; then
sudo apt-get update -qq
sudo apt-get install -y gcc-10 g++-10
if [ "${{ parameters.arch }}" = "arm64" ]; then
sudo apt-get install -y gcc-10-aarch64-linux-gnu g++-10-aarch64-linux-gnu
echo "##vso[task.setvariable variable=CC]aarch64-linux-gnu-gcc-10"
echo "##vso[task.setvariable variable=CXX]aarch64-linux-gnu-g++-10"
else
sudo apt-get install -y gcc-10 g++-10
echo "##vso[task.setvariable variable=CC]gcc-10"
echo "##vso[task.setvariable variable=CXX]g++-10"
fi
SYSROOT_PATH=$(node scripts/linux/install-sysroot.js ${{ parameters.arch }} | grep "SYSROOT_PATH=" | cut -d= -f2)
echo "##vso[task.setvariable variable=SYSROOT_PATH]$SYSROOT_PATH"
echo "##vso[task.setvariable variable=CC]gcc-10"
echo "##vso[task.setvariable variable=CXX]g++-10"
echo "Sysroot path set to: $SYSROOT_PATH"
fi
displayName: 'Install sysroot (Linux only)'
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function loadNativeModule(name: string): {dir: string, module: any} {
let lastError: unknown;
for (const d of dirs) {
for (const r of relative) {
const dir = `${r}/${d}/`;
const dir = `${r}/${d}`;
try {
return { dir, module: require(`${dir}/${name}.node`) };
} catch (e) {
Expand Down