001: /* Soot - a J*va Optimization Framework
002: * Copyright (C) 2006 Nomair A. Naeem
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the
016: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
017: * Boston, MA 02111-1307, USA.
018: */
019:
020: package soot.dava;
021:
022: import java.io.*;
023: import java.util.ArrayList;
024: import java.util.Iterator;
025:
026: /*
027: * TODO: Jalopy would be awesome here!!
028: */
029: public class DavaBuildFile {
030: public static void generate(PrintWriter out,
031: ArrayList<String> decompiledClasses) {
032: out
033: .print("<project default=\"compile\" name=\"Build file for decompiled code\">\n");
034: out.print(" <description>\n");
035: out
036: .print(" This is the build file produced by Dava for the decompiled code.\n");
037: out
038: .print(" New features like (formatting using jalopy etc) will be added to this build file\n");
039: out.print("</description>\n");
040: out.print("<!-- properties for project directories -->\n");
041: out.print("<property name=\"srcDir\" location=\"src\"/>\n");
042: out
043: .print("<property name=\"classesDir\" location=\"classes\"/>\n");
044: out.print("");
045: out.print("");
046: out.print("");
047: out.print("");
048: out.print("");
049: out.print("");
050: out.print("");
051: /* out.print("<target name=\"init\" description=\"Create necessary directories\">\n");
052: out.print("<tstamp/>\n");
053: out.print(" <!-- set the timestamps -->\n");
054: out.print(" <mkdir dir=\"${classesDir}\"/>\n");
055: out.print(" <mkdir dir=\"${docDir}\"/>\n");
056: // out.print(" <mkdir dir=\"${libDir}\"/>\n");
057: out.print("</target>\n");
058: */
059: out
060: .print(" <!-- ========== Compile Target ================= -->\n");
061: out
062: .print(" <target name=\"compile\" description=\"Compile .java files\">\n");
063: out
064: .print(" <javac srcdir=\"${srcDir}\" destdir=\"${classesDir}\">\n");
065: out.print(" <classpath>\n");
066: out.print(" <pathelement location=\"${junitJar}\"/>\n");
067: out.print(" </classpath>\n");
068: out.print(" </javac>\n");
069: out.print(" </target>\n");
070:
071: out
072: .print(" <!-- ==========AST METRICS FOR DECOMPILED CODE================= -->\n");
073: out
074: .print("<target name=\"ast-metrics\" description=\"Compute the ast metrics\">\n");
075: /*
076: * NEED TO MAKE SURE SRC-PREC IS SET so that java to jimple gets evaluate
077: * The command is going to be java soot.Main -ast-metrics followed by
078: * all the classes on which we had originally done the decompile
079: * Need a specialized task
080: */
081:
082: out.print(" <exec executable=\"java\" dir=\"src\">\n");
083: out.print(" <arg value=\"-Xmx400m\" />\n");
084: out.print(" <arg value=\"soot.Main\" />\n");
085: out.print(" <arg value=\"-ast-metrics\" />\n");
086: out.print(" <arg value=\"--src-prec\" />\n");
087: out.print(" <arg value=\"java\" />\n");
088:
089: Iterator<String> it = decompiledClasses.iterator();
090: while (it.hasNext()) {
091: String temp = it.next();
092: if (temp.endsWith(".java")) {
093: temp = temp.substring(0, temp.length() - 5);
094: }
095: //System.out.println(temp);
096: out.print(" <arg value=\"" + temp + "\" />\n");
097:
098: }
099:
100: out.print("");
101: out.print(" </exec>\n");
102: out.print(" </target>\n");
103: out.print("");
104: out.print("");
105: out.print("");
106: out.print("");
107: out.print("");
108: out.print("");
109: out.print("");
110: out.print("</project>");
111:
112: }
113: }
|