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
.io
.IOException
;
21 import java
.util
.HashMap
;
22 import java
.util
.HashSet
;
23 import java
.util
.Iterator
;
24 import java
.util
.List
;
27 import java
.util
.regex
.Matcher
;
28 import java
.util
.regex
.Pattern
;
30 import org
.apache
.xmlbeans
.XmlException
;
31 import org
.apache
.xmlbeans
.XmlObject
;
33 import org
.tianocore
.common
.exception
.EdkException
;
34 import org
.tianocore
.common
.logger
.EdkLog
;
35 import org
.tianocore
.pcd
.entity
.MemoryDatabaseManager
;
36 import org
.tianocore
.DbPathAndFilename
;
37 import org
.tianocore
.FrameworkDatabaseDocument
;
38 import org
.tianocore
.ModuleSurfaceAreaDocument
;
39 import org
.tianocore
.ModuleSurfaceAreaDocument
.ModuleSurfaceArea
;
40 import org
.tianocore
.build
.id
.FpdModuleIdentification
;
41 import org
.tianocore
.build
.id
.ModuleIdentification
;
42 import org
.tianocore
.build
.id
.PackageIdentification
;
43 import org
.tianocore
.build
.id
.PlatformIdentification
;
44 import org
.tianocore
.build
.toolchain
.ToolChainAttribute
;
45 import org
.tianocore
.build
.toolchain
.ToolChainConfig
;
46 import org
.tianocore
.build
.toolchain
.ToolChainElement
;
47 import org
.tianocore
.build
.toolchain
.ToolChainInfo
;
48 import org
.tianocore
.build
.toolchain
.ToolChainKey
;
49 import org
.tianocore
.build
.toolchain
.ToolChainMap
;
52 GlobalData provide initializing, instoring, querying and update global data.
53 It is a bridge to intercommunicate between multiple component, such as AutoGen,
56 <p>Note that all global information are initialized incrementally. All data will
57 parse and record only of necessary during build time. </p>
61 public class GlobalData
{
63 /// Record current WORKSPACE Directory
65 private static String workspaceDir
= "";
68 /// Be used to ensure Global data will be initialized only once.
70 private static boolean globalFlag
= false;
73 /// Framework Database information: package list and platform list
75 private static Set
<PackageIdentification
> packageList
= new HashSet
<PackageIdentification
>();
77 private static Set
<PlatformIdentification
> platformList
= new HashSet
<PlatformIdentification
>();
80 /// Every detail SPD informations: Module list, Library class definition,
81 /// Package header file, GUID/PPI/Protocol definitions
83 private static final Map
<PackageIdentification
, Spd
> spdTable
= new HashMap
<PackageIdentification
, Spd
>();
86 /// Build informations are divided into three parts:
87 /// 1. From MSA 2. From FPD 3. From FPD' ModuleSA
89 private static Map
<ModuleIdentification
, Map
<String
, XmlObject
>> nativeMsa
= new HashMap
<ModuleIdentification
, Map
<String
, XmlObject
>>();
91 private static Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> fpdModuleSA
= new HashMap
<FpdModuleIdentification
, Map
<String
, XmlObject
>>();
93 private static Map
<String
, XmlObject
> fpdBuildOptionsMap
= new HashMap
<String
, XmlObject
>();
95 private static XmlObject fpdBuildOptions
;
97 private static XmlObject fpdDynamicPcds
;
100 /// Parsed modules list
102 private static Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> parsedModules
= new HashMap
<FpdModuleIdentification
, Map
<String
, XmlObject
>>();
105 /// built modules list with ARCH, TARGET, TOOLCHAIN
107 private static Set
<FpdModuleIdentification
> builtModules
= new HashSet
<FpdModuleIdentification
>();
110 /// PCD memory database stored all PCD information which collected from FPD,MSA and SPD.
112 private static final MemoryDatabaseManager pcdDbManager
= new MemoryDatabaseManager();
115 /// build target + tool chain family/tag name + arch + command types + command options
119 /// toolsDef - build tool program information
120 /// fpdBuildOption - all modules's build options for tool tag or tool chain families
121 /// moduleSaBuildOption - build options for a specific module
123 private static ToolChainConfig toolsDef
;
125 private static ToolChainInfo toolChainInfo
;
126 private static ToolChainInfo toolChainEnvInfo
;
127 private static ToolChainInfo toolChainPlatformInfo
;
129 private static ToolChainMap platformToolChainOption
;
130 private static ToolChainMap platformToolChainFamilyOption
;
132 private static Map
<FpdModuleIdentification
, ToolChainMap
> moduleToolChainOption
= new HashMap
<FpdModuleIdentification
, ToolChainMap
>();
133 private static Map
<FpdModuleIdentification
, ToolChainMap
> moduleToolChainFamilyOption
= new HashMap
<FpdModuleIdentification
, ToolChainMap
>();
135 private static Pattern flagPattern
= Pattern
.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");
137 Parse framework database (DB) and all SPD files listed in DB to initialize
138 the environment for next build. This method will only be executed only once
139 in the whole build process.
141 @param workspaceDatabaseFile the file name of framework database
142 @param workspaceDir current workspace directory path
143 @throws BuildException
144 Framework Dababase or SPD or MSA file is not valid
146 public synchronized static void initInfo(String workspaceDatabaseFile
, String workspaceDir
, String toolsDefFilename
) throws EdkException
{
148 // ensure this method will be revoked only once
156 // Backup workspace directory. It will be used by other method
158 GlobalData
.workspaceDir
= workspaceDir
.replaceAll("(\\\\)", "/");
161 // Parse tools definition file
164 // If ToolChain has been set up before, do nothing.
165 // CONF dir + tools definition file name
167 File toolsDefFile
= new File(workspaceDir
+ File
.separatorChar
+ toolsDefFilename
);
168 EdkLog
.log("Init", EdkLog
.EDK_ALWAYS
, "Using tool definition file [" + toolsDefFile
.getPath() + "].");
169 toolsDef
= new ToolChainConfig(toolsDefFile
);
172 // Parse Framework Database
174 File dbFile
= new File(workspaceDir
+ File
.separatorChar
+ workspaceDatabaseFile
);
176 FrameworkDatabaseDocument db
= (FrameworkDatabaseDocument
) XmlObject
.Factory
.parse(dbFile
);
178 // validate FrameworkDatabaseFile
180 if (!db
.validate()) {
181 throw new EdkException("Framework Database file [" + dbFile
.getPath() + "] format is invalid!");
186 if (db
.getFrameworkDatabase().getPackageList() != null ) {
187 List
<DbPathAndFilename
> packages
= db
.getFrameworkDatabase().getPackageList().getFilenameList();
188 Iterator
<DbPathAndFilename
> iter
= packages
.iterator();
189 while (iter
.hasNext()) {
190 String fileName
= iter
.next().getStringValue().trim();
191 Spd spd
= new Spd(new File(workspaceDir
+ File
.separatorChar
+ fileName
));
192 packageList
.add(spd
.getPackageId());
194 // Report warning if existing two packages with same GUID and Version
196 if (spdTable
.containsKey(spd
.getPackageId())) {
200 EdkLog
.log("Init", EdkLog
.EDK_WARNING
, "Warning: Existing two packages with same GUID and Version. They are ... " + spd
.getPackageId().getSpdFile().getPath());
202 spdTable
.put(spd
.getPackageId(), spd
);
209 if (db
.getFrameworkDatabase().getPlatformList() != null) {
210 List
<DbPathAndFilename
> platforms
= db
.getFrameworkDatabase().getPlatformList().getFilenameList();
211 Iterator
<DbPathAndFilename
> iter
= platforms
.iterator();
212 while (iter
.hasNext()) {
213 String fileName
= iter
.next().getStringValue().trim();
214 File fpdFile
= new File(workspaceDir
+ File
.separatorChar
+ fileName
);
215 if ( !fpdFile
.exists() ) {
216 throw new EdkException("Platform file [" + fpdFile
.getPath() + "] not exists. ");
218 XmlObject fpdDoc
= XmlObject
.Factory
.parse(fpdFile
);
220 // Verify FPD file, if is invalid, throw Exception
222 if (!fpdDoc
.validate()) {
223 throw new EdkException("Framework Platform Surface Area file [" + fpdFile
.getPath() + "] format is invalid!");
226 // We can change Map to XmlObject
228 Map
<String
, XmlObject
> fpdDocMap
= new HashMap
<String
, XmlObject
>();
229 fpdDocMap
.put("PlatformSurfaceArea", fpdDoc
);
230 SurfaceAreaQuery saq
= new SurfaceAreaQuery(fpdDocMap
);
231 PlatformIdentification platformId
= saq
.getFpdHeader();
232 platformId
.setFpdFile(fpdFile
);
234 // Report warning if existing two platfrom with same GUID and Version
236 if (platformList
.contains(platformId
)) {
240 EdkLog
.log("Init", EdkLog
.EDK_WARNING
, "Warning: Existing two platforms with same GUID and Version. They are ... " + fpdFile
.getPath());
242 platformList
.add(platformId
);
245 } catch(IOException ex
) {
246 EdkException edkException
= new EdkException("Parse WORKSPACE Database file [" + dbFile
.getPath() + "] Error.\n" + ex
.getMessage());
247 edkException
.setStackTrace(ex
.getStackTrace());
249 } catch(XmlException ex
) {
250 EdkException edkException
= new EdkException("Parse WORKSPACE Database file [" + dbFile
.getPath() + "] Error.\n" + ex
.getMessage());
251 edkException
.setStackTrace(ex
.getStackTrace());
257 Get the current WORKSPACE Directory.
259 @return current workspace directory
261 public synchronized static String
getWorkspacePath() {
267 Get the MSA file name with absolute path
269 public synchronized static File
getMsaFile(ModuleIdentification moduleId
) throws EdkException
{
272 // TBD. Do only when package is null.
274 Iterator iter
= packageList
.iterator();
275 while (iter
.hasNext()) {
276 PackageIdentification packageId
= (PackageIdentification
)iter
.next();
277 Spd spd
= spdTable
.get(packageId
);
278 msaFile
= spd
.getModuleFile(moduleId
);
279 if (msaFile
!= null ) {
283 if (msaFile
== null){
284 throw new EdkException("Can't find Module [" + moduleId
.getName() + "] in any SPD package!");
290 public synchronized static PackageIdentification
getPackageForModule(ModuleIdentification moduleId
) throws EdkException
{
292 // If package already defined in module
294 if (moduleId
.getPackage() != null) {
295 return moduleId
.getPackage();
298 PackageIdentification packageId
= null;
299 Iterator iter
= packageList
.iterator();
300 while (iter
.hasNext()) {
301 packageId
= (PackageIdentification
)iter
.next();
302 moduleId
.setPackage(packageId
);
303 Spd spd
= spdTable
.get(packageId
);
304 File tempMsaFile
= null;
305 if ((tempMsaFile
= spd
.getModuleFile(moduleId
)) != null ) {
306 if (tempMsaFile
.getParent().equalsIgnoreCase(moduleId
.getMsaFile().getParent())) {
312 if (packageId
== null){
313 throw new EdkException("Can't find Module [" + moduleId
.getName() + "] in any SPD package!");
320 Difference between build and parse: ToolChain and Target
322 public synchronized static boolean isModuleBuilt(FpdModuleIdentification moduleId
) {
323 return builtModules
.contains(moduleId
);
326 public synchronized static void registerBuiltModule(FpdModuleIdentification fpdModuleId
) {
327 builtModules
.add(fpdModuleId
);
331 public synchronized static void registerFpdModuleSA(FpdModuleIdentification fpdModuleId
, Map
<String
, XmlObject
> doc
) throws EdkException
{
332 Map
<String
, XmlObject
> result
= new HashMap
<String
, XmlObject
>();
333 Set keySet
= doc
.keySet();
334 Iterator iter
= keySet
.iterator();
335 while (iter
.hasNext()){
336 String key
= (String
)iter
.next();
337 XmlObject item
= cloneXmlObject(doc
.get(key
), true);
338 result
.put(key
, item
);
340 fpdModuleSA
.put(fpdModuleId
, result
);
343 public synchronized static boolean hasFpdModuleSA(FpdModuleIdentification fpdModuleId
) {
344 return fpdModuleSA
.containsKey(fpdModuleId
);
348 Query module surface area information.
350 <p>Note that surface area parsing is incremental. That means the method will
351 only parse the MSA files if necessary. </p>
353 @param fpdModuleId Module ID with arch
354 @return ModuleSA info and MSA info for fpdModuleId
355 @throws BuildException Can't find MSA
357 public synchronized static Map
<String
, XmlObject
> getDoc(FpdModuleIdentification fpdModuleId
) throws EdkException
{
358 if (parsedModules
.containsKey(fpdModuleId
)) {
359 return parsedModules
.get(fpdModuleId
);
361 Map
<String
, XmlObject
> doc
= new HashMap
<String
, XmlObject
>();
362 ModuleIdentification moduleId
= fpdModuleId
.getModule();
364 // First part: get the MSA files info
366 doc
.putAll(getNativeMsa(moduleId
));
369 // Second part: put build options
371 doc
.put("BuildOptions", fpdBuildOptions
);
374 // Third part: get Module info from FPD, such as Library instances, PCDs
376 if (fpdModuleSA
.containsKey(fpdModuleId
)){
378 // merge module info in FPD to final Doc
379 // For Library Module, do nothing here
381 doc
.putAll(fpdModuleSA
.get(fpdModuleId
));
383 parsedModules
.put(fpdModuleId
, doc
);
387 public synchronized static Map
<String
, XmlObject
> getDoc(ModuleIdentification moduleId
, String arch
) throws EdkException
{
388 FpdModuleIdentification fpdModuleId
= new FpdModuleIdentification(moduleId
, arch
);
389 return getDoc(fpdModuleId
);
393 Query the native MSA information with module base name.
395 <p>Note that MSA parsing is incremental. That means the method will
396 only to parse the MSA files when never parsed before. </p>
398 @param moduleName the base name of the module
399 @return the native MSA information
400 @throws BuildException
401 MSA file is not valid
403 public synchronized static Map
<String
, XmlObject
> getNativeMsa(ModuleIdentification moduleId
) throws EdkException
{
404 if (nativeMsa
.containsKey(moduleId
)) {
405 return nativeMsa
.get(moduleId
);
407 File msaFile
= getMsaFile(moduleId
);
408 Map
<String
, XmlObject
> msaMap
= getNativeMsa(msaFile
);
409 nativeMsa
.put(moduleId
, msaMap
);
413 public synchronized static Map
<String
, XmlObject
> getNativeMsa(File msaFile
) throws EdkException
{
414 if (!msaFile
.exists()) {
415 throw new EdkException("Module Surface Area file [" + msaFile
.getPath() + "] can't be found!");
418 ModuleSurfaceAreaDocument doc
= (ModuleSurfaceAreaDocument
)XmlObject
.Factory
.parse(msaFile
);
420 // Validate File if they accord with XML Schema
422 if ( !doc
.validate()){
423 throw new EdkException("Module Surface Area file [" + msaFile
.getPath() + "] format is invalid!");
428 ModuleSurfaceArea msa
= doc
.getModuleSurfaceArea();
429 Map
<String
, XmlObject
> msaMap
= new HashMap
<String
, XmlObject
>();
430 msaMap
.put("MsaHeader", cloneXmlObject(msa
.getMsaHeader(), true));
431 msaMap
.put("ModuleDefinitions", cloneXmlObject(msa
.getModuleDefinitions(), true));
432 msaMap
.put("LibraryClassDefinitions", cloneXmlObject(msa
.getLibraryClassDefinitions(), true));
433 msaMap
.put("SourceFiles", cloneXmlObject(msa
.getSourceFiles(), true));
434 msaMap
.put("PackageDependencies", cloneXmlObject(msa
.getPackageDependencies(), true));
435 msaMap
.put("Protocols", cloneXmlObject(msa
.getProtocols(), true));
436 msaMap
.put("PPIs", cloneXmlObject(msa
.getPPIs(), true));
437 msaMap
.put("Guids", cloneXmlObject(msa
.getGuids(), true));
438 msaMap
.put("Externs", cloneXmlObject(msa
.getExterns(), true));
439 msaMap
.put("PcdCoded", cloneXmlObject(msa
.getPcdCoded(), true));
441 } catch(IOException ex
) {
442 EdkException edkException
= new EdkException("Parsing MSA file [" + msaFile
.getPath() + "] error. \n" + ex
.getMessage());
443 edkException
.setStackTrace(ex
.getStackTrace());
445 } catch(XmlException ex
) {
446 EdkException edkException
= new EdkException("Parsing MSA file [" + msaFile
.getPath() + "] error. \n" + ex
.getMessage());
447 edkException
.setStackTrace(ex
.getStackTrace());
452 public static Map
<String
, XmlObject
> getFpdBuildOptionsMap() {
453 return fpdBuildOptionsMap
;
456 public static void setFpdBuildOptions(XmlObject fpdBuildOptions
) throws EdkException
{
457 GlobalData
.fpdBuildOptions
= cloneXmlObject(fpdBuildOptions
, true);
458 fpdBuildOptionsMap
.put("BuildOptions", GlobalData
.fpdBuildOptions
);
461 public static XmlObject
getFpdDynamicPcds() {
462 return fpdDynamicPcds
;
465 public static void setFpdDynamicPcds(XmlObject fpdDynamicPcds
) {
466 GlobalData
.fpdDynamicPcds
= fpdDynamicPcds
;
469 public static Set
<ModuleIdentification
> getModules(PackageIdentification packageId
){
470 Spd spd
= spdTable
.get(packageId
);
472 Set
<ModuleIdentification
> dummy
= new HashSet
<ModuleIdentification
>();
475 return spd
.getModules();
480 * The header file path is relative to workspace dir
482 public static String
[] getLibraryClassHeaderFiles(
483 PackageIdentification
[] packages
, String name
) throws EdkException
{
484 if (packages
== null) {
485 // throw Exception or not????
486 return new String
[0];
488 String
[] result
= null;
489 for (int i
= 0; i
< packages
.length
; i
++) {
490 Spd spd
= spdTable
.get(packages
[i
]);
492 // If find one package defined the library class
494 if ((result
= spd
.getLibClassIncluder(name
)) != null) {
499 // If can't find library class declaration in every package
501 throw new EdkException("Can not find library class [" + name
502 + "] declaration in any SPD package!");
506 * The header file path is relative to workspace dir
508 public static String
getPackageHeaderFiles(PackageIdentification packages
,
510 if (packages
== null) {
511 return new String("");
513 Spd spd
= spdTable
.get(packages
);
515 // If can't find package header file, skip it
519 if ((temp
= spd
.getPackageIncluder(moduleType
)) != null) {
531 * return two values: {cName, GuidValue}
533 public static String
[] getGuid(List
<PackageIdentification
> packages
, String name
) {
534 if (packages
== null) {
535 // throw Exception or not????
536 return new String
[0];
538 String
[] result
= null;
539 Iterator item
= packages
.iterator();
540 while (item
.hasNext()){
541 Spd spd
= spdTable
.get(item
.next());
543 // If find one package defined the GUID
545 if ((result
= spd
.getGuid(name
)) != null) {
554 * return two values: {cName, GuidValue}
556 public static String
[] getPpiGuid(List
<PackageIdentification
> packages
,
558 if (packages
== null) {
559 return new String
[0];
561 String
[] result
= null;
562 Iterator item
= packages
.iterator();
563 while (item
.hasNext()){
564 Spd spd
= spdTable
.get(item
.next());
566 // If find one package defined the Ppi GUID
568 if ((result
= spd
.getPpi(name
)) != null) {
576 * return two values: {cName, GuidValue}
578 public static String
[] getProtocolGuid(List
<PackageIdentification
> packages
,
580 if (packages
== null) {
581 return new String
[0];
583 String
[] result
= null;
584 Iterator item
= packages
.iterator();
585 while (item
.hasNext()){
586 Spd spd
= spdTable
.get(item
.next());
588 // If find one package defined the protocol GUID
590 if ((result
= spd
.getProtocol(name
))!= null){
598 public synchronized static PlatformIdentification
getPlatformByName(String name
) throws EdkException
{
599 Iterator iter
= platformList
.iterator();
600 while(iter
.hasNext()){
601 PlatformIdentification platformId
= (PlatformIdentification
)iter
.next();
602 if (platformId
.getName().equalsIgnoreCase(name
)) {
606 throw new EdkException("Can't find platform [" + name
+ "] in the current WORKSPACE database!");
609 public synchronized static PlatformIdentification
getPlatform(String filename
) throws EdkException
{
610 File file
= new File(workspaceDir
+ File
.separatorChar
+ filename
);
611 Iterator iter
= platformList
.iterator();
612 while(iter
.hasNext()){
613 PlatformIdentification platformId
= (PlatformIdentification
)iter
.next();
614 if (platformId
.getFpdFile().getPath().equalsIgnoreCase(file
.getPath())) {
618 throw new EdkException("Can't find platform file [" + filename
+ "] in the current WORKSPACE database!");
621 public synchronized static PackageIdentification
refreshPackageIdentification(PackageIdentification packageId
) throws EdkException
{
622 Iterator iter
= packageList
.iterator();
623 while(iter
.hasNext()){
624 PackageIdentification packageItem
= (PackageIdentification
)iter
.next();
625 if (packageItem
.equals(packageId
)) {
626 packageId
.setName(packageItem
.getName());
627 packageId
.setSpdFile(packageItem
.getSpdFile());
631 throw new EdkException("Can't find package GUID value " + packageId
.toGuidString() + " in the current workspace!");
634 public synchronized static ModuleIdentification
refreshModuleIdentification(ModuleIdentification moduleId
) throws EdkException
{
635 PackageIdentification packageId
= getPackageForModule(moduleId
);
636 moduleId
.setPackage(packageId
);
637 Spd spd
= spdTable
.get(packageId
);
639 throw new EdkException("Can't find package GUID value " + packageId
.toGuidString() + " in the current workspace!");
641 Set
<ModuleIdentification
> modules
= spd
.getModules();
642 Iterator
<ModuleIdentification
> iter
= modules
.iterator();
643 while (iter
.hasNext()) {
644 ModuleIdentification item
= iter
.next();
645 if (item
.equals(moduleId
)) {
646 moduleId
.setName(item
.getName());
647 moduleId
.setModuleType(item
.getModuleType());
648 moduleId
.setMsaFile(item
.getMsaFile());
652 throw new EdkException("Can't find module GUID value " + moduleId
.toGuidString() + " in " + packageId
+ " under the current workspace!");
655 public synchronized static Set
<PackageIdentification
> getPackageList(){
660 BUGBUG: It is a walk around method. If do not clone, can't query info with
663 @param object XmlObject
664 @param deep flag for deep clone
665 @return XmlObject after clone
666 @throws BuildException parse original XmlObject error.
668 private static XmlObject
cloneXmlObject(XmlObject object
, boolean deep
) throws EdkException
{
669 if ( object
== null) {
672 XmlObject result
= null;
674 result
= XmlObject
.Factory
.parse(object
.getDomNode()
676 } catch (XmlException ex
) {
677 EdkException edkException
= new EdkException(ex
.getMessage());
678 edkException
.setStackTrace(ex
.getStackTrace());
685 /// Tool Chain Related, try to refine and put some logic process to ToolChainFactory
687 public synchronized static ToolChainInfo
getToolChainInfo() {
688 if (toolChainInfo
== null) {
689 toolChainInfo
= toolsDef
.getConfigInfo().intersection(toolChainEnvInfo
);
690 if (toolChainPlatformInfo
!= null) {
691 toolChainInfo
= toolChainInfo
.intersection(toolChainPlatformInfo
);
693 toolChainInfo
.addCommands(toolsDef
.getConfigInfo().getCommands());
694 toolChainInfo
.normalize();
695 EdkLog
.log("Init", EdkLog
.EDK_ALWAYS
, "Current build tool chain information summary: ");
696 EdkLog
.log("Init", EdkLog
.EDK_ALWAYS
, toolChainInfo
+ "");
698 return toolChainInfo
;
701 public static void setPlatformToolChainFamilyOption(ToolChainMap map
) {
702 platformToolChainFamilyOption
= map
;
705 public static void setPlatformToolChainOption(ToolChainMap map
) {
706 platformToolChainOption
= map
;
709 public static void addModuleToolChainOption(FpdModuleIdentification fpdModuleId
,
710 ToolChainMap toolChainOption
) {
711 moduleToolChainOption
.put(fpdModuleId
, toolChainOption
);
714 public static void addModuleToolChainFamilyOption(FpdModuleIdentification fpdModuleId
,
715 ToolChainMap toolChainOption
) {
716 moduleToolChainFamilyOption
.put(fpdModuleId
, toolChainOption
);
719 public static boolean isCommandSet(String target
, String toolchain
, String arch
) {
720 String
[] commands
= getToolChainInfo().getCommands();
722 for (int i
= 0; i
< commands
.length
; ++i
) {
723 String cmdName
= toolsDef
.getConfig().get(new String
[] {target
, toolchain
, arch
, commands
[i
], ToolChainAttribute
.NAME
.toString()});
724 if (cmdName
!= null && cmdName
.length() != 0) {
732 public synchronized static String
getCommandSetting(String
[] commandDescription
, FpdModuleIdentification fpdModuleId
) throws EdkException
{
733 ToolChainKey toolChainKey
= new ToolChainKey(commandDescription
);
734 ToolChainMap toolChainConfig
= toolsDef
.getConfig();
735 String setting
= null;
738 // Default in tools_def.txt
740 setting
= toolChainConfig
.get(toolChainKey
);
741 if (setting
== null) {
744 if (!commandDescription
[ToolChainElement
.ATTRIBUTE
.value
].equals(ToolChainAttribute
.FLAGS
.toString())) {
749 // tool's option can be in .fpd and/or .msa file
752 ToolChainMap option
= null;
753 ToolChainKey toolChainFamilyKey
= new ToolChainKey(commandDescription
);
755 toolChainFamilyKey
.setKey(ToolChainAttribute
.FAMILY
.toString(), ToolChainElement
.ATTRIBUTE
.value
);
756 String family
= toolChainConfig
.get(toolChainFamilyKey
);
757 toolChainFamilyKey
.setKey(family
, ToolChainElement
.TOOLCHAIN
.value
);
758 toolChainFamilyKey
.setKey(ToolChainAttribute
.FLAGS
.toString(), ToolChainElement
.ATTRIBUTE
.value
);
761 // Platform's tool chain family option
763 optionString
= platformToolChainFamilyOption
.get(toolChainFamilyKey
);
764 if (optionString
!= null) {
765 setting
+= (" " + optionString
);
769 // Platform's tool chain tag option
771 optionString
= platformToolChainOption
.get(toolChainKey
);
772 if (optionString
!= null) {
773 Matcher matcher
= flagPattern
.matcher(optionString
+ " ");
774 while (matcher
.find()) {
775 setting
+= (" " + optionString
.substring(matcher
.start(1), matcher
.end(1)));
780 // Module's tool chain family option
782 option
= moduleToolChainFamilyOption
.get(fpdModuleId
);
783 if (option
!= null && (optionString
= option
.get(toolChainFamilyKey
)) != null) {
784 Matcher matcher
= flagPattern
.matcher(optionString
+ " ");
785 while (matcher
.find()) {
786 setting
+= (" " + optionString
.substring(matcher
.start(1), matcher
.end(1)));
791 // Module's tool chain tag option
793 option
= moduleToolChainOption
.get(fpdModuleId
);
794 if (option
!= null && (optionString
= option
.get(toolChainKey
)) != null) {
795 Matcher matcher
= flagPattern
.matcher(optionString
+ " ");
796 while (matcher
.find()) {
797 setting
+= (" " + optionString
.substring(matcher
.start(1), matcher
.end(1)));
804 public static void setToolChainEnvInfo(ToolChainInfo envInfo
) {
805 toolChainEnvInfo
= envInfo
;
807 public static void setToolChainPlatformInfo(ToolChainInfo platformInfo
) {
808 toolChainPlatformInfo
= platformInfo
;
814 public synchronized static MemoryDatabaseManager
getPCDMemoryDBManager() {
819 // For PCD get tokenSpaceGUid
821 public synchronized static String
getGuidInfoFromCname(String cName
){
822 String cNameGuid
= null;
824 Set set
= spdTable
.keySet();
825 Iterator iter
= set
.iterator();
831 while (iter
.hasNext()){
832 Spd spd
= (Spd
) spdTable
.get(iter
.next());
833 guid
= spd
.getGuidFromCname(cName
);
845 public synchronized static Map
<FpdModuleIdentification
, XmlObject
>
846 getFpdModuleSaXmlObject(String xmlObjectName
) {
847 Set
<FpdModuleIdentification
> fpdModuleSASet
= fpdModuleSA
.keySet();
848 Iterator item
= fpdModuleSASet
.iterator();
851 Map
<FpdModuleIdentification
, XmlObject
> SAPcdBuildDef
= new HashMap
<FpdModuleIdentification
, XmlObject
>();
852 Map
<String
, XmlObject
> SANode
= new HashMap
<String
, XmlObject
>();
853 FpdModuleIdentification moduleId
;
854 while (item
.hasNext()) {
856 moduleId
= (FpdModuleIdentification
) item
.next();
857 SANode
= fpdModuleSA
.get(moduleId
);
859 if (SANode
.get(xmlObjectName
)!= null){
860 SAPcdBuildDef
.put(moduleId
,
861 (XmlObject
) SANode
.get(xmlObjectName
));
864 } catch (Exception e
){
865 EdkLog
.log(EdkLog
.EDK_INFO
, e
.getMessage());
868 return SAPcdBuildDef
;
871 public synchronized static Map
<FpdModuleIdentification
,XmlObject
> getFpdPcdBuildDefinitions() {
872 Map
<FpdModuleIdentification
,XmlObject
> pcdBuildDef
= getFpdModuleSaXmlObject ("PcdBuildDefinition");