-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·74 lines (61 loc) · 2.15 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# SANDMAN - BUILD SCRIPT
# Release path: compiled, minified
SANDMAN_RELEASE_PATH="./release"
SANDMAN_RELEASE_NAME="sandman_min.lua"
# Debug path: compiled, unminified
SANDMAN_DEBUG_PATH="./debug"
SANDMAN_DEBUG_NAME="sandman_debug.lua"
# The path to the source files
SANDMAN_SRC_PATH="./src"
# Edit these lines to add new source files to the build.
# Files are added in the order that they are listed.
SANDMAN_LOADER_INCLUDE=("util.lua" "bit.lua" "prng.lua" "settings.lua" "time.lua" "model.lua" "state.lua" "init.lua" "spec_act.lua" "api.lua" "update.lua" "editor.lua" "wizard.lua")
# -------DO NOT EDIT BELOW THIS LINE--------
SANDMAN_LOADERINIT="xx_loader.lua"
SANDMAN_COMMENTS="xx_comments.lua"
SANDMAN_FINALINIT="xx_finalinit.lua"
if [ "$1" = "debug" ]; then
SANDMAN_BUILD_PATH="$SANDMAN_DEBUG_PATH"
SANDMAN_FINAL_PATH="$SANDMAN_DEBUG_PATH/$SANDMAN_DEBUG_NAME"
else
SANDMAN_BUILD_PATH="$SANDMAN_RELEASE_PATH"
SANDMAN_FINAL_PATH="$SANDMAN_RELEASE_PATH/$SANDMAN_RELEASE_NAME"
fi
mkdir tmp
if [ -d $SANDMAN_BUILD_PATH ]; then
if [ -f $SANDMAN_FINAL_PATH ]; then
rm $SANDMAN_FINAL_PATH
fi
else
mkdir $SANDMAN_BUILD_PATH
fi
# build SANDMAN loader
for f in ${SANDMAN_LOADER_INCLUDE[@]}; do
cat $SANDMAN_SRC_PATH/$f >> tmp/header.lua
printf "\n\n" >> tmp/header.lua
done
cat tmp/header.lua > tmp/loader.lua
if [ "$1" = "debug" ]; then
cat tmp/loader.lua > tmp/loader_min.lua
else
luamin -f tmp/loader.lua > tmp/loader_min.lua
fi
# build the escape string for loading
python3 escape.py tmp/loader_min.lua tmp/loader_escaped.txt
# finalize
cat $SANDMAN_SRC_PATH/$SANDMAN_LOADERINIT >> tmp/header.lua
cat tmp/loader_escaped.txt >> tmp/header.lua
cat $SANDMAN_SRC_PATH/$SANDMAN_FINALINIT >> tmp/header.lua
# combine into final compiled minified lua
if [ "$1" = "debug" ]; then
cat tmp/header.lua > tmp/final_min.lua
else
luamin -f tmp/header.lua > tmp/final_min.lua
fi
cat $SANDMAN_SRC_PATH/$SANDMAN_COMMENTS > $SANDMAN_FINAL_PATH
printf "\n\n" >> $SANDMAN_FINAL_PATH
cat tmp/final_min.lua >> $SANDMAN_FINAL_PATH
echo "Success! SANDMAN has been compiled to $SANDMAN_FINAL_PATH."
# clear the temporary directory
rm -rf tmp