]>
Commit | Line | Data |
---|---|---|
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 | |
482407d3 | 20 | public class MigrationTool {\r |
4f60c26f | 21 | public static UI ui = null;\r |
22 | public static Database db = null;\r | |
23 | \r | |
eff5170c | 24 | public static String MIGRATIONCOMMENT = "//%@//";\r |
4f60c26f | 25 | \r |
26 | public static boolean printModuleInfo = false;\r | |
27 | public static boolean doCritic = false;\r | |
28 | public static boolean defaultoutput = false;\r | |
5f4eb6b6 | 29 | \r |
30 | public static final HashMap<ModuleInfo, String> ModuleInfoMap = new HashMap<ModuleInfo, String>();\r | |
4f60c26f | 31 | \r |
b678aaca | 32 | private static final void mainFlow(ModuleInfo mi) throws Exception {\r |
482407d3 | 33 | \r |
34 | ModuleReader.ModuleScan(mi);\r | |
5f4eb6b6 | 35 | \r |
482407d3 | 36 | //MigrationTool.ui.yesOrNo("go on replace?");\r |
16b7eeef | 37 | SourceFileReplacer.fireAt(mi); // some adding library actions are taken here,so it must be put before "MsaWriter"\r |
482407d3 | 38 | \r |
39 | //MigrationTool.ui.yesOrNo("go on show?");\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.protocol, "Protocol : ");\r | |
45 | show(mi.ppi, "Ppi : ");\r | |
46 | show(mi.guid, "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 | \r | |
55 | //MigrationTool.ui.yesOrNo("go on msawrite?");\r | |
56 | new MsaWriter(mi).flush();\r | |
57 | //MigrationTool.ui.yesOrNo("go on critic?");\r | |
58 | \r | |
59 | if (MigrationTool.doCritic) {\r | |
5f4eb6b6 | 60 | Critic.fireAt(ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename);\r |
482407d3 | 61 | }\r |
62 | \r | |
63 | //MigrationTool.ui.yesOrNo("go on delete?");\r | |
64 | Common.deleteDir(mi.modulepath + File.separator + "temp");\r | |
65 | \r | |
66 | MigrationTool.ui.println("Errors Left : " + MigrationTool.db.error);\r | |
67 | MigrationTool.ui.println("Complete!");\r | |
68 | //MigrationTool.ui.println("Your R9 module was placed here: " + mi.modulepath + File.separator + "result");\r | |
69 | //MigrationTool.ui.println("Your logfile was placed here: " + mi.modulepath);\r | |
70 | }\r | |
71 | \r | |
72 | private static final void show(Set<String> hash, String show) {\r | |
73 | MigrationTool.ui.println(show + hash.size());\r | |
74 | MigrationTool.ui.println(hash);\r | |
75 | }\r | |
76 | \r | |
5f4eb6b6 | 77 | private static final String assignOutPutPath(String inputpath) {\r |
78 | if (MigrationTool.defaultoutput) {\r | |
79 | return inputpath.replaceAll(Common.strseparate, "$1");\r | |
80 | } else {\r | |
5ad6d22a | 81 | return MigrationTool.ui.getFilepath("Please choose where to place the output module", JFileChooser.DIRECTORIES_ONLY);\r |
5f4eb6b6 | 82 | }\r |
83 | }\r | |
84 | \r | |
482407d3 | 85 | public static final void seekModule(String filepath) throws Exception {\r |
86 | if (ModuleInfo.isModule(filepath)) {\r | |
5f4eb6b6 | 87 | ModuleInfoMap.put(new ModuleInfo(filepath), assignOutPutPath(filepath));\r |
482407d3 | 88 | }\r |
89 | }\r | |
90 | \r | |
b678aaca | 91 | public static final void startMigrateAll(String path) throws Exception {\r |
482407d3 | 92 | MigrationTool.ui.println("Project Migration");\r |
93 | MigrationTool.ui.println("Copyright (c) 2006, Intel Corporation");\r | |
94 | Common.toDoAll(path, MigrationTool.class.getMethod("seekModule", String.class), null, null, Common.DIR);\r | |
5f4eb6b6 | 95 | \r |
96 | Iterator<ModuleInfo> miit = ModuleInfoMap.keySet().iterator();\r | |
97 | while (miit.hasNext()) {\r | |
98 | mainFlow(miit.next());\r | |
99 | }\r | |
100 | \r | |
101 | ModuleInfoMap.clear();\r | |
482407d3 | 102 | }\r |
103 | \r | |
482407d3 | 104 | public static void main(String[] args) throws Exception {\r |
4f60c26f | 105 | ui = FirstPanel.getInstance();\r |
106 | db = Database.getInstance();\r | |
482407d3 | 107 | }\r |
108 | }\r |