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