feat(cli): add support for armv7-unknown-linux-muslebihf (#2019)

This commit is contained in:
翠 / green 2024-04-08 22:04:57 +09:00 committed by GitHub
parent 71a528535a
commit 7ae562352a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 57 additions and 8 deletions

View file

@ -376,7 +376,7 @@ jobs:
ls -la ./cores
build-and-test-linux-armv7:
name: stable - armv7-unknown-linux-gnu - node@18
name: stable - armv7-unknown-linux-gnueabihf - node@20
runs-on: ubuntu-latest
steps:
@ -401,7 +401,7 @@ jobs:
~/.cargo/registry
~/.cargo/git
target
key: stable-linux-armv7-gnu-node@18-cargo-cache
key: stable-linux-armv7-gnueabihf-node@20-cargo-cache
- name: Install dependencies
run: |

View file

@ -26,6 +26,7 @@ jobs:
'x86_64-apple-darwin',
'x86_64-unknown-linux-musl',
'aarch64-unknown-linux-musl',
'armv7-unknown-linux-musleabihf',
]
steps:
@ -49,8 +50,6 @@ jobs:
~/.cargo/git
target
key: stable-zig-${{ matrix.target }}-cargo-cache
- name: Install aarch64 toolchain
run: rustup target add aarch64-unknown-linux-gnu
- name: Install ziglang
uses: goto-bus-stop/setup-zig@v2
with:
@ -94,6 +93,10 @@ jobs:
target: x86_64-apple-darwin
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
docker-platform: arm64
- host: ubuntu-latest
target: armv7-unknown-linux-musleabihf
docker-platform: arm/v7
steps:
- uses: actions/checkout@v4
@ -105,7 +108,7 @@ jobs:
- name: Install dependencies
run: |
yarn config set --json supportedArchitectures.libc '["current", "musl"]'
yarn config set --json supportedArchitectures.cpu '["current", "arm64"]'
yarn config set --json supportedArchitectures.cpu '["current", "arm64", "arm"]'
yarn install --immutable --mode=skip-build
- name: Download artifacts
uses: actions/download-artifact@v4
@ -130,13 +133,23 @@ jobs:
if: matrix.settings.host == 'ubuntu-latest'
- name: Test
uses: addnab/docker-run-action@v3
if: matrix.settings.target == 'aarch64-unknown-linux-musl'
if: matrix.settings.host == 'ubuntu-latest' && matrix.settings.target != 'x86_64-unknown-linux-musl' && matrix.settings.target != 'armv7-unknown-linux-musleabihf'
with:
image: node:lts-alpine
options: --platform linux/arm64 -v ${{ github.workspace }}:/build -w /build
options: --platform linux/${{ matrix.settings.docker-platform }} -v ${{ github.workspace }}:/build -w /build
run: |
set -e
yarn test
- name: Test
uses: addnab/docker-run-action@v3
if: matrix.settings.target == 'armv7-unknown-linux-musleabihf'
with:
# https://github.com/nodejs/docker-node/issues/1798
image: node:18-alpine
options: --platform linux/${{ matrix.settings.docker-platform }} -v ${{ github.workspace }}:/build -w /build
run: |
set -e
yarn test:without-lerna
- name: Test
uses: addnab/docker-run-action@v3
if: matrix.settings.target == 'x86_64-unknown-linux-musl'

View file

@ -58,6 +58,9 @@ jobs:
- host: ubuntu-latest
target: 'armv7-unknown-linux-gnueabihf'
build: ${packageManager} build --platform --target armv7-unknown-linux-gnueabihf --use-napi-cross
- host: ubuntu-latest
target: 'armv7-unknown-linux-musleabihf'
build: ${packageManager} build --platform --target armv7-unknown-linux-musleabihf -x
- host: ubuntu-latest
target: 'aarch64-linux-android'
build: ${packageManager} build --platform --target aarch64-linux-android

View file

@ -125,7 +125,11 @@ function requireNative() {
${requireTuple('linux-arm64-gnu')}
}
} else if (process.arch === 'arm') {
${requireTuple('linux-arm-gnueabihf')}
if (isMusl()) {
${requireTuple('linux-arm-musleabihf')}
} else {
${requireTuple('linux-arm-gnueabihf')}
}
} else if (process.arch === 'riscv64') {
if (isMusl()) {
${requireTuple('linux-riscv64-musl')}

View file

@ -93,6 +93,13 @@ Generated by [AVA](https://avajs.dev).
platformArchABI: 'linux-arm-gnueabihf',
triple: 'armv7-unknown-linux-gnueabihf',
},
{
abi: 'musleabihf',
arch: 'arm',
platform: 'linux',
platformArchABI: 'linux-arm-musleabihf',
triple: 'armv7-unknown-linux-musleabihf',
},
{
abi: 'eabi',
arch: 'arm',

View file

@ -79,6 +79,12 @@ export const CIConfig: Partial<
yarn_cpu: 'arm',
test_image: 'ghcr.io/napi-rs/napi-rs/nodejs:armhf-${{ matrix.node }}',
},
'armv7-unknown-linux-musleabihf': {
host: 'ubuntu-latest',
test: false,
yarn_cpu: 'arm',
yarn_libc: 'musl',
},
'aarch64-linux-android': {
host: 'ubuntu-latest',
build_setup: [

View file

@ -19,6 +19,7 @@ export const AVAILABLE_TARGETS = [
'x86_64-unknown-freebsd',
'i686-pc-windows-msvc',
'armv7-unknown-linux-gnueabihf',
'armv7-unknown-linux-musleabihf',
'armv7-linux-androideabi',
'universal-apple-darwin',
'riscv64gc-unknown-linux-gnu',

View file

@ -246,7 +246,20 @@ function requireNative() {
}
} else if (process.arch === 'arm') {
if (isMusl()) {
try {
return require('./example.linux-arm-musleabihf.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@examples/napi-linux-arm-musleabihf')
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./example.linux-arm-gnueabihf.node')
} catch (e) {
loadErrors.push(e)
@ -257,6 +270,7 @@ function requireNative() {
loadErrors.push(e)
}
}
} else if (process.arch === 'riscv64') {
if (isMusl()) {
try {

View file

@ -29,6 +29,7 @@
"format:toml": "taplo format",
"lint": "eslint -c .eslintrc.yml .",
"test": "lerna run test --concurrency=1 --ignore @napi-rs/cli",
"test:without-lerna": "yarn workspaces foreach -A --exclude \"{cli,napi-rs}\" run test",
"test:bun": "bun test examples/napi/__tests__/values.spec.ts",
"test:cli": "yarn workspace @napi-rs/cli test",
"test:electron": "electron examples/napi/electron.cjs",