forked from SWG-Source/dsrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
executable file
·267 lines (237 loc) · 11.2 KB
/
build.xml
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<project name="SWGBuildDSRC" default="echoprops" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
<description>
This build file will build the DSRC directory (scripting) of the SWG Source Code. Created by Cekis (cekisswg@gmail.com).
</description>
<!-- Get our host info -->
<hostinfo/>
<!-- Property File -->
<property file="local.properties" />
<property file="build.properties" />
<!-- Global Properties -->
<property name="build" location="build"/>
<!-- Database Service Name is derived to make it easier in the properties file -->
<property name="service_name" value="//127.0.0.1/${db_service}"/>
<!-- Setup Source Directories -->
<property name="data" location="${build}/data" relative="true" basedir="${basedir}"/>
<!-- Setup Key Game Directories -->
<property name="dsrc_server" location="sku.0/sys.server/compiled/game"/>
<property name="dsrc_shared" location="sku.0/sys.shared/compiled/game"/>
<property name="data_server" location="${data}/sku.0/sys.server/compiled/game"/>
<property name="data_shared" location="${data}/sku.0/sys.shared/compiled/game"/>
<property name="data_client" location="${data}/sku.0/sys.client/compiled"/>
<!-- Setup CRC Files to load into the database -->
<property name="object_crc_file" location="sku.0/sys.server/built/game/misc/object_template_crc_string_table.tab"/>
<property name="templates_sql_file" location="${build}/templates.sql"/>
<!-- Define where most of our compiled tools will live -->
<property name="tools_home" location="include"/>
<property environment="env"/>
<!-- The init target handles the environment setup - not much to do but create directories -->
<target name="init">
<tstamp/>
<mkdir dir="${build}"/>
<mkdir dir="${data_server}"/>
<mkdir dir="${data_shared}"/>
<mkdir dir="${data_client}"/>
</target>
<target name="echoprops">
<echoproperties/>
<echo>IP Address: ${ADDR4}</echo>
</target>
<target name="swg" description="builds the SWG DSRC codebase" depends="clean,create_database,compile,create_symlinks,load_templates">
</target>
<!-- Clean simply calls the other clean targets -->
<target name="clean" depends="clean_dsrc,init">
</target>
<!-- Delete the DSRC Build folder -->
<target name="clean_dsrc">
<echo>Cleaning the DSRC directory.</echo>
<delete includeemptydirs="true" removeNotFollowedSymlinks="true" failonerror="false">
<fileset dir="${data}" includes="**/*" followsymlinks="false"/>
</delete>
</target>
<!-- Delete the DSRC Build folder -->
<target name="clean_java">
<echo>Cleaning the DSRC script directory.</echo>
<delete dir="${data_server}/script" verbose="false"/>
</target>
<!-- Compiles the DSRC (Java) code -->
<target name="compile_java" depends="init" description="compile java code">
<javac srcdir="${dsrc_server}" destdir="${data_server}" includeantruntime="false" classpath="${data_server}" encoding="utf8" sourcepath="${dsrc_server}" debug="true" deprecation="on">
<compilerarg value="-Xlint:-options"/>
</javac>
</target>
<!-- Compiles all code necessary for server execution -->
<target name="compile" depends="compile_java,compile_miff,compile_tab,compile_tpf">
</target>
<!-- Compiles all .mif files -->
<target name="compile_miff">
<fileset id="miff_files" dir="." includes="**/*.mif"/>
<touch mkdirs="true" verbose="false">
<fileset refid="miff_files"/>
<mapper type="glob" from="*.mif" to="${data}/*/.tmp" />
</touch>
<delete>
<fileset dir="${data}" includes="**/.tmp"/>
</delete>
<apply executable="./Miff" dir="${tools_home}" dest="${data_server}" parallel="false" type="file">
<env key="PATH" value="${env.PATH}:${tools_home}"/>
<arg value="-i"/>
<srcfile prefix=""" suffix="""/>
<arg value="-o"/>
<targetfile prefix=""" suffix="""/>
<fileset refid="miff_files"/>
<mapper type="glob" from="*.mif" to="*.iff"/>
</apply>
<antcall target="cleanup"/>
</target>
<!-- Compiles all .tab files -->
<target name="compile_tab" depends="init" description="compile datatable files (.tab)">
<fileset id="tab_files" dir="../dsrc">
<include name="**/*.tab" />
<exclude name="**/object_template_crc_string_table.tab" />
<exclude name="**/quest_crc_string_table.tab" />
</fileset>
<touch mkdirs="true" verbose="false">
<fileset refid="tab_files"/>
<mapper type="glob" from="*.tab" to="build/data/*/.tmp" />
</touch>
<delete>
<fileset dir="build/data" includes="**/.tmp"/>
</delete>
<apply executable="${tools_home}/DataTableTool" dir=".." dest="../dsrc/build/data" parallel="false" type="file" failonerror="true" verbose="true">
<arg value="-i"/>
<srcfile prefix=""" suffix="""/>
<arg value="-- -s SharedFile"/>
<arg value="searchPath10=${data_shared}"/>
<arg value="searchPath10=${data_server}"/>
<arg value="searchPath10=${data_client}"/>
<fileset refid="tab_files" />
<mapper type="glob" from="*.tab" to="*.iff"/>
</apply>
<antcall target="cleanup"/>
</target>
<!-- Compiles all Template Files (.tpf) -->
<target name="compile_tpf" description="compile the template files (*.tpf) into .iff">
<echo message="Looking for Template Files to compile... please wait..."/>
<touch mkdirs="true" verbose="false">
<fileset dir="." includes="**/*.tpf"/>
<mapper type="glob" from="*.tpf" to="${data}/*/.tmp" />
</touch>
<delete>
<fileset dir="${data}" includes="**/.tmp"/>
</delete>
<apply executable="${tools_home}/TemplateCompiler" dir="${basedir}" dest="${basedir}" parallel="false" type="file" failonerror="false" relative="true">
<env key="PATH" value="${env.PATH}:${tools_home}"/>
<arg value="-compile"/>
<srcfile/>
<fileset dir="${basedir}" includes="**/*.tpf"/>
<mapper type="glob" from="*.tpf" to="${data}/*.iff"/>
</apply>
<antcall target="cleanup"/>
</target>
<!-- Creates the Object Template CRC file -->
<target name="build_object_template_crc" description="creates the object template crc file" depends="compile_tpf, compile_miff">
<exec executable="utils/build_object_template_crc_string_tables.py" dir="${basedir}">
<env key="PATH" value="${env.PATH}:${tools_home}"/>
</exec>
</target>
<!-- Creates the Quest CRC file -->
<target name="build_quest_crc" description="creates the quest crc file" depends="compile_tab">
<exec executable="utils/build_quest_crc_string_tables.py" dir="${basedir}">
<env key="PATH" value="${env.PATH}:${tools_home}"/>
</exec>
</target>
<!-- Creates SQL (insert statements) to get all the CRC Templates into the database -->
<target name="process_templates" description="generates sql from generated crc files" depends="build_object_template_crc,build_quest_crc">
<exec executable="perl" dir="${basedir}/src/game/server/database/templates" input="${object_crc_file}" output="${templates_sql_file}">
<env key="PATH" value="${env.PATH}:${tools_home}"/>
<arg value="processTemplateList.pl"/>
</exec>
</target>
<!-- Executes the generated Template CRC SQL in SQL*Plus -->
<target name="load_templates" description="loads generated templates into the database" depends="process_templates">
<exec executable="sqlplus" dir="${build}">
<arg value="${db_username}/${db_password}@${ADDR4}/${db_service}"/>
<arg value="@${templates_sql_file}"/>
</exec>
</target>
<!-- Target used to create database tables -->
<target name="create_database" description="creates database tables from existing sql scripts" if="firstrun">
<replace file="build.properties" token="firstrun = true" value="firstrun = false"/>
<exec executable="perl" dir="${basedir}/src/game/server/database/build/linux">
<env key="PATH" value="${env.PATH}:${tools_home}"/>
<arg value="database_update.pl"/>
<arg value="--username=${db_username}"/>
<arg value="--password=${db_password}"/>
<arg value="--service=${ADDR4}/${db_service}"/>
<arg value="--goldusername=${db_username}"/>
<arg value="--loginusername=${db_username}"/>
<arg value="--createnewcluster"/>
<arg value="--packages"/>
</exec>
<antcall target="add_new_cluster"/>
<antcall target="configure_limits"/>
</target>
<target name="add_new_cluster" description="Adds the cluster name to the database" if="firstrun">
<sql classpath="${env.ORACLE_HOME}/lib/ojdbc8.jar"
driver="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@${ADDR4}:1521:${db_service}"
userid="${db_username}"
password="${db_password}">
insert into cluster_list (id, name, num_characters, address, secret, locked, not_recommended)
select (select nvl(max(id)+1,1) from cluster_list), '${cluster_name}', 0, '${ADDR4}', 'N', 'N', 'N' from dual
where not exists (select '${cluster_name}', '${ADDR4}' from cluster_list);
</sql>
</target>
<target name="configure_limits" description="Defines the limits of the cluster and accounts in the database">
<sql classpath="${env.ORACLE_HOME}/lib/ojdbc8.jar"
driver="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@${ADDR4}:1521:${db_service}"
userid="${db_username}"
password="${db_password}">
update default_char_limits set account_limit = ${max_characters_per_account}, cluster_limit = ${max_characters_per_cluster};
update default_character_slots set num_slots = ${character_slots} where character_type_id = 1;
</sql>
</target>
<!-- Target used to delete database tables - change properties file "firstrun" from "false" to "true" to enable execution -->
<target name="drop_database" description="completely wipes database data">
<input message="All data WILL BE DELETED from SWG DB!!! ARE YOU SURE YOU WANT TO DELETE? Type the word DELETE if you do: " addproperty="do.delete"/>
<condition property="do.drop">
<equals arg1="DELETE" arg2="${do.delete}"/>
</condition>
<fail unless="do.drop">Database Drop Aborted.</fail>
<replace file="build.properties" token="firstrun = true" value="firstrun = false"/>
<exec executable="perl" dir="${basedir}/src/game/server/database/build/linux">
<env key="PATH" value="${env.PATH}:${tools_home}"/>
<arg value="database_update.pl"/>
<arg value="--username=${db_username}"/>
<arg value="--password=${db_password}"/>
<arg value="--service=${ADDR4}/${db_service}"/>
<arg value="--goldusername=${db_username}"/>
<arg value="--loginusername=${db_username}"/>
<arg value="--drop"/>
<arg value="--packages"/>
</exec>
</target>
<target name="create_symlinks">
<symlink link="${basedir}/data/sku.0/sys.client/compiled/clientdata" resource="${clientdata}" overwrite="true"/>
</target>
<!-- Cleans up empty folders from the build folder -->
<target name="cleanup" description="Clean up">
<delete includeemptydirs="true">
<fileset dir="${data}">
<and>
<size value="0"/>
<type type="dir"/>
</and>
</fileset>
</delete>
</target>
<target name="git_update_submods_to_latest_commit" description="Updates all submodules to the latest remote repository commit">
<exec executable="git" dir="${basedir}">
<arg value="submodule"/>
<arg value="foreach"/>
<arg line="'(git checkout master; git pull)&'"/>
</exec>
</target>
</project>