harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r804884 [2/2] - in /harmony/enhanced/tools/trunk/minijre: ./ conf/ native/ script/ src/org/crazynut/harmony/minjre/ src/org/crazynut/harmony/minjre/anttask/ src/org/crazynut/harmony/minjre/bin/
Date Mon, 17 Aug 2009 07:35:17 GMT
Modified: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/anttask/AnalyzeDependencyTask.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/anttask/AnalyzeDependencyTask.java?rev=804884&r1=804883&r2=804884&view=diff
==============================================================================
--- harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/anttask/AnalyzeDependencyTask.java
(original)
+++ harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/anttask/AnalyzeDependencyTask.java
Mon Aug 17 07:35:16 2009
@@ -1,76 +1,76 @@
-package org.crazynut.harmony.minjre.anttask;
-
-import java.util.Vector;
-import java.io.File;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.taskdefs.Ant.Reference;
-import org.apache.tools.ant.types.Path;
-import org.crazynut.harmony.minjre.StaticDependencyAnalyzer;
-
-/**
- * The ant task that can analyze static dependency of a set of classes.
- * 
- * @author  <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
- *
- */
-public class AnalyzeDependencyTask extends Task{
-	
-	private File aim = null;
-	
-	private File jrelib = null;
-	
-	private Path path = null;
-	
-	public void execute() {
-		if (null == aim || null == jrelib || 0 == path.size()) {
-			log("Incorrect use of this task.\n");
-			throw new BuildException();
-		}
-
-		String[] list = path.list();
-		for (int i = 0; i < list.length; i++) {
-			File file = new File(list[i]);
-			if (file.isFile() && (!file.getName().endsWith(".jar") || !file.getName().endsWith(".class")))
{
-				throw new BuildException(list[i] 
-				        + " is not a valid classpath.");
-			}
-		}
-		log("Start to analyze static dependency.\n");
-		log("Analyzing ...\n");
-		StaticDependencyAnalyzer ana = new StaticDependencyAnalyzer();
-		ana.setJreLibPath(jrelib.getAbsolutePath());
-		for (int i = 0; i < list.length; i++) {
-			ana.addClassPath(list[i]);
-		}
-		ana.getDependentClasses(aim.getAbsolutePath());
-		log("Analyzing complete.\n");
-	}
-	
-	public void setAim(File aim) {
-		if (aim.isFile() || aim.getName().endsWith(".cns")) {
-			this.aim = aim;
-		} else {
-			throw new BuildException(aim.getAbsolutePath() 
-					+ " is not a valid cns file.");
-		}
-	}
-	
-	public void setJrelib(File jrelib) {
-		if (jrelib.isDirectory()) {
-			this.jrelib = jrelib;
-		} else {
-			throw new BuildException(jrelib.getAbsolutePath()
-					+ " is not a valid directory.");
-		}
-	}
-
-	public Path createClasspath() {
-        if (path == null) {
-            path = new Path(getProject());
-        }
-        return path.createPath();
-	}
-
-}
+package org.crazynut.harmony.minjre.anttask;
+
+import java.util.Vector;
+import java.io.File;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Ant.Reference;
+import org.apache.tools.ant.types.Path;
+import org.crazynut.harmony.minjre.StaticDependencyAnalyzer;
+
+/**
+ * The ant task that can analyze static dependency of a set of classes.
+ * 
+ * @author  <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
+ *
+ */
+public class AnalyzeDependencyTask extends Task{
+	
+	private File aim = null;
+	
+	private File jrelib = null;
+	
+	private Path path = null;
+	
+	public void execute() {
+		if (null == aim || null == jrelib || 0 == path.size()) {
+			log("Incorrect use of this task.\n");
+			throw new BuildException();
+		}
+
+		String[] list = path.list();
+		for (int i = 0; i < list.length; i++) {
+			File file = new File(list[i]);
+			if (file.isFile() && (!file.getName().endsWith(".jar") || !file.getName().endsWith(".class")))
{
+				throw new BuildException(list[i] 
+				        + " is not a valid classpath.");
+			}
+		}
+		log("Start to analyze static dependency.\n");
+		log("Analyzing ...\n");
+		StaticDependencyAnalyzer ana = new StaticDependencyAnalyzer();
+		ana.setJreLibPath(jrelib.getAbsolutePath());
+		for (int i = 0; i < list.length; i++) {
+			ana.addClassPath(list[i]);
+		}
+		ana.getDependentClasses(aim.getAbsolutePath());
+		log("Analyzing complete.\n");
+	}
+	
+	public void setAim(File aim) {
+		if (aim.isFile() || aim.getName().endsWith(".cns")) {
+			this.aim = aim;
+		} else {
+			throw new BuildException(aim.getAbsolutePath() 
+					+ " is not a valid cns file.");
+		}
+	}
+	
+	public void setJrelib(File jrelib) {
+		if (jrelib.isDirectory()) {
+			this.jrelib = jrelib;
+		} else {
+			throw new BuildException(jrelib.getAbsolutePath()
+					+ " is not a valid directory.");
+		}
+	}
+
+	public Path createClasspath() {
+        if (path == null) {
+            path = new Path(getProject());
+        }
+        return path.createPath();
+	}
+
+}

