mirror of
https://github.com/napi-rs/napi-rs.git
synced 2025-12-08 19:56:07 +00:00
feat(cli): add support for loongarch64-unknown-linux-gnu (#2887)
* feat(target): add support for loongarch64-unknown-linux-gnu * docs(README): update platform support status * Update cli/src/utils/target.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/test-release.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: LongYinan <lynweklm@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
c3794fb215
commit
807f579796
7
.github/workflows/test-release.yaml
vendored
7
.github/workflows/test-release.yaml
vendored
@ -281,6 +281,13 @@ jobs:
|
||||
setup: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc-riscv64-linux-gnu
|
||||
- host: ubuntu-latest
|
||||
target: loongarch64-unknown-linux-gnu
|
||||
# TODO: Switch to gcc-loongarch64-linux when available
|
||||
setup: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc-13-loongarch64-linux-gnu
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
|
||||
@ -180,6 +180,7 @@ async function filterTargetsInGithubActions(
|
||||
'aarch64-unknown-linux-musl',
|
||||
'armv7-unknown-linux-gnueabihf',
|
||||
'armv7-unknown-linux-musleabihf',
|
||||
'loongarch64-unknown-linux-gnu',
|
||||
'riscv64gc-unknown-linux-gnu',
|
||||
'powerpc64le-unknown-linux-gnu',
|
||||
's390x-unknown-linux-gnu',
|
||||
|
||||
@ -190,6 +190,12 @@ function requireNative() {
|
||||
} else {
|
||||
${requireTuple('linux-arm-gnueabihf', 10)}
|
||||
}
|
||||
} else if (process.arch === 'loong64') {
|
||||
if (isMusl()) {
|
||||
${requireTuple('linux-loong64-musl', 10)}
|
||||
} else {
|
||||
${requireTuple('linux-loong64-gnu', 10)}
|
||||
}
|
||||
} else if (process.arch === 'riscv64') {
|
||||
if (isMusl()) {
|
||||
${requireTuple('linux-riscv64-musl', 10)}
|
||||
|
||||
@ -128,6 +128,13 @@ Generated by [AVA](https://avajs.dev).
|
||||
platformArchABI: 'darwin-universal',
|
||||
triple: 'universal-apple-darwin',
|
||||
},
|
||||
{
|
||||
abi: 'gnu',
|
||||
arch: 'loong64',
|
||||
platform: 'linux',
|
||||
platformArchABI: 'linux-loong64-gnu',
|
||||
triple: 'loongarch64-unknown-linux-gnu',
|
||||
},
|
||||
{
|
||||
abi: 'gnu',
|
||||
arch: 'riscv64',
|
||||
|
||||
Binary file not shown.
@ -26,6 +26,7 @@ export const AVAILABLE_TARGETS = [
|
||||
'armv7-unknown-linux-musleabihf',
|
||||
'armv7-linux-androideabi',
|
||||
'universal-apple-darwin',
|
||||
'loongarch64-unknown-linux-gnu',
|
||||
'riscv64gc-unknown-linux-gnu',
|
||||
'powerpc64le-unknown-linux-gnu',
|
||||
's390x-unknown-linux-gnu',
|
||||
@ -44,6 +45,8 @@ export const DEFAULT_TARGETS = [
|
||||
|
||||
export const TARGET_LINKER: Record<string, string> = {
|
||||
'aarch64-unknown-linux-musl': 'aarch64-linux-musl-gcc',
|
||||
// TODO: Switch to loongarch64-linux-gnu-gcc when available
|
||||
'loongarch64-unknown-linux-gnu': 'loongarch64-linux-gnu-gcc-13',
|
||||
'riscv64gc-unknown-linux-gnu': 'riscv64-linux-gnu-gcc',
|
||||
'powerpc64le-unknown-linux-gnu': 'powerpc64le-linux-gnu-gcc',
|
||||
's390x-unknown-linux-gnu': 's390x-linux-gnu-gcc',
|
||||
@ -54,6 +57,7 @@ type NodeJSArch =
|
||||
| 'arm'
|
||||
| 'arm64'
|
||||
| 'ia32'
|
||||
| 'loong64'
|
||||
| 'mips'
|
||||
| 'mipsel'
|
||||
| 'ppc'
|
||||
@ -71,6 +75,7 @@ const CpuToNodeArch: Record<string, NodeJSArch> = {
|
||||
aarch64: 'arm64',
|
||||
i686: 'ia32',
|
||||
armv7: 'arm',
|
||||
loongarch64: 'loong64',
|
||||
riscv64gc: 'riscv64',
|
||||
powerpc64le: 'ppc64',
|
||||
}
|
||||
@ -80,6 +85,7 @@ export const NodeArchToCpu: Record<string, string> = {
|
||||
arm64: 'aarch64',
|
||||
ia32: 'i686',
|
||||
arm: 'armv7',
|
||||
loong64: 'loongarch64',
|
||||
riscv64: 'riscv64gc',
|
||||
ppc64: 'powerpc64le',
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ A framework for building compiled `Node.js` add-ons in `Rust` via Node-API. Webs
|
||||
| Linux arm muslebihf | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
||||
| Linux powerpc64le gnu | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
||||
| Linux s390x gnu | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
||||
| Linux loong64 gnu | N/A | N/A | N/A | ✓ | ✓ | ✓ |
|
||||
| Linux riscv64 gnu | N/A | N/A | ✓ | ✓ | ✓ | ✓ |
|
||||
| Linux aarch64 android | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
||||
| Linux armv7 android | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
||||
|
||||
@ -348,6 +348,40 @@ function requireNative() {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
}
|
||||
} else if (process.arch === 'loong64') {
|
||||
if (isMusl()) {
|
||||
try {
|
||||
return require('./example.linux-loong64-musl.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
const binding = require('@examples/napi-linux-loong64-musl')
|
||||
const bindingPackageVersion = require('@examples/napi-linux-loong64-musl/package.json').version
|
||||
if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
return require('./example.linux-loong64-gnu.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
const binding = require('@examples/napi-linux-loong64-gnu')
|
||||
const bindingPackageVersion = require('@examples/napi-linux-loong64-gnu/package.json').version
|
||||
if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
}
|
||||
} else if (process.arch === 'riscv64') {
|
||||
if (isMusl()) {
|
||||
try {
|
||||
|
||||
@ -310,19 +310,19 @@ module.exports.platformArchTriples = {
|
||||
abi: 'musl',
|
||||
},
|
||||
],
|
||||
loongarch64: [
|
||||
loong64: [
|
||||
{
|
||||
triple: 'loongarch64-unknown-linux-gnu',
|
||||
platformArchABI: 'linux-loongarch64-gnu',
|
||||
platformArchABI: 'linux-loong64-gnu',
|
||||
platform: 'linux',
|
||||
arch: 'loongarch64',
|
||||
arch: 'loong64',
|
||||
abi: 'gnu',
|
||||
},
|
||||
{
|
||||
triple: 'loongarch64-unknown-linux-musl',
|
||||
platformArchABI: 'linux-loongarch64-musl',
|
||||
platformArchABI: 'linux-loong64-musl',
|
||||
platform: 'linux',
|
||||
arch: 'loongarch64',
|
||||
arch: 'loong64',
|
||||
abi: 'musl',
|
||||
},
|
||||
],
|
||||
|
||||
@ -311,19 +311,19 @@ export const platformArchTriples = {
|
||||
"abi": "musl"
|
||||
}
|
||||
],
|
||||
"loongarch64": [
|
||||
"loong64": [
|
||||
{
|
||||
"triple": "loongarch64-unknown-linux-gnu",
|
||||
"platformArchABI": "linux-loongarch64-gnu",
|
||||
"platformArchABI": "linux-loong64-gnu",
|
||||
"platform": "linux",
|
||||
"arch": "loongarch64",
|
||||
"arch": "loong64",
|
||||
"abi": "gnu"
|
||||
},
|
||||
{
|
||||
"triple": "loongarch64-unknown-linux-musl",
|
||||
"platformArchABI": "linux-loongarch64-musl",
|
||||
"platformArchABI": "linux-loong64-musl",
|
||||
"platform": "linux",
|
||||
"arch": "loongarch64",
|
||||
"arch": "loong64",
|
||||
"abi": "musl"
|
||||
}
|
||||
],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user