4 GlobalData provide initializing, instoring, querying and update global data.
5 It is a bridge to intercommunicate between multiple component, such as AutoGen,
8 Copyright (c) 2006, Intel Corporation
9 All rights reserved. This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 package org
.tianocore
.build
.global
;
20 import java
.util
.HashMap
;
21 import java
.util
.HashSet
;
22 import java
.util
.Iterator
;
23 import java
.util
.List
;
26 import java
.util
.logging
.Logger
;
28 import org
.apache
.tools
.ant
.BuildException
;
29 import org
.apache
.xmlbeans
.XmlObject
;
31 import org
.tianocore
.common
.exception
.EdkException
;
32 import org
.tianocore
.common
.logger
.EdkLog
;
33 import org
.tianocore
.pcd
.entity
.MemoryDatabaseManager
;
34 import org
.tianocore
.DbPathAndFilename
;
35 import org
.tianocore
.FrameworkDatabaseDocument
;
36 import org
.tianocore
.ModuleSurfaceAreaDocument
;
37 import org
.tianocore
.ModuleSurfaceAreaDocument
.ModuleSurfaceArea
;
38 import org
.tianocore
.build
.id
.FpdModuleIdentification
;
39 import org
.tianocore
.build
.id
.ModuleIdentification
;
40 import org
.tianocore
.build
.id
.PackageIdentification
;
41 import org
.tianocore
.build
.id
.PlatformIdentification
;
42 import org
.tianocore
.build
.toolchain
.ToolChainAttribute
;
43 import org
.tianocore
.build
.toolchain
.ToolChainConfig
;
44 import org
.tianocore
.build
.toolchain
.ToolChainElement
;
45 import org
.tianocore
.build
.toolchain
.ToolChainInfo
;
46 import org
.tianocore
.build
.toolchain
.ToolChainKey
;
47 import org
.tianocore
.build
.toolchain
.ToolChainMap
;
50 GlobalData provide initializing, instoring, querying and update global data.
51 It is a bridge to intercommunicate between multiple component, such as AutoGen,
54 <p>Note that all global information are initialized incrementally. All data will
55 parse and record only of necessary during build time. </p>
59 public class GlobalData
{
61 public static Logger log
= Logger
.getAnonymousLogger();
64 /// Record current WORKSPACE Directory
66 private static String workspaceDir
= "";
69 /// Be used to ensure Global data will be initialized only once.
71 private static boolean globalFlag
= false;
74 /// Framework Database information: package list and platform list
76 private static Set
<PackageIdentification
> packageList
= new HashSet
<PackageIdentification
>();
78 private static Set
<PlatformIdentification
> platformList
= new HashSet
<PlatformIdentification
>();
81 /// Every detail SPD informations: Module list, Library class definition,
82 /// Package header file, GUID/PPI/Protocol definitions
84 private static final Map
<PackageIdentification
, Spd
> spdTable
= new HashMap
<PackageIdentification
, Spd
>();
87 /// Build informations are divided into three parts:
88 /// 1. From MSA 2. From FPD 3. From FPD' ModuleSA
90 private static Map
<ModuleIdentification
, Map
<String
, XmlObject
>> nativeMsa
= new HashMap
<ModuleIdentification
, Map
<String
, XmlObject
>>();
92 private static Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> fpdModuleSA
= new HashMap
<FpdModuleIdentification
, Map
<String
, XmlObject
>>();
94 private static XmlObject fpdBuildOptions
;
96 private static XmlObject fpdDynamicPcds
;
99 /// Parsed modules list
101 private static Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> parsedModules
= new HashMap
<FpdModuleIdentification
, Map
<String
, XmlObject
>>();
104 /// built modules list with ARCH, TARGET, TOOLCHAIN
106 private static Set
<FpdModuleIdentification
> builtModules
= new HashSet
<FpdModuleIdentification
>();
109 /// PCD memory database stored all PCD information which collected from FPD,MSA and SPD.
111 private static final MemoryDatabaseManager pcdDbManager
= new MemoryDatabaseManager();
114 /// build target + tool chain family/tag name + arch + command types + command options
118 /// toolsDef - build tool program information
119 /// fpdBuildOption - all modules's build options for tool tag or tool chain families
120 /// moduleSaBuildOption - build options for a specific module
122 private static ToolChainConfig toolsDef
;
124 private static ToolChainInfo toolChainInfo
;
125 private static ToolChainInfo toolChainEnvInfo
;
126 private static ToolChainInfo toolChainPlatformInfo
;
128 private static ToolChainMap platformToolChainOption
;
129 private static ToolChainMap platformToolChainFamilyOption
;
131 private static Map
<FpdModuleIdentification
, ToolChainMap
> moduleToolChainOption
= new HashMap
<FpdModuleIdentification
, ToolChainMap
>();
132 private static Map
<FpdModuleIdentification
, ToolChainMap
> moduleToolChainFamilyOption
= new HashMap
<FpdModuleIdentification
, ToolChainMap
>();
135 Parse framework database (DB) and all SPD files listed in DB to initialize
136 the environment for next build. This method will only be executed only once
137 in the whole build process.
139 @param workspaceDatabaseFile the file name of framework database
140 @param workspaceDir current workspace directory path
141 @throws BuildException
142 Framework Dababase or SPD or MSA file is not valid
144 public synchronized static void initInfo(String workspaceDatabaseFile
, String workspaceDir
, String toolsDefFilename
) throws BuildException
{
146 // ensure this method will be revoked only once
154 // Backup workspace directory. It will be used by other method
156 GlobalData
.workspaceDir
= workspaceDir
.replaceAll("(\\\\)", "/");
159 // Parse tools definition file
162 // If ToolChain has been set up before, do nothing.
163 // CONF dir + tools definition file name
165 File toolsDefFile
= new File(workspaceDir
+ File
.separatorChar
+ toolsDefFilename
);
166 System
.out
.println("Using tool definiton file [" + toolsDefFile
.getPath() + "].");
167 toolsDef
= new ToolChainConfig(toolsDefFile
);
170 // Parse Framework Database
172 File dbFile
= new File(workspaceDir
+ File
.separatorChar
+ workspaceDatabaseFile
);
174 FrameworkDatabaseDocument db
= (FrameworkDatabaseDocument
) XmlObject
.Factory
.parse(dbFile
);
176 // validate FrameworkDatabaseFile
178 if (! db
.validate()) {
179 throw new BuildException("Framework Database file [" + dbFile
.getPath() + "] format is invalid!");
184 if (db
.getFrameworkDatabase().getPackageList() != null ) {
185 List
<DbPathAndFilename
> packages
= db
.getFrameworkDatabase().getPackageList().getFilenameList();
186 Iterator
<DbPathAndFilename
> iter
= packages
.iterator();
187 while (iter
.hasNext()) {
188 String fileName
= iter
.next().getStringValue();
189 Spd spd
= new Spd(new File(workspaceDir
+ File
.separatorChar
+ fileName
));
190 packageList
.add(spd
.getPackageId());
191 spdTable
.put(spd
.getPackageId(), spd
);
198 if (db
.getFrameworkDatabase().getPlatformList() != null) {
199 List
<DbPathAndFilename
> platforms
= db
.getFrameworkDatabase().getPlatformList().getFilenameList();
200 Iterator
<DbPathAndFilename
> iter
= platforms
.iterator();
201 while (iter
.hasNext()) {
202 String fileName
= iter
.next().getStringValue();
203 File fpdFile
= new File(workspaceDir
+ File
.separatorChar
+ fileName
);
204 if ( ! fpdFile
.exists() ) {
205 throw new BuildException("Platform file [" + fpdFile
.getPath() + "] not exists. ");
207 XmlObject fpdDoc
= XmlObject
.Factory
.parse(fpdFile
);
209 // Verify FPD file, if is invalid, throw Exception
211 if (! fpdDoc
.validate()) {
212 throw new BuildException("Framework Platform Surface Area file [" + fpdFile
.getPath() + "] format is invalid!");
215 // We can change Map to XmlObject
218 // TBD check SPD or FPD is existed in FS
220 Map
<String
, XmlObject
> fpdDocMap
= new HashMap
<String
, XmlObject
>();
221 fpdDocMap
.put("PlatformSurfaceArea", fpdDoc
);
222 SurfaceAreaQuery
.setDoc(fpdDocMap
);
223 PlatformIdentification platformId
= SurfaceAreaQuery
.getFpdHeader();
224 platformId
.setFpdFile(fpdFile
);
225 platformList
.add(platformId
);
228 } catch (Exception e
) {
229 throw new BuildException("Parse WORKSPACE Database file [" + dbFile
.getPath() + "] Error.\n" + e
.getMessage());
234 Get the current WORKSPACE Directory.
236 @return current workspace directory
238 public synchronized static String
getWorkspacePath() {
244 Get the MSA file name with absolute path
246 public synchronized static File
getMsaFile(ModuleIdentification moduleId
) throws BuildException
{
249 // TBD. Do only when package is null.
251 Iterator iter
= packageList
.iterator();
252 while (iter
.hasNext()) {
253 PackageIdentification packageId
= (PackageIdentification
)iter
.next();
254 Spd spd
= spdTable
.get(packageId
);
255 msaFile
= spd
.getModuleFile(moduleId
);
256 if (msaFile
!= null ) {
260 if (msaFile
== null){
261 throw new BuildException("Can't find Module [" + moduleId
.getName() + "] in any SPD package!");
268 public synchronized static PackageIdentification
getPackageForModule(ModuleIdentification moduleId
) {
270 // If package already defined in module
272 if (moduleId
.getPackage() != null) {
273 return moduleId
.getPackage();
276 PackageIdentification packageId
= null;
277 Iterator iter
= packageList
.iterator();
278 while (iter
.hasNext()) {
279 packageId
= (PackageIdentification
)iter
.next();
280 moduleId
.setPackage(packageId
);
281 Spd spd
= spdTable
.get(packageId
);
282 if (spd
.getModuleFile(moduleId
) != null ) {
286 if (packageId
== null){
287 throw new BuildException("Can't find Module [" + moduleId
.getName() + "] in any SPD package!");
295 Difference between build and parse: ToolChain and Target
297 public synchronized static boolean isModuleBuilt(FpdModuleIdentification moduleId
) {
298 return builtModules
.contains(moduleId
);
301 public synchronized static void registerBuiltModule(FpdModuleIdentification fpdModuleId
) {
302 builtModules
.add(fpdModuleId
);
306 public synchronized static void registerFpdModuleSA(FpdModuleIdentification fpdModuleId
, Map
<String
, XmlObject
> doc
) {
307 Map
<String
, XmlObject
> result
= new HashMap
<String
, XmlObject
>();
308 Set keySet
= doc
.keySet();
309 Iterator iter
= keySet
.iterator();
310 while (iter
.hasNext()){
311 String key
= (String
)iter
.next();
312 XmlObject item
= cloneXmlObject(doc
.get(key
), true);
313 result
.put(key
, item
);
315 fpdModuleSA
.put(fpdModuleId
, result
);
318 public synchronized static boolean hasFpdModuleSA(FpdModuleIdentification fpdModuleId
) {
319 return fpdModuleSA
.containsKey(fpdModuleId
);
323 Query overrided module surface area information. If current is Package
324 or Platform build, also include the information from FPD file.
326 <p>Note that surface area parsing is incremental. That means the method will
327 only parse the MSA and MBD files if necessary. </p>
329 @param moduleName the base name of the module
330 @return the overrided module surface area information
331 @throws BuildException
332 MSA or MBD is not valid
334 public synchronized static Map
<String
, XmlObject
> getDoc(FpdModuleIdentification fpdModuleId
) throws BuildException
{
335 if (parsedModules
.containsKey(fpdModuleId
)) {
336 return parsedModules
.get(fpdModuleId
);
338 Map
<String
, XmlObject
> doc
= new HashMap
<String
, XmlObject
>();
339 ModuleIdentification moduleId
= fpdModuleId
.getModule();
341 // First part: get the MSA files info
343 doc
.putAll(getNativeMsa(moduleId
));
346 // Second part: put build options
348 doc
.put("BuildOptions", fpdBuildOptions
);
351 // Third part: get Module info from FPD, such as Library instances, PCDs
353 if (fpdModuleSA
.containsKey(fpdModuleId
)){
355 // merge module info in FPD to final Doc
356 // For Library Module, do nothing here
358 doc
.putAll(fpdModuleSA
.get(fpdModuleId
));
360 parsedModules
.put(fpdModuleId
, doc
);
364 public synchronized static Map
<String
, XmlObject
> getDoc(ModuleIdentification moduleId
, String arch
) throws BuildException
{
365 FpdModuleIdentification fpdModuleId
= new FpdModuleIdentification(moduleId
, arch
);
366 return getDoc(fpdModuleId
);
369 Query the native MSA information with module base name.
371 <p>Note that MSA parsing is incremental. That means the method will
372 only to parse the MSA files when never parsed before. </p>
374 @param moduleName the base name of the module
375 @return the native MSA information
376 @throws BuildException
377 MSA file is not valid
379 public synchronized static Map
<String
, XmlObject
> getNativeMsa(ModuleIdentification moduleId
) throws BuildException
{
380 if (nativeMsa
.containsKey(moduleId
)) {
381 return nativeMsa
.get(moduleId
);
383 File msaFile
= getMsaFile(moduleId
);
384 Map
<String
, XmlObject
> msaMap
= getNativeMsa(msaFile
);
385 nativeMsa
.put(moduleId
, msaMap
);
389 public synchronized static Map
<String
, XmlObject
> getNativeMsa(File msaFile
) throws BuildException
{
390 if (! msaFile
.exists()) {
391 throw new BuildException("Module Surface Area file [" + msaFile
.getPath() + "] can't be found!");
394 ModuleSurfaceAreaDocument doc
= (ModuleSurfaceAreaDocument
)XmlObject
.Factory
.parse(msaFile
);
396 // Validate File if they accord with XML Schema
398 if ( ! doc
.validate()){
399 throw new BuildException("Module Surface Area file [" + msaFile
.getPath() + "] format is invalid!");
404 ModuleSurfaceArea msa
= doc
.getModuleSurfaceArea();
405 Map
<String
, XmlObject
> msaMap
= new HashMap
<String
, XmlObject
>();
406 msaMap
.put("MsaHeader", cloneXmlObject(msa
.getMsaHeader(), true));
407 msaMap
.put("ModuleDefinitions", cloneXmlObject(msa
.getModuleDefinitions(), true));
408 msaMap
.put("LibraryClassDefinitions", cloneXmlObject(msa
.getLibraryClassDefinitions(), true));
409 msaMap
.put("SourceFiles", cloneXmlObject(msa
.getSourceFiles(), true));
410 msaMap
.put("PackageDependencies", cloneXmlObject(msa
.getPackageDependencies(), true));
411 msaMap
.put("Protocols", cloneXmlObject(msa
.getProtocols(), true));
412 msaMap
.put("PPIs", cloneXmlObject(msa
.getPPIs(), true));
413 msaMap
.put("Guids", cloneXmlObject(msa
.getGuids(), true));
414 msaMap
.put("Externs", cloneXmlObject(msa
.getExterns(), true));
415 msaMap
.put("PcdCoded", cloneXmlObject(msa
.getPcdCoded(), true));
418 catch (Exception ex
){
419 throw new BuildException(ex
.getMessage());
423 public static Map
<String
, XmlObject
> getFpdBuildOptions() {
424 Map
<String
, XmlObject
> map
= new HashMap
<String
, XmlObject
>();
425 map
.put("BuildOptions", fpdBuildOptions
);
429 public static void setFpdBuildOptions(XmlObject fpdBuildOptions
) {
430 GlobalData
.fpdBuildOptions
= cloneXmlObject(fpdBuildOptions
, true);
433 public static XmlObject
getFpdDynamicPcds() {
434 return fpdDynamicPcds
;
437 public static void setFpdDynamicPcds(XmlObject fpdDynamicPcds
) {
438 GlobalData
.fpdDynamicPcds
= fpdDynamicPcds
;
441 //////////////////////////////////////////////
442 //////////////////////////////////////////////
444 public static Set
<ModuleIdentification
> getModules(PackageIdentification packageId
){
445 Spd spd
= spdTable
.get(packageId
);
447 Set
<ModuleIdentification
> dummy
= new HashSet
<ModuleIdentification
>();
451 return spd
.getModules();
456 * The header file path is relative to workspace dir
458 public static String
[] getLibraryClassHeaderFiles(
459 PackageIdentification
[] packages
, String name
)
460 throws BuildException
{
461 if (packages
== null) {
462 // throw Exception or not????
463 return new String
[0];
465 String
[] result
= null;
466 for (int i
= 0; i
< packages
.length
; i
++) {
467 Spd spd
= spdTable
.get(packages
[i
]);
469 // If find one package defined the library class
471 if ((result
= spd
.getLibClassIncluder(name
)) != null) {
476 // If can't find library class declaration in every package
478 throw new BuildException("Can not find library class [" + name
479 + "] declaration in any SPD package!");
483 * The header file path is relative to workspace dir
485 public static String
getPackageHeaderFiles(PackageIdentification packages
,
486 String moduleType
) throws BuildException
{
487 if (packages
== null) {
488 return new String("");
490 Spd spd
= spdTable
.get(packages
);
492 // If can't find package header file, skip it
496 if ((temp
= spd
.getPackageIncluder(moduleType
)) != null) {
508 * return two values: {cName, GuidValue}
510 public static String
[] getGuid(List
<PackageIdentification
> packages
, String name
)
511 throws BuildException
{
512 if (packages
== null) {
513 // throw Exception or not????
514 return new String
[0];
516 String
[] result
= null;
517 Iterator item
= packages
.iterator();
518 while (item
.hasNext()){
519 Spd spd
= spdTable
.get(item
.next());
521 // If find one package defined the GUID
523 if ((result
= spd
.getGuid(name
)) != null) {
532 * return two values: {cName, GuidValue}
534 public static String
[] getPpiGuid(List
<PackageIdentification
> packages
,
535 String name
) throws BuildException
{
536 if (packages
== null) {
537 return new String
[0];
539 String
[] result
= null;
540 Iterator item
= packages
.iterator();
541 while (item
.hasNext()){
542 Spd spd
= spdTable
.get(item
.next());
544 // If find one package defined the Ppi GUID
546 if ((result
= spd
.getPpi(name
)) != null) {
555 * return two values: {cName, GuidValue}
557 public static String
[] getProtocolGuid(List
<PackageIdentification
> packages
,
558 String name
) throws BuildException
{
559 if (packages
== null) {
560 return new String
[0];
562 String
[] result
= null;
563 Iterator item
= packages
.iterator();
564 while (item
.hasNext()){
565 Spd spd
= spdTable
.get(item
.next());
567 // If find one package defined the protocol GUID
569 if ((result
= spd
.getProtocol(name
))!= null){
577 public synchronized static PlatformIdentification
getPlatformByName(String name
) throws BuildException
{
578 Iterator iter
= platformList
.iterator();
579 while(iter
.hasNext()){
580 PlatformIdentification platformId
= (PlatformIdentification
)iter
.next();
581 if (platformId
.getName().equalsIgnoreCase(name
)) {
585 throw new BuildException("Can't find platform [" + name
+ "] in the current WORKSPACE database!");
588 public synchronized static PlatformIdentification
getPlatform(String filename
) throws BuildException
{
589 File file
= new File(workspaceDir
+ File
.separatorChar
+ filename
);
590 Iterator iter
= platformList
.iterator();
591 while(iter
.hasNext()){
592 PlatformIdentification platformId
= (PlatformIdentification
)iter
.next();
593 if (platformId
.getFpdFile().getPath().equalsIgnoreCase(file
.getPath())) {
597 throw new BuildException("Can't find platform file [" + filename
+ "] in the current WORKSPACE database!");
600 public synchronized static PackageIdentification
refreshPackageIdentification(PackageIdentification packageId
) throws BuildException
{
601 Iterator iter
= packageList
.iterator();
602 while(iter
.hasNext()){
603 PackageIdentification packageItem
= (PackageIdentification
)iter
.next();
604 if (packageItem
.equals(packageId
)) {
605 packageId
.setName(packageItem
.getName());
606 packageId
.setSpdFile(packageItem
.getSpdFile());
610 throw new BuildException("Can't find package GUID value " + packageId
.getGuid() + " in the current workspace!");
613 public synchronized static ModuleIdentification
refreshModuleIdentification(ModuleIdentification moduleId
) throws BuildException
{
614 // System.out.println("1");
615 // System.out.println("##" + moduleId.getGuid());
616 PackageIdentification packageId
= getPackageForModule(moduleId
);
617 // System.out.println("" + packageId.getGuid());
618 moduleId
.setPackage(packageId
);
619 Spd spd
= spdTable
.get(packageId
);
621 throw new BuildException("Can't find package GUID value " + packageId
.getGuid() + " in the current workspace!");
623 Set
<ModuleIdentification
> modules
= spd
.getModules();
624 Iterator
<ModuleIdentification
> iter
= modules
.iterator();
625 while (iter
.hasNext()) {
626 ModuleIdentification item
= iter
.next();
627 if (item
.equals(moduleId
)) {
628 moduleId
.setName(item
.getName());
629 moduleId
.setModuleType(item
.getModuleType());
630 moduleId
.setMsaFile(item
.getMsaFile());
634 throw new BuildException("Can't find module GUID value " + moduleId
.getGuid() + " in package, " + packageId
+ ", in the current workspace!");
637 public synchronized static Set
<PackageIdentification
> getPackageList(){
641 private static XmlObject
cloneXmlObject(XmlObject object
, boolean deep
) throws BuildException
{
642 if ( object
== null) {
645 XmlObject result
= null;
647 result
= XmlObject
.Factory
.parse(object
.getDomNode()
649 } catch (Exception ex
) {
650 throw new BuildException(ex
.getMessage());
655 ////// Tool Chain Related, try to refine and put some logic process to ToolChainFactory
657 public static ToolChainInfo
getToolChainInfo() {
658 // GlobalData.log.info(toolsDef.getConfigInfo() + "" + toolChainEnvInfo + toolChainPlatformInfo);
659 if (toolChainInfo
== null) {
660 toolChainInfo
= toolsDef
.getConfigInfo().intersection(toolChainEnvInfo
);
661 if (toolChainPlatformInfo
!= null) {
662 toolChainInfo
= toolChainInfo
.intersection(toolChainPlatformInfo
);
664 toolChainInfo
.addCommands(toolsDef
.getConfigInfo().getCommands());
665 toolChainInfo
.normalize();
666 GlobalData
.log
.info(toolChainInfo
+ "");
668 return toolChainInfo
;
673 public static void setPlatformToolChainFamilyOption(ToolChainMap map
) {
674 platformToolChainFamilyOption
= map
;
677 public static void setPlatformToolChainOption(ToolChainMap map
) {
678 platformToolChainOption
= map
;
681 public static void addModuleToolChainOption(FpdModuleIdentification fpdModuleId
,
682 ToolChainMap toolChainOption
) {
683 moduleToolChainOption
.put(fpdModuleId
, toolChainOption
);
686 public static void addModuleToolChainFamilyOption(FpdModuleIdentification fpdModuleId
,
687 ToolChainMap toolChainOption
) {
688 moduleToolChainFamilyOption
.put(fpdModuleId
, toolChainOption
);
691 public static boolean isCommandSet(String target
, String toolchain
, String arch
) {
692 String
[] commands
= getToolChainInfo().getCommands();
694 for (int i
= 0; i
< commands
.length
; ++i
) {
695 String cmdName
= toolsDef
.getConfig().get(new String
[] {target
, toolchain
, arch
, commands
[i
], ToolChainAttribute
.NAME
.toString()});
696 if (cmdName
!= null && cmdName
.length() != 0) {
704 public static String
getCommandSetting(String
[] commandDescription
, FpdModuleIdentification fpdModuleId
) throws EdkException
{
705 ToolChainKey toolChainKey
= new ToolChainKey(commandDescription
);
706 ToolChainMap toolChainConfig
= toolsDef
.getConfig();
707 String setting
= null;
709 if (!commandDescription
[ToolChainElement
.ATTRIBUTE
.value
].equals(ToolChainAttribute
.FLAGS
.toString())) {
710 setting
= toolChainConfig
.get(toolChainKey
);
711 if (setting
== null) {
718 // get module specific options, if any
721 ToolChainMap option
= moduleToolChainOption
.get(fpdModuleId
);
722 ToolChainKey toolChainFamilyKey
= null;
724 if ((option
== null) || (option
!= null && (setting
= option
.get(toolChainKey
)) == null)) {
726 // then tool chain family
728 toolChainFamilyKey
= new ToolChainKey(commandDescription
);
729 toolChainFamilyKey
.setKey(ToolChainAttribute
.FAMILY
.toString(), ToolChainElement
.ATTRIBUTE
.value
);
730 String family
= toolChainConfig
.get(toolChainFamilyKey
);
731 toolChainFamilyKey
.setKey(family
, ToolChainElement
.TOOLCHAIN
.value
);
732 toolChainFamilyKey
.setKey(ToolChainAttribute
.FLAGS
.toString(), ToolChainElement
.ATTRIBUTE
.value
);
734 option
= moduleToolChainFamilyOption
.get(fpdModuleId
);
735 if (option
!= null) {
736 setting
= option
.get(toolChainFamilyKey
);
741 // get platform options, if any
743 if (setting
== null) {
745 if (platformToolChainOption
== null || (setting
= platformToolChainOption
.get(toolChainKey
)) == null) {
746 // then tool chain family
747 if (toolChainFamilyKey
== null) {
748 toolChainFamilyKey
= new ToolChainKey(commandDescription
);
749 toolChainFamilyKey
.setKey(ToolChainAttribute
.FAMILY
.toString(), ToolChainElement
.ATTRIBUTE
.value
);
750 String family
= toolChainConfig
.get(toolChainFamilyKey
);
751 toolChainFamilyKey
.setKey(family
, ToolChainElement
.TOOLCHAIN
.value
);
752 toolChainFamilyKey
.setKey(ToolChainAttribute
.FLAGS
.toString(), ToolChainElement
.ATTRIBUTE
.value
);
755 setting
= platformToolChainFamilyOption
.get(toolChainFamilyKey
);
759 if (setting
== null) {
766 public static void setToolChainEnvInfo(ToolChainInfo envInfo
) {
767 toolChainEnvInfo
= envInfo
;
769 public static void setToolChainPlatformInfo(ToolChainInfo platformInfo
) {
770 toolChainPlatformInfo
= platformInfo
;
776 public synchronized static MemoryDatabaseManager
getPCDMemoryDBManager() {
781 // For PCD get tokenSpaceGUid
783 public synchronized static String
getGuidInfoFromCname(String cName
){
784 String cNameGuid
= null;
786 Set set
= spdTable
.keySet();
787 Iterator iter
= set
.iterator();
793 while (iter
.hasNext()){
794 Spd spd
= (Spd
) spdTable
.get(iter
.next());
795 guid
= spd
.getGuidFromCname(cName
);
807 public synchronized static Map
<FpdModuleIdentification
, XmlObject
>
808 getFpdModuleSaXmlObject(String xmlObjectName
) {
809 Set
<FpdModuleIdentification
> fpdModuleSASet
= fpdModuleSA
.keySet();
810 Iterator item
= fpdModuleSASet
.iterator();
813 Map
<FpdModuleIdentification
, XmlObject
> SAPcdBuildDef
= new HashMap
<FpdModuleIdentification
, XmlObject
>();
814 Map
<String
, XmlObject
> SANode
= new HashMap
<String
, XmlObject
>();
815 FpdModuleIdentification moduleId
;
816 while (item
.hasNext()) {
818 moduleId
= (FpdModuleIdentification
) item
.next();
819 SANode
= fpdModuleSA
.get(moduleId
);
821 if (SANode
.get(xmlObjectName
)!= null){
822 SAPcdBuildDef
.put(moduleId
,
823 (XmlObject
) SANode
.get(xmlObjectName
));
826 } catch (Exception e
){
827 EdkLog
.log(EdkLog
.EDK_INFO
, e
.getMessage());
830 return SAPcdBuildDef
;
833 public synchronized static Map
<FpdModuleIdentification
,XmlObject
> getFpdPcdBuildDefinitions() {
834 Map
<FpdModuleIdentification
,XmlObject
> pcdBuildDef
= getFpdModuleSaXmlObject ("PcdBuildDefinition");