]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Java/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java
Coding Style
[mirror_edk2.git] / Tools / Java / 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
71f30e51 15import java.io.File;\r
16import java.util.HashSet;\r
17import java.util.Set;\r
0dc8c589 18\r
323e2ffc 19import org.tianocore.UsageTypes;\r
8270b34d 20import org.tianocore.SupportedArchitectures.Enum;\r
323e2ffc 21\r
0dc8c589 22/*\r
71f30e51 23 * Class ModuleInfo is built for scanning the source files, it contains all the\r
24 * needed information and all the temporary data.\r
25 */\r
1eac75f9 26public final class ModuleInfo {\r
71f30e51 27 ModuleInfo(String modulepath) throws Exception {\r
28 this.modulepath = modulepath;\r
29 this.temppath = MigrationTool.getTempDir(this.modulepath);\r
30 }\r
31\r
32 public final String modulepath;\r
33\r
34 public final String temppath;\r
35\r
36 private MsaOwner msaowner = MsaOwner.initNewMsaOwner();\r
37\r
38 public String modulename = null;\r
39\r
40 public String guidvalue = null;\r
41\r
42 public String moduletype = null;\r
43\r
44 public String entrypoint = null;\r
45\r
46 public String license = null;\r
47\r
48 public final Set<String> localmodulesources = new HashSet<String>(); // contains\r
49 // both\r
50 // .c\r
51 // and\r
52 // .h\r
53\r
54 public final Set<String> preprocessedccodes = new HashSet<String>();\r
55\r
56 public final Set<String> msaorinf = new HashSet<String>(); // only a\r
57 // little, hash\r
58 // may be too\r
59 // big for this\r
60\r
61 public final Set<String> infincludes = new HashSet<String>();\r
62\r
63 public final Set<String> infsources = new HashSet<String>();\r
64\r
65 public final Set<String> hashfuncc = new HashSet<String>();\r
66\r
67 public final Set<String> hashfuncd = new HashSet<String>();\r
68\r
69 public final Set<String> hashnonlocalfunc = new HashSet<String>();\r
70\r
71 public final Set<String> hashnonlocalmacro = new HashSet<String>();\r
72\r
73 public final Set<String> hashEFIcall = new HashSet<String>();\r
74\r
75 public final Set<String> hashr8only = new HashSet<String>();\r
76\r
77 public final Set<String> hashmacro = new HashSet<String>();\r
78\r
79 public final Set<String> hashrequiredr9libs = new HashSet<String>(); // hashrequiredr9libs\r
80 // is\r
81 // now\r
82 // all\r
83 // added\r
84 // in\r
85 // SourceFileReplacer\r
86\r
87 public final Set<String> guids = new HashSet<String>();\r
88\r
89 public final Set<String> protocols = new HashSet<String>();\r
90\r
91 public final Set<String> ppis = new HashSet<String>();\r
92\r
93 // -----------------------------------------------------------------------------------//\r
94\r
95 // addModuleType\r
96 // addGuidValue\r
97 // addModuleName\r
98\r
99 public final boolean addSourceFile(String filename, Enum en) {\r
100 localmodulesources.add(filename);\r
101 return msaowner.addSourceFile(filename, en);\r
102 }\r
103\r
104 public final boolean addProtocol(String proname, UsageTypes.Enum usage) {\r
105 protocols.add(proname);\r
106 return msaowner.addProtocol(proname, usage);\r
107 }\r
108\r
109 public final boolean addPpi(String ppiname, UsageTypes.Enum usage) {\r
110 ppis.add(ppiname);\r
111 return msaowner.addPpi(ppiname, usage);\r
112 }\r
113\r
114 public final boolean addGuid(String guidname, UsageTypes.Enum usage) {\r
115 guids.add(guidname);\r
116 return msaowner.addGuid(guidname, usage);\r
117 }\r
118\r
119 public final boolean addLibraryClass(String name, UsageTypes.Enum usage) {\r
120 //\r
121 // This section is only for adding library classes, this functionality\r
122 // should be inside MsaOwner!!!\r
123 //\r
124 // if (!hashrequiredr9libs.contains(name)) {\r
125 msaowner.addLibraryClass(name, usage);\r
126 // }\r
127 //\r
128 hashrequiredr9libs.add(name);\r
129 return true;\r
130 }\r
131\r
132 // -----------------------------------------------------------------------------------//\r
133\r
134 public final String getModuleType() {\r
135 if (moduletype.contains("PEI")) {\r
136 return "PEIM";\r
137 } else {\r
138 return "DXE_DRIVER";\r
139 }\r
140 }\r
141\r
142 public final void enroll(String filepath) throws Exception {\r
143 String temp = null;\r
144 if (filepath.contains(".inf") || filepath.contains(".msa")) {\r
145 temp = filepath.replace(modulepath + File.separator, "");\r
146 if (!temp.contains(File.separator)) { // .inf in subdirectory is\r
147 // not regarded\r
148 msaorinf.add(temp);\r
149 }\r
150 } else if (filepath.contains(".c") || filepath.contains(".C")\r
151 || filepath.contains(".h") || filepath.contains(".H")\r
152 || filepath.contains(".dxs") || filepath.contains(".uni")\r
153 || filepath.contains(".s") || filepath.contains(".S")\r
154 || filepath.contains(".i") || filepath.contains(".asm")) {\r
155 addSourceFile(filepath.replace(modulepath + File.separator, ""),\r
156 null);\r
157 }\r
158 }\r
159\r
160 public static final boolean isModule(String path) {\r
161 String[] list = new File(path).list();\r
162 for (int i = 0; i < list.length; i++) {\r
163 if (!new File(list[i]).isDirectory()) {\r
164 if (list[i].contains(".inf") || list[i].contains(".msa")) {\r
165 return true;\r
166 }\r
167 }\r
168 }\r
169 return false;\r
170 }\r
171\r
172 public final MsaOwner getMsaOwner() {\r
173 return msaowner;\r
174 }\r
e6a5df3b 175}