-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb_build.sh
executable file
·70 lines (59 loc) · 1.95 KB
/
web_build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Function to activate Emscripten
activate_emscripten() {
# Update this path to where your Emscripten installation is located
EMSDK_PATH="$HOME/mulVid/libs/emscripten" # Adjust this path as needed
if [ -d "$EMSDK_PATH" ]; then
echo "Activating latest Emscripten SDK..."
cd "$EMSDK_PATH"
./emsdk activate latest
source ./emsdk_env.sh
cd - > /dev/null # Return to original directory
else
echo "Error: Emscripten not found at $EMSDK_PATH"
echo "Please install Emscripten or update the EMSDK_PATH in the script."
exit 1
fi
}
# Check if Emscripten is activated
if ! command -v emcc &> /dev/null; then
echo "Emscripten is not activated. Attempting to activate..."
activate_emscripten
fi
# Verify Emscripten is now available
if ! command -v emcc &> /dev/null; then
echo "Error: Failed to activate Emscripten. Please check your installation."
exit 1
fi
echo "Emscripten is active. Proceeding with the build..."
# Check if build_web directory exists and delete it if it does
if [ -d "build_web" ]; then
echo "Removing existing build_web directory..."
rm -rf build_web
fi
# Create a new build_web directory
echo "Creating new build_web directory..."
mkdir build_web
cd build_web
# Generate build files using Emscripten
echo "Generating build files with Emscripten..."
emcmake cmake -DCMAKE_BUILD_TYPE=Release ..
if [ $? -ne 0 ]; then
echo "CMake configuration failed!"
read -p "Press enter to continue"
exit 1
fi
# Build the project
echo "Building the project..."
emmake cmake --build . -j$(nproc)
if [ $? -ne 0 ]; then
echo "Build failed!"
read -p "Press enter to continue"
exit 1
fi
echo "Build successful!"
echo "You can now deploy the generated HTML and JavaScript files."
# Optional: Add a command to serve the built project
# For example, using Python's built-in HTTP server:
# echo "Starting a local server..."
# python3 -m http.server 8000