GlobalData provide initializing, instoring, querying and update global data.\r
It is a bridge to intercommunicate between multiple component, such as AutoGen,\r
GlobalData provide initializing, instoring, querying and update global data.\r
It is a bridge to intercommunicate between multiple component, such as AutoGen,\r
Copyright (c) 2006, Intel Corporation\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
Copyright (c) 2006, Intel Corporation\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
import org.tianocore.DbPathAndFilename;\r
import org.tianocore.FrameworkDatabaseDocument;\r
import org.tianocore.ModuleSurfaceAreaDocument;\r
import org.tianocore.DbPathAndFilename;\r
import org.tianocore.FrameworkDatabaseDocument;\r
import org.tianocore.ModuleSurfaceAreaDocument;\r
import org.tianocore.build.id.ModuleIdentification;\r
import org.tianocore.build.id.PackageIdentification;\r
import org.tianocore.build.id.PlatformIdentification;\r
import org.tianocore.build.id.ModuleIdentification;\r
import org.tianocore.build.id.PackageIdentification;\r
import org.tianocore.build.id.PlatformIdentification;\r
import org.tianocore.build.toolchain.ToolChainAttribute;\r
import org.tianocore.build.toolchain.ToolChainConfig;\r
import org.tianocore.build.toolchain.ToolChainElement;\r
import org.tianocore.build.toolchain.ToolChainInfo;\r
import org.tianocore.build.toolchain.ToolChainKey;\r
import org.tianocore.build.toolchain.ToolChainMap;\r
import org.tianocore.build.toolchain.ToolChainAttribute;\r
import org.tianocore.build.toolchain.ToolChainConfig;\r
import org.tianocore.build.toolchain.ToolChainElement;\r
import org.tianocore.build.toolchain.ToolChainInfo;\r
import org.tianocore.build.toolchain.ToolChainKey;\r
import org.tianocore.build.toolchain.ToolChainMap;\r
\r
/**\r
GlobalData provide initializing, instoring, querying and update global data.\r
It is a bridge to intercommunicate between multiple component, such as AutoGen,\r
\r
/**\r
GlobalData provide initializing, instoring, querying and update global data.\r
It is a bridge to intercommunicate between multiple component, such as AutoGen,\r
///\r
/// Be used to ensure Global data will be initialized only once.\r
///\r
private static boolean globalFlag = false;\r
///\r
/// Be used to ensure Global data will be initialized only once.\r
///\r
private static boolean globalFlag = false;\r
\r
private static Map<FpdModuleIdentification, Map<String, XmlObject>> fpdModuleSA= new HashMap<FpdModuleIdentification, Map<String, XmlObject>>();\r
\r
\r
private static Map<FpdModuleIdentification, Map<String, XmlObject>> fpdModuleSA= new HashMap<FpdModuleIdentification, Map<String, XmlObject>>();\r
\r
///\r
/// Parsed modules list\r
///\r
private static Map<FpdModuleIdentification, Map<String, XmlObject>> parsedModules = new HashMap<FpdModuleIdentification, Map<String, XmlObject>>();\r
///\r
/// Parsed modules list\r
///\r
private static Map<FpdModuleIdentification, Map<String, XmlObject>> parsedModules = new HashMap<FpdModuleIdentification, Map<String, XmlObject>>();\r
///\r
/// built modules list with ARCH, TARGET, TOOLCHAIN\r
///\r
private static Set<FpdModuleIdentification> builtModules = new HashSet<FpdModuleIdentification>();\r
///\r
/// built modules list with ARCH, TARGET, TOOLCHAIN\r
///\r
private static Set<FpdModuleIdentification> builtModules = new HashSet<FpdModuleIdentification>();\r
/// toolsDef - build tool program information\r
/// fpdBuildOption - all modules's build options for tool tag or tool chain families\r
/// moduleSaBuildOption - build options for a specific module\r
/// toolsDef - build tool program information\r
/// fpdBuildOption - all modules's build options for tool tag or tool chain families\r
/// moduleSaBuildOption - build options for a specific module\r
/**\r
Parse framework database (DB) and all SPD files listed in DB to initialize\r
the environment for next build. This method will only be executed only once\r
/**\r
Parse framework database (DB) and all SPD files listed in DB to initialize\r
the environment for next build. This method will only be executed only once\r
@param workspaceDatabaseFile the file name of framework database\r
@param workspaceDir current workspace directory path\r
@throws BuildException\r
@param workspaceDatabaseFile the file name of framework database\r
@param workspaceDir current workspace directory path\r
@throws BuildException\r
// Backup workspace directory. It will be used by other method\r
//\r
GlobalData.workspaceDir = workspaceDir.replaceAll("(\\\\)", "/");\r
// Backup workspace directory. It will be used by other method\r
//\r
GlobalData.workspaceDir = workspaceDir.replaceAll("(\\\\)", "/");\r
// CONF dir + tools definition file name\r
//\r
File toolsDefFile = new File(workspaceDir + File.separatorChar + toolsDefFilename);\r
// CONF dir + tools definition file name\r
//\r
File toolsDefFile = new File(workspaceDir + File.separatorChar + toolsDefFilename);\r
- System.out.println("Using tool definiton file [" + toolsDefFile.getPath() + "].");\r
- toolsDef = new ToolChainConfig(toolsDefFile);\r
- \r
+ EdkLog.log("Init", "Using tool definiton file [" + toolsDefFile.getPath() + "].");\r
+ try {\r
+ toolsDef = new ToolChainConfig(toolsDefFile);\r
+ } catch (Exception e) {\r
+ throw new BuildException(e.getMessage());\r
+ }\r
+\r
List<DbPathAndFilename> packages = db.getFrameworkDatabase().getPackageList().getFilenameList();\r
Iterator<DbPathAndFilename> iter = packages.iterator();\r
while (iter.hasNext()) {\r
List<DbPathAndFilename> packages = db.getFrameworkDatabase().getPackageList().getFilenameList();\r
Iterator<DbPathAndFilename> iter = packages.iterator();\r
while (iter.hasNext()) {\r
Spd spd = new Spd(new File(workspaceDir + File.separatorChar + fileName));\r
packageList.add(spd.getPackageId());\r
spdTable.put(spd.getPackageId(), spd);\r
Spd spd = new Spd(new File(workspaceDir + File.separatorChar + fileName));\r
packageList.add(spd.getPackageId());\r
spdTable.put(spd.getPackageId(), spd);\r
List<DbPathAndFilename> platforms = db.getFrameworkDatabase().getPlatformList().getFilenameList();\r
Iterator<DbPathAndFilename> iter = platforms.iterator();\r
while (iter.hasNext()) {\r
List<DbPathAndFilename> platforms = db.getFrameworkDatabase().getPlatformList().getFilenameList();\r
Iterator<DbPathAndFilename> iter = platforms.iterator();\r
while (iter.hasNext()) {\r
throw new BuildException("Platform file [" + fpdFile.getPath() + "] not exists. ");\r
}\r
XmlObject fpdDoc = XmlObject.Factory.parse(fpdFile);\r
//\r
// Verify FPD file, if is invalid, throw Exception\r
//\r
throw new BuildException("Platform file [" + fpdFile.getPath() + "] not exists. ");\r
}\r
XmlObject fpdDoc = XmlObject.Factory.parse(fpdFile);\r
//\r
// Verify FPD file, if is invalid, throw Exception\r
//\r
//\r
Map<String, XmlObject> fpdDocMap = new HashMap<String, XmlObject>();\r
fpdDocMap.put("PlatformSurfaceArea", fpdDoc);\r
//\r
Map<String, XmlObject> fpdDocMap = new HashMap<String, XmlObject>();\r
fpdDocMap.put("PlatformSurfaceArea", fpdDoc);\r
- SurfaceAreaQuery.setDoc(fpdDocMap);\r
- PlatformIdentification platformId = SurfaceAreaQuery.getFpdHeader();\r
+ SurfaceAreaQuery saq = new SurfaceAreaQuery(fpdDocMap);\r
+ PlatformIdentification platformId = saq.getFpdHeader();\r
PackageIdentification packageId = null;\r
Iterator iter = packageList.iterator();\r
while (iter.hasNext()) {\r
PackageIdentification packageId = null;\r
Iterator iter = packageList.iterator();\r
while (iter.hasNext()) {\r
}\r
if (packageId == null){\r
throw new BuildException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");\r
}\r
if (packageId == null){\r
throw new BuildException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");\r
/**\r
Difference between build and parse: ToolChain and Target\r
**/\r
public synchronized static boolean isModuleBuilt(FpdModuleIdentification moduleId) {\r
return builtModules.contains(moduleId);\r
}\r
/**\r
Difference between build and parse: ToolChain and Target\r
**/\r
public synchronized static boolean isModuleBuilt(FpdModuleIdentification moduleId) {\r
return builtModules.contains(moduleId);\r
}\r
public synchronized static void registerBuiltModule(FpdModuleIdentification fpdModuleId) {\r
builtModules.add(fpdModuleId);\r
}\r
\r
public synchronized static void registerBuiltModule(FpdModuleIdentification fpdModuleId) {\r
builtModules.add(fpdModuleId);\r
}\r
\r
public synchronized static void registerFpdModuleSA(FpdModuleIdentification fpdModuleId, Map<String, XmlObject> doc) {\r
Map<String, XmlObject> result = new HashMap<String, XmlObject>();\r
Set keySet = doc.keySet();\r
public synchronized static void registerFpdModuleSA(FpdModuleIdentification fpdModuleId, Map<String, XmlObject> doc) {\r
Map<String, XmlObject> result = new HashMap<String, XmlObject>();\r
Set keySet = doc.keySet();\r
- Query overrided module surface area information. If current is Package\r
- or Platform build, also include the information from FPD file. \r
- \r
- <p>Note that surface area parsing is incremental. That means the method will \r
- only parse the MSA and MBD files if necessary. </p>\r
+ Query module surface area information.\r
+\r
+ <p>Note that surface area parsing is incremental. That means the method will\r
+ only parse the MSA files if necessary. </p>\r
- @param moduleName the base name of the module\r
- @return the overrided module surface area information\r
- @throws BuildException\r
- MSA or MBD is not valid\r
+ @param fpdModuleId Module ID with arch\r
+ @return ModuleSA info and MSA info for fpdModuleId\r
+ @throws BuildException Can't find MSA\r
**/\r
public synchronized static Map<String, XmlObject> getDoc(FpdModuleIdentification fpdModuleId) throws BuildException {\r
if (parsedModules.containsKey(fpdModuleId)) {\r
**/\r
public synchronized static Map<String, XmlObject> getDoc(FpdModuleIdentification fpdModuleId) throws BuildException {\r
if (parsedModules.containsKey(fpdModuleId)) {\r
//\r
// Second part: put build options\r
//\r
doc.put("BuildOptions", fpdBuildOptions);\r
//\r
// Second part: put build options\r
//\r
doc.put("BuildOptions", fpdBuildOptions);\r
- Query the native MSA information with module base name. \r
- \r
- <p>Note that MSA parsing is incremental. That means the method will \r
+ Query the native MSA information with module base name.\r
+\r
+ <p>Note that MSA parsing is incremental. That means the method will\r
- \r
- public static Map<String, XmlObject> getFpdBuildOptions() {\r
- Map<String, XmlObject> map = new HashMap<String, XmlObject>();\r
- map.put("BuildOptions", fpdBuildOptions);\r
- return map;\r
+\r
+ public static Map<String, XmlObject> getFpdBuildOptionsMap() {\r
+ return fpdBuildOptionsMap;\r
public static void setFpdBuildOptions(XmlObject fpdBuildOptions) {\r
GlobalData.fpdBuildOptions = cloneXmlObject(fpdBuildOptions, true);\r
public static void setFpdBuildOptions(XmlObject fpdBuildOptions) {\r
GlobalData.fpdBuildOptions = cloneXmlObject(fpdBuildOptions, true);\r
public static Set<ModuleIdentification> getModules(PackageIdentification packageId){\r
Spd spd = spdTable.get(packageId);\r
if (spd == null ) {\r
Set<ModuleIdentification> dummy = new HashSet<ModuleIdentification>();\r
return dummy;\r
public static Set<ModuleIdentification> getModules(PackageIdentification packageId){\r
Spd spd = spdTable.get(packageId);\r
if (spd == null ) {\r
Set<ModuleIdentification> dummy = new HashSet<ModuleIdentification>();\r
return dummy;\r
public synchronized static PlatformIdentification getPlatformByName(String name) throws BuildException {\r
Iterator iter = platformList.iterator();\r
while(iter.hasNext()){\r
public synchronized static PlatformIdentification getPlatformByName(String name) throws BuildException {\r
Iterator iter = platformList.iterator();\r
while(iter.hasNext()){\r
public synchronized static PlatformIdentification getPlatform(String filename) throws BuildException {\r
File file = new File(workspaceDir + File.separatorChar + filename);\r
Iterator iter = platformList.iterator();\r
public synchronized static PlatformIdentification getPlatform(String filename) throws BuildException {\r
File file = new File(workspaceDir + File.separatorChar + filename);\r
Iterator iter = platformList.iterator();\r
public synchronized static PackageIdentification refreshPackageIdentification(PackageIdentification packageId) throws BuildException {\r
Iterator iter = packageList.iterator();\r
while(iter.hasNext()){\r
public synchronized static PackageIdentification refreshPackageIdentification(PackageIdentification packageId) throws BuildException {\r
Iterator iter = packageList.iterator();\r
while(iter.hasNext()){\r
}\r
Set<ModuleIdentification> modules = spd.getModules();\r
Iterator<ModuleIdentification> iter = modules.iterator();\r
}\r
Set<ModuleIdentification> modules = spd.getModules();\r
Iterator<ModuleIdentification> iter = modules.iterator();\r
+\r
+ /**\r
+ BUGBUG: It is a walk around method. If do not clone, can't query info with\r
+ XPath correctly. \r
+ \r
+ @param object XmlObject\r
+ @param deep flag for deep clone\r
+ @return XmlObject after clone\r
+ @throws BuildException parse original XmlObject error. \r
+ **/\r
if (toolChainInfo == null) {\r
toolChainInfo = toolsDef.getConfigInfo().intersection(toolChainEnvInfo);\r
if (toolChainPlatformInfo != null) {\r
if (toolChainInfo == null) {\r
toolChainInfo = toolsDef.getConfigInfo().intersection(toolChainEnvInfo);\r
if (toolChainPlatformInfo != null) {\r
public static void setPlatformToolChainFamilyOption(ToolChainMap map) {\r
platformToolChainFamilyOption = map;\r
}\r
public static void setPlatformToolChainFamilyOption(ToolChainMap map) {\r
platformToolChainFamilyOption = map;\r
}\r
\r
public static String getCommandSetting(String[] commandDescription, FpdModuleIdentification fpdModuleId) throws EdkException {\r
ToolChainKey toolChainKey = new ToolChainKey(commandDescription);\r
\r
public static String getCommandSetting(String[] commandDescription, FpdModuleIdentification fpdModuleId) throws EdkException {\r
ToolChainKey toolChainKey = new ToolChainKey(commandDescription);\r
toolChainFamilyKey.setKey(ToolChainAttribute.FLAGS.toString(), ToolChainElement.ATTRIBUTE.value);\r
\r
option = moduleToolChainFamilyOption.get(fpdModuleId);\r
toolChainFamilyKey.setKey(ToolChainAttribute.FLAGS.toString(), ToolChainElement.ATTRIBUTE.value);\r
\r
option = moduleToolChainFamilyOption.get(fpdModuleId);\r
getFpdModuleSaXmlObject(String xmlObjectName) {\r
Set<FpdModuleIdentification> fpdModuleSASet = fpdModuleSA.keySet();\r
Iterator item = fpdModuleSASet.iterator();\r
getFpdModuleSaXmlObject(String xmlObjectName) {\r
Set<FpdModuleIdentification> fpdModuleSASet = fpdModuleSA.keySet();\r
Iterator item = fpdModuleSASet.iterator();\r
\r
Map<FpdModuleIdentification, XmlObject> SAPcdBuildDef = new HashMap<FpdModuleIdentification, XmlObject>();\r
Map<String, XmlObject> SANode = new HashMap<String, XmlObject>();\r
FpdModuleIdentification moduleId;\r
while (item.hasNext()) {\r
\r
Map<FpdModuleIdentification, XmlObject> SAPcdBuildDef = new HashMap<FpdModuleIdentification, XmlObject>();\r
Map<String, XmlObject> SANode = new HashMap<String, XmlObject>();\r
FpdModuleIdentification moduleId;\r
while (item.hasNext()) {\r