]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java
remove MigrationTools.java
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / ModuleInfo.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.*;
16 import java.util.*;
17
18 /*
19 Class ModuleInfo is built for scanning the source files, it contains all the needed
20 information and all the temporary data.
21 */
22 public class ModuleInfo {
23 ModuleInfo(String modulepath) throws Exception {
24 this.modulepath = modulepath;
25
26 ModuleInfo.ui.println("Choose where to place the result");
27 if ((outputpath = ModuleInfo.ui.getFilepath()) == null) {
28 outputpath = modulepath;
29 }
30 ModuleInfo.ui.println(outputpath);
31
32 mainFlow();
33 }
34
35 public String modulepath = null;
36
37 public String outputpath = null;
38
39 public String modulename = null;
40 public String guidvalue = null;
41 public String moduletype = null;
42 public String entrypoint = null;
43
44 public Set<String> localmodulesources = new HashSet<String>(); //contains both .c and .h
45 public Set<String> preprocessedccodes = new HashSet<String>();
46 public Set<String> msaorinf = new HashSet<String>(); //only a little, hash may be too big for this
47
48 public Set<String> hashfuncc = new HashSet<String>();
49 public Set<String> hashfuncd = new HashSet<String>();
50 public Set<String> hashnonlocalfunc = new HashSet<String>();
51 public Set<String> hashnonlocalmacro = new HashSet<String>();
52 public Set<String> hashEFIcall = new HashSet<String>();
53 public Set<String> hashr8only = new HashSet<String>();
54
55 public Set<String> hashrequiredr9libs = new HashSet<String>(); // hashrequiredr9libs is now all added in SourceFileReplacer
56 public Set<String> guid = new HashSet<String>();
57 public Set<String> protocol = new HashSet<String>();
58 public Set<String> ppi = new HashSet<String>();
59
60 private void mainFlow() throws Exception {
61
62 ModuleReader.ModuleScan(this);
63
64 SourceFileReplacer.flush(this); // some adding library actions are taken here,so it must be put before "MsaWriter"
65
66 // show result
67 if (ModuleInfo.printModuleInfo) {
68 ModuleInfo.ui.println("\nModule Information : ");
69 ModuleInfo.ui.println("Entrypoint : " + entrypoint);
70 show(protocol, "Protocol : ");
71 show(ppi, "Ppi : ");
72 show(guid, "Guid : ");
73 show(hashfuncc, "call : ");
74 show(hashfuncd, "def : ");
75 show(hashEFIcall, "EFIcall : ");
76 show(hashnonlocalmacro, "macro : ");
77 show(hashnonlocalfunc, "nonlocal : ");
78 show(hashr8only, "hashr8only : ");
79 }
80
81 new MsaWriter(this).flush();
82
83 if (ModuleInfo.doCritic) {
84 Critic.fireAt(outputpath + File.separator + "Migration_" + modulename);
85 }
86
87 Common.deleteDir(modulepath + File.separator + "temp");
88
89 ModuleInfo.ui.println("Errors Left : " + ModuleInfo.db.error);
90 ModuleInfo.ui.println("Complete!");
91 ModuleInfo.ui.println("Your R9 module was placed here: " + modulepath + File.separator + "result");
92 ModuleInfo.ui.println("Your logfile was placed here: " + modulepath);
93 }
94
95 private void show(Set<String> hash, String show) {
96 ModuleInfo.ui.println(show + hash.size());
97 ModuleInfo.ui.println(hash);
98 }
99
100 public final void enroll(String filepath) throws Exception {
101 String[] temp;
102 if (filepath.contains(".c") || filepath.contains(".C") || filepath.contains(".h") ||
103 filepath.contains(".H") || filepath.contains(".dxs") || filepath.contains(".uni")) {
104 temp = filepath.split("\\\\");
105 localmodulesources.add(temp[temp.length - 1]);
106 } else if (filepath.contains(".inf") || filepath.contains(".msa")) {
107 temp = filepath.split("\\\\");
108 msaorinf.add(temp[temp.length - 1]);
109 }
110 }
111
112 public static final void seekModule(String filepath) throws Exception {
113 if (isModule(filepath)) {
114 new ModuleInfo(filepath);
115 }
116 }
117
118 private static final boolean isModule(String path) {
119 String[] list = new File(path).list();
120 for (int i = 0 ; i < list.length ; i++) {
121 if (!new File(list[i]).isDirectory()) {
122 if (list[i].contains(".inf") || list[i].contains(".msa")) {
123 return true;
124 }
125 }
126 }
127 return false;
128 }
129
130 public static final void triger(String path) throws Exception {
131 ModuleInfo.ui.println("Project Migration");
132 ModuleInfo.ui.println("Copyright (c) 2006, Intel Corporation");
133 Common.toDoAll(path, ModuleInfo.class.getMethod("seekModule", String.class), null, null, Common.DIR);
134 }
135
136 //---------------------------------------------------------------------------//
137
138 public static UI ui = null;
139 public static Database db = null;
140
141 public static final String migrationcomment = "//%$//";
142
143 public static boolean printModuleInfo = false;
144 public static boolean doCritic = false;
145
146 public static void main(String[] args) throws Exception {
147 ui = FirstPanel.init();
148 db = Database.init();
149 }
150 }