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