Add WebAssembly for NodeJS. (#628)
This commit is contained in:
41
.github/workflows/npm.yaml
vendored
41
.github/workflows/npm.yaml
vendored
@@ -9,6 +9,7 @@ concurrency:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
nodejs:
|
||||
@@ -20,10 +21,20 @@ jobs:
|
||||
python-version: ["3.8"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install emsdk
|
||||
uses: mymindstorm/setup-emsdk@v14
|
||||
|
||||
- name: View emsdk version
|
||||
shell: bash
|
||||
run: |
|
||||
emcc -v
|
||||
echo "--------------------"
|
||||
emcc --check
|
||||
|
||||
- name: Setup Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
@@ -31,28 +42,38 @@ jobs:
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 13
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Display node version
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
cd nodejs-examples
|
||||
|
||||
npm install npm@6.14.4 -g
|
||||
npm install npm@6.14.4
|
||||
npm --version
|
||||
|
||||
- name: Build nodejs package
|
||||
shell: bash
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
./build-wasm-simd-nodejs.sh
|
||||
cp -v build-wasm-simd-nodejs/install/bin/wasm/nodejs/*.js ./scripts/nodejs/
|
||||
cp -v build-wasm-simd-nodejs/install/bin/wasm/nodejs/*.wasm ./scripts/nodejs/
|
||||
|
||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||
|
||||
cd scripts/nodejs
|
||||
./run.sh
|
||||
|
||||
owner=${{ github.repository_owner }}
|
||||
echo "owner: $owner"
|
||||
|
||||
sed -i.bak s/SHERPA_ONNX_VERSION/$SHERPA_ONNX_VERSION/g ./package.json
|
||||
sed -i.bak s/k2-fsa/$owner/g ./package.json
|
||||
|
||||
rm package.json.bak
|
||||
|
||||
git diff
|
||||
|
||||
npm install
|
||||
rm run.sh
|
||||
npm ci
|
||||
# see https://docs.npmjs.com/generating-provenance-statements
|
||||
npm publish --provenance --access public
|
||||
|
||||
1
.github/workflows/test-nodejs-npm.yaml
vendored
1
.github/workflows/test-nodejs-npm.yaml
vendored
@@ -40,7 +40,6 @@ jobs:
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 13
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Display node version
|
||||
|
||||
64
.github/workflows/test-nodejs.yaml
vendored
64
.github/workflows/test-nodejs.yaml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest] #, windows-2019]
|
||||
os: [ubuntu-latest] #, macos-latest] #, windows-2019]
|
||||
python-version: ["3.8"]
|
||||
|
||||
steps:
|
||||
@@ -32,49 +32,38 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ matrix.os }}-Release-ON
|
||||
- name: Install emsdk
|
||||
uses: mymindstorm/setup-emsdk@v14
|
||||
|
||||
- name: Configure CMake
|
||||
- name: View emsdk version
|
||||
shell: bash
|
||||
run: |
|
||||
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
||||
cmake --version
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=./install ..
|
||||
cmake --build . --target install --config Release
|
||||
|
||||
ls -lh install/lib
|
||||
emcc -v
|
||||
echo "--------------------"
|
||||
emcc --check
|
||||
|
||||
- name: Setup Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Copy files
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Display node version
|
||||
shell: bash
|
||||
run: |
|
||||
os=${{ matrix.os }}
|
||||
if [[ $os == 'ubuntu-latest' ]]; then
|
||||
mkdir -p scripts/nodejs/lib/linux-x64
|
||||
dst=scripts/nodejs/lib/linux-x64
|
||||
elif [[ $os == 'macos-latest' ]]; then
|
||||
mkdir -p scripts/nodejs/lib/osx-x64
|
||||
dst=scripts/nodejs/lib/osx-x64
|
||||
elif [[ $os == 'windows-2019' ]]; then
|
||||
mkdir -p scripts/nodejs/lib/win-x64
|
||||
dst=scripts/nodejs/lib/win-x64
|
||||
fi
|
||||
ls -lh build/install/lib/
|
||||
node --version
|
||||
|
||||
rm -rf build/install/lib/pkgconfig
|
||||
|
||||
cp -v build/install/lib/* $dst/
|
||||
- name: Build nodejs package
|
||||
shell: bash
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
./build-wasm-simd-nodejs.sh
|
||||
cp -v build-wasm-simd-nodejs/install/bin/wasm/nodejs/*.js ./scripts/nodejs/
|
||||
cp -v build-wasm-simd-nodejs/install/bin/wasm/nodejs/*.wasm ./scripts/nodejs/
|
||||
|
||||
- name: replace files
|
||||
shell: bash
|
||||
@@ -89,17 +78,6 @@ jobs:
|
||||
git diff
|
||||
cp *.js ../scripts/nodejs
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 13
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Display node version
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user