]> git.proxmox.com Git - mirror_edk2.git/commitdiff
add ModuleInfo2OutputPath Map
authoralfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 1 Sep 2006 03:24:35 +0000 (03:24 +0000)
committeralfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 1 Sep 2006 03:24:35 +0000 (03:24 +0000)
modify inf chooser

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1417 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/MigrationTools/org/tianocore/migration/Common.java
Tools/Source/MigrationTools/org/tianocore/migration/MigrationTool.java
Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java
Tools/Source/MigrationTools/org/tianocore/migration/ModuleReader.java
Tools/Source/MigrationTools/org/tianocore/migration/MsaWriter.java
Tools/Source/MigrationTools/org/tianocore/migration/PathIterator.java [new file with mode: 0644]
Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java

index 5b4d33adb8299e8fa0633a90d5b1250a3d5a2503..ca51ed43adf4b4ea3bfa951300301a70f7340bf1 100644 (file)
@@ -165,42 +165,4 @@ public final class Common {
        public static interface ForDoAll {\r
                public void toDo(String filepath) throws Exception;\r
        }\r
-       /*\r
-       // this PathIterator is based on HashSet, an thread implementation is required.\r
-       private final class PathIterator implements ForDoAll{\r
-               PathIterator(String path) throws Exception {\r
-                       startpath = path;\r
-                       Common.toDoAll(startpath, this, mode);\r
-               }\r
-               PathIterator(String path, int md) throws Exception {\r
-                       startpath = path;\r
-                       mode = md;\r
-                       Common.toDoAll(startpath, this, mode);\r
-               }\r
-               private String startpath;\r
-               private int mode = Common.BOTH;\r
-               private HashSet<String> pathlist = new HashSet<String>();\r
-               private Iterator<String> it = pathlist.iterator();\r
-               \r
-               public final void toDo(String path) throws Exception {\r
-                       pathlist.add(path);\r
-               }\r
-               \r
-               public final String next() {\r
-                       return it.next();\r
-               }\r
-               \r
-               public final boolean hasNext() {\r
-                       return it.hasNext();\r
-               }\r
-               \r
-               public final String toString() {\r
-                       return pathlist.toString();\r
-               }\r
-       }\r
-       \r
-       public final PathIterator getPathIterator(String path, int md) throws Exception {\r
-               return new PathIterator(path, md);\r
-       }\r
-       */\r
 }\r
index 5c74ee03f18724d6fea8a7a83b47031c06d0112b..3b3486fea6674f6cab546e735f306118750f4c0b 100644 (file)
@@ -1,7 +1,7 @@
 package org.tianocore.migration;\r
 \r
 import java.io.File;\r
