forked from soot-oss/soot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
446 lines (398 loc) · 18.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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
<?xml version="1.0"?>
<project xmlns:ivy="antlib:org.apache.ivy.ant" default="compile" name="Soot Build File">
<property file="ant.settings"/>
<property name="ivy.install.version" value="2.1.0-rc2" />
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
</condition>
<property name="ivy.home" value="${user.home}/.ivy2" />
<property name="ivy.jar.dir" value="${ivy.home}/lib" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<target name="settings">
<fail
message="Please copy ant.settings.template to ant.settings, and set the variables in it."
unless="jasmin.jar"
/>
</target>
<target name="compile" depends="settings,sablecc,jastadd,copypeephole,settings,singletons,options"
description="Build Soot.">
<mkdir dir="classes"/>
<javac
destdir="classes"
debug="true"
includeantruntime="true"
deprecation="on"
source="1.6"
target="1.6"
fork="true"
memorymaximumsize="512m"
>
<compilerarg value="-Xlint:all"/>
<compilerarg value="-Xlint:-unchecked"/>
<compilerarg value="-Xlint:-serial"/>
<compilerarg value="-Xlint:-dep-ann"/>
<compilerarg value="-Xlint:-cast"/>
<classpath>
<pathelement location="classes"/>
<pathelement location="${polyglot.jar}"/>
<pathelement location="${xmlprinter.jar}"/>
<pathelement location="${jasmin.jar}"/>
<pathelement location="${heros.jar}"/>
<pathelement location="${axmlprinter2.jar}"/>
<pathelement location="${asm.jar}"/>
<pathelement location="${jboss-common-core.jar}"/>
<pathelement location="${slf4j-api.jar}"/>
<pathelement location="${slf4j-simple.jar}"/>
<pathelement location="${dexlib2.jar}"/>
<pathelement location="${dexlib-utils.jar}"/>
</classpath>
<src path="src"/>
<src path="generated/singletons"/>
<src path="generated/sablecc"/>
<src path="generated/jastadd"/>
<src path="generated/options"/>
</javac>
<copy file="src/soot/jbco/gui/jbco.jpg" tofile="classes/soot/jbco/gui/jbco.jpg"/>
</target>
<target name="singletons" depends="singletons-dep" unless="singletons-uptodate">
<xslt
style="${basedir}/src/make-singletons.xsl"
in="${basedir}/src/singletons.xml"
out="${basedir}/generated/singletons/soot/Singletons.java"
/>
</target>
<target name="singletons-dep">
<uptodate property="singletons-uptodate" targetfile="generated/singletons/soot/Singletons.java">
<srcfiles dir="src" includes="singletons.xml"/>
</uptodate>
</target>
<target name="options" depends="settings">
<xslt
style="${basedir}/src/soot/options/make-soot-options.xsl"
in="${basedir}/src/soot/options/soot_options.xml"
out="${basedir}/generated/options/soot/options/Options.java"
/>
<xslt
style="${basedir}/src/soot/options/ant-task.xsl"
in="${basedir}/src/soot/options/soot_options.xml"
out="${basedir}/generated/options/soot/AntTask.java"
/>
<xslt
style="${basedir}/src/soot/options/phase_options_dialog.xsl"
in="${basedir}/src/soot/options/soot_options.xml"
out="${basedir}/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/ui/PhaseOptionsDialog.java"
/>
<xslt
style="${basedir}/src/soot/options/soot_options.xsl"
in="${basedir}/src/soot/options/soot_options.xml"
out="${basedir}/doc/soot_options.htm"
/>
<copy file="${basedir}/src/soot/options/soot_options.css" todir="${basedir}/doc" />
</target>
<target name="copypeephole" depends="sablecc,settings">
<copy file="src/soot/baf/toolkits/base/peephole.dat" tofile="classes/soot/baf/toolkits/base/peephole.dat"/>
<copy file="generated/sablecc/soot/jimple/parser/parser/parser.dat" tofile="classes/soot/jimple/parser/parser/parser.dat"/>
<copy file="generated/sablecc/soot/jimple/parser/lexer/lexer.dat" tofile="classes/soot/jimple/parser/lexer/lexer.dat"/>
</target>
<target name="determine-sablecc-uptodate">
<uptodate property="sablecc.uptodate" srcfile="src/jimple.scc" targetfile="generated/sablecc/soot/jimple/parser/parser/Parser.java"/>
</target>
<target name="sablecc" depends="determine-sablecc-uptodate,settings" unless="sablecc.uptodate">
</target>
<target name="determine-jastadd-uptodate" depends="settings" if="jastaddfrontend.loc">
<uptodate property="jastadd.uptodate" targetfile="generated/jastadd/beaver/Action.java">
<srcfiles dir= "${jastaddfrontend.loc}" includes="**/*.jrag,**/*.flex,**/*.parser,**/*.scanner"/>
</uptodate>
</target>
<target name="jastadd" depends="determine-jastadd-uptodate,settings" unless="jastadd.uptodate" if="jastaddfrontend.loc">
<ant antfile="${jastaddfrontend.loc}/build.xml" target="gen" inheritall="false"/>
<mkdir dir="generated/jastadd"/>
<copy todir="generated/jastadd/soot">
<fileset dir="${jastaddfrontend.loc}/soot" includes="**/*.java"/>
</copy>
<copy todir="generated/jastadd/beaver">
<fileset dir="${jastaddfrontend.loc}/beaver" includes="**/*.java"/>
</copy>
</target>
<target name="javadoc"
description="Build the javadoc.">
<javadoc
classpath="classes:${polyglot.jar}:${jasmin.jar}:${heros.jar}"
sourcepath="src:generated/singletons:generated/sablecc:generated/options"
destdir="javadoc"
maxmemory="400m"
link="${javaapi.url}"
windowtitle="Soot API"
use="true"
useexternalfile="true"
>
<fileset dir="src" includes="**/*.java"/>
</javadoc>
<jar basedir="javadoc" destfile="${release.loc}/sootjavadoc-${soot.version}.jar" />
</target>
<target name="clean" depends="clean-reports"
description="Delete the class files and test reports.">
<delete quiet="true">
<fileset dir="classes" includes="**/*.class" />
<fileset dir="testclasses" includes="**/*.class" />
<fileset dir="eclipse/ca.mcgill.sable.soot/classes" includes="**/*.class" />
<fileset dir="eclipse/ca.mcgill.sable.graph/classes" includes="**/*.class" />
</delete>
</target>
<target name="clean-reports">
<delete quiet="true" includeEmptyDirs="true">
<fileset dir="reports"/>
</delete>
</target>
<target name="veryclean" depends="clean,veryclean-singletons,veryclean-options,veryclean-sablecc,veryclean-jastadd"
description="Delete the class files, test reports, and automatically-generated source files."/>
<target name="veryclean-singletons">
<delete quiet="true">
<fileset dir="generated/singletons" includes="**/*" />
</delete>
</target>
<target name="veryclean-options">
<delete quiet="true">
<fileset dir="generated/options" includes="**/*" />
<filename name="eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/ui/PhaseOptionsDialog.java"/>
</delete>
</target>
<target name="veryclean-sablecc">
<input
message="This will delete files that require SABLECC to be installed to regenerate. Are you sure?"
validargs="y,n"
addproperty="do.sablecc.delete"
/>
<condition property="do.sablecc.abort">
<equals arg1="n" arg2="${do.sablecc.delete}"/>
</condition>
<fail if="do.sablecc.abort">Build aborted by user.</fail>
<delete quiet="true">
<fileset dir="generated/sablecc" includes="**/*" />
</delete>
</target>
<target name="veryclean-jastadd">
<input
message="This will delete files that require JastAdd to be installed to regenerate. Are you sure?"
validargs="y,n"
addproperty="do.jastadd.delete"
/>
<condition property="do.jastadd.abort">
<equals arg1="n" arg2="${do.jastadd.delete}"/>
</condition>
<fail if="do.jastadd.abort">Build aborted by user.</fail>
<delete quiet="true" includeemptydirs="true">
<fileset dir="generated/jastadd" includes="**/*" />
</delete>
</target>
<target name="badfields" depends="compile,settings"
description="Build BadFields: a utility for displaying various warnings about a program.">
<java
classname="soot.tools.BadFields"
maxmemory="200m"
fork="true"
classpath="classes:${polyglot.jar}:${jasmin.jar}"
>
<arg value="-w"/>
<arg value="-f"/>
<arg value="none"/>
<arg value="-process-dir"/>
<arg value="classes"/>
<arg value="soot.Main"/>
</java>
</target>
<target name="buildtests" depends="compile,settings">
<mkdir dir="testclasses"/>
<javac
source="1.6"
target="1.6"
srcdir="tests"
destdir="testclasses"
debug="true">
<classpath>
<pathelement location="classes"/>
<pathelement location="${polyglot.jar}"/>
<pathelement location="${jasmin.jar}"/>
<pathelement location="${asm.jar}"/>
<pathelement location="${junit.jar}"/>
<pathelement location="${hamcrest.jar}"/>
<pathelement location="${mockito.jar}"/>
<pathelement location="${powermock-mockito.jar}"/>
</classpath>
</javac>
</target>
<target name="runtests" depends="buildtests,settings"
description="Run the regression test suite.">
<mkdir dir="reports" />
<junit printsummary="yes" fork="true">
<classpath>
<pathelement location="testclasses"/>
<pathelement location="classes"/>
<pathelement location="${polyglot.jar}"/>
<pathelement location="${jasmin.jar}"/>
<pathelement location="${axmlprinter2.jar}"/>
<pathelement location="${dexlib2.jar}"/>
<pathelement location="${dexlib-utils.jar}"/>
<pathelement location="${heros.jar}"/>
<pathelement location="${asm.jar}"/>
<pathelement location="${javassist.jar}"/>
<pathelement location="${xmlprinter.jar}"/>
<pathelement location="${jboss-common-core.jar}"/>
<pathelement location="${slf4j-api.jar}"/>
<pathelement location="${slf4j-simple.jar}"/>
<pathelement location="${junit.jar}"/>
<pathelement location="${hamcrest.jar}"/>
<pathelement location="${mockito.jar}"/>
<pathelement location="${powermock-mockito.jar}"/>
</classpath>
<jvmarg value="-ea" />
<formatter type="xml" usefile="true" />
<batchtest todir="reports">
<fileset dir="testclasses" includes="**/Test*.class" excludes="**/Abstract*.class" />
<fileset dir="testclasses" includes="**/*Test.class" excludes="**/Abstract*.class" />
</batchtest>
</junit>
</target>
<target name="reporttests" depends="runtests"
description="Run the regression test suite and create its JUnit reports in reports subdirectory.">
<junitreport tofile="TESTS-TestSuites.xml" todir="reports">
<fileset dir="reports">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="reports" />
</junitreport>
</target>
<target name="release" depends="barebones,javadoc,settings">
</target>
<target name="barebones" depends="clean,options,sablecc,settings"
description="Build a tarball and a jar of the source root directory in the release subdirectory (usually lib).">
<tar destfile="${release.loc}/sootsrc-${soot.version}.tar.gz" compression="gzip" longfile="gnu">
<tarfileset dir="."/>
</tar>
<jar destfile="${release.loc}/sootsrc-${soot.version}.jar">
<fileset dir="."/>
</jar>
</target>
<target name="classesjar" depends="settings,compile"
description="Build the class files jar in the release subdirectory (usually lib).">
<mkdir dir="META-INF"/>
<manifest file="META-INF/MANIFEST.MF">
<attribute name="Main-Class" value="soot.Main"/>
<attribute name="Implementation-Version" value="${soot.version}"/>
</manifest>
<jar destfile="${release.loc}/sootclasses-${soot.version}.jar" manifest="META-INF/MANIFEST.MF">
<fileset dir="classes"/>
</jar>
<delete dir="META-INF"/>
</target>
<target name="eclipse-plugin" depends="compile,settings,graph-plugin"
description="Build the Eclipse plugin.">
<xslt
style="src/soot/options/phase_options_dialog.xsl"
in="src/soot/options/soot_options.xml"
out="eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/ui/PhaseOptionsDialog.java"
/>
<javac
destdir="eclipse/ca.mcgill.sable.soot/classes"
debug="true"
>
<src path="eclipse/ca.mcgill.sable.soot/src"/>
<classpath>
<pathelement location="classes"/>
<pathelement location="eclipse/ca.mcgill.sable.graph/graph.jar"/>
<fileset dir="${eclipse.loc}/plugins/" includes="**/*.jar"/>
</classpath>
</javac>
<jar destfile="eclipse/ca.mcgill.sable.soot/soot-plugin.jar">
<fileset dir="eclipse/ca.mcgill.sable.soot/classes"/>
<fileset dir="eclipse/ca.mcgill.sable.soot/src" includes="**/*.properties"/>
</jar>
<replaceregexp
match="sootclasses-.*\.jar"
replace="sootclasses-${soot.version}.jar"
>
<fileset dir="eclipse/ca.mcgill.sable.soot" includes="plugin.xml"/>
</replaceregexp>
</target>
<!-- build the graph plugin-->
<target name="graph-plugin">
<javac
destdir="eclipse/ca.mcgill.sable.graph/classes"
debug="true"
>
<src path="eclipse/ca.mcgill.sable.graph/src"/>
<classpath>
<pathelement location="classes"/>
<fileset dir="${eclipse.loc}/plugins/" includes="**/*.jar"/>
</classpath>
</javac>
<jar destfile="eclipse/ca.mcgill.sable.graph/graph.jar">
<fileset dir="eclipse/ca.mcgill.sable.graph/classes"/>
</jar>
</target>
<target name="fulljar" depends="classesjar"
description="Build the complete jar file sootclasses-(version).jar that includes Soot's class files and its required libraries, in the release subdirectory (usually lib).">
<mkdir dir="META-INF"/>
<manifest file="META-INF/MANIFEST.MF">
<attribute name="Main-Class" value="soot.Main"/>
<attribute name="Implementation-Version" value="${soot.version}"/>
</manifest>
<jar destfile="${release.loc}/soot-${soot.version}.jar" manifest="META-INF/MANIFEST.MF">
<zipfileset src="${release.loc}/sootclasses-${soot.version}.jar"/>
<zipfileset src="${jasmin.jar}"/>
<zipfileset src="${heros.jar}"/>
<zipfileset src="${polyglot.jar}"/>
<zipfileset src="${xmlprinter.jar}"/>
<zipfileset src="${dexlib2.jar}"/>
<zipfileset src="${dexlib-utils.jar}"/>
<zipfileset src="${asm.jar}"/>
<zipfileset src="${jboss-common-core.jar}"/>
</jar>
<delete dir="META-INF"/>
</target>
<target name="sourcejar"
description="Build the jar file sootsources-(version).jar containing only the source files, in the release subdirectory (usually lib).">
<jar destfile="${release.loc}/sootsources-${soot.version}.jar">
<fileset dir="src"/>
<fileset dir="generated/singletons"/>
<fileset dir="generated/sablecc"/>
<fileset dir="generated/jastadd"/>
<fileset dir="generated/options"/>
</jar>
</target>
<!-- IVY-RELATED TARGETS -->
<target name="download-ivy" unless="offline">
<mkdir dir="${ivy.jar.dir}"/>
<!-- download Ivy from web site so that it can be used even without any special installation -->
<get src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
</target>
<target name="init-ivy" depends="download-ivy">
<!-- try to load ivy here from ivy home, in case the user has not already dropped
it into ant's lib dir (note that the latter copy will always take precedence).
We will not fail as long as local lib dir exists (it may be empty) and
ivy is in at least one of ant's lib dir or the local lib dir. -->
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</target>
<target name="gen-pom" depends="init-ivy">
<ivy:makepom ivyfile="ivy.xml" pomfile="${release.loc}/soot-${soot.version}.pom">
<mapping conf="default" scope="compile" />
</ivy:makepom>
</target>
<target name="publish-local" depends="init-ivy, gen-pom, fulljar, classesjar, sourcejar, javadoc">
<ivy:resolve/>
<ivy:publish pubrevision="${soot.version}" status="release" resolver="local" overwrite="true" >
<artifacts pattern="${release.loc}/[artifact]-[revision].[ext]"/>
</ivy:publish>
</target>
<target name="publish-local-maven" depends="init-ivy, gen-pom, fulljar, classesjar, sourcejar, javadoc" description="Publish jar/source to Maven repository mounted at ~/.m2/repository.">
<ivy:resolve/>
<ivy:publish pubrevision="${soot.version}" resolver="local-m2-publish" forcedeliver="true" overwrite="true" publishivy="false">
<artifacts pattern="${release.loc}/[artifact]-[revision].[ext]" />
</ivy:publish>
</target>
</project>