forked from dgrunwald/arden2bytecode
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.xml
252 lines (229 loc) · 11.3 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
Alternate build option for arden2bytecode.
Used in Eclipse Project to launch SableCC.
Author: Hannes Flicka (hflicka@github)
-->
<project name="arden2bytecode" default="default" basedir=".">
<description>arden2bytecode ant build script.</description>
<target name="default" depends="jar"
description="default target, depends on 'jar' which means a binary jar file will be built.">
</target>
<target name="init"
description="initializes used variables, mostly paths and directories">
<tstamp>
<format property="release.stamp" pattern="yyyy-MM-dd" locale="en,US" />
</tstamp>
<property name="debug" value="on" />
<property name="optimize" value="off" />
<property name="deprecation" value="on" />
<property name="version" value="${DSTAMP}-${TSTAMP}" />
<property name="name" value="${ant.project.name}" />
<property name="src.dir" value="src" />
<property name="tools.dir" value="tools" />
<property name="resource.dir" value="resource" />
<property name="lib.dir" value="lib" />
<property name="build.dir" value="bin" />
<property name="dist.dir" value="dist" />
<property name="dist.jar" value="${name}-${version}.jar" />
<property name="run.entrypoint" value="arden.MainClass" />
<filter token="log" value="true" />
<filter token="verbose" value="true" />
<path id="build.classpath">
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<path id="run.classpath">
<path refid="build.classpath" />
<path location="${build.dir}" />
<path location="." />
</path>
<path id="jar.classpath">
<path location="." />
</path>
<condition property="sableCCDirectoriesExist">
<and>
<available file="${src.dir}/arden/compiler/analysis" type="dir" />
<available file="${src.dir}/arden/compiler/lexer" type="dir" />
<available file="${src.dir}/arden/compiler/node" type="dir" />
<available file="${src.dir}/arden/compiler/parser" type="dir" />
<available file="${src.dir}/arden/constants/analysis" type="dir" />
<available file="${src.dir}/arden/constants/lexer" type="dir" />
<available file="${src.dir}/arden/constants/node" type="dir" />
<available file="${src.dir}/arden/constants/parser" type="dir" />
</and>
</condition>
</target>
<target name="createSableCCDirectories" unless="sableCCDirectoriesExist">
<mkdir dir="${src.dir}/arden/compiler/analysis" />
<mkdir dir="${src.dir}/arden/compiler/lexer" />
<mkdir dir="${src.dir}/arden/compiler/node" />
<mkdir dir="${src.dir}/arden/compiler/parser" />
<mkdir dir="${src.dir}/arden/constants/analysis" />
<mkdir dir="${src.dir}/arden/constants/lexer" />
<mkdir dir="${src.dir}/arden/constants/node" />
<mkdir dir="${src.dir}/arden/constants/parser" />
</target>
<target name="cleanClasses" depends="init"
description="clean all java classes and files in the 'bin' directory">
<mkdir dir="${build.dir}" />
<delete includeemptydirs="true">
<fileset dir="${build.dir}" includes="**/*" />
</delete>
</target>
<target name="clean" depends="init,createSableCCDirectories,cleanClasses"
description="clean the 'bin' and 'dist' directories and delete sableCC-generated .java files">
<mkdir dir="${dist.dir}" />
<delete includeemptydirs="true">
<fileset dir="${dist.dir}" includes="**/*" />
<fileset dir="${src.dir}/arden/compiler/analysis" includes="**/*" />
<fileset dir="${src.dir}/arden/compiler/lexer" includes="**/*" />
<fileset dir="${src.dir}/arden/compiler/node" includes="**/*" />
<fileset dir="${src.dir}/arden/compiler/parser" includes="**/*" />
<fileset dir="${src.dir}/arden/constants/analysis" includes="**/*" />
<fileset dir="${src.dir}/arden/constants/lexer" includes="**/*" />
<fileset dir="${src.dir}/arden/constants/node" includes="**/*" />
<fileset dir="${src.dir}/arden/constants/parser" includes="**/*" />
</delete>
</target>
<target name="initSableCC" depends="init,createSableCCDirectories">
<uptodate property="arden.compiler.update.necessary" targetfile="${src.dir}/arden.scc">
<srcfiles dir="${src.dir}/arden/compiler/analysis" includes="**/*" />
<srcfiles dir="${src.dir}/arden/compiler/lexer" includes="**/*" />
<srcfiles dir="${src.dir}/arden/compiler/node" includes="**/*" />
<srcfiles dir="${src.dir}/arden/compiler/parser" includes="**/*" />
</uptodate>
<uptodate property="arden.constants.update.necessary" targetfile="${src.dir}/ardenConstants.scc">
<srcfiles dir="${src.dir}/arden/constants/analysis" includes="**/*" />
<srcfiles dir="${src.dir}/arden/constants/lexer" includes="**/*" />
<srcfiles dir="${src.dir}/arden/constants/node" includes="**/*" />
<srcfiles dir="${src.dir}/arden/constants/parser" includes="**/*" />
</uptodate>
<taskdef name="sablecc" classname="org.sablecc.ant.taskdef.Sablecc">
<classpath>
<pathelement location="${tools.dir}/sablecc.jar"/>
</classpath>
</taskdef>
</target>
<target name="sableCC.constants" depends="init,initSableCC" if="arden.constants.update.necessary">
<sablecc src="${src.dir}" includes="ardenConstants.scc"
outputdirectory="${src.dir}"></sablecc>
</target>
<target name="sableCC.compiler" depends="init,initSableCC" if="arden.compiler.update.necessary">
<sablecc src="${src.dir}" includes="arden.scc"
outputdirectory="${src.dir}"></sablecc>
</target>
<target name="sableCC" depends="init,initSableCC,sableCC.constants,sableCC.compiler"
description="start sableCC to generate parsers from grammars">
</target>
<target name="compileOnly" depends="init"
description="compile all .java files in ./src except for tests">
<mkdir dir="${build.dir}" />
<copy todir="${build.dir}">
<fileset dir="${src.dir}">
<exclude name="**/*.java"/>
<exclude name="**/*.class"/>
</fileset>
</copy>
<javac srcdir="${src.dir}"
destdir="${build.dir}"
debug="${debug}"
classpathref="build.classpath"
optimize="${optimize}"
source="1.6"
includeantruntime="false">
<include name="**/*.java" />
<exclude name="arden/tests/*.java"/>
</javac>
</target>
<target name="compile" depends="sableCC,compileOnly"
description="start sableCC and, after that, compile sources">
</target>
<target name="jarOnly" depends="init"
description="generate .jar bundle from compiled files without actually compiling the sources">
<mkdir dir="${dist.dir}" />
<manifestclasspath property="manifest.classpath" jarfile="${dist.jar}">
<classpath refid="jar.classpath" />
</manifestclasspath>
<jar destfile="${dist.dir}/${dist.jar}">
<manifest>
<attribute name="Built-By" value="${user.name}" />
<attribute name="Main-Class" value="${run.entrypoint}" />
<!-- <attribute name="Class-Path" value="${manifest.classpath}" /> -->
<attribute name="Implementation-Vendor" value="${user.name}" />
<attribute name="Implementation-Title" value="${name}" />
<attribute name="Implementation-Version" value="${version}" />
</manifest>
<fileset dir="${build.dir}" />
<fileset file="${resource.dir}/arden2bytecode.config" />
<zipgroupfileset dir="${lib.dir}" includes="*.jar" />
</jar>
<basename property="jar.filename" file="${dist.jar}" />
<echo file="${dist.dir}/${name}.cmd" append="false">@echo off
java -jar "%~dp0${jar.filename}" %*
rem pause
</echo>
<echo file="${dist.dir}/${name}" append="false">#!/bin/sh
java -jar "$( cd -P "$( dirname "$0" )" && pwd )/${jar.filename}" "$@"
</echo>
<chmod file="${dist.dir}/${name}" perm="ugo+x" />
</target>
<target name="jar" depends="compile,jarOnly"
description="compile, then package everything into a .jar">
</target>
<target name="distOnly" depends="jarOnly"
description="build distribution .tar and .zip file">
<tar destfile="${dist.dir}/${name} - binary release ${release.stamp}.tar.gz"
compression="gzip">
<tarfileset dir="${dist.dir}">
<include name="${dist.jar}"/>
<include name="${name}.cmd"/>
</tarfileset>
<tarfileset dir="${dist.dir}" filemode="755">
<include name="${name}"/>
</tarfileset>
<tarfileset dir="${resource.dir}">
<include name="examples/**" />
</tarfileset>
</tar>
<zip destfile="${dist.dir}/${name} - binary release ${release.stamp}.zip">
<zipfileset dir="${dist.dir}">
<include name="${dist.jar}" />
<include name="${name}.cmd" />
</zipfileset>
<zipfileset dir="${dist.dir}" filemode="755">
<include name="${name}" />
</zipfileset>
<zipfileset dir="${resource.dir}">
<include name="examples/**" />
</zipfileset>
</zip>
</target>
<target name="dist" depends="jar,distOnly"
description="build distribution .tar and .zip file">
</target>
<target name="compileAndJarOnly" depends="compileOnly,jarOnly"
description="compile the sources without starting sableCC, then package a .jar">
</target>
<target name="runOnly" depends="init"
description="run the program from the bin directory">
<property name="echoclasspath" refid="run.classpath" />
<echo message="Running ${run.entrypoint} with classpath: ${echoclasspath}" />
<java classname="${run.entrypoint}" classpathref="run.classpath" fork="true"></java>
</target>
<target name="run" depends="compile,runOnly"
description="compile, then run the program">
</target>
<target name="runAndRedirectOutput" depends="compile"
description="run the program and redirect output to 'output.txt'">
<property name="echoclasspath" refid="run.classpath" />
<echo message="Redirecting output to 'output.txt'" />
<echo message="Running ${run.entrypoint} with classpath: ${echoclasspath}" />
<java classname="${run.entrypoint}"
classpathref="run.classpath"
fork="true"
output="output.txt"
logError="true"></java>
</target>
</project>