-
Notifications
You must be signed in to change notification settings - Fork 20
/
build.sh
executable file
·56 lines (40 loc) · 1.28 KB
/
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
#!/bin/bash
set -e
# Generate compressed maps
mkdir -p bin
gcc src/maps/compress.c -o bin/compress
./bin/compress > src/wasm/maps.h
# Generate wasm file
make clean
make
wasm-dis bin/game.wasm | grep '(export\|(import\|(global \$'
ls -la bin/game.wasm
# copy JS file into bin directory.
# The game can be tested in this directory
cp src/js/* bin/
exit 0
# minify
mkdir -p minify
cd minify
cp ../src/tools/minify.js .
npm install node-minify
node minify.js
# put all script directly into the html file
sed 's/<script src=audio.js>/<script>$x/' index.html | x="$(cat audio.js)" envsubst '$x' > 1.html
sed 's/<script src=game.js>/<script>$x/' 1.html | x="$(cat game.js)" envsubst '$x' > 2.html
sed 's/<script src=level.js>/<script>$x/' 2.html | x="$(cat level.js)" envsubst '$x' > 3.html
cp 3.html index.html
cd ..
# copy wasm file into the minify directory.
# Now the game can be tested in the minified version
cp bin/game.wasm minify/
# compress
FILENAME=Interplanetary_Postal_Lander_minified.zip
rm -f $FILENAME
zip -j $FILENAME minify/game.wasm minify/index.html
advzip -i 100 -p -z -4 $FILENAME
zip -T $FILENAME
# show file size
stat --printf="size = %s\n" Interplanetary_Postal_Lander_minified.zip
rm -f Interplanetary_Postal_Lander.zip
zip Interplanetary_Postal_Lander.zip compile.sh src/*