Skip to content

Commit 9f4c08a

Browse files
committed
Implement build script for WebAssembly combined output and update .gitignore to include build artifacts
1 parent 3a1e98e commit 9f4c08a

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ README-DEV.txt
140140
# WASM combined build artifacts
141141
wasm/combined/*.wasm
142142
wasm/combined/sherpa-onnx-wasm-combined.js
143-
build-wasm-combined
143+
build-wasm-combined/
144+
# Don't ignore the build script
145+
!build-wasm-combined.sh
144146

145147
##clion
146148
.idea

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)