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