Manifest-Version: 1.0\r
-Main-Class: org.tianocore.migration.ModuleInfo\r
+Main-Class: org.tianocore.migration.MigrationTool\r
\r
mibox = new JCheckBox("Print ModuleInfo", false);\r
mibox.addItemListener(this);\r
- ModuleInfo.printModuleInfo = false;\r
+ MigrationTool.printModuleInfo = false;\r
\r
criticbox = new JCheckBox("Run Critic", true);\r
criticbox.addItemListener(this);\r
- ModuleInfo.doCritic = true;\r
+ MigrationTool.doCritic = true;\r
\r
defaultpathbox = new JCheckBox("Use Default Output Path", true);\r
defaultpathbox.addItemListener(this);\r
- ModuleInfo.defaultoutput = true;\r
+ MigrationTool.defaultoutput = true;\r
\r
JPanel modulePanel = new JPanel();\r
modulePanel.add(moduleButton);\r
if ( e.getSource() == goButton ) {\r
try {\r
logfile = new PrintWriter(new BufferedWriter(new FileWriter(startpath.replaceAll(Common.strseparate, "$1") + File.separator + "migration.log")));\r
- ModuleInfo.triger(startpath);\r
+ MigrationTool.triger(startpath);\r
logfile.flush();\r
} catch (Exception en) {\r
println(en.getMessage());\r
}\r
} else if (e.getSource() == mibox) {\r
if (e.getStateChange() == ItemEvent.DESELECTED) {\r
- ModuleInfo.printModuleInfo = false;\r
+ MigrationTool.printModuleInfo = false;\r
} else if (e.getStateChange() == ItemEvent.SELECTED) {\r
- ModuleInfo.printModuleInfo = true;\r
+ MigrationTool.printModuleInfo = true;\r
}\r
} else if (e.getSource() == criticbox) {\r
if (e.getStateChange() == ItemEvent.DESELECTED) {\r
- ModuleInfo.doCritic = false;\r
+ MigrationTool.doCritic = false;\r
} else if (e.getStateChange() == ItemEvent.SELECTED) {\r
- ModuleInfo.doCritic = true;\r
+ MigrationTool.doCritic = true;\r
}\r
} else if (e.getSource() == defaultpathbox) {\r
if (e.getStateChange() == ItemEvent.DESELECTED) {\r
- ModuleInfo.defaultoutput = false;\r
+ MigrationTool.defaultoutput = false;\r
} else if (e.getStateChange() == ItemEvent.SELECTED) {\r
- ModuleInfo.defaultoutput = true;\r
+ MigrationTool.defaultoutput = true;\r
}\r
}\r
}\r
String temp = null;\r
\r
temp = mtr.group();\r
- if (ModuleInfo.db.hasGuid(temp)) { // only changed guids registered, because both changed and not changed guids are included in database\r
- type = ModuleInfo.db.getGuidType(temp);\r
+ if (MigrationTool.db.hasGuid(temp)) { // only changed guids registered, because both changed and not changed guids are included in database\r
+ type = MigrationTool.db.getGuidType(temp);\r
if (type.matches("Protocol")) {\r
mi.protocol.add(temp);\r
} else if (type.matches("Ppi")) {\r
String temp = null;\r
\r
temp = mtr.group();\r
- if (ModuleInfo.db.hasMacro(temp)) { // only changed macros registered, because the database of macro has only changed ones\r
+ if (MigrationTool.db.hasMacro(temp)) { // only changed macros registered, because the database of macro has only changed ones\r
if (!unmacro.contains(temp)) {\r
mi.hashnonlocalmacro.add(temp);\r
}\r
--- /dev/null
+package org.tianocore.migration;\r
+\r
+import java.io.File;\r
+import java.util.Set;\r
+\r
+public class MigrationTool {\r
+ private static final void manipulate(ModuleInfo mi) throws Exception {\r
+\r
+ ModuleReader.ModuleScan(mi);\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
+ //MigrationTool.ui.yesOrNo("go on show?");\r
+ // show result\r
+ if (MigrationTool.printModuleInfo) {\r
+ MigrationTool.ui.println("\nModule Information : ");\r
+ MigrationTool.ui.println("Entrypoint : " + mi.entrypoint);\r
+ show(mi.protocol, "Protocol : ");\r
+ show(mi.ppi, "Ppi : ");\r
+ show(mi.guid, "Guid : ");\r
+ show(mi.hashfuncc, "call : ");\r
+ show(mi.hashfuncd, "def : ");\r
+ show(mi.hashEFIcall, "EFIcall : ");\r
+ show(mi.hashnonlocalmacro, "macro : ");\r
+ show(mi.hashnonlocalfunc, "nonlocal : ");\r
+ show(mi.hashr8only, "hashr8only : ");\r
+ }\r
+\r
+ //MigrationTool.ui.yesOrNo("go on msawrite?");\r
+ new MsaWriter(mi).flush();\r
+ //MigrationTool.ui.yesOrNo("go on critic?");\r
+\r
+ if (MigrationTool.doCritic) {\r
+ Critic.fireAt(mi.outputpath + File.separator + "Migration_" + mi.modulename);\r
+ }\r
+\r
+ //MigrationTool.ui.yesOrNo("go on delete?");\r
+ Common.deleteDir(mi.modulepath + File.separator + "temp");\r
+\r
+ MigrationTool.ui.println("Errors Left : " + MigrationTool.db.error);\r
+ MigrationTool.ui.println("Complete!");\r
+ //MigrationTool.ui.println("Your R9 module was placed here: " + mi.modulepath + File.separator + "result");\r
+ //MigrationTool.ui.println("Your logfile was placed here: " + mi.modulepath);\r
+ }\r
+\r
+ private static final void show(Set<String> hash, String show) {\r
+ MigrationTool.ui.println(show + hash.size());\r
+ MigrationTool.ui.println(hash);\r
+ }\r
+\r
+ public static final void seekModule(String filepath) throws Exception {\r
+ if (ModuleInfo.isModule(filepath)) {\r
+ manipulate(new ModuleInfo(filepath));\r
+ }\r
+ }\r
+\r
+ public static final void triger(String path) throws Exception {\r
+ 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
+\r
+ public static UI ui = null;\r
+ public static Database db = null;\r
+\r
+ public static final String MIGRATIONCOMMENT = "//%$//";\r
+\r
+ public static boolean printModuleInfo = false;\r
+ public static boolean doCritic = false;\r
+ public static boolean defaultoutput = false;\r
+\r
+ public static void main(String[] args) throws Exception {\r
+ ui = FirstPanel.init();\r
+ db = Database.init();\r
+ }\r
+}\r
ModuleInfo(String modulepath) throws Exception {\r
this.modulepath = modulepath;\r
\r
- if (ModuleInfo.defaultoutput) {\r
+ if (MigrationTool.defaultoutput) {\r
this.outputpath = this.modulepath.replaceAll(Common.strseparate, "$1");\r
} else {\r
- ModuleInfo.ui.println("Choose where to place the result");\r
- if ((outputpath = ModuleInfo.ui.getFilepath("Please choose where to place the output module")) == null) {\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
- ModuleInfo.ui.println("Output to: " + outputpath);\r
+ MigrationTool.ui.println("Output to: " + outputpath);\r
}\r
}\r
\r
}\r
return false;\r
}\r
-\r
- //---------------------------------------------------------------------------//\r
- \r
- private static final void manipulate(ModuleInfo mi) throws Exception {\r
- \r
- ModuleReader.ModuleScan(mi);\r
- //ModuleInfo.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
- //ModuleInfo.ui.yesOrNo("go on show?");\r
- // show result\r
- if (ModuleInfo.printModuleInfo) {\r
- ModuleInfo.ui.println("\nModule Information : ");\r
- ModuleInfo.ui.println("Entrypoint : " + mi.entrypoint);\r
- show(mi.protocol, "Protocol : ");\r
- show(mi.ppi, "Ppi : ");\r
- show(mi.guid, "Guid : ");\r
- show(mi.hashfuncc, "call : ");\r
- show(mi.hashfuncd, "def : ");\r
- show(mi.hashEFIcall, "EFIcall : ");\r
- show(mi.hashnonlocalmacro, "macro : ");\r
- show(mi.hashnonlocalfunc, "nonlocal : ");\r
- show(mi.hashr8only, "hashr8only : ");\r
- }\r
-\r
- //ModuleInfo.ui.yesOrNo("go on msawrite?");\r
- new MsaWriter(mi).flush();\r
- //ModuleInfo.ui.yesOrNo("go on critic?");\r
-\r
- if (ModuleInfo.doCritic) {\r
- Critic.fireAt(mi.outputpath + File.separator + "Migration_" + mi.modulename);\r
- }\r
-\r
- //ModuleInfo.ui.yesOrNo("go on delete?");\r
- Common.deleteDir(mi.modulepath + File.separator + "temp");\r
- \r
- ModuleInfo.ui.println("Errors Left : " + ModuleInfo.db.error);\r
- ModuleInfo.ui.println("Complete!");\r
- //ModuleInfo.ui.println("Your R9 module was placed here: " + mi.modulepath + File.separator + "result");\r
- //ModuleInfo.ui.println("Your logfile was placed here: " + mi.modulepath);\r
- }\r
- \r
- private static final void show(Set<String> hash, String show) {\r
- ModuleInfo.ui.println(show + hash.size());\r
- ModuleInfo.ui.println(hash);\r
- }\r
- \r
- public static final void seekModule(String filepath) throws Exception {\r
- if (ModuleInfo.isModule(filepath)) {\r
- manipulate(new ModuleInfo(filepath));\r
- }\r
- }\r
-\r
- public static final void triger(String path) throws Exception {\r
- ModuleInfo.ui.println("Project Migration");\r
- ModuleInfo.ui.println("Copyright (c) 2006, Intel Corporation");\r
- Common.toDoAll(path, ModuleInfo.class.getMethod("seekModule", String.class), null, null, Common.DIR);\r
- }\r
- \r
- public static UI ui = null;\r
- public static Database db = null;\r
- \r
- public static final String migrationcomment = "//%$//";\r
- \r
- public static boolean printModuleInfo = false;\r
- public static boolean doCritic = false;\r
- public static boolean defaultoutput = false;\r
- \r
- public static void main(String[] args) throws Exception {\r
- ui = FirstPanel.init();\r
- db = Database.init();\r
- }\r
}
\ No newline at end of file
\r
String filename = null;\r
if (mi.msaorinf.isEmpty()) {\r
- ModuleInfo.ui.println("No INF nor MSA file found!");\r
+ MigrationTool.ui.println("No INF nor MSA file found!");\r
System.exit(0);\r
} else {\r
if (mi.msaorinf.size() == 1) {\r
filename = (String)mi.msaorinf.toArray()[0];\r
} else {\r
- filename = ModuleInfo.ui.choose("Found .inf or .msa file for module\n" + mi.modulepath + "\nChoose one Please", mi.msaorinf.toArray());\r
+ filename = MigrationTool.ui.choose("Found .inf or .msa file for module\n" + mi.modulepath + "\nChoose one Please", mi.msaorinf.toArray());\r
}\r
}\r
if (filename.contains(".inf")) {\r
}\r
if (mtrinfequation.group(1).matches("DPX_SOURCE")) {\r
if (!mi.localmodulesources.contains(mtrinfequation.group(2))) {\r
- ModuleInfo.ui.println("DPX File Missing! : " + mtrinfequation.group(2));\r
+ MigrationTool.ui.println("DPX File Missing! : " + mtrinfequation.group(2));\r
}\r
}\r
}\r
mtrfilename = ptnfilename.matcher(mtrsection.group(2));\r
while (mtrfilename.find()) {\r
if (!mi.localmodulesources.contains(mtrfilename.group())) {\r
- ModuleInfo.ui.println("Source File Missing! : " + mtrfilename.group());\r
+ MigrationTool.ui.println("Source File Missing! : " + mtrfilename.group());\r
}\r
}\r
}\r
mtrinclude = ptninclude.matcher(line);\r
if (mtrinclude.find() && mi.localmodulesources.contains(mtrinclude.group(1))) {\r
} else {\r
- line = ModuleInfo.migrationcomment + line;\r
+ line = MigrationTool.MIGRATIONCOMMENT + line;\r
}\r
}\r
outfile.append(line + '\n');\r
// find guid\r
matguid = Guid.ptnguid.matcher(line); // several ways to implement this , which one is faster ? :\r
while (matguid.find()) { // 1.currently , find once , then call to identify which is it\r
- if ((temp = Guid.register(matguid, mi, ModuleInfo.db)) != null) { // 2.use 3 different matchers , search 3 times to find each\r
- //matguid.appendReplacement(result, ModuleInfo.db.getR9Guidname(temp)); // search the database for all 3 kinds of guids , high cost\r
+ if ((temp = Guid.register(matguid, mi, MigrationTool.db)) != null) { // 2.use 3 different matchers , search 3 times to find each\r
+ //matguid.appendReplacement(result, MigrationTool.db.getR9Guidname(temp)); // search the database for all 3 kinds of guids , high cost\r
}\r
}\r
//matguid.appendTail(result);\r
// find function call\r
matfuncc = Func.ptnfuncc.matcher(line);\r
while (matfuncc.find()) {\r
- if ((temp = Func.register(matfuncc, mi, ModuleInfo.db)) != null) {\r
- //ModuleInfo.ui.println(ifile + " dofunc " + temp);\r
- //matfuncc.appendReplacement(result, ModuleInfo.db.getR9Func(temp));\r
+ if ((temp = Func.register(matfuncc, mi, MigrationTool.db)) != null) {\r
+ //MigrationTool.ui.println(ifile + " dofunc " + temp);\r
+ //matfuncc.appendReplacement(result, MigrationTool.db.getR9Func(temp));\r
}\r
}\r
//matfuncc.appendTail(result);\r
// find macro\r
matmacro = Macro.ptntmacro.matcher(line);\r
while (matmacro.find()) {\r
- if ((temp = Macro.register(matmacro, mi, ModuleInfo.db)) != null) {\r
+ if ((temp = Macro.register(matmacro, mi, MigrationTool.db)) != null) {\r
}\r
}\r
\r
\r
matfuncd = Func.ptnfuncd.matcher(line);\r
while (matfuncd.find()) {\r
- if ((temp = Func.register(matfuncd, mi, ModuleInfo.db)) != null) {\r
+ if ((temp = Func.register(matfuncd, mi, MigrationTool.db)) != null) {\r
}\r
}\r
}\r
}\r
\r
private void addNode() {\r
- addNode((DefaultMutableTreeNode)(tree.getSelectionPath().getLastPathComponent()), ModuleInfo.ui.getInput("Input Node Name"));\r
+ addNode((DefaultMutableTreeNode)(tree.getSelectionPath().getLastPathComponent()), MigrationTool.ui.getInput("Input Node Name"));\r
}\r
\r
private void addNode(DefaultMutableTreeNode parentNode, Object child) {\r
String outname = null;\r
String inname = null;\r
/*\r
- if (ModuleInfo.ui.yesOrNo("Changes will be made to the Source Code. View details?")) {\r
+ if (MigrationTool.ui.yesOrNo("Changes will be made to the Source Code. View details?")) {\r
showdetails = true;\r
}\r
*/\r
} else {\r
outname = inname;\r
}\r
- ModuleInfo.ui.println("\nModifying file: " + inname);\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
} else if (inname.contains(".h") || inname.contains(".H") || inname.contains(".dxs") || inname.contains(".uni")) {\r
if (inname.contains(".H")) {\r
} else {\r
outname = inname;\r
}\r
- ModuleInfo.ui.println("\nCopying file: " + inname);\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
}\r
}\r
\r
private static final void addr8only() throws Exception {\r
String paragraph = null;\r
- String line = Common.file2string(ModuleInfo.db.DatabasePath + File.separator + "R8Lib.c");\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
// replace BS -> gBS , RT -> gRT\r
Matcher mat = pat.matcher(line);\r
if (mat.find()) { // add a library here\r
- ModuleInfo.ui.println("Converting all BS->gBS, RT->gRT");\r
+ MigrationTool.ui.println("Converting all BS->gBS, RT->gRT");\r
line = mat.replaceAll("g$1$2$3"); //unknown correctiveness\r
}\r
mat.reset();\r
Pattern patentrypoint = Pattern.compile("EFI_DRIVER_ENTRY_POINT[^\\}]*\\}");\r
Matcher matentrypoint = patentrypoint.matcher(line);\r
if (matentrypoint.find()) {\r
- ModuleInfo.ui.println("Deleting Entry_Point");\r
+ MigrationTool.ui.println("Deleting Entry_Point");\r
line = matentrypoint.replaceAll("");\r
}\r
*/\r
mi.hashrequiredr9libs.add("UefiRuntimeServicesTableLib"); //a\r
mi.hashrequiredr9libs.add("DxeServicesTableLib"); //l\r
} else { //\r
- mi.hashrequiredr9libs.add(ModuleInfo.db.getR9Lib(r8thing)); // add a library here\r
+ mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing)); // add a library here\r
}\r
\r
- if ((r9thing = ModuleInfo.db.getR9Func(r8thing)) != null) {\r
+ if ((r9thing = MigrationTool.db.getR9Func(r8thing)) != null) {\r
if (!r8thing.equals(r9thing)) {\r
if (line.contains(r8thing)) {\r
line = line.replaceAll(r8thing, r9thing);\r
Iterator<r8tor9> rt = filefunc.iterator();\r
while (rt.hasNext()) {\r
temp = rt.next();\r
- if (ModuleInfo.db.r8only.contains(temp.r8thing)) {\r
+ if (MigrationTool.db.r8only.contains(temp.r8thing)) {\r
filer8only.add(r8thing);\r
mi.hashr8only.add(r8thing);\r
addr8 = true;\r
it = mi.hashnonlocalmacro.iterator();\r
while (it.hasNext()) { //macros are all assumed MdePkg currently\r
r8thing = it.next();\r
- //mi.hashrequiredr9libs.add(ModuleInfo.db.getR9Lib(r8thing)); \r
- if ((r9thing = ModuleInfo.db.getR9Macro(r8thing)) != null) {\r
+ //mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing)); \r
+ if ((r9thing = MigrationTool.db.getR9Macro(r8thing)) != null) {\r
if (line.contains(r8thing)) {\r
line = line.replaceAll(r8thing, r9thing);\r
filemacro.add(new r8tor9(r8thing, r9thing));\r
show(fileppi, "ppi");\r
show(fileprotocol, "protocol");\r
if (!filer8only.isEmpty()) {\r
- ModuleInfo.ui.println("Converting r8only : " + filer8only);\r
+ MigrationTool.ui.println("Converting r8only : " + filer8only);\r
}\r
\r
filefunc.clear();\r
r8tor9 temp;\r
if (showdetails) {\r
if (!hash.isEmpty()) {\r
- ModuleInfo.ui.print("Converting " + sh + " : ");\r
+ MigrationTool.ui.print("Converting " + sh + " : ");\r
while (it.hasNext()) {\r
temp = it.next();\r
- ModuleInfo.ui.print("[" + temp.r8thing + "->" + temp.r9thing + "] ");\r
+ MigrationTool.ui.print("[" + temp.r8thing + "->" + temp.r9thing + "] ");\r
}\r
- ModuleInfo.ui.println("");\r
+ MigrationTool.ui.println("");\r
}\r
}\r
}\r
it = hash.iterator();\r
while (it.hasNext()) {\r
r8thing = it.next();\r
- if ((r9thing = ModuleInfo.db.getR9Guidname(r8thing)) != null) {\r
+ if ((r9thing = MigrationTool.db.getR9Guidname(r8thing)) != null) {\r
if (!r8thing.equals(r9thing)) {\r
if (line.contains(r8thing)) {\r
line = line.replaceAll(r8thing, r9thing);\r
export CLASSPATH=$CLASSPATH:$WORKSPACE/Tools/bin/MigrationTools.jar
# Run Migration Tool
-java org.tianocore.migration.ModuleInfo
\ No newline at end of file
+java org.tianocore.migration.MigrationTool
\ No newline at end of file
)\r
\r
@REM Run Migration\r
-call "java" org.tianocore.migration.ModuleInfo\r
+call "java" org.tianocore.migration.MigrationTool\r
\r
goto end\r
\r