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