]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/Spd.java
Changed the output message when handling dummy files in msa.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / global / Spd.java
CommitLineData
a13899c5 1/** @file\r
2 Spd class.\r
3\r
4 This class is to generate a global table for the content of spd file.\r
5 \r
6 Copyright (c) 2006, Intel Corporation\r
7 All rights reserved. This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
11 \r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15 **/\r
16package org.tianocore.frameworkwizard.platform.ui.global;\r
17\r
18import java.io.File;\r
19import java.util.HashMap;\r
20import java.util.Iterator;\r
21import java.util.Map;\r
22import java.util.Set;\r
23\r
24import org.apache.xmlbeans.XmlObject;\r
25import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;\r
26import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;\r
27\r
28/**\r
29 \r
30 This class is to generate a global table for the content of spd file.\r
31 \r
32 **/\r
33public class Spd {\r
34 ///\r
35 ///\r
36 ///\r
37 Map<ModuleIdentification, File> msaInfo = new HashMap<ModuleIdentification, File>();\r
38\r
39 ///\r
40 /// Map of module info. \r
41 /// Key : moduletype\r
42 /// Value: moduletype related include file\r
43 ///\r
44 Map<String, String> packageHeaderInfo = new HashMap<String, String>();\r
45\r
46 ///\r
47 /// Map of PPI info.\r
48 /// Key : PPI name\r
49 /// value: String[] a. PPI C_NAME; b. PPI GUID;\r
50 ///\r
51 Map<String, String[]> ppiInfo = new HashMap<String, String[]>();\r
52\r
53 ///\r
54 /// Map of Protocol info.\r
55 /// Key : Protocol name\r
56 /// value: String[] a. Protocol C_NAME; b. Protocol GUID;\r
57 ///\r
58 Map<String, String[]> protocolInfo = new HashMap<String, String[]>();\r
59\r
60 ///\r
61 /// Map of Guid info.\r
62 /// Key : Guid name\r
63 /// value: String[] a. Guid C_NAME; b. Guid's GUID;\r
64 ///\r
65 Map<String, String[]> guidInfo = new HashMap<String, String[]>();\r
66\r
67 ///\r
68 /// Map of library class and its exposed header file.\r
69 /// Key : library class name\r
70 /// value : library class corresponding header file\r
71 ///\r
72 Map<String, String[]> libClassHeaderList = new HashMap<String, String[]>();\r
73\r
74 //\r
75 // Xml Doc of Spd file, Msa file\r
76 //\r
77 public Map<String, XmlObject> spdDocMap = new HashMap<String, XmlObject>();\r
78 public Map<ModuleIdentification, XmlObject> msaDocMap = new HashMap<ModuleIdentification, XmlObject>();\r
79 ///\r
80 /// Package path.\r
81 ///\r
82 PackageIdentification packageId;\r
83\r
84 /**\r
85 Constructor function\r
86 \r
87 This function mainly initialize some member variables. \r
88 **/\r
89 Spd(File packageFile) throws Exception {\r
90 try {\r
91 XmlObject spdDoc = XmlObject.Factory.parse(packageFile);\r
92 //\r
93 // Verify SPD file, if is invalid, throw Exception\r
94 //\r
95// if (! spdDoc.validate()) {\r
96// throw new Exception("Package Surface Area file [" + packageFile.getPath() + "] is invalid. ");\r
97// }\r
98 // We can change Map to XmlObject\r
99 \r
100 spdDocMap.put("PackageSurfaceArea", spdDoc);\r
101 SurfaceAreaQuery.setDoc(spdDocMap);\r
102 //\r
103 //\r
104 //\r
105 packageId = SurfaceAreaQuery.getSpdHeader();\r
106 packageId.setSpdFile(packageFile);\r
107 \r
108 //\r
109 // initialize Msa Files\r
110 // MSA file is absolute file path\r
111 //\r
112 String[] msaFilenames = SurfaceAreaQuery.getSpdMsaFile();\r
113 for (int i = 0; i < msaFilenames.length; i++){\r
114 File msaFile = new File(packageId.getPackageDir() + File.separatorChar + msaFilenames[i]);\r
115 Map<String, XmlObject> msaDoc = GlobalData.getNativeMsa( msaFile );\r
116 SurfaceAreaQuery.push(msaDoc);\r
117 ModuleIdentification moduleId = SurfaceAreaQuery.getMsaHeader();\r
118 SurfaceAreaQuery.pop();\r
119 moduleId.setPackage(packageId);\r
120 msaInfo.put(moduleId, msaFile);\r
121 msaDocMap.put(moduleId, msaDoc.get("ModuleSurfaceArea"));\r
122 }\r
123 //\r
124 // initialize Package header files\r
125 //\r
126// Map<String, String> packageHeaders = SurfaceAreaQuery.getSpdPackageHeaderFiles();\r
127// Set keys = packageHeaders.keySet();\r
128// Iterator iter = keys.iterator();\r
129// while (iter.hasNext()){\r
130// String moduleType = (String)iter.next();\r
131// String header = packageId.getPackageRelativeDir() + File.separatorChar + packageHeaders.get(moduleType);\r
132// //\r
133// // Change path seperator to system-dependent path separator\r
134// //\r
135// File file = new File (header);\r
136// header = file.getParent();\r
137// packageHeaderInfo.put(moduleType, header);\r
138// }\r
139 //\r
140 // initialize Guid Info\r
141 //\r
142 guidInfo.putAll(SurfaceAreaQuery.getSpdGuid());\r
143 //\r
144 // initialize PPI info\r
145 //\r
146 ppiInfo.putAll(SurfaceAreaQuery.getSpdPpi());\r
147 //\r
148 // initialize Protocol info\r
149 //\r
150 protocolInfo.putAll(SurfaceAreaQuery.getSpdProtocol());\r
151 //\r
152 // initialize library class declaration\r
153 //\r
154 Map<String, String[]> libraryClassHeaders = SurfaceAreaQuery.getSpdLibraryClasses();\r
155 Set<String> keys = libraryClassHeaders.keySet();\r
156 Iterator iter = keys.iterator();\r
157 while (iter.hasNext()){\r
158 String libraryClassName = (String)iter.next();\r
159 String[] headerFiles = libraryClassHeaders.get(libraryClassName);\r
160 for (int i = 0; i < headerFiles.length; i++){\r
161 headerFiles[i] = packageId.getPackageRelativeDir() + File.separatorChar + headerFiles[i];\r
162 \r
163 //\r
164 // Change path separator to system system-dependent path separator. \r
165 //\r
166 File file = new File (headerFiles[i]);\r
167 headerFiles[i] = file.getPath();\r
168 }\r
169 libClassHeaderList.put(libraryClassName, headerFiles);\r
170 }\r
171 }\r
172 catch (Exception e) {\r
173 e.setStackTrace(e.getStackTrace());\r
174 throw new Exception("Parse package description file [" + packageId.getSpdFile() + "] Error.\n"\r
175 + e.getMessage());\r
176 }\r
177 }\r
178\r
179 public PackageIdentification getPackageId() {\r
180 return packageId;\r
181 }\r
182\r
183 public File getModuleFile(ModuleIdentification moduleId) {\r
184 return msaInfo.get(moduleId);\r
185 }\r
186 \r
187 public Set<ModuleIdentification> getModules(){\r
188 return msaInfo.keySet();\r
189 }\r
190\r
191 /**\r
192 return two value {CName, Guid}. If not found, return null.\r
193 **/\r
194 public String[] getPpi(String ppiName) {\r
195 return ppiInfo.get(ppiName);\r
196 }\r
197\r
198 /**\r
199 return two value {CName, Guid}. If not found, return null.\r
200 **/\r
201 public String[] getProtocol(String protocolName) {\r
202 return protocolInfo.get(protocolName);\r
203 }\r
204\r
205 /**\r
206 return two value {CName, Guid}. If not found, return null.\r
207 **/\r
208 public String[] getGuid(String guidName) {\r
209 return guidInfo.get(guidName);\r
210 }\r
211\r
212 /**\r
213 getLibClassInclude \r
214 \r
215 This function is to get the library exposed header file name according \r
216 library class name.\r
217 \r
218 @param libName Name of library class \r
219 @return Name of header file\r
220 **/\r
221 String[] getLibClassIncluder(String libName) {\r
222 return libClassHeaderList.get(libName);\r
223 }\r
224\r
225 /**\r
226 getModuleTypeIncluder\r
227 \r
228 This function is to get the header file name from module info map \r
229 according to module type.\r
230 \r
231 @param moduleType Module type.\r
232 @return Name of header file.\r
233 **/\r
234 String getPackageIncluder(String moduleType) {\r
235 return packageHeaderInfo.get(moduleType);\r
236 }\r
237}\r