@@ -14,6 +14,15 @@ if ! command -v emcmake &> /dev/null; then
1414 exit 1
1515fi
1616
17+ # Get CPU count based on OS
18+ if [[ " $OSTYPE " == " darwin" * ]]; then
19+ # macOS
20+ CPU_COUNT=$( sysctl -n hw.ncpu)
21+ else
22+ # Linux and others
23+ CPU_COUNT=$( nproc)
24+ fi
25+
1726# Create build directory
1827mkdir -p build
1928cd build
@@ -24,13 +33,32 @@ emcmake cmake .. \
2433 -DBUILD_TESTS=OFF \
2534 -DCMAKE_BUILD_TYPE=Release
2635
36+ # Check if configuration was successful
37+ if [ $? -ne 0 ]; then
38+ echo " CMake configuration failed. Please check SDL2 installation."
39+ echo " You might need to install SDL2 for Emscripten with: emscripten/emsdk/upstream/emscripten/embuilder.py build sdl2"
40+ exit 1
41+ fi
42+
2743# Build
28- cmake --build . -j$( nproc)
44+ cmake --build . -j${CPU_COUNT}
45+
46+ # Check if build directory exists and create if needed
47+ mkdir -p ../public
2948
30- # Copy web files
31- cp ../target/release/* .wasm ../public/
32- cp ../target/release/* .js ../public/
33- cp ../target/release/* .data ../public/
49+ # Copy web files if they exist
50+ if [ -d " src" ]; then
51+ # Find and copy WASM, JS and data files to the public directory
52+ find src -name " *.wasm" -exec cp {} ../public/ \;
53+ find src -name " *.js" -exec cp {} ../public/ \;
54+ find src -name " *.data" -exec cp {} ../public/ \;
55+ else
56+ # Alternative locations to search for output files
57+ find . -name " *.wasm" -exec cp {} ../public/ \;
58+ find . -name " *.js" -exec cp {} ../public/ \;
59+ find . -name " *.data" -exec cp {} ../public/ \;
60+ fi
3461
3562cd ..
36- ls -la
63+ echo " Build complete. Files in public directory:"
64+ ls -la public/
0 commit comments