]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | **/\r | |
13 | package org.tianocore.migration;\r | |
14 | \r | |
15 | import java.io.File;\r | |
16 | import java.util.*;\r | |
17 | \r | |
18 | import javax.swing.JFileChooser;\r | |
19 | \r | |
20 | import org.tianocore.UsageTypes;\r | |
21 | \r | |
22 | public class MigrationTool {\r | |
23 | public static UI ui = null;\r | |
24 | public static Database db = null;\r | |
25 | \r | |
26 | public static String MIGRATIONCOMMENT = "//@MT:";\r | |
27 | \r | |
28 | public static boolean printModuleInfo = false;\r | |
29 | public static boolean doCritic = false;\r | |
30 | public static boolean defaultoutput = false;\r | |
31 | \r | |
32 | public static final HashMap<ModuleInfo, String> ModuleInfoMap = new HashMap<ModuleInfo, String>();\r | |
33 | \r | |
34 | private static String startpath = null;\r | |
35 | \r | |
36 | private static final void mainFlow(ModuleInfo mi) throws Exception {\r | |
37 | ModuleReader.aimAt(mi);\r | |
38 | SourceFileReplacer.fireAt(mi); // some adding library actions are taken here,so it must be put before "MsaWriter"\r | |
39 | \r | |
40 | // show result\r | |
41 | if (MigrationTool.printModuleInfo) {\r | |
42 | MigrationTool.ui.println("\nModule Information : ");\r | |
43 | MigrationTool.ui.println("Entrypoint : " + mi.entrypoint);\r | |
44 | show(mi.protocols, "Protocol : ");\r | |
45 | show(mi.ppis, "Ppi : ");\r | |
46 | show(mi.guids, "Guid : ");\r | |
47 | show(mi.hashfuncc, "call : ");\r | |
48 | show(mi.hashfuncd, "def : ");\r | |
49 | show(mi.hashEFIcall, "EFIcall : ");\r | |
50 | show(mi.hashnonlocalmacro, "macro : ");\r | |
51 | show(mi.hashnonlocalfunc, "nonlocal : ");\r | |
52 | show(mi.hashr8only, "hashr8only : ");\r | |
53 | }\r | |
54 | new MsaWriter(mi).flush();\r | |
55 | \r | |
56 | //mi.getMsaOwner().flush(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + mi.modulename + ".___");\r | |
57 | \r | |
58 | if (MigrationTool.doCritic) {\r | |
59 | Critic.fireAt(ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename);\r | |
60 | }\r | |
61 | \r | |
62 | MigrationTool.ui.println("Errors Left : " + MigrationTool.db.error);\r | |
63 | MigrationTool.ui.println("Complete!");\r | |
64 | }\r | |
65 | \r | |
66 | private static final void show(Set<String> hash, String show) {\r | |
67 | MigrationTool.ui.println(show + hash.size());\r | |
68 | MigrationTool.ui.println(hash);\r | |
69 | }\r | |
70 | \r | |
71 | public static final String getTempDir(String modulepath) {\r | |
72 | return "C:" + File.separator + "MigrationTool_Temp" + modulepath.replace(startpath, "");\r | |
73 | }\r | |
74 | \r | |
75 | private static final String assignOutPutPath(String inputpath) {\r | |
76 | if (MigrationTool.defaultoutput) {\r | |
77 | return inputpath.replaceAll(Common.STRSEPARATER, "$1");\r | |
78 | } else {\r | |
79 | return MigrationTool.ui.getFilepath("Please choose where to place the output module", JFileChooser.DIRECTORIES_ONLY);\r | |
80 | }\r | |
81 | }\r | |
82 | \r | |
83 | public static final void seekModule(String filepath) throws Exception {\r | |
84 | if (ModuleInfo.isModule(filepath)) {\r | |
85 | ModuleInfoMap.put(new ModuleInfo(filepath), assignOutPutPath(filepath));\r | |
86 | }\r | |
87 | }\r | |
88 | \r | |
89 | public static final void startMigrateAll(String path) throws Exception {\r | |
90 | startpath = path;\r | |
91 | MigrationTool.ui.println("Project Migration");\r | |
92 | MigrationTool.ui.println("Copyright (c) 2006, Intel Corporation");\r | |
93 | \r | |
94 | if (new File("C:" + File.separator + "MigrationTool_Temp").exists()) {\r | |
95 | Common.deleteDir("C:" + File.separator + "MigrationTool_Temp");\r | |
96 | }\r | |
97 | \r | |
98 | Common.toDoAll(path, MigrationTool.class.getMethod("seekModule", String.class), null, null, Common.DIR);\r | |
99 | \r | |
100 | Iterator<ModuleInfo> miit = ModuleInfoMap.keySet().iterator();\r | |
101 | while (miit.hasNext()) {\r | |
102 | mainFlow(miit.next());\r | |
103 | }\r | |
104 | \r | |
105 | ModuleInfoMap.clear();\r | |
106 | \r | |
107 | Common.deleteDir("C:" + File.separator + "MigrationTool_Temp");\r | |
108 | }\r | |
109 | \r | |
110 | public static void main(String[] args) throws Exception {\r | |
111 | ui = FirstPanel.getInstance();\r | |
112 | db = Database.getInstance();\r | |
113 | }\r | |
114 | }\r |