5ad6d22a |
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 |
482407d3 |
13 | package org.tianocore.migration;\r |
14 | \r |
15 | import java.io.File;\r |
5f4eb6b6 |
16 | import java.util.*;\r |
482407d3 |
17 | \r |
5ad6d22a |
18 | import javax.swing.JFileChooser;\r |
19 | \r |
1ea59929 |
20 | import org.tianocore.UsageTypes;\r |
21 | \r |
482407d3 |
22 | public class MigrationTool {\r |
27e0221a |
23 | public static UI ui = null;\r |
24 | public static Database db = null;\r |
25 | \r |
10e4f990 |
26 | public static String MIGRATIONCOMMENT = "//@MT:";\r |
27e0221a |
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 |
df87de9b |
34 | private static String startpath = null;\r |
35 | \r |
27e0221a |
36 | private static final void mainFlow(ModuleInfo mi) throws Exception {\r |
39e5e412 |
37 | ModuleReader.aimAt(mi);\r |
27e0221a |
38 | SourceFileReplacer.fireAt(mi); // some adding library actions are taken here,so it must be put before "MsaWriter"\r |
39 | \r |
27e0221a |
40 | // show result\r |
41 | if (MigrationTool.printModuleInfo) {\r |
42 | MigrationTool.ui.println("\nModule Information : ");\r |
43 | MigrationTool.ui.println("Entrypoint : " + mi.entrypoint);\r |
323e2ffc |
44 | show(mi.protocols, "Protocol : ");\r |
45 | show(mi.ppis, "Ppi : ");\r |
46 | show(mi.guids, "Guid : ");\r |
27e0221a |
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 | \r |
27e0221a |
55 | new MsaWriter(mi).flush();\r |
1ea59929 |
56 | /*\r |
57 | mi.addGuid("guid", UsageTypes.ALWAYS_CONSUMED);\r |
58 | mi.addLibraryClass("class", UsageTypes.ALWAYS_CONSUMED);\r |
59 | mi.addPpi("ppi", UsageTypes.ALWAYS_CONSUMED);\r |
60 | mi.addProtocol("protocol", UsageTypes.ALWAYS_CONSUMED);\r |
61 | */\r |
62 | mi.getMsaOwner().flush(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + mi.modulename + ".___");\r |
63 | \r |
27e0221a |
64 | if (MigrationTool.doCritic) {\r |
65 | Critic.fireAt(ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename);\r |
66 | }\r |
67 | \r |
27e0221a |
68 | MigrationTool.ui.println("Errors Left : " + MigrationTool.db.error);\r |
69 | MigrationTool.ui.println("Complete!");\r |
70 | //MigrationTool.ui.println("Your R9 module was placed here: " + mi.modulepath + File.separator + "result");\r |
71 | //MigrationTool.ui.println("Your logfile was placed here: " + mi.modulepath);\r |
72 | }\r |
73 | \r |
74 | private static final void show(Set<String> hash, String show) {\r |
75 | MigrationTool.ui.println(show + hash.size());\r |
76 | MigrationTool.ui.println(hash);\r |
77 | }\r |
df87de9b |
78 | \r |
55bfa0f1 |
79 | public static final String getTempDir(String modulepath) {\r |
372a4642 |
80 | return "C:" + File.separator + "MigrationTool_Temp" + modulepath.replace(startpath, "");\r |
55bfa0f1 |
81 | }\r |
df87de9b |
82 | \r |
27e0221a |
83 | private static final String assignOutPutPath(String inputpath) {\r |
84 | if (MigrationTool.defaultoutput) {\r |
39e5e412 |
85 | return inputpath.replaceAll(Common.STRSEPARATER, "$1");\r |
27e0221a |
86 | } else {\r |
87 | return MigrationTool.ui.getFilepath("Please choose where to place the output module", JFileChooser.DIRECTORIES_ONLY);\r |
88 | }\r |
89 | }\r |
90 | \r |
91 | public static final void seekModule(String filepath) throws Exception {\r |
92 | if (ModuleInfo.isModule(filepath)) {\r |
93 | ModuleInfoMap.put(new ModuleInfo(filepath), assignOutPutPath(filepath));\r |
94 | }\r |
95 | }\r |
96 | \r |
97 | public static final void startMigrateAll(String path) throws Exception {\r |
372a4642 |
98 | startpath = path;\r |
27e0221a |
99 | MigrationTool.ui.println("Project Migration");\r |
100 | MigrationTool.ui.println("Copyright (c) 2006, Intel Corporation");\r |
df87de9b |
101 | \r |
102 | if (new File("C:" + File.separator + "MigrationTool_Temp").exists()) {\r |
103 | Common.deleteDir("C:" + File.separator + "MigrationTool_Temp");\r |
104 | }\r |
105 | \r |
27e0221a |
106 | Common.toDoAll(path, MigrationTool.class.getMethod("seekModule", String.class), null, null, Common.DIR);\r |
107 | \r |
108 | Iterator<ModuleInfo> miit = ModuleInfoMap.keySet().iterator();\r |
109 | while (miit.hasNext()) {\r |
110 | mainFlow(miit.next());\r |
111 | }\r |
112 | \r |
113 | ModuleInfoMap.clear();\r |
df87de9b |
114 | \r |
115 | Common.deleteDir("C:" + File.separator + "MigrationTool_Temp");\r |
27e0221a |
116 | }\r |
117 | \r |
118 | public static void main(String[] args) throws Exception {\r |
119 | ui = FirstPanel.getInstance();\r |
120 | db = Database.getInstance();\r |
121 | }\r |
482407d3 |
122 | }\r |