Propchange: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/anttask/AnalyzeDependencyTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/anttask/GenerateJreTask.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/anttask/GenerateJreTask.java?rev=804884&r1=804883&r2=804884&view=diff
==============================================================================
--- harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/anttask/GenerateJreTask.java
(original)
+++ harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/anttask/GenerateJreTask.java
Mon Aug 17 07:35:16 2009
@@ -1,92 +1,92 @@
-package org.crazynut.harmony.minjre.anttask;
-
-import java.io.File;
-import java.util.Vector;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.taskdefs.Ant.Reference;
-import org.apache.tools.ant.types.Path;
-import org.crazynut.harmony.minjre.JreGenerator;
-
-/**
- * The ant task that can generate a new JRE from a set of cns files.
- * 
- * @author  <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
- *
- */
-public class GenerateJreTask extends Task {
-	
-	private File origin = null;
-	
-	private File target = null;
-	
-	private String jre = null;
-	
-	private Path path = null;
-	
-	public void execute() {
-		if (null == origin || null == target 
-				|| null == jre || 0 == path.size()) {
-			log("Incorrect use of this task.\n");
-			throw new BuildException();
-		}
-		JreGenerator gen = new JreGenerator(jre);
-		String[] list = path.list();
-		for (int i = 0; i < list.length; i++) {
-			File current = new File(list[i]);
-			if (current.isFile()) {
-				if (current.getName().endsWith(".cns")) {
-					gen.addReservedClasses(current);
-				} else {
-					throw new BuildException(list[i] 
-				        + " is not a valid cns file.");
-				}
-			} else if (current.isDirectory()) {
-				File[] files = current.listFiles();
-				for (int j = 0; j < files.length; j++) {
-					if (files[j].isFile() && files[j].getName().endsWith(".cns")) {
-						gen.addReservedClasses(files[j]);
-					}
-				}
-			} else {
-				throw new BuildException(list[i]
-			        + " does not exist.");
-			}
-		}
-		log("Start to generate JRE.\n");
-		log("Generating ...\n");
-		gen.generateMinJre(origin.getAbsolutePath(), target.getAbsolutePath());
-		log("Generating complete.\n");
-	}
-
-	public void setJre(String jre) {
-		this.jre = jre;
-	}
-	
-	public void setOrigin(File origin) {
-		if (origin.isDirectory()) {
-			this.origin = origin;
-		} else {
-			throw new BuildException(origin.getAbsolutePath() 
-					+ " is not a valid existing directory.");
-		}
-	}
-	
-	public void setTarget(File target) {
-		if (target.isDirectory() || target.mkdir()) {
-			this.target = target;
-		} else {
-			throw new BuildException(target.getAbsolutePath()
-					+ " does not exist or can not be created.");
-		}
-	}
-	
-	public Path createCnspath() {
-        if (path == null) {
-            path = new Path(getProject());
-        }
-        return path.createPath();
-	}
-
-}
+package org.crazynut.harmony.minjre.anttask;
+
+import java.io.File;
+import java.util.Vector;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Ant.Reference;
+import org.apache.tools.ant.types.Path;
+import org.crazynut.harmony.minjre.JreGenerator;
+
+/**
+ * The ant task that can generate a new JRE from a set of cns files.
+ * 
+ * @author  <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
+ *
+ */
+public class GenerateJreTask extends Task {
+	
+	private File origin = null;
+	
+	private File target = null;
+	
+	private String jre = null;
+	
+	private Path path = null;
+	
+	public void execute() {
+		if (null == origin || null == target 
+				|| null == jre || 0 == path.size()) {
+			log("Incorrect use of this task.\n");
+			throw new BuildException();
+		}
+		JreGenerator gen = new JreGenerator(jre);
+		String[] list = path.list();
+		for (int i = 0; i < list.length; i++) {
+			File current = new File(list[i]);
+			if (current.isFile()) {
+				if (current.getName().endsWith(".cns")) {
+					gen.addReservedClasses(current);
+				} else {
+					throw new BuildException(list[i] 
+				        + " is not a valid cns file.");
+				}
+			} else if (current.isDirectory()) {
+				File[] files = current.listFiles();
+				for (int j = 0; j < files.length; j++) {
+					if (files[j].isFile() && files[j].getName().endsWith(".cns")) {
+						gen.addReservedClasses(files[j]);
+					}
+				}
+			} else {
+				throw new BuildException(list[i]
+			        + " does not exist.");
+			}
+		}
+		log("Start to generate JRE.\n");
+		log("Generating ...\n");
+		gen.generateMinJre(origin.getAbsolutePath(), target.getAbsolutePath());
+		log("Generating complete.\n");
+	}
+
+	public void setJre(String jre) {
+		this.jre = jre;
+	}
+	
+	public void setOrigin(File origin) {
+		if (origin.isDirectory()) {
+			this.origin = origin;
+		} else {
+			throw new BuildException(origin.getAbsolutePath() 
+					+ " is not a valid existing directory.");
+		}
+	}
+	
+	public void setTarget(File target) {
+		if (target.isDirectory() || target.mkdir()) {
+			this.target = target;
+		} else {
+			throw new BuildException(target.getAbsolutePath()
+					+ " does not exist or can not be created.");
+		}
+	}
+	
+	public Path createCnspath() {
+        if (path == null) {
+            path = new Path(getProject());
+        }
+        return path.createPath();
+	}
+
+}

