|
15 | 15 | description: Expected NAPI-RS binary filename |
16 | 16 | required: true |
17 | 17 | type: string |
18 | | - use_napi_cross: |
19 | | - description: Build with the NAPI-RS cross toolchain |
20 | | - default: false |
21 | | - required: false |
22 | | - type: boolean |
23 | 18 |
|
24 | 19 | permissions: |
25 | 20 | contents: read |
@@ -52,34 +47,67 @@ jobs: |
52 | 47 | shell: bash |
53 | 48 | run: rustup target add "$RUST_TARGET" |
54 | 49 |
|
55 | | - - name: Build native binding with NAPI-RS cross toolchain |
56 | | - if: inputs.use_napi_cross |
| 50 | + - name: Setup Zig |
| 51 | + if: contains(inputs.target, 'musl') |
| 52 | + uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1 |
| 53 | + with: |
| 54 | + version: 0.14.1 |
| 55 | + |
| 56 | + - name: Install cargo-zigbuild |
| 57 | + if: contains(inputs.target, 'musl') |
| 58 | + uses: taiki-e/install-action@6c6fd71fe4fb72c3697d269963d0e15df8adedad # v2.85.10 |
| 59 | + with: |
| 60 | + tool: cargo-zigbuild@0.23.0 |
| 61 | + |
| 62 | + - name: Install RISC-V GNU toolchain |
| 63 | + if: inputs.target == 'riscv64gc-unknown-linux-gnu' |
57 | 64 | shell: bash |
58 | | - working-directory: packages/rstack |
59 | | - run: >- |
60 | | - pnpm exec napi build --platform --release |
61 | | - --target "$RUST_TARGET" |
62 | | - --manifest-path ../../Cargo.toml |
63 | | - --package rstack-binding |
64 | | - --package-json-path package.json |
65 | | - --output-dir . |
66 | | - --js binding.cjs |
67 | | - --dts binding.d.cts |
68 | | - --use-napi-cross |
| 65 | + run: | |
| 66 | + sudo apt-get update |
| 67 | + sudo apt-get install --yes gcc-riscv64-linux-gnu |
69 | 68 |
|
70 | 69 | - name: Build native binding |
71 | | - if: ${{ !inputs.use_napi_cross }} |
72 | 70 | shell: bash |
73 | 71 | working-directory: packages/rstack |
74 | | - run: >- |
75 | | - pnpm exec napi build --platform --release |
76 | | - --target "$RUST_TARGET" |
77 | | - --manifest-path ../../Cargo.toml |
78 | | - --package rstack-binding |
79 | | - --package-json-path package.json |
80 | | - --output-dir . |
81 | | - --js binding.cjs |
82 | | - --dts binding.d.cts |
| 72 | + run: | |
| 73 | + args=( |
| 74 | + build |
| 75 | + --platform |
| 76 | + --release |
| 77 | + --target "$RUST_TARGET" |
| 78 | + --manifest-path ../../Cargo.toml |
| 79 | + --package rstack-binding |
| 80 | + --output-dir . |
| 81 | + --js binding.cjs |
| 82 | + --dts binding.d.cts |
| 83 | + ) |
| 84 | +
|
| 85 | + case "$RUST_TARGET" in |
| 86 | + x86_64-unknown-linux-gnu | aarch64-unknown-linux-gnu | \ |
| 87 | + powerpc64le-unknown-linux-gnu | s390x-unknown-linux-gnu) |
| 88 | + args+=(--use-napi-cross) |
| 89 | + ;; |
| 90 | + x86_64-unknown-linux-musl | aarch64-unknown-linux-musl | \ |
| 91 | + riscv64gc-unknown-linux-musl) |
| 92 | + args+=(--cross-compile) |
| 93 | + ;; |
| 94 | + aarch64-apple-darwin | x86_64-apple-darwin) |
| 95 | + export MACOSX_DEPLOYMENT_TARGET=11.0 |
| 96 | + ;; |
| 97 | + i686-pc-windows-msvc) |
| 98 | + export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=32 |
| 99 | + export CARGO_PROFILE_RELEASE_LTO=false |
| 100 | + ;; |
| 101 | + riscv64gc-unknown-linux-gnu | x86_64-pc-windows-msvc | \ |
| 102 | + aarch64-pc-windows-msvc) |
| 103 | + ;; |
| 104 | + *) |
| 105 | + echo "Unsupported native target: $RUST_TARGET" >&2 |
| 106 | + exit 1 |
| 107 | + ;; |
| 108 | + esac |
| 109 | +
|
| 110 | + pnpm exec napi "${args[@]}" |
83 | 111 |
|
84 | 112 | - name: Upload native binding |
85 | 113 | uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 |
|
0 commit comments