-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_em.sh
executable file
·51 lines (43 loc) · 1.23 KB
/
build_em.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
#!/usr/bin/env sh
preload_files="--preload-file ./shaders/webgl --preload-file ./res/fonts"
# flags
is_rebuild=false
is_regen=false
# Parse arguments
while [ $# -gt 0 ]; do # Check if total number of args is greater than 0
key="$1" # Get the first argument
case $key in
--rebuild)
# Set the rebuild flag to true
is_rebuild=true
;;
--regen)
is_regen=true
;;
--production)
is_production=true
;;
esac
# Shift the arguments to the left
shift
done
# Setup
if ! [ -d build-web ] || [ "$is_regen" = true ] || [ "$is_production" = true ]; then
emcmake cmake -S . -Bbuild-web -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXE_LINKER_FLAGS="${preload_files}"
fi
# Copy resources
mkdir -p ./build-web/res/fonts
cp ./index.html ./build-web
cp -rf ./shaders ./build-web
cp -rf ./res/fonts/Cozette ./build-web/res/fonts
# Clean
if [ "$is_rebuild" = true ] || [ "$is_production" = true ]; then
cmake --build build-web --target clean
fi
# Build
cmake --build build-web -j
if [ "$is_production" = true ]; then
rm -rf dist && mkdir -p dist
cp -rf ./build-web/hellotext.* ./dist
cp -rf ./build-web/index.html ./dist
fi