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