]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
ff225cbb | 2 | GlobalData class.\r |
3 | \r | |
878ddf1f | 4 | GlobalData provide initializing, instoring, querying and update global data.\r |
5 | It is a bridge to intercommunicate between multiple component, such as AutoGen,\r | |
ff225cbb | 6 | PCD and so on.\r |
7 | \r | |
878ddf1f | 8 | Copyright (c) 2006, Intel Corporation\r |
9 | All rights reserved. This program and the accompanying materials\r | |
10 | are licensed and made available under the terms and conditions of the BSD License\r | |
11 | which accompanies this distribution. The full text of the license may be found at\r | |
12 | http://opensource.org/licenses/bsd-license.php\r | |
13 | \r | |
14 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
15 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
16 | **/\r | |
17 | package org.tianocore.build.global;\r | |
18 | \r | |
73b4e31a | 19 | import java.io.File;\r |
892b0e7a | 20 | import java.io.IOException;\r |
fe6d0f74 | 21 | import java.util.ArrayList;\r |
22 | import java.util.Collection;\r | |
73b4e31a | 23 | import java.util.HashMap;\r |
24 | import java.util.HashSet;\r | |
25 | import java.util.Iterator;\r | |
92cfaeee | 26 | import java.util.LinkedHashSet;\r |
73b4e31a | 27 | import java.util.List;\r |
28 | import java.util.Map;\r | |
29 | import java.util.Set;\r | |
73b4e31a | 30 | \r |
892b0e7a | 31 | import org.apache.xmlbeans.XmlException;\r |
a29c47e0 | 32 | import org.apache.xmlbeans.XmlObject;\r |
fe6d0f74 | 33 | import org.apache.xmlbeans.XmlOptions;\r |
a29c47e0 | 34 | import org.tianocore.DbPathAndFilename;\r |
35 | import org.tianocore.FrameworkDatabaseDocument;\r | |
36 | import org.tianocore.ModuleSurfaceAreaDocument;\r | |
37 | import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r | |
a29c47e0 | 38 | import org.tianocore.build.id.FpdModuleIdentification;\r |
39 | import org.tianocore.build.id.ModuleIdentification;\r | |
40 | import org.tianocore.build.id.PackageIdentification;\r | |
41 | import org.tianocore.build.id.PlatformIdentification;\r | |
a29c47e0 | 42 | import org.tianocore.build.toolchain.ToolChainConfig;\r |
43 | import org.tianocore.build.toolchain.ToolChainElement;\r | |
44 | import org.tianocore.build.toolchain.ToolChainInfo;\r | |
45 | import org.tianocore.build.toolchain.ToolChainKey;\r | |
46 | import org.tianocore.build.toolchain.ToolChainMap;\r | |
fe6d0f74 | 47 | import org.tianocore.common.definitions.ToolDefinitions;\r |
48 | import org.tianocore.common.exception.EdkException;\r | |
49 | import org.tianocore.common.logger.EdkLog;\r | |
50 | import org.tianocore.pcd.entity.MemoryDatabaseManager;\r | |
a29c47e0 | 51 | \r |
878ddf1f | 52 | /**\r |
53 | GlobalData provide initializing, instoring, querying and update global data.\r | |
54 | It is a bridge to intercommunicate between multiple component, such as AutoGen,\r | |
ff225cbb | 55 | PCD and so on.\r |
56 | \r | |
57 | <p>Note that all global information are initialized incrementally. All data will\r | |
a29c47e0 | 58 | parse and record only of necessary during build time. </p>\r |
ff225cbb | 59 | \r |
878ddf1f | 60 | @since GenBuild 1.0\r |
61 | **/\r | |
62 | public class GlobalData {\r | |
878ddf1f | 63 | ///\r |
64 | /// Record current WORKSPACE Directory\r | |
65 | ///\r | |
66 | private static String workspaceDir = "";\r | |
ff225cbb | 67 | \r |
878ddf1f | 68 | ///\r |
a29c47e0 | 69 | /// Be used to ensure Global data will be initialized only once.\r |
878ddf1f | 70 | ///\r |
a29c47e0 | 71 | private static boolean globalFlag = false;\r |
ff225cbb | 72 | \r |
878ddf1f | 73 | ///\r |
a29c47e0 | 74 | /// Framework Database information: package list and platform list\r |
878ddf1f | 75 | ///\r |
ff225cbb | 76 | private static Set<PackageIdentification> packageList = new HashSet<PackageIdentification>();\r |
878ddf1f | 77 | \r |
a29c47e0 | 78 | private static Set<PlatformIdentification> platformList = new HashSet<PlatformIdentification>();\r |
878ddf1f | 79 | \r |
80 | ///\r | |
a29c47e0 | 81 | /// Every detail SPD informations: Module list, Library class definition,\r |
82 | /// Package header file, GUID/PPI/Protocol definitions\r | |
878ddf1f | 83 | ///\r |
a29c47e0 | 84 | private static final Map<PackageIdentification, Spd> spdTable = new HashMap<PackageIdentification, Spd>();\r |
878ddf1f | 85 | \r |
86 | ///\r | |
a29c47e0 | 87 | /// Build informations are divided into three parts:\r |
88 | /// 1. From MSA 2. From FPD 3. From FPD' ModuleSA\r | |
878ddf1f | 89 | ///\r |
a29c47e0 | 90 | private static Map<ModuleIdentification, Map<String, XmlObject>> nativeMsa = new HashMap<ModuleIdentification, Map<String, XmlObject>>();\r |
878ddf1f | 91 | \r |
a29c47e0 | 92 | private static Map<FpdModuleIdentification, Map<String, XmlObject>> fpdModuleSA= new HashMap<FpdModuleIdentification, Map<String, XmlObject>>();\r |
878ddf1f | 93 | \r |
19bf6b15 | 94 | private static Map<String, XmlObject> fpdBuildOptionsMap = new HashMap<String, XmlObject>();\r |
95 | \r | |
a29c47e0 | 96 | private static XmlObject fpdBuildOptions;\r |
878ddf1f | 97 | \r |
a29c47e0 | 98 | private static XmlObject fpdDynamicPcds;\r |
ff225cbb | 99 | \r |
878ddf1f | 100 | ///\r |
a29c47e0 | 101 | /// Parsed modules list\r |
878ddf1f | 102 | ///\r |
a29c47e0 | 103 | private static Map<FpdModuleIdentification, Map<String, XmlObject>> parsedModules = new HashMap<FpdModuleIdentification, Map<String, XmlObject>>();\r |
ff225cbb | 104 | \r |
878ddf1f | 105 | ///\r |
a29c47e0 | 106 | /// built modules list with ARCH, TARGET, TOOLCHAIN\r |
878ddf1f | 107 | ///\r |
a29c47e0 | 108 | private static Set<FpdModuleIdentification> builtModules = new HashSet<FpdModuleIdentification>();\r |
ff225cbb | 109 | \r |
878ddf1f | 110 | ///\r |
a29c47e0 | 111 | /// PCD memory database stored all PCD information which collected from FPD,MSA and SPD.\r |
878ddf1f | 112 | ///\r |
8b7bd455 | 113 | private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager();\r |
878ddf1f | 114 | \r |
115 | ///\r | |
a29c47e0 | 116 | /// build target + tool chain family/tag name + arch + command types + command options\r |
878ddf1f | 117 | ///\r |
a29c47e0 | 118 | ///\r |
119 | /// Tool Chain Data\r | |
120 | /// toolsDef - build tool program information\r | |
121 | /// fpdBuildOption - all modules's build options for tool tag or tool chain families\r | |
122 | /// moduleSaBuildOption - build options for a specific module\r | |
ff225cbb | 123 | ///\r |
a29c47e0 | 124 | private static ToolChainConfig toolsDef;\r |
878ddf1f | 125 | \r |
a29c47e0 | 126 | private static ToolChainInfo toolChainInfo;\r |
127 | private static ToolChainInfo toolChainEnvInfo;\r | |
128 | private static ToolChainInfo toolChainPlatformInfo;\r | |
878ddf1f | 129 | \r |
a29c47e0 | 130 | private static ToolChainMap platformToolChainOption;\r |
131 | private static ToolChainMap platformToolChainFamilyOption;\r | |
878ddf1f | 132 | \r |
a29c47e0 | 133 | private static Map<FpdModuleIdentification, ToolChainMap> moduleToolChainOption = new HashMap<FpdModuleIdentification, ToolChainMap>();\r |
134 | private static Map<FpdModuleIdentification, ToolChainMap> moduleToolChainFamilyOption = new HashMap<FpdModuleIdentification, ToolChainMap>();\r | |
878ddf1f | 135 | \r |
b69bb9ba | 136 | private static Map<ModuleIdentification, ToolChainMap> msaBuildOption = new HashMap<ModuleIdentification, ToolChainMap>();\r |
137 | private static Map<ModuleIdentification, ToolChainMap> msaFamilyBuildOption = new HashMap<ModuleIdentification, ToolChainMap>();\r | |
138 | \r | |
878ddf1f | 139 | /**\r |
140 | Parse framework database (DB) and all SPD files listed in DB to initialize\r | |
141 | the environment for next build. This method will only be executed only once\r | |
ff225cbb | 142 | in the whole build process.\r |
143 | \r | |
878ddf1f | 144 | @param workspaceDatabaseFile the file name of framework database\r |
145 | @param workspaceDir current workspace directory path\r | |
146 | @throws BuildException\r | |
a29c47e0 | 147 | Framework Dababase or SPD or MSA file is not valid\r |
878ddf1f | 148 | **/\r |
892b0e7a | 149 | public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir, String toolsDefFilename ) throws EdkException {\r |
a29c47e0 | 150 | //\r |
151 | // ensure this method will be revoked only once\r | |
152 | //\r | |
878ddf1f | 153 | if (globalFlag) {\r |
154 | return;\r | |
155 | }\r | |
156 | globalFlag = true;\r | |
73b4e31a | 157 | \r |
ff225cbb | 158 | //\r |
a29c47e0 | 159 | // Backup workspace directory. It will be used by other method\r |
160 | //\r | |
161 | GlobalData.workspaceDir = workspaceDir.replaceAll("(\\\\)", "/");\r | |
ff225cbb | 162 | \r |
a29c47e0 | 163 | //\r |
164 | // Parse tools definition file\r | |
165 | //\r | |
166 | //\r | |
167 | // If ToolChain has been set up before, do nothing.\r | |
168 | // CONF dir + tools definition file name\r | |
169 | //\r | |
de4bb9f6 | 170 | File toolsDefFile = new File(workspaceDir + File.separatorChar + toolsDefFilename);\r |
2eb7d78d | 171 | EdkLog.log("Init", EdkLog.EDK_ALWAYS, "Using tool definition file [" + toolsDefFile.getPath() + "].");\r |
892b0e7a | 172 | toolsDef = new ToolChainConfig(toolsDefFile);\r |
173 | \r | |
a29c47e0 | 174 | //\r |
175 | // Parse Framework Database\r | |
176 | //\r | |
878ddf1f | 177 | File dbFile = new File(workspaceDir + File.separatorChar + workspaceDatabaseFile);\r |
fe6d0f74 | 178 | FrameworkDatabaseDocument db = null;\r |
878ddf1f | 179 | try {\r |
fe6d0f74 | 180 | db = (FrameworkDatabaseDocument)parseXmlFile(dbFile);\r |
a29c47e0 | 181 | //\r |
182 | // Get package list\r | |
183 | //\r | |
184 | if (db.getFrameworkDatabase().getPackageList() != null ) {\r | |
185 | List<DbPathAndFilename> packages = db.getFrameworkDatabase().getPackageList().getFilenameList();\r | |
186 | Iterator<DbPathAndFilename> iter = packages.iterator();\r | |
187 | while (iter.hasNext()) {\r | |
83fba802 | 188 | String fileName = iter.next().getStringValue().trim();\r |
a29c47e0 | 189 | Spd spd = new Spd(new File(workspaceDir + File.separatorChar + fileName));\r |
190 | packageList.add(spd.getPackageId());\r | |
892b0e7a | 191 | //\r |
192 | // Report warning if existing two packages with same GUID and Version\r | |
193 | //\r | |
194 | if (spdTable.containsKey(spd.getPackageId())) {\r | |
195 | //\r | |
196 | // BUGBUG\r | |
197 | //\r | |
198 | EdkLog.log("Init", EdkLog.EDK_WARNING, "Warning: Existing two packages with same GUID and Version. They are ... " + spd.getPackageId().getSpdFile().getPath());\r | |
199 | }\r | |
a29c47e0 | 200 | spdTable.put(spd.getPackageId(), spd);\r |
250258de | 201 | }\r |
202 | }\r | |
fe6d0f74 | 203 | } catch(IOException ex) {\r |
204 | EdkException edkException = new EdkException("Parse of WORKSPACE Database file [" + dbFile.getPath() + "] failed!\n" + ex.getMessage());\r | |
205 | edkException.setStackTrace(ex.getStackTrace());\r | |
206 | throw edkException;\r | |
207 | } catch(XmlException ex) {\r | |
208 | EdkException edkException = new EdkException("Parse of WORKSPACE Database file [" + dbFile.getPath() + "] failed!\n" + ex.getMessage());\r | |
209 | edkException.setStackTrace(ex.getStackTrace());\r | |
210 | throw edkException;\r | |
211 | }\r | |
250258de | 212 | \r |
fe6d0f74 | 213 | File fpdFile = null;\r |
214 | try {\r | |
a29c47e0 | 215 | //\r |
216 | // Get platform list\r | |
217 | //\r | |
218 | if (db.getFrameworkDatabase().getPlatformList() != null) {\r | |
219 | List<DbPathAndFilename> platforms = db.getFrameworkDatabase().getPlatformList().getFilenameList();\r | |
220 | Iterator<DbPathAndFilename> iter = platforms.iterator();\r | |
221 | while (iter.hasNext()) {\r | |
83fba802 | 222 | String fileName = iter.next().getStringValue().trim();\r |
fe6d0f74 | 223 | fpdFile = new File(workspaceDir + File.separatorChar + fileName);\r |
82516887 | 224 | if ( !fpdFile.exists() ) {\r |
892b0e7a | 225 | throw new EdkException("Platform file [" + fpdFile.getPath() + "] not exists. ");\r |
250258de | 226 | }\r |
fe6d0f74 | 227 | XmlObject fpdDoc = parseXmlFile(fpdFile);\r |
a29c47e0 | 228 | //\r |
229 | // We can change Map to XmlObject\r | |
230 | //\r | |
a29c47e0 | 231 | Map<String, XmlObject> fpdDocMap = new HashMap<String, XmlObject>();\r |
232 | fpdDocMap.put("PlatformSurfaceArea", fpdDoc);\r | |
83fba802 | 233 | SurfaceAreaQuery saq = new SurfaceAreaQuery(fpdDocMap);\r |
234 | PlatformIdentification platformId = saq.getFpdHeader();\r | |
a29c47e0 | 235 | platformId.setFpdFile(fpdFile);\r |
892b0e7a | 236 | //\r |
237 | // Report warning if existing two platfrom with same GUID and Version\r | |
238 | //\r | |
239 | if (platformList.contains(platformId)) {\r | |
240 | //\r | |
241 | // BUGBUG\r | |
242 | //\r | |
243 | EdkLog.log("Init", EdkLog.EDK_WARNING, "Warning: Existing two platforms with same GUID and Version. They are ... " + fpdFile.getPath());\r | |
244 | }\r | |
a29c47e0 | 245 | platformList.add(platformId);\r |
878ddf1f | 246 | }\r |
878ddf1f | 247 | }\r |
892b0e7a | 248 | } catch(IOException ex) {\r |
fe6d0f74 | 249 | EdkException edkException = new EdkException("Parse of platform definition file [" + fpdFile.getPath() + "] failed!\n" + ex.getMessage());\r |
892b0e7a | 250 | edkException.setStackTrace(ex.getStackTrace());\r |
251 | throw edkException;\r | |
252 | } catch(XmlException ex) {\r | |
fe6d0f74 | 253 | EdkException edkException = new EdkException("Parse of platform definition file [" + fpdFile.getPath() + "] failed!\n" + ex.getMessage());\r |
892b0e7a | 254 | edkException.setStackTrace(ex.getStackTrace());\r |
255 | throw edkException;\r | |
878ddf1f | 256 | }\r |
257 | }\r | |
ff225cbb | 258 | \r |
878ddf1f | 259 | /**\r |
ff225cbb | 260 | Get the current WORKSPACE Directory.\r |
261 | \r | |
a29c47e0 | 262 | @return current workspace directory\r |
878ddf1f | 263 | **/\r |
a29c47e0 | 264 | public synchronized static String getWorkspacePath() {\r |
265 | return workspaceDir;\r | |
878ddf1f | 266 | }\r |
267 | \r | |
878ddf1f | 268 | \r |
269 | /**\r | |
a29c47e0 | 270 | Get the MSA file name with absolute path\r |
271 | */\r | |
892b0e7a | 272 | public synchronized static File getMsaFile(ModuleIdentification moduleId) throws EdkException {\r |
a29c47e0 | 273 | File msaFile = null;\r |
274 | //\r | |
ff225cbb | 275 | // TBD. Do only when package is null.\r |
a29c47e0 | 276 | //\r |
277 | Iterator iter = packageList.iterator();\r | |
278 | while (iter.hasNext()) {\r | |
279 | PackageIdentification packageId = (PackageIdentification)iter.next();\r | |
280 | Spd spd = spdTable.get(packageId);\r | |
281 | msaFile = spd.getModuleFile(moduleId);\r | |
282 | if (msaFile != null ) {\r | |
283 | break ;\r | |
284 | }\r | |
285 | }\r | |
286 | if (msaFile == null){\r | |
892b0e7a | 287 | throw new EdkException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");\r |
82516887 | 288 | } else {\r |
a29c47e0 | 289 | return msaFile;\r |
290 | }\r | |
878ddf1f | 291 | }\r |
292 | \r | |
892b0e7a | 293 | public synchronized static PackageIdentification getPackageForModule(ModuleIdentification moduleId) throws EdkException {\r |
a29c47e0 | 294 | //\r |
295 | // If package already defined in module\r | |
296 | //\r | |
297 | if (moduleId.getPackage() != null) {\r | |
298 | return moduleId.getPackage();\r | |
299 | }\r | |
ff225cbb | 300 | \r |
a29c47e0 | 301 | PackageIdentification packageId = null;\r |
302 | Iterator iter = packageList.iterator();\r | |
303 | while (iter.hasNext()) {\r | |
304 | packageId = (PackageIdentification)iter.next();\r | |
305 | moduleId.setPackage(packageId);\r | |
306 | Spd spd = spdTable.get(packageId);\r | |
89e1408f | 307 | File tempMsaFile = null;\r |
308 | if ((tempMsaFile = spd.getModuleFile(moduleId)) != null ) {\r | |
309 | if (tempMsaFile.getParent().equalsIgnoreCase(moduleId.getMsaFile().getParent())) {\r | |
310 | break ;\r | |
311 | }\r | |
312 | tempMsaFile = null;\r | |
a29c47e0 | 313 | }\r |
314 | }\r | |
315 | if (packageId == null){\r | |
892b0e7a | 316 | throw new EdkException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");\r |
82516887 | 317 | } else {\r |
a29c47e0 | 318 | return packageId;\r |
319 | }\r | |
320 | }\r | |
ff225cbb | 321 | \r |
878ddf1f | 322 | /**\r |
a29c47e0 | 323 | Difference between build and parse: ToolChain and Target\r |
878ddf1f | 324 | **/\r |
a29c47e0 | 325 | public synchronized static boolean isModuleBuilt(FpdModuleIdentification moduleId) {\r |
326 | return builtModules.contains(moduleId);\r | |
878ddf1f | 327 | }\r |
ff225cbb | 328 | \r |
a29c47e0 | 329 | public synchronized static void registerBuiltModule(FpdModuleIdentification fpdModuleId) {\r |
330 | builtModules.add(fpdModuleId);\r | |
878ddf1f | 331 | }\r |
332 | \r | |
ff225cbb | 333 | \r |
892b0e7a | 334 | public synchronized static void registerFpdModuleSA(FpdModuleIdentification fpdModuleId, Map<String, XmlObject> doc) throws EdkException{\r |
a29c47e0 | 335 | Map<String, XmlObject> result = new HashMap<String, XmlObject>();\r |
336 | Set keySet = doc.keySet();\r | |
337 | Iterator iter = keySet.iterator();\r | |
338 | while (iter.hasNext()){\r | |
339 | String key = (String)iter.next();\r | |
340 | XmlObject item = cloneXmlObject(doc.get(key), true);\r | |
341 | result.put(key, item);\r | |
342 | }\r | |
343 | fpdModuleSA.put(fpdModuleId, result);\r | |
878ddf1f | 344 | }\r |
57cc2ee7 | 345 | \r |
346 | public synchronized static boolean hasFpdModuleSA(FpdModuleIdentification fpdModuleId) {\r | |
347 | return fpdModuleSA.containsKey(fpdModuleId);\r | |
348 | }\r | |
349 | \r | |
878ddf1f | 350 | /**\r |
82516887 | 351 | Query module surface area information.\r |
ff225cbb | 352 | \r |
353 | <p>Note that surface area parsing is incremental. That means the method will\r | |
82516887 | 354 | only parse the MSA files if necessary. </p>\r |
355 | \r | |
356 | @param fpdModuleId Module ID with arch\r | |
357 | @return ModuleSA info and MSA info for fpdModuleId\r | |
358 | @throws BuildException Can't find MSA\r | |
878ddf1f | 359 | **/\r |
892b0e7a | 360 | public synchronized static Map<String, XmlObject> getDoc(FpdModuleIdentification fpdModuleId) throws EdkException{\r |
a29c47e0 | 361 | if (parsedModules.containsKey(fpdModuleId)) {\r |
362 | return parsedModules.get(fpdModuleId);\r | |
363 | }\r | |
364 | Map<String, XmlObject> doc = new HashMap<String, XmlObject>();\r | |
365 | ModuleIdentification moduleId = fpdModuleId.getModule();\r | |
878ddf1f | 366 | //\r |
a29c47e0 | 367 | // First part: get the MSA files info\r |
878ddf1f | 368 | //\r |
136adffc | 369 | doc.putAll(getNativeMsa(moduleId));\r |
ff225cbb | 370 | \r |
a29c47e0 | 371 | //\r |
372 | // Second part: put build options\r | |
373 | //\r | |
374 | doc.put("BuildOptions", fpdBuildOptions);\r | |
ff225cbb | 375 | \r |
a29c47e0 | 376 | //\r |
377 | // Third part: get Module info from FPD, such as Library instances, PCDs\r | |
378 | //\r | |
379 | if (fpdModuleSA.containsKey(fpdModuleId)){\r | |
380 | //\r | |
381 | // merge module info in FPD to final Doc\r | |
382 | // For Library Module, do nothing here\r | |
383 | //\r | |
384 | doc.putAll(fpdModuleSA.get(fpdModuleId));\r | |
878ddf1f | 385 | }\r |
a29c47e0 | 386 | parsedModules.put(fpdModuleId, doc);\r |
387 | return doc;\r | |
878ddf1f | 388 | }\r |
389 | \r | |
892b0e7a | 390 | public synchronized static Map<String, XmlObject> getDoc(ModuleIdentification moduleId, String arch) throws EdkException{\r |
a29c47e0 | 391 | FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, arch);\r |
392 | return getDoc(fpdModuleId);\r | |
393 | }\r | |
892b0e7a | 394 | \r |
878ddf1f | 395 | /**\r |
ff225cbb | 396 | Query the native MSA information with module base name.\r |
397 | \r | |
398 | <p>Note that MSA parsing is incremental. That means the method will\r | |
878ddf1f | 399 | only to parse the MSA files when never parsed before. </p>\r |
ff225cbb | 400 | \r |
878ddf1f | 401 | @param moduleName the base name of the module\r |
402 | @return the native MSA information\r | |
403 | @throws BuildException\r | |
404 | MSA file is not valid\r | |
405 | **/\r | |
892b0e7a | 406 | public synchronized static Map<String, XmlObject> getNativeMsa(ModuleIdentification moduleId) throws EdkException {\r |
a29c47e0 | 407 | if (nativeMsa.containsKey(moduleId)) {\r |
408 | return nativeMsa.get(moduleId);\r | |
409 | }\r | |
410 | File msaFile = getMsaFile(moduleId);\r | |
411 | Map<String, XmlObject> msaMap = getNativeMsa(msaFile);\r | |
412 | nativeMsa.put(moduleId, msaMap);\r | |
413 | return msaMap;\r | |
414 | }\r | |
ff225cbb | 415 | \r |
892b0e7a | 416 | public synchronized static Map<String, XmlObject> getNativeMsa(File msaFile) throws EdkException {\r |
82516887 | 417 | if (!msaFile.exists()) {\r |
892b0e7a | 418 | throw new EdkException("Module Surface Area file [" + msaFile.getPath() + "] can't be found!");\r |
a29c47e0 | 419 | }\r |
420 | try {\r | |
fe6d0f74 | 421 | ModuleSurfaceAreaDocument doc = (ModuleSurfaceAreaDocument)parseXmlFile(msaFile);\r |
a29c47e0 | 422 | //\r |
423 | // parse MSA file\r | |
424 | //\r | |
425 | ModuleSurfaceArea msa= doc.getModuleSurfaceArea();\r | |
426 | Map<String, XmlObject> msaMap = new HashMap<String, XmlObject>();\r | |
427 | msaMap.put("MsaHeader", cloneXmlObject(msa.getMsaHeader(), true));\r | |
428 | msaMap.put("ModuleDefinitions", cloneXmlObject(msa.getModuleDefinitions(), true));\r | |
429 | msaMap.put("LibraryClassDefinitions", cloneXmlObject(msa.getLibraryClassDefinitions(), true));\r | |
430 | msaMap.put("SourceFiles", cloneXmlObject(msa.getSourceFiles(), true));\r | |
431 | msaMap.put("PackageDependencies", cloneXmlObject(msa.getPackageDependencies(), true));\r | |
432 | msaMap.put("Protocols", cloneXmlObject(msa.getProtocols(), true));\r | |
433 | msaMap.put("PPIs", cloneXmlObject(msa.getPPIs(), true));\r | |
434 | msaMap.put("Guids", cloneXmlObject(msa.getGuids(), true));\r | |
435 | msaMap.put("Externs", cloneXmlObject(msa.getExterns(), true));\r | |
136adffc | 436 | msaMap.put("PcdCoded", cloneXmlObject(msa.getPcdCoded(), true));\r |
b69bb9ba | 437 | msaMap.put("ModuleBuildOptions", cloneXmlObject(msa.getModuleBuildOptions(), true));\r |
a29c47e0 | 438 | return msaMap;\r |
892b0e7a | 439 | } catch(IOException ex) {\r |
fe6d0f74 | 440 | EdkException edkException = new EdkException("Parse of MSA file [" + msaFile.getPath() + "] failed!\n" + ex.getMessage());\r |
892b0e7a | 441 | edkException.setStackTrace(ex.getStackTrace());\r |
442 | throw edkException;\r | |
443 | } catch(XmlException ex) {\r | |
fe6d0f74 | 444 | EdkException edkException = new EdkException("Parse of MSA file [" + msaFile.getPath() + "] failed!\n" + ex.getMessage());\r |
892b0e7a | 445 | edkException.setStackTrace(ex.getStackTrace());\r |
446 | throw edkException;\r | |
a29c47e0 | 447 | }\r |
448 | }\r | |
ff225cbb | 449 | \r |
19bf6b15 | 450 | public static Map<String, XmlObject> getFpdBuildOptionsMap() {\r |
451 | return fpdBuildOptionsMap;\r | |
878ddf1f | 452 | }\r |
ff225cbb | 453 | \r |
892b0e7a | 454 | public static void setFpdBuildOptions(XmlObject fpdBuildOptions) throws EdkException {\r |
a29c47e0 | 455 | GlobalData.fpdBuildOptions = cloneXmlObject(fpdBuildOptions, true);\r |
19bf6b15 | 456 | fpdBuildOptionsMap.put("BuildOptions", GlobalData.fpdBuildOptions);\r |
a29c47e0 | 457 | }\r |
458 | \r | |
459 | public static XmlObject getFpdDynamicPcds() {\r | |
460 | return fpdDynamicPcds;\r | |
461 | }\r | |
462 | \r | |
463 | public static void setFpdDynamicPcds(XmlObject fpdDynamicPcds) {\r | |
464 | GlobalData.fpdDynamicPcds = fpdDynamicPcds;\r | |
465 | }\r | |
466 | \r | |
a29c47e0 | 467 | public static Set<ModuleIdentification> getModules(PackageIdentification packageId){\r |
468 | Spd spd = spdTable.get(packageId);\r | |
469 | if (spd == null ) {\r | |
470 | Set<ModuleIdentification> dummy = new HashSet<ModuleIdentification>();\r | |
471 | return dummy;\r | |
82516887 | 472 | } else {\r |
a29c47e0 | 473 | return spd.getModules();\r |
878ddf1f | 474 | }\r |
878ddf1f | 475 | }\r |
476 | \r | |
477 | /**\r | |
a29c47e0 | 478 | * The header file path is relative to workspace dir\r |
479 | */\r | |
480 | public static String[] getLibraryClassHeaderFiles(\r | |
892b0e7a | 481 | PackageIdentification[] packages, String name) throws EdkException{\r |
a29c47e0 | 482 | if (packages == null) {\r |
483 | // throw Exception or not????\r | |
484 | return new String[0];\r | |
485 | }\r | |
486 | String[] result = null;\r | |
487 | for (int i = 0; i < packages.length; i++) {\r | |
488 | Spd spd = spdTable.get(packages[i]);\r | |
489 | //\r | |
490 | // If find one package defined the library class\r | |
491 | //\r | |
492 | if ((result = spd.getLibClassIncluder(name)) != null) {\r | |
493 | return result;\r | |
494 | }\r | |
495 | }\r | |
496 | //\r | |
497 | // If can't find library class declaration in every package\r | |
498 | //\r | |
892b0e7a | 499 | throw new EdkException("Can not find library class [" + name\r |
391dbbb1 | 500 | + "] declaration in any SPD package!");\r |
878ddf1f | 501 | }\r |
502 | \r | |
503 | /**\r | |
a29c47e0 | 504 | * The header file path is relative to workspace dir\r |
878ddf1f | 505 | */\r |
a29c47e0 | 506 | public static String getPackageHeaderFiles(PackageIdentification packages,\r |
892b0e7a | 507 | String moduleType) {\r |
a29c47e0 | 508 | if (packages == null) {\r |
509 | return new String("");\r | |
510 | }\r | |
511 | Spd spd = spdTable.get(packages);\r | |
512 | //\r | |
513 | // If can't find package header file, skip it\r | |
514 | //\r | |
515 | String temp = null;\r | |
516 | if (spd != null) {\r | |
517 | if ((temp = spd.getPackageIncluder(moduleType)) != null) {\r | |
518 | return temp;\r | |
519 | } else {\r | |
520 | temp = "";\r | |
521 | return temp;\r | |
878ddf1f | 522 | }\r |
a29c47e0 | 523 | } else {\r |
524 | return null;\r | |
878ddf1f | 525 | }\r |
878ddf1f | 526 | }\r |
527 | \r | |
a29c47e0 | 528 | /**\r |
529 | * return two values: {cName, GuidValue}\r | |
530 | */\r | |
892b0e7a | 531 | public static String[] getGuid(List<PackageIdentification> packages, String name) {\r |
a29c47e0 | 532 | if (packages == null) {\r |
533 | // throw Exception or not????\r | |
534 | return new String[0];\r | |
535 | }\r | |
536 | String[] result = null;\r | |
136adffc | 537 | Iterator item = packages.iterator();\r |
538 | while (item.hasNext()){\r | |
539 | Spd spd = spdTable.get(item.next());\r | |
a29c47e0 | 540 | //\r |
541 | // If find one package defined the GUID\r | |
542 | //\r | |
543 | if ((result = spd.getGuid(name)) != null) {\r | |
544 | return result;\r | |
878ddf1f | 545 | }\r |
546 | }\r | |
136adffc | 547 | \r |
a29c47e0 | 548 | return null;\r |
878ddf1f | 549 | }\r |
550 | \r | |
551 | /**\r | |
a29c47e0 | 552 | * return two values: {cName, GuidValue}\r |
878ddf1f | 553 | */\r |
136adffc | 554 | public static String[] getPpiGuid(List<PackageIdentification> packages,\r |
892b0e7a | 555 | String name) {\r |
a29c47e0 | 556 | if (packages == null) {\r |
557 | return new String[0];\r | |
558 | }\r | |
559 | String[] result = null;\r | |
136adffc | 560 | Iterator item = packages.iterator();\r |
561 | while (item.hasNext()){\r | |
562 | Spd spd = spdTable.get(item.next());\r | |
a29c47e0 | 563 | //\r |
564 | // If find one package defined the Ppi GUID\r | |
565 | //\r | |
566 | if ((result = spd.getPpi(name)) != null) {\r | |
567 | return result;\r | |
878ddf1f | 568 | }\r |
569 | }\r | |
a29c47e0 | 570 | return null;\r |
878ddf1f | 571 | }\r |
572 | \r | |
a29c47e0 | 573 | /**\r |
574 | * return two values: {cName, GuidValue}\r | |
575 | */\r | |
136adffc | 576 | public static String[] getProtocolGuid(List<PackageIdentification> packages,\r |
892b0e7a | 577 | String name) {\r |
a29c47e0 | 578 | if (packages == null) {\r |
579 | return new String[0];\r | |
580 | }\r | |
581 | String[] result = null;\r | |
136adffc | 582 | Iterator item = packages.iterator();\r |
583 | while (item.hasNext()){\r | |
584 | Spd spd = spdTable.get(item.next());\r | |
a29c47e0 | 585 | //\r |
586 | // If find one package defined the protocol GUID\r | |
587 | //\r | |
136adffc | 588 | if ((result = spd.getProtocol(name))!= null){\r |
a29c47e0 | 589 | return result;\r |
590 | }\r | |
591 | }\r | |
592 | return null;\r | |
878ddf1f | 593 | \r |
a29c47e0 | 594 | }\r |
ff225cbb | 595 | \r |
892b0e7a | 596 | public synchronized static PlatformIdentification getPlatformByName(String name) throws EdkException {\r |
a29c47e0 | 597 | Iterator iter = platformList.iterator();\r |
598 | while(iter.hasNext()){\r | |
599 | PlatformIdentification platformId = (PlatformIdentification)iter.next();\r | |
600 | if (platformId.getName().equalsIgnoreCase(name)) {\r | |
a29c47e0 | 601 | return platformId;\r |
878ddf1f | 602 | }\r |
a29c47e0 | 603 | }\r |
892b0e7a | 604 | throw new EdkException("Can't find platform [" + name + "] in the current WORKSPACE database!");\r |
de4bb9f6 | 605 | }\r |
ff225cbb | 606 | \r |
892b0e7a | 607 | public synchronized static PlatformIdentification getPlatform(String filename) throws EdkException {\r |
de4bb9f6 | 608 | File file = new File(workspaceDir + File.separatorChar + filename);\r |
609 | Iterator iter = platformList.iterator();\r | |
610 | while(iter.hasNext()){\r | |
611 | PlatformIdentification platformId = (PlatformIdentification)iter.next();\r | |
612 | if (platformId.getFpdFile().getPath().equalsIgnoreCase(file.getPath())) {\r | |
613 | return platformId;\r | |
614 | }\r | |
615 | }\r | |
892b0e7a | 616 | throw new EdkException("Can't find platform file [" + filename + "] in the current WORKSPACE database!");\r |
a29c47e0 | 617 | }\r |
ff225cbb | 618 | \r |
892b0e7a | 619 | public synchronized static PackageIdentification refreshPackageIdentification(PackageIdentification packageId) throws EdkException {\r |
a29c47e0 | 620 | Iterator iter = packageList.iterator();\r |
621 | while(iter.hasNext()){\r | |
622 | PackageIdentification packageItem = (PackageIdentification)iter.next();\r | |
623 | if (packageItem.equals(packageId)) {\r | |
624 | packageId.setName(packageItem.getName());\r | |
625 | packageId.setSpdFile(packageItem.getSpdFile());\r | |
626 | return packageId;\r | |
878ddf1f | 627 | }\r |
628 | }\r | |
892b0e7a | 629 | throw new EdkException("Can't find package GUID value " + packageId.toGuidString() + " in the current workspace!");\r |
a29c47e0 | 630 | }\r |
ff225cbb | 631 | \r |
892b0e7a | 632 | public synchronized static ModuleIdentification refreshModuleIdentification(ModuleIdentification moduleId) throws EdkException {\r |
a29c47e0 | 633 | PackageIdentification packageId = getPackageForModule(moduleId);\r |
a29c47e0 | 634 | moduleId.setPackage(packageId);\r |
635 | Spd spd = spdTable.get(packageId);\r | |
636 | if (spd == null) {\r | |
892b0e7a | 637 | throw new EdkException("Can't find package GUID value " + packageId.toGuidString() + " in the current workspace!");\r |
a29c47e0 | 638 | }\r |
639 | Set<ModuleIdentification> modules = spd.getModules();\r | |
640 | Iterator<ModuleIdentification> iter = modules.iterator();\r | |
641 | while (iter.hasNext()) {\r | |
642 | ModuleIdentification item = iter.next();\r | |
643 | if (item.equals(moduleId)) {\r | |
644 | moduleId.setName(item.getName());\r | |
645 | moduleId.setModuleType(item.getModuleType());\r | |
646 | moduleId.setMsaFile(item.getMsaFile());\r | |
647 | return moduleId;\r | |
648 | }\r | |
649 | }\r | |
892b0e7a | 650 | throw new EdkException("Can't find module GUID value " + moduleId.toGuidString() + " in " + packageId + " under the current workspace!");\r |
a29c47e0 | 651 | }\r |
ff225cbb | 652 | \r |
a29c47e0 | 653 | public synchronized static Set<PackageIdentification> getPackageList(){\r |
654 | return packageList;\r | |
655 | }\r | |
82516887 | 656 | \r |
657 | /**\r | |
658 | BUGBUG: It is a walk around method. If do not clone, can't query info with\r | |
659 | XPath correctly. \r | |
660 | \r | |
661 | @param object XmlObject\r | |
662 | @param deep flag for deep clone\r | |
663 | @return XmlObject after clone\r | |
664 | @throws BuildException parse original XmlObject error. \r | |
665 | **/\r | |
892b0e7a | 666 | private static XmlObject cloneXmlObject(XmlObject object, boolean deep) throws EdkException {\r |
a29c47e0 | 667 | if ( object == null) {\r |
668 | return null;\r | |
669 | }\r | |
670 | XmlObject result = null;\r | |
671 | try {\r | |
672 | result = XmlObject.Factory.parse(object.getDomNode()\r | |
673 | .cloneNode(deep));\r | |
892b0e7a | 674 | } catch (XmlException ex) {\r |
675 | EdkException edkException = new EdkException(ex.getMessage());\r | |
676 | edkException.setStackTrace(ex.getStackTrace());\r | |
677 | throw edkException;\r | |
a29c47e0 | 678 | }\r |
679 | return result;\r | |
878ddf1f | 680 | }\r |
681 | \r | |
4b5f5549 | 682 | ///\r |
683 | /// Tool Chain Related, try to refine and put some logic process to ToolChainFactory\r | |
684 | ///\r | |
05b52e96 | 685 | public synchronized static ToolChainInfo getToolChainInfo() {\r |
a29c47e0 | 686 | if (toolChainInfo == null) {\r |
687 | toolChainInfo = toolsDef.getConfigInfo().intersection(toolChainEnvInfo);\r | |
688 | if (toolChainPlatformInfo != null) {\r | |
689 | toolChainInfo = toolChainInfo.intersection(toolChainPlatformInfo);\r | |
878ddf1f | 690 | }\r |
a29c47e0 | 691 | toolChainInfo.addCommands(toolsDef.getConfigInfo().getCommands());\r |
692 | toolChainInfo.normalize();\r | |
2b0fe8b4 | 693 | \r |
2eb7d78d | 694 | EdkLog.log("Init", EdkLog.EDK_ALWAYS, "Current build tool chain information summary: ");\r |
695 | EdkLog.log("Init", EdkLog.EDK_ALWAYS, toolChainInfo + "");\r | |
878ddf1f | 696 | }\r |
a29c47e0 | 697 | return toolChainInfo;\r |
698 | }\r | |
699 | \r | |
a29c47e0 | 700 | public static void setPlatformToolChainFamilyOption(ToolChainMap map) {\r |
701 | platformToolChainFamilyOption = map;\r | |
878ddf1f | 702 | }\r |
703 | \r | |
a29c47e0 | 704 | public static void setPlatformToolChainOption(ToolChainMap map) {\r |
705 | platformToolChainOption = map;\r | |
706 | }\r | |
878ddf1f | 707 | \r |
a29c47e0 | 708 | public static void addModuleToolChainOption(FpdModuleIdentification fpdModuleId,\r |
709 | ToolChainMap toolChainOption) {\r | |
710 | moduleToolChainOption.put(fpdModuleId, toolChainOption);\r | |
878ddf1f | 711 | }\r |
712 | \r | |
a29c47e0 | 713 | public static void addModuleToolChainFamilyOption(FpdModuleIdentification fpdModuleId,\r |
714 | ToolChainMap toolChainOption) {\r | |
715 | moduleToolChainFamilyOption.put(fpdModuleId, toolChainOption);\r | |
878ddf1f | 716 | }\r |
b69bb9ba | 717 | \r |
718 | public static void addMsaBuildOption(ModuleIdentification moduleId,\r | |
719 | ToolChainMap toolChainOption) {\r | |
720 | msaBuildOption.put(moduleId, toolChainOption);\r | |
721 | }\r | |
722 | \r | |
723 | public static void addMsaFamilyBuildOption(ModuleIdentification moduleId,\r | |
724 | ToolChainMap toolChainOption) {\r | |
725 | msaFamilyBuildOption.put(moduleId, toolChainOption);\r | |
726 | }\r | |
727 | \r | |
2b0fe8b4 | 728 | public static boolean isCommandSet(String target, String toolchain, String arch) throws EdkException {\r |
c773bec0 | 729 | String[] commands = getToolChainInfo().getCommands();\r |
730 | \r | |
731 | for (int i = 0; i < commands.length; ++i) {\r | |
b0a80562 | 732 | String cmdName = toolsDef.getConfig().get(new String[] {target, toolchain, arch, commands[i], ToolDefinitions.TOOLS_DEF_ATTRIBUTE_NAME});\r |
a10c0400 | 733 | if (cmdName != null && cmdName.length() != 0) {\r |
c773bec0 | 734 | return true;\r |
735 | }\r | |
736 | }\r | |
737 | \r | |
738 | return false;\r | |
739 | }\r | |
740 | \r | |
b69bb9ba | 741 | /**\r |
742 | Except FLAGS, all attribute are from TOOLS_DEF file. \r | |
743 | \r | |
744 | For FLAGS, information from four places, they are: \r | |
745 | <pre>\r | |
746 | 1. tools_def.txt\r | |
747 | 2. MSA <BuildOptions>/<Options>\r | |
748 | 3. FPD <BuildOptions>/<Options>\r | |
749 | 4. FPD <FrameworkModules>/<ModuleSaBuildOptions>/<Options>\r | |
750 | </pre>\r | |
751 | \r | |
752 | @param commandDescription Key: TARGET, TAGNAME, ARCH, COMMANDTYPE, ATTRIBUTE\r | |
753 | @param fpdModuleId Module Identification with Arch\r | |
754 | @return The corresponding String\r | |
755 | @throws EdkException If build option definition error\r | |
756 | **/\r | |
2f2c367a | 757 | public synchronized static String getCommandSetting(String[] commandDescription, FpdModuleIdentification fpdModuleId) throws EdkException {\r |
a29c47e0 | 758 | ToolChainKey toolChainKey = new ToolChainKey(commandDescription);\r |
ff225cbb | 759 | ToolChainMap toolChainConfig = toolsDef.getConfig();\r |
a29c47e0 | 760 | String setting = null;\r |
761 | \r | |
8c84e1b1 | 762 | //\r |
763 | // Default in tools_def.txt\r | |
764 | // \r | |
0923e8b3 | 765 | setting = toolChainConfig.get(toolChainKey);\r |
766 | if (setting == null) {\r | |
8c84e1b1 | 767 | setting = "";\r |
0923e8b3 | 768 | }\r |
b0a80562 | 769 | if (!commandDescription[ToolChainElement.ATTRIBUTE.value].equals(ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FLAGS)) {\r |
a29c47e0 | 770 | return setting;\r |
878ddf1f | 771 | }\r |
878ddf1f | 772 | \r |
92cfaeee | 773 | Set<String> flagSet = new LinkedHashSet<String>();\r |
774 | flagSet.add(setting);\r | |
775 | \r | |
a29c47e0 | 776 | //\r |
b69bb9ba | 777 | // Tool's option can be in .fpd and/or .msa file\r |
8c84e1b1 | 778 | //\r |
779 | String optionString;\r | |
780 | ToolChainMap option = null;\r | |
781 | ToolChainKey toolChainFamilyKey = new ToolChainKey(commandDescription);\r | |
0923e8b3 | 782 | \r |
b0a80562 | 783 | toolChainFamilyKey.setKey(ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FAMILY, ToolChainElement.ATTRIBUTE.value);\r |
8c84e1b1 | 784 | String family = toolChainConfig.get(toolChainFamilyKey);\r |
785 | toolChainFamilyKey.setKey(family, ToolChainElement.TOOLCHAIN.value);\r | |
b0a80562 | 786 | toolChainFamilyKey.setKey(ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FLAGS, ToolChainElement.ATTRIBUTE.value);\r |
0923e8b3 | 787 | \r |
b69bb9ba | 788 | //\r |
789 | // MSA's tool chain family option\r | |
790 | //\r | |
791 | option = msaFamilyBuildOption.get(fpdModuleId.getModule());\r | |
792 | if (option != null && (optionString = option.get(toolChainFamilyKey)) != null) {\r | |
92cfaeee | 793 | flagSet.add(optionString);\r |
b69bb9ba | 794 | }\r |
795 | \r | |
796 | //\r | |
797 | // MSA's tool chain option\r | |
798 | //\r | |
799 | option = msaBuildOption.get(fpdModuleId.getModule());\r | |
800 | if (option != null && (optionString = option.get(toolChainKey)) != null) {\r | |
92cfaeee | 801 | flagSet.add(optionString);\r |
b69bb9ba | 802 | }\r |
803 | \r | |
0923e8b3 | 804 | //\r |
8c84e1b1 | 805 | // Platform's tool chain family option\r |
0923e8b3 | 806 | //\r |
8c84e1b1 | 807 | optionString = platformToolChainFamilyOption.get(toolChainFamilyKey);\r |
808 | if (optionString != null) {\r | |
92cfaeee | 809 | flagSet.add(optionString);\r |
878ddf1f | 810 | }\r |
878ddf1f | 811 | \r |
a29c47e0 | 812 | //\r |
8c84e1b1 | 813 | // Platform's tool chain tag option\r |
a29c47e0 | 814 | //\r |
8c84e1b1 | 815 | optionString = platformToolChainOption.get(toolChainKey);\r |
816 | if (optionString != null) {\r | |
92cfaeee | 817 | flagSet.add(optionString);\r |
8c84e1b1 | 818 | }\r |
a29c47e0 | 819 | \r |
8c84e1b1 | 820 | //\r |
821 | // Module's tool chain family option\r | |
822 | //\r | |
823 | option = moduleToolChainFamilyOption.get(fpdModuleId);\r | |
824 | if (option != null && (optionString = option.get(toolChainFamilyKey)) != null) {\r | |
92cfaeee | 825 | flagSet.add(optionString);\r |
a29c47e0 | 826 | }\r |
827 | \r | |
8c84e1b1 | 828 | //\r |
829 | // Module's tool chain tag option\r | |
830 | //\r | |
831 | option = moduleToolChainOption.get(fpdModuleId);\r | |
832 | if (option != null && (optionString = option.get(toolChainKey)) != null) {\r | |
92cfaeee | 833 | flagSet.add(optionString);\r |
834 | }\r | |
835 | \r | |
836 | setting = "";\r | |
837 | for(Iterator<String> iter = flagSet.iterator(); iter.hasNext();) {\r | |
838 | setting += iter.next() +" ";\r | |
a29c47e0 | 839 | }\r |
a29c47e0 | 840 | return setting;\r |
841 | }\r | |
ff225cbb | 842 | \r |
a29c47e0 | 843 | public static void setToolChainEnvInfo(ToolChainInfo envInfo) {\r |
844 | toolChainEnvInfo = envInfo;\r | |
845 | }\r | |
846 | public static void setToolChainPlatformInfo(ToolChainInfo platformInfo) {\r | |
847 | toolChainPlatformInfo = platformInfo;\r | |
878ddf1f | 848 | }\r |
a29c47e0 | 849 | \r |
850 | //\r | |
851 | // for PCD\r | |
852 | //\r | |
136adffc | 853 | public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() {\r |
854 | return pcdDbManager;\r | |
855 | }\r | |
a29c47e0 | 856 | \r |
857 | //\r | |
136adffc | 858 | // For PCD get tokenSpaceGUid\r |
a29c47e0 | 859 | //\r |
20c5c53f | 860 | public synchronized static String getGuidInfoFromCname(String cName){\r |
861 | String cNameGuid = null;\r | |
136adffc | 862 | String guid = null;\r |
863 | Set set = spdTable.keySet();\r | |
864 | Iterator iter = set.iterator();\r | |
548ce97a | 865 | \r |
866 | if (iter == null) {\r | |
867 | return null;\r | |
868 | }\r | |
869 | \r | |
136adffc | 870 | while (iter.hasNext()){\r |
871 | Spd spd = (Spd) spdTable.get(iter.next());\r | |
872 | guid = spd.getGuidFromCname(cName);\r | |
873 | if (guid != null){\r | |
20c5c53f | 874 | cNameGuid = guid;\r |
136adffc | 875 | break;\r |
876 | }\r | |
877 | }\r | |
878 | return cNameGuid;\r | |
879 | }\r | |
a29c47e0 | 880 | \r |
881 | //\r | |
882 | // For PCD\r | |
883 | //\r | |
ff225cbb | 884 | public synchronized static Map<FpdModuleIdentification, XmlObject>\r |
eece174a | 885 | getFpdModuleSaXmlObject(String xmlObjectName) {\r |
136adffc | 886 | Set<FpdModuleIdentification> fpdModuleSASet = fpdModuleSA.keySet();\r |
887 | Iterator item = fpdModuleSASet.iterator();\r | |
ff225cbb | 888 | \r |
136adffc | 889 | \r |
890 | Map<FpdModuleIdentification, XmlObject> SAPcdBuildDef = new HashMap<FpdModuleIdentification, XmlObject>();\r | |
891 | Map<String, XmlObject> SANode = new HashMap<String, XmlObject>();\r | |
892 | FpdModuleIdentification moduleId;\r | |
893 | while (item.hasNext()) {\r | |
ff225cbb | 894 | \r |
136adffc | 895 | moduleId = (FpdModuleIdentification) item.next();\r |
896 | SANode = fpdModuleSA.get(moduleId);\r | |
897 | try{\r | |
898 | if (SANode.get(xmlObjectName)!= null){\r | |
899 | SAPcdBuildDef.put(moduleId,\r | |
eece174a | 900 | (XmlObject) SANode.get(xmlObjectName));\r |
136adffc | 901 | \r |
902 | }\r | |
136adffc | 903 | } catch (Exception e){\r |
904 | EdkLog.log(EdkLog.EDK_INFO, e.getMessage());\r | |
905 | }\r | |
eece174a | 906 | }\r |
136adffc | 907 | return SAPcdBuildDef;\r |
908 | }\r | |
eece174a | 909 | \r |
910 | public synchronized static Map<FpdModuleIdentification,XmlObject> getFpdPcdBuildDefinitions() {\r | |
911 | Map<FpdModuleIdentification,XmlObject> pcdBuildDef = getFpdModuleSaXmlObject ("PcdBuildDefinition");\r | |
912 | \r | |
913 | return pcdBuildDef;\r | |
914 | }\r | |
fe6d0f74 | 915 | \r |
916 | public static XmlObject parseXmlFile(File xmlFile) throws IOException, XmlException {\r | |
917 | Collection errors = new ArrayList(); \r | |
918 | XmlOptions opt = new XmlOptions();\r | |
919 | \r | |
920 | opt.setLoadLineNumbers();\r | |
921 | opt.setLoadMessageDigest();\r | |
922 | opt.setErrorListener(errors);\r | |
923 | \r | |
924 | XmlObject doc = XmlObject.Factory.parse(xmlFile, opt);\r | |
925 | //\r | |
926 | // Validate File if they accord with XML Schema\r | |
927 | //\r | |
928 | if (!doc.validate(opt)){\r | |
929 | StringBuilder errorMessage = new StringBuilder(1024);\r | |
930 | for (Iterator it = errors.iterator(); it.hasNext(); ) {\r | |
931 | errorMessage.append(it.next());\r | |
932 | errorMessage.append("\n");\r | |
933 | }\r | |
934 | throw new XmlException(errorMessage.toString());\r | |
935 | }\r | |
936 | \r | |
937 | return doc;\r | |
938 | }\r | |
878ddf1f | 939 | }\r |
a29c47e0 | 940 | \r |