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