-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuild.xml
184 lines (166 loc) · 7.43 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
<!--
This file is released under terms of BSD license
See LICENSE file for more information
@author: Mikhail Zhigun
-->
<!-- CLAWFC build process -->
<project name="clawfc" default="main" basedir=".">
<description>Build CLAWFC driver</description>
<!-- Value set externally-->
<property name="claw.properties.dir" value=""/>
<property file="${claw.properties.dir}/claw.properties"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${ant-contrib.dep}"/>
<!-- Classpath for the CX2T Translator library -->
<path id="build.path">
<fileset dir="${3rdparty.dist.dir}">
<include name="**/*.jar" />
</fileset>
<pathelement path="${claw.wani.dep}"/>
<pathelement path="${omni.jni.dep}"/>
</path>
<path id="antlr.path">
<pathelement path="${st4.dep}"/>
<pathelement path="${antlr.dep}"/>
<pathelement path="${antlr4.dep}"/>
<pathelement path="${antlr4.runtime.dep}"/>
</path>
<path id="jaxb.path">
<fileset dir="${3rdparty.dist.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<property name="dep.scan.dir"
value="${driver.gen.src.dir}/clawfc/depscan"/>
<!-- Dependencies scan parser classes -->
<property name="dep.scan.parser.dir"
value="${dep.scan.dir}/parser"/>
<property name="driver.parsers.dir"
value="${driver.gen.src.dir}/clawfc/parsers"/>
<!-- Initialization step -->
<target name="init" description="Initialize build directories">
<tstamp/>
<mkdir dir="${driver.classes.dir}"/>
<mkdir dir="${dep.scan.dir}"/>
<mkdir dir="${dep.scan.parser.dir}"/>
<mkdir dir="${driver.parsers.dir}"/>
</target>
<!-- Check if dependencies scan parsers are up-to-date or need to be re-generated -->
<target name="antlr.depscan" depends="init" description="Generate parsers from ANTLR grammar file">
<outofdate outputsources="antlr.depscan.outdated.sources">
<sourcefiles>
<fileset dir="${driver.src.dir}/clawfc/depscan" casesensitive="yes">
<include name="*.g4"/>
</fileset>
</sourcefiles>
<targetfiles path="${driver.dep}"/>
<sequential>
<echo message=" ${antlr.depscan.outdated.sources}"/>
<java jvm="${java.exec}" classname="org.antlr.v4.Tool" fork="true" failonerror="true" classpathref="antlr.path">
<arg value="-o"/>
<arg value="${dep.scan.parser.dir}"/>
<arg value="-package"/>
<arg value="clawfc.depscan.parser"/>
<arg line="${antlr.depscan.outdated.sources}"/>
</java>
</sequential>
</outofdate>
</target>
<target name="antlr.clawfc" depends="init" description="Generate parsers from ANTLR grammar file">
<outofdate outputsources="antlr.clawfc.outdated.sources">
<sourcefiles>
<fileset dir="${driver.src.dir}/clawfc" casesensitive="yes">
<include name="*.g4"/>
</fileset>
</sourcefiles>
<targetfiles path="${driver.dep}"/>
<sequential>
<echo message=" ${antlr.clawfc.outdated.sources}"/>
<java jvm="${java.exec}" classname="org.antlr.v4.Tool" fork="true" failonerror="true" classpathref="antlr.path">
<arg value="-o"/>
<arg value="${driver.parsers.dir}"/>
<arg value="-package"/>
<arg value="clawfc.parsers"/>
<arg line="${antlr.clawfc.outdated.sources}"/>
</java>
</sequential>
</outofdate>
</target>
<target name="antlr" depends="antlr.depscan,antlr.clawfc" description="Generate parsers from ANTLR grammar files"/>
<target name="xjc" depends="init" description="Generate serialization classes from xsd schemas">
<outofdate outputsources="outdated.xsds">
<sourcefiles>
<fileset dir="${driver.src.dir}/clawfc/depscan/serial" casesensitive="yes">
<include name="*.xsd"/>
</fileset>
</sourcefiles>
<targetfiles path="${driver.dep}"/>
<sequential>
<echo message=" ${outdated.xsds}"/>
<java jvm="${java.exec}" classname="com.sun.tools.xjc.XJCFacade" fork="true" failonerror="true" classpathref="jaxb.path">
<arg value="-d"/>
<arg value="${driver.gen.src.dir}"/>
<arg value="-p"/>
<arg value="clawfc.depscan.serial"/>
<arg line="${outdated.xsds}"/>
</java>
</sequential>
</outofdate>
</target>
<target name="compile" depends="antlr, xjc" description="compile the source">
<javac executable="${javac.exec}" fork="yes" includeantruntime="false" srcdir=""
destdir="${driver.classes.dir}" classpathref="build.path" debug="on">
<src>
<pathelement path="${driver.src.dir}"/>
<pathelement path="${driver.gen.src.dir}"/>
</src>
</javac>
</target>
<!-- Package compiled files into their own library -->
<target name="jar" depends="compile" description="package, output to JAR">
<mkdir dir="${dist.dir}"/>
<!-- Driver -->
<jar jarfile="${driver.dep}" basedir="${driver.classes.dir}"
includes="clawfc/**">
<manifest>
<attribute name="Main-Class" value="clawfc.Driver"/>
<attribute name="Class-Path" value="${driver.runtime.classpath}"/>
</manifest>
<zipfileset dir="${driver.conf.dir}"
includes="${driver.conf.file}"
fullpath="config/${driver.conf.file}"/>
<zipfileset dir="${driver.src.dir}/clawfc/depscan/serial"
includes="**/*.xsd"
prefix="clawfc/depscan/serial"/>
</jar>
<chmod file="${driver.dep}" perm="a+x"/>
</target>
<!-- Update jar config after install-->
<target name="post-install" description="Update jar config">
<copy file="${driver.conf.dir}/${driver.conf.file}" tofile="${driver.conf.dir}/${driver.runtime.conf.file}"/>
<propertyfile file="${driver.conf.dir}/${driver.runtime.conf.file}">
<entry key="claw.home" value="${claw.install.dir}"/>
<entry key="omni.home" value="${xcodeml-tools.install.dir}"/>
</propertyfile>
<jar destfile="${claw.install.dir}/bin/${driver.jar}" update="true">
<zipfileset dir="${driver.conf.dir}"
includes="${driver.runtime.conf.file}"
fullpath="config/${driver.conf.file}"/>
</jar>
<chmod file="${claw.install.dir}/bin/${driver.jar}" perm="a+x"/>
</target>
<target name="clean" description="clean up">
<delete dir="${driver.classes.dir}"/>
<delete dir="${dep.scan.dir}"/>
<delete file="${driver.dep}"/>
</target>
<path id="ut.build.path">
<pathelement path="${junit.dep}" />
<pathelement path="${st4.dep}"/>
<pathelement path="${antlr.dep}"/>
<pathelement path="${antlr4.dep}"/>
<pathelement path="${antlr4.runtime.dep}"/>
<pathelement path="${driver.dep}"/>
</path>
<!-- Default target -->
<target name="main" depends="init, antlr, xjc, compile, jar"/>
</project>