forked from soot-oss/soot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDavaBuildFile.java
More file actions
102 lines (93 loc) · 3.76 KB
/
DavaBuildFile.java
File metadata and controls
102 lines (93 loc) · 3.76 KB
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
package soot.dava;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2006 Nomair A. Naeem
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
/*
* TODO: Jalopy would be awesome here!!
*/
public class DavaBuildFile {
public static void generate(PrintWriter out, ArrayList<String> decompiledClasses) {
out.print("<project default=\"compile\" name=\"Build file for decompiled code\">\n");
out.print(" <description>\n");
out.print(" This is the build file produced by Dava for the decompiled code.\n");
out.print(" New features like (formatting using jalopy etc) will be added to this build file\n");
out.print("</description>\n");
out.print("<!-- properties for project directories -->\n");
out.print("<property name=\"srcDir\" location=\"src\"/>\n");
out.print("<property name=\"classesDir\" location=\"classes\"/>\n");
out.print("");
out.print("");
out.print("");
out.print("");
out.print("");
out.print("");
out.print("");
/*
* out.print("<target name=\"init\" description=\"Create necessary directories\">\n"); out.print("<tstamp/>\n");
* out.print(" <!-- set the timestamps -->\n"); out.print(" <mkdir dir=\"${classesDir}\"/>\n");
* out.print(" <mkdir dir=\"${docDir}\"/>\n"); // out.print(" <mkdir dir=\"${libDir}\"/>\n");
* out.print("</target>\n");
*/
out.print(" <!-- ========== Compile Target ================= -->\n");
out.print(" <target name=\"compile\" description=\"Compile .java files\">\n");
out.print(" <javac srcdir=\"${srcDir}\" destdir=\"${classesDir}\">\n");
out.print(" <classpath>\n");
out.print(" <pathelement location=\"${junitJar}\"/>\n");
out.print(" </classpath>\n");
out.print(" </javac>\n");
out.print(" </target>\n");
out.print(" <!-- ==========AST METRICS FOR DECOMPILED CODE================= -->\n");
out.print("<target name=\"ast-metrics\" description=\"Compute the ast metrics\">\n");
/*
* NEED TO MAKE SURE SRC-PREC IS SET so that java to jimple gets evaluate The command is going to be java soot.Main
* -ast-metrics followed by all the classes on which we had originally done the decompile Need a specialized task
*/
out.print(" <exec executable=\"java\" dir=\"src\">\n");
out.print(" <arg value=\"-Xmx400m\" />\n");
out.print(" <arg value=\"soot.Main\" />\n");
out.print(" <arg value=\"-ast-metrics\" />\n");
out.print(" <arg value=\"--src-prec\" />\n");
out.print(" <arg value=\"java\" />\n");
Iterator<String> it = decompiledClasses.iterator();
while (it.hasNext()) {
String temp = it.next();
if (temp.endsWith(".java")) {
temp = temp.substring(0, temp.length() - 5);
}
// System.out.println(temp);
out.print(" <arg value=\"" + temp + "\" />\n");
}
out.print("");
out.print(" </exec>\n");
out.print(" </target>\n");
out.print("");
out.print("");
out.print("");
out.print("");
out.print("");
out.print("");
out.print("");
out.print("</project>");
}
}