add ModuleInfo2OutputPath Map
modify inf chooser git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1417 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
eb8ea8292e
commit
5f4eb6b6d5
|
@ -165,42 +165,4 @@ public final class Common {
|
||||||
public static interface ForDoAll {
|
public static interface ForDoAll {
|
||||||
public void toDo(String filepath) throws Exception;
|
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);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.tianocore.migration;
|
package org.tianocore.migration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Set;
|
import java.util.*;
|
||||||
|
|
||||||
public class MigrationTool {
|
public class MigrationTool {
|
||||||
public static UI ui = null;
|
public static UI ui = null;
|
||||||
|
@ -12,10 +12,13 @@ public class MigrationTool {
|
||||||
public static boolean printModuleInfo = false;
|
public static boolean printModuleInfo = false;
|
||||||
public static boolean doCritic = false;
|
public static boolean doCritic = false;
|
||||||
public static boolean defaultoutput = 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 {
|
private static final void mainFlow(ModuleInfo mi) throws Exception {
|
||||||
|
|
||||||
ModuleReader.ModuleScan(mi);
|
ModuleReader.ModuleScan(mi);
|
||||||
|
|
||||||
//MigrationTool.ui.yesOrNo("go on replace?");
|
//MigrationTool.ui.yesOrNo("go on replace?");
|
||||||
SourceFileReplacer.flush(mi); // some adding library actions are taken here,so it must be put before "MsaWriter"
|
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?");
|
//MigrationTool.ui.yesOrNo("go on critic?");
|
||||||
|
|
||||||
if (MigrationTool.doCritic) {
|
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?");
|
//MigrationTool.ui.yesOrNo("go on delete?");
|
||||||
|
@ -57,9 +60,17 @@ public class MigrationTool {
|
||||||
MigrationTool.ui.println(hash);
|
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 {
|
public static final void seekModule(String filepath) throws Exception {
|
||||||
if (ModuleInfo.isModule(filepath)) {
|
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("Project Migration");
|
||||||
MigrationTool.ui.println("Copyright (c) 2006, Intel Corporation");
|
MigrationTool.ui.println("Copyright (c) 2006, Intel Corporation");
|
||||||
Common.toDoAll(path, MigrationTool.class.getMethod("seekModule", String.class), null, null, Common.DIR);
|
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 {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
|
@ -22,22 +22,10 @@ information and all the temporary data.
|
||||||
public final class ModuleInfo {
|
public final class ModuleInfo {
|
||||||
ModuleInfo(String modulepath) throws Exception {
|
ModuleInfo(String modulepath) throws Exception {
|
||||||
this.modulepath = modulepath;
|
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 final String modulepath;
|
||||||
|
|
||||||
public String outputpath = null;
|
|
||||||
|
|
||||||
public String modulename = null;
|
public String modulename = null;
|
||||||
public String guidvalue = null;
|
public String guidvalue = null;
|
||||||
public String moduletype = null;
|
public String moduletype = null;
|
||||||
|
@ -60,11 +48,15 @@ public final class ModuleInfo {
|
||||||
public final Set<String> ppi = new HashSet<String>();
|
public final Set<String> ppi = new HashSet<String>();
|
||||||
|
|
||||||
public final void enroll(String filepath) throws Exception {
|
public final void enroll(String filepath) throws Exception {
|
||||||
|
String temp = null;
|
||||||
if (filepath.contains(".c") || filepath.contains(".C") || filepath.contains(".h") ||
|
if (filepath.contains(".c") || filepath.contains(".C") || filepath.contains(".h") ||
|
||||||
filepath.contains(".H") || filepath.contains(".dxs") || filepath.contains(".uni")) {
|
filepath.contains(".H") || filepath.contains(".dxs") || filepath.contains(".uni")) {
|
||||||
localmodulesources.add(filepath.replace(modulepath + "\\", ""));
|
localmodulesources.add(filepath.replace(modulepath + "\\", ""));
|
||||||
} else if (filepath.contains(".inf") || filepath.contains(".msa")) {
|
} 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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());
|
filename = MigrationTool.ui.choose("Found .inf or .msa file for module\n" + mi.modulepath + "\nChoose one Please", mi.msaorinf.toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename.contains(".inf")) {
|
if (filename.contains(".inf")) {
|
||||||
readInf(filename);
|
readInf(filename);
|
||||||
} else if (filename.contains(".msa")) {
|
} else if (filename.contains(".msa")) {
|
||||||
|
|
|
@ -181,7 +181,7 @@ public class MsaWriter {
|
||||||
options.setSavePrettyPrintIndent(2);
|
options.setSavePrettyPrintIndent(2);
|
||||||
options.setUseDefaultNamespace();
|
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);
|
fulfillMsadoc().save(bw, options);
|
||||||
//MsaTreeEditor.init(mi, ui, msadoc);
|
//MsaTreeEditor.init(mi, ui, msadoc);
|
||||||
bw.flush();
|
bw.flush();
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,7 +61,7 @@ public final class SourceFileReplacer {
|
||||||
outname = inname;
|
outname = inname;
|
||||||
}
|
}
|
||||||
MigrationTool.ui.println("\nModifying file: " + 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")) {
|
} else if (inname.contains(".h") || inname.contains(".H") || inname.contains(".dxs") || inname.contains(".uni")) {
|
||||||
if (inname.contains(".H")) {
|
if (inname.contains(".H")) {
|
||||||
outname = inname.replaceFirst(".H", ".h");
|
outname = inname.replaceFirst(".H", ".h");
|
||||||
|
@ -69,7 +69,7 @@ public final class SourceFileReplacer {
|
||||||
outname = inname;
|
outname = inname;
|
||||||
}
|
}
|
||||||
MigrationTool.ui.println("\nCopying file: " + 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 paragraph = null;
|
||||||
String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");
|
String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");
|
||||||
//Common.ensureDir(mi.modulepath + File.separator + "Migration_" + mi.modulename + 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 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(mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.h")));
|
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);
|
Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL);
|
||||||
Matcher mtrr8only = ptnr8only.matcher(line);
|
Matcher mtrr8only = ptnr8only.matcher(line);
|
||||||
Matcher mtrr8onlyhead;
|
Matcher mtrr8onlyhead;
|
||||||
|
|
Loading…
Reference in New Issue