Propchange: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/anttask/GenerateJreTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/bin/AnalyzeDependency.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/bin/AnalyzeDependency.java?rev=804884&r1=804883&r2=804884&view=diff
==============================================================================
--- harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/bin/AnalyzeDependency.java
(original)
+++ harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/bin/AnalyzeDependency.java
Mon Aug 17 07:35:16 2009
@@ -1,101 +1,101 @@
-package org.crazynut.harmony.minjre.bin;
-
-import java.io.File;
-
-import org.crazynut.harmony.minjre.StaticDependencyAnalyzer;
-
-/**
- * The main class of the static dependency analyzer of MinJre Toolkit.<p>
- * 
- * @author <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
- *
- */
-public class AnalyzeDependency {
-
-	private static String jreLibPath = null;
-	
-	private static String[] rootPath = null;
-	
-	private static String aimFile = null;
-	
-	private static String msg = "";
-	
-	/**
-	 * Parse the arguments.
-	 * 
-	 * @param args the arguments
-	 * @return parsing result
-	 */
-	private static int parseArgs(final String[] args) {
-		if (args.length < 3) {
-			return -1;
-		} else {
-			String[] libArg = args[0].split("=");
-			String[] pathArg = args[1].split("=");
-			String[] aimArg = args[2].split("=");
-			if (!libArg[0].equals("-jrelib") || !pathArg[0].equals("-classpath") || !aimArg[0].equals("-aim")

-					|| libArg.length != 2 || pathArg.length != 2 || aimArg.length != 2) {
-				return -1;
-			} else {
-				File libFile = new File(libArg[1]);
-				if (!libFile.exists() || libFile.isFile()) {
-					msg = libArg[1] + " does not exists as a directory.";
-					return 0;
-				}
-				jreLibPath = libArg[1];
-				String[] paths = pathArg[1].split(";");
-				for (int i = 0; i < paths.length; i++) {
-					File file = new File(paths[i]);
-					if (!file.exists() || (file.isFile() && !paths[i].endsWith(".jar"))) {
-						msg = file + " is not a valid class path.";
-						return 0;
-					}
-				}
-				rootPath = paths;
-			}
-			if (aimArg[1].endsWith(".cns")) {
-				aimFile = aimArg[1];
-			} else {
-				msg = aimArg[1] + " should be a cns file.";
-				return 0;
-			}
-		}
-		return 1;
-	}
-	
-	/**
-	 * 
-	 */
-	private static void printUsage() {
-		System.out.println(
-				"Usage: analyze -jrelib=<jre lib dir> -classpath=<root path list> -aim=<aim
file path>\n" 
-				+ "\tThe root path list is a ; seperated list of directories or jar files or just class
files, which containing all classes in the application.\n" 
-				+ "\tExample: analyze -jrelib=%JRE_HOME%\\lib -classpath=c:\\app\\module1;c:\\app\\lib\\lib1.jar
c:\\app\\cns\\static.cns"
-				);
-	}
-	
-	/**
-	 * @param args
-	 */
-	public static void main(String[] args) {
-		int flag = parseArgs(args);
-		switch (flag) {
-			case -1:
-				printUsage();
-				break;
-			case  0:
-				System.out.println(msg);
-				break;
-			case  1:
-				StaticDependencyAnalyzer ana = new StaticDependencyAnalyzer();
-				ana.setJreLibPath(jreLibPath);
-				for (int i = 0; i < rootPath.length; i++) {
-					ana.addClassPath(rootPath[i]);
-				}
-				ana.getDependentClasses(aimFile);
-				break;
-		default:
-			break;
-		}
-	}
-}
+package org.crazynut.harmony.minjre.bin;
+
+import java.io.File;
+
+import org.crazynut.harmony.minjre.StaticDependencyAnalyzer;
+
+/**
+ * The main class of the static dependency analyzer of MinJre Toolkit.<p>
+ * 
+ * @author <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
+ *
+ */
+public class AnalyzeDependency {
+
+	private static String jreLibPath = null;
+	
+	private static String[] rootPath = null;
+	
+	private static String aimFile = null;
+	
+	private static String msg = "";
+	
+	/**
+	 * Parse the arguments.
+	 * 
+	 * @param args the arguments
+	 * @return parsing result
+	 */
+	private static int parseArgs(final String[] args) {
+		if (args.length < 3) {
+			return -1;
+		} else {
+			String[] libArg = args[0].split("=");
+			String[] pathArg = args[1].split("=");
+			String[] aimArg = args[2].split("=");
+			if (!libArg[0].equals("-jrelib") || !pathArg[0].equals("-classpath") || !aimArg[0].equals("-aim")

+					|| libArg.length != 2 || pathArg.length != 2 || aimArg.length != 2) {
+				return -1;
+			} else {
+				File libFile = new File(libArg[1]);
+				if (!libFile.exists() || libFile.isFile()) {
+					msg = libArg[1] + " does not exists as a directory.";
+					return 0;
+				}
+				jreLibPath = libArg[1];
+				String[] paths = pathArg[1].split(";");
+				for (int i = 0; i < paths.length; i++) {
+					File file = new File(paths[i]);
+					if (!file.exists() || (file.isFile() && !paths[i].endsWith(".jar"))) {
+						msg = file + " is not a valid class path.";
+						return 0;
+					}
+				}
+				rootPath = paths;
+			}
+			if (aimArg[1].endsWith(".cns")) {
+				aimFile = aimArg[1];
+			} else {
+				msg = aimArg[1] + " should be a cns file.";
+				return 0;
+			}
+		}
+		return 1;
+	}
+	
+	/**
+	 * 
+	 */
+	private static void printUsage() {
+		System.out.println(
+				"Usage: analyze -jrelib=<jre lib dir> -classpath=<root path list> -aim=<aim
file path>\n" 
+				+ "\tThe root path list is a ; seperated list of directories or jar files or just class
files, which containing all classes in the application.\n" 
+				+ "\tExample: analyze -jrelib=%JRE_HOME%\\lib -classpath=c:\\app\\module1;c:\\app\\lib\\lib1.jar
c:\\app\\cns\\static.cns"
+				);
+	}
+	
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		int flag = parseArgs(args);
+		switch (flag) {
+			case -1:
+				printUsage();
+				break;
+			case  0:
+				System.out.println(msg);
+				break;
+			case  1:
+				StaticDependencyAnalyzer ana = new StaticDependencyAnalyzer();
+				ana.setJreLibPath(jreLibPath);
+				for (int i = 0; i < rootPath.length; i++) {
+					ana.addClassPath(rootPath[i]);
+				}
+				ana.getDependentClasses(aimFile);
+				break;
+		default:
+			break;
+		}
+	}
+}

