1. Fix EDKT214 "Framework Wizard is not synchronized with FrameworkDatabase.db when...
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / MigrationTool.java
CommitLineData
482407d3 1package org.tianocore.migration;\r
2\r
3import java.io.File;\r
5f4eb6b6 4import java.util.*;\r
482407d3 5\r
6public class MigrationTool {\r
4f60c26f 7 public static UI ui = null;\r
8 public static Database db = null;\r
9\r
e3e8956d 10 public static String MIGRATIONCOMMENT = "//%$//";\r
4f60c26f 11\r
12 public static boolean printModuleInfo = false;\r
13 public static boolean doCritic = false;\r
14 public static boolean defaultoutput = false;\r
5f4eb6b6 15 \r
16 public static final HashMap<ModuleInfo, String> ModuleInfoMap = new HashMap<ModuleInfo, String>();\r
4f60c26f 17\r
b678aaca 18 private static final void mainFlow(ModuleInfo mi) throws Exception {\r
482407d3 19\r
20 ModuleReader.ModuleScan(mi);\r
5f4eb6b6 21 \r
482407d3 22 //MigrationTool.ui.yesOrNo("go on replace?");\r
23 SourceFileReplacer.flush(mi); // some adding library actions are taken here,so it must be put before "MsaWriter"\r
24\r
25 //MigrationTool.ui.yesOrNo("go on show?");\r
26 // show result\r
27 if (MigrationTool.printModuleInfo) {\r
28 MigrationTool.ui.println("\nModule Information : ");\r
29 MigrationTool.ui.println("Entrypoint : " + mi.entrypoint);\r
30 show(mi.protocol, "Protocol : ");\r
31 show(mi.ppi, "Ppi : ");\r
32 show(mi.guid, "Guid : ");\r
33 show(mi.hashfuncc, "call : ");\r
34 show(mi.hashfuncd, "def : ");\r
35 show(mi.hashEFIcall, "EFIcall : ");\r
36 show(mi.hashnonlocalmacro, "macro : ");\r
37 show(mi.hashnonlocalfunc, "nonlocal : ");\r
38 show(mi.hashr8only, "hashr8only : ");\r
39 }\r
40\r
41 //MigrationTool.ui.yesOrNo("go on msawrite?");\r
42 new MsaWriter(mi).flush();\r
43 //MigrationTool.ui.yesOrNo("go on critic?");\r
44\r
45 if (MigrationTool.doCritic) {\r
5f4eb6b6 46 Critic.fireAt(ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename);\r
482407d3 47 }\r
48\r
49 //MigrationTool.ui.yesOrNo("go on delete?");\r
50 Common.deleteDir(mi.modulepath + File.separator + "temp");\r
51\r
52 MigrationTool.ui.println("Errors Left : " + MigrationTool.db.error);\r
53 MigrationTool.ui.println("Complete!");\r
54 //MigrationTool.ui.println("Your R9 module was placed here: " + mi.modulepath + File.separator + "result");\r
55 //MigrationTool.ui.println("Your logfile was placed here: " + mi.modulepath);\r
56 }\r
57\r
58 private static final void show(Set<String> hash, String show) {\r
59 MigrationTool.ui.println(show + hash.size());\r
60 MigrationTool.ui.println(hash);\r
61 }\r
62\r
5f4eb6b6 63 private static final String assignOutPutPath(String inputpath) {\r
64 if (MigrationTool.defaultoutput) {\r
65 return inputpath.replaceAll(Common.strseparate, "$1");\r
66 } else {\r
67 return MigrationTool.ui.getFilepath("Please choose where to place the output module");\r
68 }\r
69 }\r
70 \r
482407d3 71 public static final void seekModule(String filepath) throws Exception {\r
72 if (ModuleInfo.isModule(filepath)) {\r
5f4eb6b6 73 ModuleInfoMap.put(new ModuleInfo(filepath), assignOutPutPath(filepath));\r
482407d3 74 }\r
75 }\r
76\r
b678aaca 77 public static final void startMigrateAll(String path) throws Exception {\r
482407d3 78 MigrationTool.ui.println("Project Migration");\r
79 MigrationTool.ui.println("Copyright (c) 2006, Intel Corporation");\r
80 Common.toDoAll(path, MigrationTool.class.getMethod("seekModule", String.class), null, null, Common.DIR);\r
5f4eb6b6 81 \r
82 Iterator<ModuleInfo> miit = ModuleInfoMap.keySet().iterator();\r
83 while (miit.hasNext()) {\r
84 mainFlow(miit.next());\r
85 }\r
86 \r
87 ModuleInfoMap.clear();\r
482407d3 88 }\r
89\r
482407d3 90 public static void main(String[] args) throws Exception {\r
4f60c26f 91 ui = FirstPanel.getInstance();\r
92 db = Database.getInstance();\r
482407d3 93 }\r
94}\r