import java.util.*;\r
\r
/*\r
- Class ModuleInfo is built for scanning the source files, it contains all the needed\r
+ Class ModuleInfo is built for scanning the source files, it contains all the needed\r
information and all the temporary data.\r
*/\r
public final class ModuleInfo {\r
- ModuleInfo(String modulepath) throws Exception {\r
- this.modulepath = modulepath;\r
- \r
- if (ModuleInfo.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
- outputpath = modulepath; \r
- }\r
- ModuleInfo.ui.println("Output to: " + outputpath);\r
- }\r
- }\r
+ ModuleInfo(String modulepath) throws Exception {\r
+ this.modulepath = modulepath;\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
- public String entrypoint = null;\r
- \r
- public final Set<String> localmodulesources = new HashSet<String>(); //contains both .c and .h\r
- public final Set<String> preprocessedccodes = new HashSet<String>();\r
- public final Set<String> msaorinf = new HashSet<String>(); //only a little, hash may be too big for this\r
- \r
- public final Set<String> hashfuncc = new HashSet<String>();\r
- public final Set<String> hashfuncd = new HashSet<String>();\r
- public final Set<String> hashnonlocalfunc = new HashSet<String>();\r
- public final Set<String> hashnonlocalmacro = new HashSet<String>();\r
- public final Set<String> hashEFIcall = new HashSet<String>();\r
- public final Set<String> hashr8only = new HashSet<String>();\r
- \r
- public final Set<String> hashrequiredr9libs = new HashSet<String>(); // hashrequiredr9libs is now all added in SourceFileReplacer \r
- public final Set<String> guid = new HashSet<String>();\r
- public final Set<String> protocol = new HashSet<String>();\r
- public final Set<String> ppi = new HashSet<String>();\r
+ public final String modulepath;\r
+ \r
+ public String modulename = null;\r
+ public String guidvalue = null;\r
+ public String moduletype = null;\r
+ public String entrypoint = null;\r
+ \r
+ public final Set<String> localmodulesources = new HashSet<String>(); //contains both .c and .h\r
+ public final Set<String> preprocessedccodes = new HashSet<String>();\r
+ public final Set<String> msaorinf = new HashSet<String>(); //only a little, hash may be too big for this\r
+ \r
+ public final Set<String> hashfuncc = new HashSet<String>();\r
+ public final Set<String> hashfuncd = new HashSet<String>();\r
+ public final Set<String> hashnonlocalfunc = new HashSet<String>();\r
+ public final Set<String> hashnonlocalmacro = new HashSet<String>();\r
+ public final Set<String> hashEFIcall = new HashSet<String>();\r
+ public final Set<String> hashr8only = new HashSet<String>();\r
+ \r
+ public final Set<String> hashrequiredr9libs = new HashSet<String>(); // hashrequiredr9libs is now all added in SourceFileReplacer \r
+ public final Set<String> guid = new HashSet<String>();\r
+ public final Set<String> protocol = new HashSet<String>();\r
+ public final Set<String> ppi = new HashSet<String>();\r
\r
- public final void enroll(String filepath) throws Exception {\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
- }\r
- }\r
+ public final String getModuleType() {\r
+ if (moduletype.contains("PEI")) {\r
+ return "PEIM";\r
+ } else {\r
+ return "DXE_DRIVER";\r
+ }\r
+ }\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 + File.separator, ""));\r
+ } else if (filepath.contains(".inf") || filepath.contains(".msa")) {\r
+ temp = filepath.replace(modulepath + File.separator, "");\r
+ if (!temp.contains(File.separator)) { // .inf in subdirectory is not regarded\r
+ msaorinf.add(temp);\r
+ }\r
+ }\r
+ }\r
\r
- public static final boolean isModule(String path) {\r
- String[] list = new File(path).list();\r
- for (int i = 0 ; i < list.length ; i++) {\r
- if (!new File(list[i]).isDirectory()) {\r
- if (list[i].contains(".inf") || list[i].contains(".msa")) {\r
- return true;\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
+ public static final boolean isModule(String path) {\r
+ String[] list = new File(path).list();\r
+ for (int i = 0 ; i < list.length ; i++) {\r
+ if (!new File(list[i]).isDirectory()) {\r
+ if (list[i].contains(".inf") || list[i].contains(".msa")) {\r
+ return true;\r
+ }\r
+ }\r
+ }\r
+ return false;\r
+ }\r
}
\ No newline at end of file