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