Skip to content

Commit e0a9eb7

Browse files
committed
Implement build script for WebAssembly combined output and update .gitignore to include build artifacts
1 parent ddee01f commit e0a9eb7

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ sherpa-onnx-fire-red-asr-large-zh_en-2025-02-16
137137
cmake-build-debug
138138
README-DEV.txt
139139

140+
# WASM combined build artifacts
141+
wasm/combined/*.wasm
142+
wasm/combined/sherpa-onnx-wasm-combined.js
143+
build-wasm-combined/
144+
# Don't ignore the build script
145+
!build-wasm-combined.sh
146+
140147
##clion
141148
.idea
142149
scripts/dotnet/examples/obj/Debug/net8.0/Common.AssemblyInfo.cs

build-wasm-combined.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2024 Xiaomi Corporation
4+
5+
# Exit on error and print commands
6+
set -ex
7+
8+
echo "=== Starting build process for sherpa-onnx WASM combined ==="
9+
10+
# Set environment flag to indicate we're using this script
11+
export SHERPA_ONNX_IS_USING_BUILD_WASM_SH=1
12+
13+
# Create build directory
14+
mkdir -p build-wasm-combined
15+
cd build-wasm-combined
16+
17+
echo "=== Running CMake configuration ==="
18+
# Configure with CMake
19+
emcmake cmake \
20+
-DCMAKE_BUILD_TYPE=Release \
21+
-DSHERPA_ONNX_ENABLE_WASM=ON \
22+
-DSHERPA_ONNX_ENABLE_CHECK=OFF \
23+
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
24+
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
25+
-DSHERPA_ONNX_ENABLE_PYTHON=OFF \
26+
-DSHERPA_ONNX_ENABLE_JNI=OFF \
27+
-DSHERPA_ONNX_ENABLE_C_API=ON \
28+
-DSHERPA_ONNX_ENABLE_TEST=OFF \
29+
-DSHERPA_ONNX_ENABLE_WASM_COMBINED=ON \
30+
-DSHERPA_ONNX_INSTALL_TO_REPO=ON \
31+
..
32+
33+
echo "=== Building the target ==="
34+
# Build the target with full path to the target
35+
emmake make -j $(nproc) sherpa-onnx-wasm-combined
36+
37+
echo "=== Installing the files ==="
38+
# Install the files
39+
emmake make install/strip
40+
41+
if [ $? -eq 0 ]; then
42+
echo "=== Build completed successfully! ==="
43+
echo "Files have been installed to bin/wasm/combined and copied to wasm/combined/"
44+
else
45+
echo "=== Build failed! Check the error messages above ==="
46+
exit 1
47+
fi

0 commit comments

Comments
 (0)