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