Propchange: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/bin/AnalyzeDependency.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/bin/GenerateJre.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/bin/GenerateJre.java?rev=804884&r1=804883&r2=804884&view=diff
==============================================================================
--- harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/bin/GenerateJre.java
(original)
+++ harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/bin/GenerateJre.java
Mon Aug 17 07:35:16 2009
@@ -1,119 +1,119 @@
-package org.crazynut.harmony.minjre.bin;
-
-import java.io.File;
-
-import org.crazynut.harmony.minjre.JreGenerator;
-
-/**
- * The main class of the JRE generator of MinJre Toolkit.<p>
- * 
- * @author <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
- *
- */
-public class GenerateJre {
-
-	private static String jre = null;
-	
-	private static File[] cnsPath = null;
-	
-	private static String toPath = null;
-	
-	private static String fromPath = null;
-	
-	private static String msg = "";
-	
-	/**
-	 * Parse the arguments.
-	 * 
-	 * @param args the arguments
-	 * @return parsing result
-	 */
-	private static int parseArgs(final String[] args) {
-		if (args.length < 4) {
-			return -1;
-		} else {
-			String[] typeArg = args[0].split("=");
-			String[] pathArg = args[1].split("=");
-			String[] originArg = args[2].split("=");
-			String[] targetArg = args[3].split("=");
-			if (!typeArg[0].equals("-jre") || !pathArg[0].equals("-cnspath") || !originArg[0].equals("-origin")
|| !targetArg[0].equals("-target") 
-					|| typeArg.length != 2 || pathArg.length != 2 || originArg.length != 2 || targetArg.length
!= 2) {
-				return -1;
-			} else {
-				//File ini = new File("conf" + File.separator + typeArg[1] + ".cns");
-				//iniFile = ini.getAbsolutePath();
-				jre = typeArg[1];
-				String[] paths = pathArg[1].split(";");
-				cnsPath = new File[paths.length];
-				for (int i = 0; i < paths.length; i++) {
-					cnsPath[i] = new File(paths[i]);
-					if (!cnsPath[i].exists()) {
-						msg = paths[i] + " does not exist.";
-						return 0;
-					}
-					if (cnsPath[i].isFile() && !cnsPath[i].getName().endsWith(".cns")) {
-						msg = paths[i] + " is not a cns file.";
-						return 0;
-					}
-				}
-			}
-			if (new File(originArg[1]).isDirectory()) {
-				fromPath = originArg[1];
-			} else {
-				msg = originArg[1] + " does not exist as a directory.";
-				return 0;
-			}
-			if (new File(targetArg[1]).isDirectory()) {
-				toPath = targetArg[1];
-			} else {
-				msg = targetArg[1] + " does not exist as a directory.";
-				return 0;
-			}
-		}
-		return 1;
-	}
-	
-	/**
-	 * Print out usage of the program.
-	 */
-	private static void printUsage() {
-		System.out.println(
-				"Usage: jregen -jre=<jretype> -cnspath=<cns path list> -origin=<originjre>
-target=<targetdir>\n" 
-				+ "\tThe cns path list is a ; seperated list of cns files and directories which containing
cns files needed to generate the jre.\n" 
-				+ "\tExample: jregen -jre=harmony -cnspath=c:\\app\\module1\\cns;c:\\app\\module2\\cns
-origin=%JRE_HOME% -target=c:\\java\\minjre"
-				);
-	}
-	
-	/**
-	 * @param args
-	 */
-	public static void main(String[] args) {
-		int flag = parseArgs(args);
-		switch (flag) {
-			case -1:
-				printUsage();
-				break;
-			case  0:
-				System.out.println(msg);
-				break;
-			case  1:
-				JreGenerator gen = new JreGenerator(jre);			
-				for (int i = 0; i < cnsPath.length; i++) {
-					if (cnsPath[i].isDirectory()) {
-						File[] list = cnsPath[i].listFiles();
-						for (int j = 0; j < list.length; j++) {
-							if (list[j].getName().endsWith(".cns")) {
-								gen.addReservedClasses(list[j]);
-							}
-						}
-					} else if (cnsPath[i].isFile()) {
-							gen.addReservedClasses(cnsPath[i]);
-					}
-				}
-				gen.generateMinJre(fromPath, toPath);
-				break;
-		default:
-			break;
-		}
-	}
-}
+package org.crazynut.harmony.minjre.bin;
+
+import java.io.File;
+
+import org.crazynut.harmony.minjre.JreGenerator;
+
+/**
+ * The main class of the JRE generator of MinJre Toolkit.<p>
+ * 
+ * @author <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
+ *
+ */
+public class GenerateJre {
+
+	private static String jre = null;
+	
+	private static File[] cnsPath = null;
+	
+	private static String toPath = null;
+	
+	private static String fromPath = null;
+	
+	private static String msg = "";
+	
+	/**
+	 * Parse the arguments.
+	 * 
+	 * @param args the arguments
+	 * @return parsing result
+	 */
+	private static int parseArgs(final String[] args) {
+		if (args.length < 4) {
+			return -1;
+		} else {
+			String[] typeArg = args[0].split("=");
+			String[] pathArg = args[1].split("=");
+			String[] originArg = args[2].split("=");
+			String[] targetArg = args[3].split("=");
+			if (!typeArg[0].equals("-jre") || !pathArg[0].equals("-cnspath") || !originArg[0].equals("-origin")
|| !targetArg[0].equals("-target") 
+					|| typeArg.length != 2 || pathArg.length != 2 || originArg.length != 2 || targetArg.length
!= 2) {
+				return -1;
+			} else {
+				//File ini = new File("conf" + File.separator + typeArg[1] + ".cns");
+				//iniFile = ini.getAbsolutePath();
+				jre = typeArg[1];
+				String[] paths = pathArg[1].split(";");
+				cnsPath = new File[paths.length];
+				for (int i = 0; i < paths.length; i++) {
+					cnsPath[i] = new File(paths[i]);
+					if (!cnsPath[i].exists()) {
+						msg = paths[i] + " does not exist.";
+						return 0;
+					}
+					if (cnsPath[i].isFile() && !cnsPath[i].getName().endsWith(".cns")) {
+						msg = paths[i] + " is not a cns file.";
+						return 0;
+					}
+				}
+			}
+			if (new File(originArg[1]).isDirectory()) {
+				fromPath = originArg[1];
+			} else {
+				msg = originArg[1] + " does not exist as a directory.";
+				return 0;
+			}
+			if (new File(targetArg[1]).isDirectory()) {
+				toPath = targetArg[1];
+			} else {
+				msg = targetArg[1] + " does not exist as a directory.";
+				return 0;
+			}
+		}
+		return 1;
+	}
+	
+	/**
+	 * Print out usage of the program.
+	 */
+	private static void printUsage() {
+		System.out.println(
+				"Usage: jregen -jre=<jretype> -cnspath=<cns path list> -origin=<originjre>
-target=<targetdir>\n" 
+				+ "\tThe cns path list is a ; seperated list of cns files and directories which containing
cns files needed to generate the jre.\n" 
+				+ "\tExample: jregen -jre=harmony -cnspath=c:\\app\\module1\\cns;c:\\app\\module2\\cns
-origin=%JRE_HOME% -target=c:\\java\\minjre"
+				);
+	}
+	
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		int flag = parseArgs(args);
+		switch (flag) {
+			case -1:
+				printUsage();
+				break;
+			case  0:
+				System.out.println(msg);
+				break;
+			case  1:
+				JreGenerator gen = new JreGenerator(jre);			
+				for (int i = 0; i < cnsPath.length; i++) {
+					if (cnsPath[i].isDirectory()) {
+						File[] list = cnsPath[i].listFiles();
+						for (int j = 0; j < list.length; j++) {
+							if (list[j].getName().endsWith(".cns")) {
+								gen.addReservedClasses(list[j]);
+							}
+						}
+					} else if (cnsPath[i].isFile()) {
+							gen.addReservedClasses(cnsPath[i]);
+					}
+				}
+				gen.generateMinJre(fromPath, toPath);
+				break;
+		default:
+			break;
+		}
+	}
+}

Propchange: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/bin/GenerateJre.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message