- private static String migrationcomment = "//%$//";\r
- \r
- private void moduleScan() throws Exception {\r
- String[] list = new File(modulepath).list();\r
- boolean hasInf = false;\r
- String infname = null;\r
- boolean hasMsa = false;\r
- String msaname = null;\r
- \r
- for (int i = 0 ; i < list.length ; i++) {\r
- if (new File(list[i]).isDirectory()) {\r
- ;\r
- } else {\r
- if (list[i].contains(".c") || list[i].contains(".C")) {\r
- localmodulesources.add(list[i]);\r
- } else if (list[i].contains(".h") || list[i].contains(".H")) {\r
- localmodulesources.add(list[i]);\r
- localmoduleheaders.add(list[i]); //the case that several .inf or .msa found is not concerned\r
- } else if (list[i].contains(".inf")) {\r
- if (ui.yesOrNo("Found .inf file : " + list[i] + "\nUse this file as this module's .inf ?")) {\r
- hasInf = true;\r
- infname = list[i];\r
- } else {\r
- continue;\r
- }\r
- } else if (list[i].contains(".msa")) {\r
- if (ui.yesOrNo("Found .msa file : " + list[i] + "\nUse this file as this module's .msa ?")) {\r
- hasMsa = true;\r
- msaname = list[i];\r
- } else {\r
- continue;\r
- }\r
- }\r
- }\r
- }\r
- \r
- ModuleReader mr = new ModuleReader(modulepath, this, db);\r
- if (hasInf) { // this sequence shows using .inf as default\r
- mr.readInf(infname);\r
- } else if (hasMsa) {\r
- mr.readMsa(msaname);\r
- } else {\r
- ui.println("No Inf Nor Msa Found");\r
- }\r
- \r
- CommentOutNonLocalHFile();\r
- parsePreProcessedSourceCode();\r
- \r
- new SourceFileReplacer(modulepath, this, db, ui).flush(); // some adding library actions are taken here,so it must be put before "MsaWriter"\r
- \r
- // show result\r
- if (ui.yesOrNo("Parse Module Information Complete . See details ?")) {\r
- ui.println("\nModule Information : ");\r
- ui.println("Entrypoint : " + entrypoint);\r
- show(protocol, "Protocol : ");\r
- show(ppi, "Ppi : ");\r
- show(guid, "Guid : ");\r
- show(hashfuncc, "call : ");\r
- show(hashfuncd, "def : ");\r
- show(hashEFIcall, "EFIcall : ");\r
- show(hashnonlocalmacro, "macro : ");\r
- show(hashnonlocalfunc, "nonlocal : ");\r
- show(hashr8only, "hashr8only : ");\r
- }\r
- \r
- new MsaWriter(modulepath, this, db).flush();\r
- \r
- // remove temp directory\r
- //File tempdir = new File(modulepath + File.separator + "temp");\r
- //System.out.println("Deleting Dir");\r
- //if (tempdir.exists()) tempdir.d;\r
- \r
- ui.println("Errors Left : " + db.error);\r
- ui.println("Complete!");\r
- ui.println("Your R9 module is placed at " + modulepath + File.separator + "result");\r
- ui.println("Your logfile is placed at " + modulepath);\r
- }\r
- \r
- private void show(Set<String> hash, String show) {\r
- ui.println(show + hash.size());\r
- ui.println(hash);\r
- }\r
-\r
- // add '//' to all non-local include lines\r
- private void CommentOutNonLocalHFile() throws IOException {\r
- BufferedReader rd;\r
- String line;\r
- String curFile;\r
- PrintWriter outfile;\r