-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathL
executable file
·194 lines (170 loc) · 4.44 KB
/
L
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
#!/bin/bash
TOPHAT_EMSCRIPTEN_VAR=""
BUTLER_VAR=""
BUTLER_USERNAME=""
BUTLER_PROJECTNAME=""
alias butler=/mnt/c/Butler/butler.exe
if [ -x "$(command -v butler)" ]; then
BUTLER_VAR="butler"
fi
if [ -x "$(command -v butler.exe)" ]; then
BUTLER_VAR="butler.exe"
fi
if [ -x "$(command -v ../tophat/cmd/th_emscripten_link)" ]; then
TOPHAT_EMSCRIPTEN_VAR="../tophat/cmd/th_emscripten_link"
fi
if [[ ! -z "$BUTLER_VAR" ]]; then
if [[ -f user/butler_env.sh ]]; then
source user/butler_env.sh
else
echo "No butler configuration found."
fi
fi
if [[ ! -f data/img/test.png ]]; then
echo -e "There's asset files missing. You probably need to install Git LFS.\nAfter installing do \`git lfs install\` and \`git lfs pull\` while in the repo's root folder.\nOtherwise, this shouldn't happen really, I recommend to check if all files are in place."
exit -1
fi
ARGS=( $@ )
SILENT=""
PROF=""
TESTTYPE="any"
NARG=0
PROG_NAME=$0
TOPHAT=./umbox/tophat/tophat
COMPILER=no_compiler_lol
# Probe if we are running WSL.
if grep -qi microsoft /proc/version; then
TOPHAT=./umbox/tophat/tophat.exe
fi
# Probe if we are running some bash emulator on Windows
if [[ "`uname`" == "WindowsNT" ]]; then
TOPHAT=./umbox/tophat/tophat.exe
fi
if [ -x "$(command -v gcc)" ]; then
COMPILER=gcc
fi
if [ -x "$(command -v clang)" ]; then
COMPILER=clang
fi
# TODO: emcc compiler support, we need build target for web.
# TODO: cl compiler support, because windows doesn't have the same cli
no_compiler_lol() {
echo "WARNING: NO COMPILER, RUNNING AS IS"
}
# $1 offset
getarg() {
echo ${ARGS[$NARG + $1]}
}
engage() {
if [ -z "$PROF" ]; then
$TOPHAT -dpiaware $SILENT $@
else
# https://github.com/colrdavidson/spall
# https://gravitymoth.com/spall/spall-web.html
$TOPHAT -dpiaware $PROF trace.json $SILENT $@
fi
}
# $1 test name
target_test() {
if [ -z "$1" ]; then
echo -e "What am I gonna test? \n$PROG_NAME test test_name"
exit 1
elif [[ -d "test/$1" && -f "test/$1/tmain.um" ]]; then
TESTTYPE=$TESTTYPE TEST_PFX="test/$1/" engage -main "test/$1/tmain.um"
else
echo -e "I don't know test \"$1\".\nTests are in ./test directory, you must make a folder named \"$1\" inside it, and put a tmain.um file in it. That's the way it is!"
exit 2
fi
}
target_emscripten() {
mv main.um main_temp.um
mv main_game.um main.um
$TOPHAT_EMSCRIPTEN_VAR data src umbox main.um
mv main.um main_game.um
mv main_temp.um main.um
}
hasargs=1
# Fetch all sparse args
while [ $hasargs -eq 1 ]
do
case `getarg 0` in
prof)
PROF=-prof
NARG=$(( $NARG + 1 ))
;;
jprof)
PROF=-prof\ -profjson
NARG=$(( $NARG + 1 ))
;;
silent)
NARG=$(( $NARG + 1 ))
SILENT=-silent
;;
testbed)
NARG=$(( $NARG + 1 ))
TESTTYPE="testbed"
;;
unit)
NARG=$(( $NARG + 1 ))
TESTTYPE="unit"
;;
*)
hasargs=0
;;
esac
done
case `getarg 0` in
play)
engage -main main.um
;;
check)
engage check -main main.um
for d in test/*; do
TEST_PFX="%d/" $TOPHAT $SILENT check main "$d/tmain.um"
done
;;
testall)
for d in test/*; do
echo "Testing ---" `basename $d`
target_test `basename $d`
done
;;
test)
target_test `getarg 1`
;;
publish)
mkdir -p pkg
mkdir -p pkg/native
cp -r ./src ./data ./umbox ./tophat.exe ./main.um ./pkg/native
if [[ -z "$BUTLER_VAR" ]]; then
echo "Butler not found. Skipping publishing to itch.io"
else
if [[ ! -z "$BUTLER_USERNAME" ]]; then
if [[ ! -z "$BUTLER_PROJECTNAME" ]]; then
if [[ ! -z "$TOPHAT_EMSCRIPTEN_VAR" ]]; then
echo "Publishing to itch.io!"
target_emscripten
rm -rf pkg/wasm-out
pwd
mv ../th_wasm_data/wasm-out pkg
$BUTLER_VAR push pkg/wasm-out $BUTLER_USERNAME/$BUTLER_PROJECTNAME:index
$BUTLER_VAR push pkg/native $BUTLER_USERNAME/$BUTLER_PROJECTNAME:windows
else
echo "Can't publish to itch.io: Can't find th_emscripten_link."
fi
else
echo "Can't publish to itch.io: BUTLER_PROJECTNAME is not defined. Define it in user/butler_env.sh file."
fi
else
echo "Can't publish to itch.io: BUTLER_USERNAME is not defined. Define it in user/butler_env.sh file."
fi
fi
;;
cl)
wc -l src/*.um src/**/*.um src/**/**/*.um
;;
*)
echo "You can do: test, check, play"
exit 3
;;
esac