forked from evan-erdos/CMU.ADV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
179 lines (146 loc) · 3.29 KB
/
build
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
#!/bin/bash
#
# Ben Scott <[email protected]> 2016-01-01
#
# CMU.ADV
# name of the project, and the output files
NAME="cmu_adv"
# flags to be sent directly to the compiler
FLAGS=""
# tell the compiler to print a bunch of nonsense
VERBOSE="-v -w1"
# optional debug flag
DEBUG="-d"
# a comment to be put at the head of the makefiles
HEADER="# ${NAME} - TADS 3 Build File"
# flags shared between web and cmd builds
MAKE_FLAGS="
-DLANGUAGE=en_us
-DMESSAGESTYLE=neu
-nobanner"
# filename for chararray makefile
MAKE_CMD="obj/cmd/${NAME}_cmd.t3m"
# filename for web makefile
MAKE_WEB="obj/web/${NAME}_web.t3m"
# flags for building to the command line
CMD_FLAGS="
-Fy ../cmd -Fo ../cmd
-I ../../src/
-o ../../tgt/${NAME}_cmd.t3
-lib system
-lib adv3/adv3"
# flags for building to the web
WEB_FLAGS="
-D TADS_INCLUDE_NET
-Fy ../web -Fo ../web
-I ../../src/
-o ../../tgt/${NAME}_web.t3
-lib system
-lib adv3/adv3web
-lib webui
-source tadsnet"
# `usage`
#
# Displays the usage syntax and flags.
function usage {
echo "usage: . build [-bcdhqrw]"
}
# `about`
#
# When the user does something dumb, display this help text.
function about {
usage
echo "options:
-b, --build clean, compile and run
-c, --clean clean build files
-d, --debug compile debug version
-h, --help displays this help text
-q, --qtads runs the build via QTADS.
-r, --run runs the console build
-w, --web runs the web build"
}
# `make`
#
# Constructs two `*.t3m` files for building the t3make.
function make {
mkdir -p obj/web
mkdir -p obj/cmd
echo -e "${HEADER}\n${MAKE_FLAGS}" > $MAKE_WEB
echo -e "${HEADER}\n${MAKE_FLAGS}" > $MAKE_CMD
for dir in $(find ./src -type d); do
echo "-Fs ../.${dir}" >> $MAKE_WEB
echo "-Fs ../.${dir}" >> $MAKE_CMD
done
echo "${WEB_FLAGS}" >> $MAKE_WEB
echo "${CMD_FLAGS}" >> $MAKE_CMD
for file in $(find ./src -name '*.t'); do
echo "-source ${file##*/}" >> $MAKE_WEB
echo "-source ${file##*/}" >> $MAKE_CMD
done
}
# `clean`
#
# Explicitly deletes all the object files in `obj/` and deletes
# the `*.t3` executables from `tgt/`.
function clean {
t3make -clean -f $MAKE_WEB
t3make -clean -f $MAKE_CMD
}
# `build`
#
# When the `-b` is explicitly specified, it first calls `clean`
# and then this function, which first constructs the `*.t3m`
# makefiles, compiles the project, and then runs it.
function build {
make
t3make $FLAGS -f $MAKE_WEB &&
t3make $FLAGS -f $MAKE_CMD
}
# `debug`
#
# sets flags for a debug build
function debug {
FLAGS="$DEBUG $VERBOSE $FLAGS"
build
run
}
# `run`
#
# Uses frob to run the command line version.
function run {
frob tgt/${NAME}_cmd.t3
}
# `web`
#
# Uses frob to run the web build.
function web {
frob -N 44 tgt/${NAME}_web.t3
}
# `qtads`
#
# Attempts to use QTads to run the game.
function qtads {
open -a QTads tgt/${NAME}_cmd.t3
}
if [ $# -gt 0 ]; then
while [ "$1" != "" ]; do
case $1 in
-b | --build ) clean
build
run;;
-d | --debug ) debug;;
-c | --clean ) clean;;
-h | --help ) about;;
-r | --run ) build
run;;
-w | --web ) build
web;;
-q | --qtads ) build
qtads;;
* ) usage;;
esac
shift
done
else
build && run
fi