X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2Fglobal%2FGlobalData.java;h=74a2d4fe435987ffe6758d044d583e32068b8e44;hb=e485bb4bff9dbd617d73f2b93b840c4e2c54d6db;hp=1e7568757af2ef77e978d26a8e0c2a0193134334;hpb=391dbbb1c00daefe78e7e44499d048943ca866ae;p=mirror_edk2.git
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
index 1e7568757a..74a2d4fe43 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
@@ -1,10 +1,10 @@
/** @file
- GlobalData class.
-
+ GlobalData class.
+
GlobalData provide initializing, instoring, querying and update global data.
It is a bridge to intercommunicate between multiple component, such as AutoGen,
- PCD and so on.
-
+ PCD and so on.
+
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -23,10 +23,13 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.logging.Logger;
import org.apache.tools.ant.BuildException;
import org.apache.xmlbeans.XmlObject;
+
+import org.tianocore.common.exception.EdkException;
+import org.tianocore.common.logger.EdkLog;
+import org.tianocore.pcd.entity.MemoryDatabaseManager;
import org.tianocore.DbPathAndFilename;
import org.tianocore.FrameworkDatabaseDocument;
import org.tianocore.ModuleSurfaceAreaDocument;
@@ -35,44 +38,38 @@ import org.tianocore.build.id.FpdModuleIdentification;
import org.tianocore.build.id.ModuleIdentification;
import org.tianocore.build.id.PackageIdentification;
import org.tianocore.build.id.PlatformIdentification;
-import org.tianocore.pcd.entity.MemoryDatabaseManager;
import org.tianocore.build.toolchain.ToolChainAttribute;
import org.tianocore.build.toolchain.ToolChainConfig;
import org.tianocore.build.toolchain.ToolChainElement;
import org.tianocore.build.toolchain.ToolChainInfo;
import org.tianocore.build.toolchain.ToolChainKey;
import org.tianocore.build.toolchain.ToolChainMap;
-import org.tianocore.exception.EdkException;
-import org.tianocore.logger.EdkLog;
/**
GlobalData provide initializing, instoring, querying and update global data.
It is a bridge to intercommunicate between multiple component, such as AutoGen,
- PCD and so on.
-
-
Note that all global information are initialized incrementally. All data will
+ PCD and so on.
+
+
Note that all global information are initialized incrementally. All data will
parse and record only of necessary during build time.
-
+
@since GenBuild 1.0
**/
public class GlobalData {
-
- public static Logger log = Logger.getAnonymousLogger();
-
///
/// Record current WORKSPACE Directory
///
private static String workspaceDir = "";
-
+
///
/// Be used to ensure Global data will be initialized only once.
///
private static boolean globalFlag = false;
-
+
///
/// Framework Database information: package list and platform list
///
- private static Set packageList = new HashSet();
+ private static Set packageList = new HashSet();
private static Set platformList = new HashSet();
@@ -93,17 +90,17 @@ public class GlobalData {
private static XmlObject fpdBuildOptions;
private static XmlObject fpdDynamicPcds;
-
+
///
/// Parsed modules list
///
private static Map> parsedModules = new HashMap>();
-
+
///
/// built modules list with ARCH, TARGET, TOOLCHAIN
///
private static Set builtModules = new HashSet();
-
+
///
/// PCD memory database stored all PCD information which collected from FPD,MSA and SPD.
///
@@ -117,7 +114,7 @@ public class GlobalData {
/// toolsDef - build tool program information
/// fpdBuildOption - all modules's build options for tool tag or tool chain families
/// moduleSaBuildOption - build options for a specific module
- ///
+ ///
private static ToolChainConfig toolsDef;
private static ToolChainInfo toolChainInfo;
@@ -133,8 +130,8 @@ public class GlobalData {
/**
Parse framework database (DB) and all SPD files listed in DB to initialize
the environment for next build. This method will only be executed only once
- in the whole build process.
-
+ in the whole build process.
+
@param workspaceDatabaseFile the file name of framework database
@param workspaceDir current workspace directory path
@throws BuildException
@@ -149,11 +146,11 @@ public class GlobalData {
}
globalFlag = true;
- //
+ //
// Backup workspace directory. It will be used by other method
//
GlobalData.workspaceDir = workspaceDir.replaceAll("(\\\\)", "/");
-
+
//
// Parse tools definition file
//
@@ -163,8 +160,12 @@ public class GlobalData {
//
File toolsDefFile = new File(workspaceDir + File.separatorChar + toolsDefFilename);
System.out.println("Using tool definiton file [" + toolsDefFile.getPath() + "].");
- toolsDef = new ToolChainConfig(toolsDefFile);
-
+ try {
+ toolsDef = new ToolChainConfig(toolsDefFile);
+ } catch (Exception e) {
+ throw new BuildException(e.getMessage());
+ }
+
//
// Parse Framework Database
//
@@ -174,7 +175,7 @@ public class GlobalData {
//
// validate FrameworkDatabaseFile
//
- if (! db.validate()) {
+ if (!db.validate()) {
throw new BuildException("Framework Database file [" + dbFile.getPath() + "] format is invalid!");
}
//
@@ -200,14 +201,14 @@ public class GlobalData {
while (iter.hasNext()) {
String fileName = iter.next().getStringValue();
File fpdFile = new File(workspaceDir + File.separatorChar + fileName);
- if ( ! fpdFile.exists() ) {
+ if ( !fpdFile.exists() ) {
throw new BuildException("Platform file [" + fpdFile.getPath() + "] not exists. ");
}
XmlObject fpdDoc = XmlObject.Factory.parse(fpdFile);
//
// Verify FPD file, if is invalid, throw Exception
//
- if (! fpdDoc.validate()) {
+ if (!fpdDoc.validate()) {
throw new BuildException("Framework Platform Surface Area file [" + fpdFile.getPath() + "] format is invalid!");
}
//
@@ -228,10 +229,10 @@ public class GlobalData {
throw new BuildException("Parse WORKSPACE Database file [" + dbFile.getPath() + "] Error.\n" + e.getMessage());
}
}
-
+
/**
- Get the current WORKSPACE Directory.
-
+ Get the current WORKSPACE Directory.
+
@return current workspace directory
**/
public synchronized static String getWorkspacePath() {
@@ -245,7 +246,7 @@ public class GlobalData {
public synchronized static File getMsaFile(ModuleIdentification moduleId) throws BuildException {
File msaFile = null;
//
- // TBD. Do only when package is null.
+ // TBD. Do only when package is null.
//
Iterator iter = packageList.iterator();
while (iter.hasNext()) {
@@ -258,8 +259,7 @@ public class GlobalData {
}
if (msaFile == null){
throw new BuildException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");
- }
- else {
+ } else {
return msaFile;
}
}
@@ -271,7 +271,7 @@ public class GlobalData {
if (moduleId.getPackage() != null) {
return moduleId.getPackage();
}
-
+
PackageIdentification packageId = null;
Iterator iter = packageList.iterator();
while (iter.hasNext()) {
@@ -284,24 +284,23 @@ public class GlobalData {
}
if (packageId == null){
throw new BuildException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");
- }
- else {
+ } else {
return packageId;
}
}
-
+
/**
Difference between build and parse: ToolChain and Target
**/
public synchronized static boolean isModuleBuilt(FpdModuleIdentification moduleId) {
return builtModules.contains(moduleId);
}
-
+
public synchronized static void registerBuiltModule(FpdModuleIdentification fpdModuleId) {
builtModules.add(fpdModuleId);
}
-
+
public synchronized static void registerFpdModuleSA(FpdModuleIdentification fpdModuleId, Map doc) {
Map result = new HashMap();
Set keySet = doc.keySet();
@@ -319,16 +318,14 @@ public class GlobalData {
}
/**
- Query overrided module surface area information. If current is Package
- or Platform build, also include the information from FPD file.
-
- Note that surface area parsing is incremental. That means the method will
- only parse the MSA and MBD files if necessary.
+ Query module surface area information.
+
+ Note that surface area parsing is incremental. That means the method will
+ only parse the MSA files if necessary.
- @param moduleName the base name of the module
- @return the overrided module surface area information
- @throws BuildException
- MSA or MBD is not valid
+ @param fpdModuleId Module ID with arch
+ @return ModuleSA info and MSA info for fpdModuleId
+ @throws BuildException Can't find MSA
**/
public synchronized static Map getDoc(FpdModuleIdentification fpdModuleId) throws BuildException {
if (parsedModules.containsKey(fpdModuleId)) {
@@ -340,12 +337,12 @@ public class GlobalData {
// First part: get the MSA files info
//
doc.putAll(getNativeMsa(moduleId));
-
+
//
// Second part: put build options
//
doc.put("BuildOptions", fpdBuildOptions);
-
+
//
// Third part: get Module info from FPD, such as Library instances, PCDs
//
@@ -365,11 +362,11 @@ public class GlobalData {
return getDoc(fpdModuleId);
}
/**
- Query the native MSA information with module base name.
-
- Note that MSA parsing is incremental. That means the method will
+ Query the native MSA information with module base name.
+
+
Note that MSA parsing is incremental. That means the method will
only to parse the MSA files when never parsed before.
-
+
@param moduleName the base name of the module
@return the native MSA information
@throws BuildException
@@ -384,9 +381,9 @@ public class GlobalData {
nativeMsa.put(moduleId, msaMap);
return msaMap;
}
-
+
public synchronized static Map getNativeMsa(File msaFile) throws BuildException {
- if (! msaFile.exists()) {
+ if (!msaFile.exists()) {
throw new BuildException("Module Surface Area file [" + msaFile.getPath() + "] can't be found!");
}
try {
@@ -394,7 +391,7 @@ public class GlobalData {
//
// Validate File if they accord with XML Schema
//
- if ( ! doc.validate()){
+ if ( !doc.validate()){
throw new BuildException("Module Surface Area file [" + msaFile.getPath() + "] format is invalid!");
}
//
@@ -415,16 +412,16 @@ public class GlobalData {
return msaMap;
}
catch (Exception ex){
- throw new BuildException(ex.getMessage());
+ throw new BuildException("Parsing MSA file [" + msaFile.getPath() + "] error. \n" + ex.getMessage() );
}
}
-
+
public static Map getFpdBuildOptions() {
Map map = new HashMap();
map.put("BuildOptions", fpdBuildOptions);
return map;
}
-
+
public static void setFpdBuildOptions(XmlObject fpdBuildOptions) {
GlobalData.fpdBuildOptions = cloneXmlObject(fpdBuildOptions, true);
}
@@ -437,16 +434,12 @@ public class GlobalData {
GlobalData.fpdDynamicPcds = fpdDynamicPcds;
}
- //////////////////////////////////////////////
- //////////////////////////////////////////////
-
public static Set getModules(PackageIdentification packageId){
Spd spd = spdTable.get(packageId);
if (spd == null ) {
Set dummy = new HashSet();
return dummy;
- }
- else {
+ } else {
return spd.getModules();
}
}
@@ -547,7 +540,6 @@ public class GlobalData {
}
}
return null;
-
}
/**
@@ -572,7 +564,7 @@ public class GlobalData {
return null;
}
-
+
public synchronized static PlatformIdentification getPlatformByName(String name) throws BuildException {
Iterator iter = platformList.iterator();
while(iter.hasNext()){
@@ -583,7 +575,7 @@ public class GlobalData {
}
throw new BuildException("Can't find platform [" + name + "] in the current WORKSPACE database!");
}
-
+
public synchronized static PlatformIdentification getPlatform(String filename) throws BuildException {
File file = new File(workspaceDir + File.separatorChar + filename);
Iterator iter = platformList.iterator();
@@ -595,7 +587,7 @@ public class GlobalData {
}
throw new BuildException("Can't find platform file [" + filename + "] in the current WORKSPACE database!");
}
-
+
public synchronized static PackageIdentification refreshPackageIdentification(PackageIdentification packageId) throws BuildException {
Iterator iter = packageList.iterator();
while(iter.hasNext()){
@@ -606,18 +598,15 @@ public class GlobalData {
return packageId;
}
}
- throw new BuildException("Can't find package GUID value " + packageId.getGuid() + " in the current workspace!");
+ throw new BuildException("Can't find package GUID value " + packageId.toGuidString() + " in the current workspace!");
}
-
+
public synchronized static ModuleIdentification refreshModuleIdentification(ModuleIdentification moduleId) throws BuildException {
-// System.out.println("1");
-// System.out.println("##" + moduleId.getGuid());
PackageIdentification packageId = getPackageForModule(moduleId);
-// System.out.println("" + packageId.getGuid());
moduleId.setPackage(packageId);
Spd spd = spdTable.get(packageId);
if (spd == null) {
- throw new BuildException("Can't find package GUID value " + packageId.getGuid() + " in the current workspace!");
+ throw new BuildException("Can't find package GUID value " + packageId.toGuidString() + " in the current workspace!");
}
Set modules = spd.getModules();
Iterator iter = modules.iterator();
@@ -630,13 +619,22 @@ public class GlobalData {
return moduleId;
}
}
- throw new BuildException("Can't find module GUID value " + moduleId.getGuid() + " in package, " + packageId + ", in the current workspace!");
+ throw new BuildException("Can't find module GUID value " + moduleId.toGuidString() + " in " + packageId + " under the current workspace!");
}
-
+
public synchronized static Set getPackageList(){
return packageList;
}
- ///// remove!!
+
+ /**
+ BUGBUG: It is a walk around method. If do not clone, can't query info with
+ XPath correctly.
+
+ @param object XmlObject
+ @param deep flag for deep clone
+ @return XmlObject after clone
+ @throws BuildException parse original XmlObject error.
+ **/
private static XmlObject cloneXmlObject(XmlObject object, boolean deep) throws BuildException {
if ( object == null) {
return null;
@@ -651,10 +649,10 @@ public class GlobalData {
return result;
}
- ////// Tool Chain Related, try to refine and put some logic process to ToolChainFactory
-
+ ///
+ /// Tool Chain Related, try to refine and put some logic process to ToolChainFactory
+ ///
public static ToolChainInfo getToolChainInfo() {
-// GlobalData.log.info(toolsDef.getConfigInfo() + "" + toolChainEnvInfo + toolChainPlatformInfo);
if (toolChainInfo == null) {
toolChainInfo = toolsDef.getConfigInfo().intersection(toolChainEnvInfo);
if (toolChainPlatformInfo != null) {
@@ -662,13 +660,12 @@ public class GlobalData {
}
toolChainInfo.addCommands(toolsDef.getConfigInfo().getCommands());
toolChainInfo.normalize();
- GlobalData.log.info(toolChainInfo + "");
+ System.out.println("Current build tool chain information summary: ");
+ System.out.println(toolChainInfo + "");
}
return toolChainInfo;
}
-
-
public static void setPlatformToolChainFamilyOption(ToolChainMap map) {
platformToolChainFamilyOption = map;
}
@@ -702,7 +699,7 @@ public class GlobalData {
public static String getCommandSetting(String[] commandDescription, FpdModuleIdentification fpdModuleId) throws EdkException {
ToolChainKey toolChainKey = new ToolChainKey(commandDescription);
- ToolChainMap toolChainConfig = toolsDef.getConfig();
+ ToolChainMap toolChainConfig = toolsDef.getConfig();
String setting = null;
if (!commandDescription[ToolChainElement.ATTRIBUTE.value].equals(ToolChainAttribute.FLAGS.toString())) {
@@ -731,7 +728,7 @@ public class GlobalData {
toolChainFamilyKey.setKey(ToolChainAttribute.FLAGS.toString(), ToolChainElement.ATTRIBUTE.value);
option = moduleToolChainFamilyOption.get(fpdModuleId);
- if (option != null) {
+ if (option != null) {
setting = option.get(toolChainFamilyKey);
}
}
@@ -761,7 +758,7 @@ public class GlobalData {
return setting;
}
-
+
public static void setToolChainEnvInfo(ToolChainInfo envInfo) {
toolChainEnvInfo = envInfo;
}
@@ -803,17 +800,17 @@ public class GlobalData {
//
// For PCD
//
- public synchronized static Map
+ public synchronized static Map
getFpdModuleSaXmlObject(String xmlObjectName) {
Set fpdModuleSASet = fpdModuleSA.keySet();
Iterator item = fpdModuleSASet.iterator();
-
+
Map SAPcdBuildDef = new HashMap();
Map SANode = new HashMap();
FpdModuleIdentification moduleId;
while (item.hasNext()) {
-
+
moduleId = (FpdModuleIdentification) item.next();
SANode = fpdModuleSA.get(moduleId);
try{