From 71d8b93a322bf7fe8c89d2d2874db20f9f47f4e2 Mon Sep 17 00:00:00 2001 From: phancb Date: Tue, 26 Dec 2023 23:05:13 +0800 Subject: [PATCH] feat(target): add riscv64 support --- .cargo/config.toml | 3 +++ .github/workflows/release.yml | 6 ++++++ package.json | 2 +- scripts/build-npm.js | 7 ++++++- yarn.lock | 8 ++++---- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index a05c05ab..a554d509 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -9,5 +9,8 @@ linker = "arm-linux-gnueabihf-gcc" linker = "aarch64-linux-musl-gcc" rustflags = ["-C", "target-feature=-crt-static"] +[target.riscv64gc-unknown-linux-gnu] +linker = "riscv64-linux-gnu-gcc" + [target.wasm32-unknown-unknown] rustflags = ["-C", "link-arg=--export-table"] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5e0254d6..36571bdc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -115,6 +115,12 @@ jobs: - target: x86_64-unknown-linux-musl image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine strip: strip + - target: riscv64gc-unknown-linux-gnu + image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian + strip: riscv64-linux-gnu-strip + setup: | + sudo apt-get update + sudo apt-get install gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu -y name: build-${{ matrix.target }} runs-on: ubuntu-latest diff --git a/package.json b/package.json index 9a0d6969..febd93eb 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@codemirror/lint": "^6.1.0", "@codemirror/theme-one-dark": "^6.1.0", "@mdn/browser-compat-data": "^5.3.29", - "@napi-rs/cli": "^2.14.0", + "@napi-rs/cli": "^2.17.0", "autoprefixer": "^10.4.16", "codemirror": "^6.0.1", "cssnano": "^5.0.8", diff --git a/scripts/build-npm.js b/scripts/build-npm.js index dd4c91bc..0377e20f 100644 --- a/scripts/build-npm.js +++ b/scripts/build-npm.js @@ -35,13 +35,18 @@ const triples = [ }, { name: 'x86_64-unknown-freebsd' - } + }, + { + name: 'riscv64gc-unknown-linux-gnu', + libc: 'glibc', + }, ]; const cpuToNodeArch = { x86_64: 'x64', aarch64: 'arm64', i686: 'ia32', armv7: 'arm', + riscv64gc: 'riscv64', }; const sysToNodePlatform = { linux: 'linux', diff --git a/yarn.lock b/yarn.lock index c56adaf7..2a01dd29 100644 --- a/yarn.lock +++ b/yarn.lock @@ -412,10 +412,10 @@ resolved "https://registry.yarnpkg.com/@msgpackr-extract/msgpackr-extract-win32-x64/-/msgpackr-extract-win32-x64-2.1.2.tgz#f2d8b9ddd8d191205ed26ce54aba3dfc5ae3e7c9" integrity sha512-rIZVR48zA8hGkHIK7ED6+ZiXsjRCcAVBJbm8o89OKAMTmEAQ2QvoOxoiu3w2isAaWwzgtQIOFIqHwvZDyLKCvw== -"@napi-rs/cli@^2.14.0": - version "2.14.0" - resolved "https://registry.yarnpkg.com/@napi-rs/cli/-/cli-2.14.0.tgz#ca1c1a75d6922f8af098d8d56f4914e0889963c8" - integrity sha512-hQW+gOTQ80nCoBAWA0hq49HM3QqyC7x879CdF/CEEFHeJNlHT8tgru8nbMQa6YqMP1XADfiudsYzy5V7TxBxCw== +"@napi-rs/cli@^2.17.0": + version "2.17.0" + resolved "https://registry.yarnpkg.com/@napi-rs/cli/-/cli-2.17.0.tgz#05566f0550333789824325e4d817e613cc91181c" + integrity sha512-/M7MZ3dIqyFs6c0Bxtk+SOobPq6vYWYqBLYCOKx3dYWqoyJNBEgmDKUTrxIZu9eHw9Ill3WyEoHPqS9P99cd8A== "@parcel/bundler-default@2.8.2": version "2.8.2"