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