-import java.util.Set;\r
+import java.util.*;\r
 \r
 public class MigrationTool {\r
        public static UI ui = null;\r
@@ -12,10 +12,13 @@ public class MigrationTool {
        public static boolean printModuleInfo = false;\r
        public static boolean doCritic = false;\r
        public static boolean defaultoutput = false;\r
+       \r
+       public static final HashMap<ModuleInfo, String> ModuleInfoMap = new HashMap<ModuleInfo, String>();\r
 \r
        private static final void mainFlow(ModuleInfo mi) throws Exception {\r
 \r
                ModuleReader.ModuleScan(mi);\r
+               \r
                //MigrationTool.ui.yesOrNo("go on replace?");\r
                SourceFileReplacer.flush(mi);   // some adding library actions are taken here,so it must be put before "MsaWriter"\r
 \r
@@ -40,7 +43,7 @@ public class MigrationTool {
                //MigrationTool.ui.yesOrNo("go on critic?");\r
 \r
                if (MigrationTool.doCritic) {\r
-                       Critic.fireAt(mi.outputpath + File.separator + "Migration_" + mi.modulename);\r
+                       Critic.fireAt(ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename);\r
                }\r
 \r
                //MigrationTool.ui.yesOrNo("go on delete?");\r
@@ -57,9 +60,17 @@ public class MigrationTool {
                MigrationTool.ui.println(hash);\r
        }\r
 \r
+       private static final String assignOutPutPath(String inputpath) {\r
+               if (MigrationTool.defaultoutput) {\r
+                       return inputpath.replaceAll(Common.strseparate, "$1");\r
+               } else {\r
+                       return MigrationTool.ui.getFilepath("Please choose where to place the output module");\r
+               }\r
+       }\r
+       \r
        public static final void seekModule(String filepath) throws Exception {\r
                if (ModuleInfo.isModule(filepath)) {\r
-                       mainFlow(new ModuleInfo(filepath));\r
+                       ModuleInfoMap.put(new ModuleInfo(filepath), assignOutPutPath(filepath));\r
                }\r
        }\r
 \r
@@ -67,6 +78,13 @@ public class MigrationTool {
                MigrationTool.ui.println("Project Migration");\r
                MigrationTool.ui.println("Copyright (c) 2006, Intel Corporation");\r
                Common.toDoAll(path, MigrationTool.class.getMethod("seekModule", String.class), null, null, Common.DIR);\r
+               \r
+               Iterator<ModuleInfo> miit = ModuleInfoMap.keySet().iterator();\r
+               while (miit.hasNext()) {\r
+                       mainFlow(miit.next());\r
+               }\r
+               \r
+               ModuleInfoMap.clear();\r
        }\r
 \r
        public static void main(String[] args) throws Exception {\r
index 3fd446433a97d835eb9c10747e6d880529e0a6ac..428f82b659e44b0584f69e44f6b0919499020c81 100644 (file)
@@ -22,22 +22,10 @@ information and all the temporary data.
 public final class ModuleInfo {\r
        ModuleInfo(String modulepath) throws Exception {\r
                this.modulepath = modulepath;\r
-               \r
-               if (MigrationTool.defaultoutput) {\r
-                       this.outputpath = this.modulepath.replaceAll(Common.strseparate, "$1");\r
-               } else {\r
-                       MigrationTool.ui.println("Choose where to place the result");\r
-                       if ((outputpath = MigrationTool.ui.getFilepath("Please choose where to place the output module")) == null) {\r
-                               outputpath = modulepath; \r
-                       }\r
-                       MigrationTool.ui.println("Output to: " + outputpath);\r
-               }\r
        }\r
 \r
        public final String modulepath;\r
        \r
-       public String outputpath = null;\r
-       \r
        public String modulename = null;\r
        public String guidvalue = null;\r
        public String moduletype = null;\r
@@ -60,11 +48,15 @@ public final class ModuleInfo {
        public final Set<String> ppi = new HashSet<String>();\r
 \r
        public final void enroll(String filepath) throws Exception {\r
+               String temp = null;\r
                if (filepath.contains(".c") || filepath.contains(".C") || filepath.contains(".h") || \r
                                filepath.contains(".H") || filepath.contains(".dxs") || filepath.contains(".uni")) {\r
                        localmodulesources.add(filepath.replace(modulepath + "\\", ""));\r
                } else if (filepath.contains(".inf") || filepath.contains(".msa")) {\r
-                       msaorinf.add(filepath.replace(modulepath + "\\", ""));\r
+                       temp = filepath.replace(modulepath + "\\", "");\r
+                       if (!temp.contains(File.separator)) {                                                           // .inf in subdirectory is not regarded\r
+                               msaorinf.add(temp);\r
+                       }\r
                }\r
        }\r
 \r
index bc3fd75cb21e97f78de05a0031302891c674f28c..b5c47c40b5a5a1e10cb8ead21ee74a7227709d10 100644 (file)
@@ -41,6 +41,7 @@ public final class ModuleReader {
                                filename = MigrationTool.ui.choose("Found .inf or .msa file for module\n" + mi.modulepath + "\nChoose one Please", mi.msaorinf.toArray());\r
                        }\r
                }\r
+\r
                if (filename.contains(".inf")) {\r
                        readInf(filename);\r
                } else if (filename.contains(".msa")) {\r
index cf4426df827c0f2c4362d75363dc781161c74dc9..d6d836cc740eaf32f0c71d30179512fbd393314f 100644 (file)
@@ -181,7 +181,7 @@ public class MsaWriter {
         options.setSavePrettyPrintIndent(2);\r
         options.setUseDefaultNamespace();\r
         \r
-               BufferedWriter bw = new BufferedWriter(new FileWriter(mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + mi.modulename + ".msa"));\r
+               BufferedWriter bw = new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + mi.modulename + ".msa"));\r
                fulfillMsadoc().save(bw, options);\r
                //MsaTreeEditor.init(mi, ui, msadoc);\r
                bw.flush();\r
diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/PathIterator.java b/Tools/Source/MigrationTools/org/tianocore/migration/PathIterator.java
new file mode 100644 (file)
index 0000000..0207577
--- /dev/null
@@ -0,0 +1,33 @@
+package org.tianocore.migration;\r
+\r
+import java.util.*;\r
+\r
+public final class PathIterator implements Common.ForDoAll {\r
+//      this PathIterator is based on HashSet, an thread implementation is required.\r
+       PathIterator(String path, int md) throws Exception {\r
+               startpath = path;\r
+               mode = md;\r
+               Common.toDoAll(startpath, this, mode);\r
+               it = pathlist.iterator();\r
+       }\r
+       private String startpath = null;\r
+       private int mode;\r
+       private HashSet<String> pathlist = new HashSet<String>();\r
+       private Iterator<String> it = null;\r
+\r
+       public final void toDo(String path) throws Exception {\r
+               pathlist.add(path);\r
+       }\r
+\r
+       public final String next() {\r
+               return it.next();\r
+       }\r
+\r
+       public final boolean hasNext() {\r
+               return it.hasNext();\r
+       }\r
+\r
+       public final String toString() {\r
+               return pathlist.toString();\r
+       }\r
+}\r
index 42a220f6809b007596ea231fa47ef96b2e3cc90c..8ae1d8d05e0283360db2f8352d521e0576371a87 100644 (file)
@@ -61,7 +61,7 @@ public final class SourceFileReplacer {
                                        outname = inname;\r
                                }\r
                                MigrationTool.ui.println("\nModifying file: " + inname);\r
-                               Common.string2file(sourcefilereplace(mi.modulepath + File.separator + "temp" + File.separator + inname), mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + outname);\r
+                               Common.string2file(sourcefilereplace(mi.modulepath + File.separator + "temp" + File.separator + inname), MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + outname);\r
                        } else if (inname.contains(".h") || inname.contains(".H") || inname.contains(".dxs") || inname.contains(".uni")) {\r
                                if (inname.contains(".H")) {\r
                                        outname = inname.replaceFirst(".H", ".h");\r
@@ -69,7 +69,7 @@ public final class SourceFileReplacer {
                                        outname = inname;\r
                                }\r
                                MigrationTool.ui.println("\nCopying file: " + inname);\r
-                               Common.string2file(Common.file2string(mi.modulepath + File.separator + "temp" + File.separator + inname), mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + outname);\r
+                               Common.string2file(Common.file2string(mi.modulepath + File.separator + "temp" + File.separator + inname), MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + outname);\r
                        }\r
                }\r
 \r
@@ -82,8 +82,8 @@ public final class SourceFileReplacer {
                String paragraph = null;\r
                String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");\r
                //Common.ensureDir(mi.modulepath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c");\r
-               PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c")));\r
-               PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.h")));\r
+               PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c")));\r
+               PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.h")));\r
                Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL);\r
                Matcher mtrr8only = ptnr8only.matcher(line);\r
                Matcher mtrr8onlyhead;\r