]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java
enhance ModuleReader
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / ModuleInfo.java
CommitLineData
b0282412 1/** @file\r
2 \r
3 Copyright (c) 2006, Intel Corporation\r
4 All rights reserved. This program and the accompanying materials\r
5 are licensed and made available under the terms and conditions of the BSD License\r
6 which accompanies this distribution. The full text of the license may be found at\r
7 http://opensource.org/licenses/bsd-license.php\r
8 \r
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11 \r
12 **/\r
0dc8c589 13package org.tianocore.migration;\r
14\r
15import java.io.*;\r
16import java.util.*;\r
0dc8c589 17\r
18/*\r
19 Class ModuleInfo is built for scanning the source files, it contains all the needed\r
20information and all the temporary data.\r
21*/\r
22public class ModuleInfo {\r
5ea254f6 23 ModuleInfo(String modulepath) throws Exception {\r
0dc8c589 24 this.modulepath = modulepath;\r
5ea254f6 25 \r
7bcb8d17 26 MigrationTool.ui.println("Choose where to place the result");\r
27 if ((outputpath = MigrationTool.ui.getFilepath()) == null) {\r
5ea254f6 28 outputpath = modulepath; \r
29 }\r
7bcb8d17 30 MigrationTool.ui.println(outputpath);\r
5ea254f6 31 \r
446e26ee 32 mainFlow();\r
0dc8c589 33 }\r
5ea254f6 34\r
5ea254f6 35 public String modulepath = null;\r
0dc8c589 36 \r
5ea254f6 37 public String outputpath = null;\r
0dc8c589 38 \r
39 public String modulename = null;\r
40 public String guidvalue = null;\r
41 public String moduletype = null;\r
42 public String entrypoint = null;\r
43 \r
44 public Set<String> localmodulesources = new HashSet<String>(); //contains both .c and .h\r
0dc8c589 45 public Set<String> preprocessedccodes = new HashSet<String>();\r
e6a5df3b 46 public Set<String> msaorinf = new HashSet<String>(); //only a little, hash may be too big for this\r
0dc8c589 47 \r
48 public Set<String> hashfuncc = new HashSet<String>();\r
49 public Set<String> hashfuncd = new HashSet<String>();\r
50 public Set<String> hashnonlocalfunc = new HashSet<String>();\r
51 public Set<String> hashnonlocalmacro = new HashSet<String>();\r
52 public Set<String> hashEFIcall = new HashSet<String>();\r
53 public Set<String> hashr8only = new HashSet<String>();\r
54 \r
55 public Set<String> hashrequiredr9libs = new HashSet<String>(); // hashrequiredr9libs is now all added in SourceFileReplacer \r
56 public Set<String> guid = new HashSet<String>();\r
57 public Set<String> protocol = new HashSet<String>();\r
58 public Set<String> ppi = new HashSet<String>();\r
59 \r
446e26ee 60 private void mainFlow() throws Exception {\r
5ea254f6 61 \r
446e26ee 62 ModuleReader.ModuleScan(this);\r
0dc8c589 63 \r
eee63a7b 64 SourceFileReplacer.flush(this); // some adding library actions are taken here,so it must be put before "MsaWriter"\r
0dc8c589 65 \r
66 // show result\r
446e26ee 67 if (MigrationTool.printModuleInfo) {\r
7bcb8d17 68 MigrationTool.ui.println("\nModule Information : ");\r
69 MigrationTool.ui.println("Entrypoint : " + entrypoint);\r
0dc8c589 70 show(protocol, "Protocol : ");\r
71 show(ppi, "Ppi : ");\r
72 show(guid, "Guid : ");\r
73 show(hashfuncc, "call : ");\r
74 show(hashfuncd, "def : ");\r
75 show(hashEFIcall, "EFIcall : ");\r
76 show(hashnonlocalmacro, "macro : ");\r
77 show(hashnonlocalfunc, "nonlocal : ");\r
78 show(hashr8only, "hashr8only : ");\r
79 }\r
80 \r
eee63a7b 81 new MsaWriter(this).flush();\r
5ea254f6 82\r
446e26ee 83 if (MigrationTool.doCritic) {\r
84 Critic.fireAt(outputpath + File.separator + "Migration_" + modulename);\r
85 }\r
86 \r
5ea254f6 87 Common.deleteDir(modulepath + File.separator + "temp");\r
0dc8c589 88 \r
7bcb8d17 89 MigrationTool.ui.println("Errors Left : " + MigrationTool.db.error);\r
90 MigrationTool.ui.println("Complete!");\r
91 MigrationTool.ui.println("Your R9 module was placed here: " + modulepath + File.separator + "result");\r
92 MigrationTool.ui.println("Your logfile was placed here: " + modulepath);\r
0dc8c589 93 }\r
94 \r
95 private void show(Set<String> hash, String show) {\r
7bcb8d17 96 MigrationTool.ui.println(show + hash.size());\r
97 MigrationTool.ui.println(hash);\r
0dc8c589 98 }\r
e6a5df3b 99 \r
5ea254f6 100 public final void enroll(String filepath) throws Exception {\r
101 String[] temp;\r
102 if (filepath.contains(".c") || filepath.contains(".C") || filepath.contains(".h") || \r
103 filepath.contains(".H") || filepath.contains(".dxs") || filepath.contains(".uni")) {\r
104 temp = filepath.split("\\\\");\r
105 localmodulesources.add(temp[temp.length - 1]);\r
106 } else if (filepath.contains(".inf") || filepath.contains(".msa")) {\r
107 temp = filepath.split("\\\\");\r
108 msaorinf.add(temp[temp.length - 1]);\r
109 }\r
110 }\r
7bcb8d17 111\r
5ea254f6 112 public static final void seekModule(String filepath) throws Exception {\r
113 if (isModule(filepath)) {\r
5ea254f6 114 new ModuleInfo(filepath);\r
115 }\r
116 }\r
117\r
118 private static final boolean isModule(String path) {\r
119 String[] list = new File(path).list();\r
120 for (int i = 0 ; i < list.length ; i++) {\r
121 if (!new File(list[i]).isDirectory()) {\r
122 if (list[i].contains(".inf") || list[i].contains(".msa")) {\r
123 return true;\r
124 }\r
125 }\r
126 }\r
127 return false;\r
128 }\r
446e26ee 129\r
7bcb8d17 130 public static final void triger(String path) throws Exception {\r
131 MigrationTool.ui.println("Project Migration");\r
132 MigrationTool.ui.println("Copyright (c) 2006, Intel Corporation");\r
133 Common.toDoAll(path, ModuleInfo.class.getMethod("seekModule", String.class), null, null, Common.DIR);\r
0dc8c589 134 }\r
e6a5df3b 135}