-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.sh
executable file
·226 lines (214 loc) · 5.14 KB
/
run.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/bin/bash
export PROJECT_NAME="raylib-5k"
export WSLENV="PROJECT_NAME"
set -e
set -o pipefail
PLATFORM="macOS"
EXE=""
TIME="time"
TIME_TOTAL="time"
if [[ -f /proc/version ]]; then
if grep -q Linux /proc/version; then
PLATFORM="lin"
TIME="time --format=%es\n"
TIME_TOTAL="time --format=total\t%es\n"
fi
if grep -q Microsoft /proc/version; then
EXE=".exe"
PLATFORM="win"
fi
fi
CMAKE="cmake$EXE"
CLANG_FORMAT="clang-format$EXE"
GO="go$EXE"
GX="gx$EXE"
CMAKE="$TIME $CMAKE"
GO="$TIME $GO"
validate-glsl() {
#cd assets/
#for f in *.frag; do
# glslangValidator$EXE $f | sed "s/^ERROR: 0/assets\/$f/g" | sed "/\.frag$/d"
#done
#cd - > /dev/null
:
}
run-gx() {
if [ ../gx/gx.go -nt ../gx/$GX ] || [ ../gx/gx.hh -nt ../gx/$GX ]; then
cd ../gx
$GO build gx.go
cd - > /dev/null
fi
mkdir -p build/gx
$TIME ../gx/$GX ./game build/gx/game
}
case "$1" in
# Compile commands DB (used by editor plugins)
db)
run-gx
$CMAKE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -H. -Bbuild/db -GNinja
cp ./build/db/compile_commands.json .
;;
# Format
format)
$CLANG_FORMAT -i -style=file $(find core/ game/ -name '*.hh' -o -name '*.cc' -type f)
;;
# Count lines of code
cloc)
cloc core/ game/ --by-file --exclude_list_file=.cloc_exclude_list
;;
# Desktop
release)
validate-glsl
run-gx
$CMAKE -H. -Bbuild/release -GNinja
$CMAKE --build build/release
case $PLATFORM in
lin|macOS)
if [[ -z "$VALGRIND" ]]; then
./build/release/$PROJECT_NAME $2
else
SUPPRESSIONS="
{
ignore_versioned_system_libs
Memcheck:Leak
...
obj:*/lib*/lib*.so.*
}
{
ignore_decompose_rpath
Memcheck:Addr8
...
fun:decompose_rpath
...
}
{
ignore_iris_dri
Memcheck:Leak
...
obj:*/dri/iris_dri.so
...
}
{
ignore_dl_open
Memcheck:Leak
...
fun:_dl_open
...
}
{
ignore_dl_open
Memcheck:Addr16
...
fun:_dl_open
...
}
{
ignore_dl_close
Memcheck:Leak
...
fun:_dl_close
...
}
"
valgrind \
--log-file="./build/valgrind.log" \
--suppressions=<(echo "$SUPPRESSIONS") \
--gen-suppressions=all \
--leak-check=full \
--show-leak-kinds=all \
-s \
./build/release/$PROJECT_NAME $2
cat build/valgrind.log
fi
;;
win)
./build/release/$PROJECT_NAME.exe $2
;;
esac
;;
debug)
validate-glsl
run-gx
$CMAKE -DCMAKE_BUILD_TYPE=Debug -H. -Bbuild/debug -GNinja
$CMAKE --build build/debug
case $PLATFORM in
lin|macOS)
./build/debug/$PROJECT_NAME $2
;;
win)
./build/debug/$PROJECT_NAME.exe $2
;;
esac
;;
# Web
web-init)
case $PLATFORM in
lin|macOS)
cd vendor/emsdk
./emsdk install latest
./emsdk activate latest
;;
win)
cd vendor/emsdk
cmd.exe /c emsdk install latest
cmd.exe /c emsdk activate latest
;;
esac
;;
web-release)
if [[ ! -f "vendor/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" ]]; then
./run.sh web-init
fi
validate-glsl
run-gx
if [[ ! -d "build/web-release" ]]; then
$CMAKE -DWEB=ON -H. -Bbuild/web-release -GNinja
fi
$CMAKE --build build/web-release
touch build/web-release/reload-trigger
;;
web-release-fast)
if [[ ! -f "vendor/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" ]]; then
./run.sh web-init
fi
validate-glsl
run-gx
if [[ ! -d "build/web-release-fast" ]]; then
$CMAKE -DWEB=ON -DWEB_BUNDLE_ASSETS=ON -DRELEASE_FAST=ON -H. -Bbuild/web-release-fast -GNinja
fi
$CMAKE --build build/web-release-fast
cp build/web-release-fast/{index.*,$PROJECT_NAME.*} app/web-release-fast
rm app/web-release-fast/raylib-5k.data
touch app/web-release-fast/raylib-5k.data
;;
web-watch-release)
find CMakeLists.txt core game assets web -type f | entr $TIME_TOTAL ./run.sh web-release
;;
web-serve-release)
npx http-server -p 9002 -c-1 build/web-release
;;
itch-publish)
./run.sh web-release-fast
cd build/web-release-fast
gsed -i 's/new URLSearch/true || new URLSearch/g' index.js
zip itch-publish.zip -r index.* $PROJECT_NAME.*
mv itch-publish.zip ../..
;;
web-publish)
./run.sh web-release-fast
cd build/web-release-fast
gsed -i 's/new URLSearch/true || new URLSearch/g' index.js
cd -
rm -rf docs/*
cp build/web-release-fast/{index.*,$PROJECT_NAME.*} docs/
git add docs
git commit -m 'web publish'
git push origin master
;;
# Electron
electron)
cd app
npm i
npx electron-packager . --overwrite
;;
esac