-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-wasm.sh
executable file
·48 lines (40 loc) · 1.25 KB
/
build-wasm.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
#!/usr/bin/env bash
echoPurple() {
echo -e "\x1b[95m$1\x1b[0m"
}
echoYellow() {
echo -e "\x1b[93m$1\x1b[0m"
}
if [ -d "dist" ]; then
echoPurple "✅ Dist directory exists"
else
echoYellow "❌ Dist directory missing"
echoYellow "🔨 Creating dist directory"
mkdir dist
echoPurple "✅ Dist directory created"
fi
echoPurple "✅ Building for WebAssembly"
GOOS=js GOARCH=wasm go build -o dist/roguelike-demo.wasm
if [ -f "dist/roguelike-demo.wasm" ]; then
echoPurple "✅ Finished build"
else
echoYellow "❌ WebAssembly module failed to build. Exiting..."
exit 1
fi
if [ -f "dist/wasm_exec.js" ]; then
echoPurple "✅ wasm_exec.js exists in dist directory"
else
echoYellow "❌ wasm_exec.js not in dist directory"
echoPurple "🔨Copy the wasm_exec.js file to the dist directory"
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" dist
echoPurple "✅ wasm_exec.js copied to dist directory"
fi
if [ -f "dist/index.html" ]; then
echoPurple "✅ index.html exists in dist directory"
else
echoYellow "❌ index.html not in dist directory"
echoPurple "🔨 Copy the index.html file to the dist directory"
cp index.html dist
echoPurple "✅ index.html copied to dist directory"
fi
echoPurple "🎉 Build complete"