In preprocess for getting platform PCD information, if meet error, put error into stack but not stop immediately, all errors will be summaried after preprocess working.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1194 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2 2006-08-06 07:26:05 +00:00
parent d7506e116a
commit e55d8a3c6b
4 changed files with 199 additions and 90 deletions

View File

@ -28,18 +28,19 @@ import java.util.Map;
import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlObject;
import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions; import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions;
import org.tianocore.PcdBuildDefinitionDocument;
import org.tianocore.PlatformSurfaceAreaDocument; import org.tianocore.PlatformSurfaceAreaDocument;
import org.tianocore.build.exception.PlatformPcdPreprocessBuildException;
import org.tianocore.build.fpd.FpdParserTask; import org.tianocore.build.fpd.FpdParserTask;
import org.tianocore.build.global.GlobalData; import org.tianocore.build.global.GlobalData;
import org.tianocore.build.id.FpdModuleIdentification; import org.tianocore.build.id.FpdModuleIdentification;
import org.tianocore.pcd.action.ActionMessage; import org.tianocore.pcd.action.ActionMessage;
import org.tianocore.pcd.entity.ModulePcdInfoFromFpd; import org.tianocore.pcd.action.PlatformPcdPreprocessAction;
import org.tianocore.pcd.entity.MemoryDatabaseManager; import org.tianocore.pcd.entity.MemoryDatabaseManager;
import org.tianocore.pcd.entity.ModulePcdInfoFromFpd;
import org.tianocore.pcd.entity.Token; import org.tianocore.pcd.entity.Token;
import org.tianocore.pcd.entity.UsageIdentification; import org.tianocore.pcd.entity.UsageIdentification;
import org.tianocore.pcd.exception.EntityException; import org.tianocore.pcd.exception.EntityException;
import org.tianocore.pcd.action.PlatformPcdPreprocessAction;
import org.tianocore.build.exception.PlatformPcdPreprocessBuildException;
import org.tianocore.pcd.exception.PlatformPcdPreprocessException; import org.tianocore.pcd.exception.PlatformPcdPreprocessException;
/** /**
@ -120,7 +121,9 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
**/ **/
public void execute() throws PlatformPcdPreprocessBuildException { public void execute() throws PlatformPcdPreprocessBuildException {
String errorMessageHeader = "Fail to initialize Pcd memory database for building. Because:"; String errorMessageHeader = "Fail to initialize Pcd memory database for building. Because:";
String errorsForPreprocess = null;
// //
// Get memoryDatabaseManager instance from GlobalData. // Get memoryDatabaseManager instance from GlobalData.
// The memoryDatabaseManager should be initialized as static variable // The memoryDatabaseManager should be initialized as static variable
@ -138,6 +141,10 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
} catch (PlatformPcdPreprocessException exp) { } catch (PlatformPcdPreprocessException exp) {
throw new PlatformPcdPreprocessBuildException(errorMessageHeader + exp.getMessage()); throw new PlatformPcdPreprocessBuildException(errorMessageHeader + exp.getMessage());
} }
errorsForPreprocess = this.getErrorString();
if (errorsForPreprocess != null) {
throw new PlatformPcdPreprocessBuildException(errorMessageHeader + "\r\n" + errorsForPreprocess);
}
// //
// Generate for PEI, DXE PCD DATABASE's definition and initialization. // Generate for PEI, DXE PCD DATABASE's definition and initialization.
@ -228,7 +235,10 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
id.getArch(), id.getArch(),
id.getModule().getVersion(), id.getModule().getVersion(),
id.getModule().getModuleType()); id.getModule().getModuleType());
allModules.add(new ModulePcdInfoFromFpd(usageId, pcdBuildDefinitions.get(id))); allModules.add(
new ModulePcdInfoFromFpd(
usageId,
((PcdBuildDefinitionDocument)pcdBuildDefinitions.get(id)).getPcdBuildDefinition()));
} }
return allModules; return allModules;
} }
@ -542,7 +552,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
return exceptionString; return exceptionString;
} }
} else { } else {
exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+ exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n"+
"1) UNICODE string: like L\"xxxx\";\r\n"+ "1) UNICODE string: like L\"xxxx\";\r\n"+
"2) ANSIC string: like \"xxx\";\r\n"+ "2) ANSIC string: like \"xxx\";\r\n"+
"3) Byte array: like {0x2, 0x45, 0x23}\r\n"+ "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
@ -602,19 +612,18 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
"PCD entry %s in module %s!", "PCD entry %s in module %s!",
token.cName, token.cName,
moduleName); moduleName);
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
return null;
} }
dynamicPcdBuildDataArray = dynamicPcdBuildDefinitions.getPcdBuildDataList(); dynamicPcdBuildDataArray = dynamicPcdBuildDefinitions.getPcdBuildDataList();
for (index = 0; index < dynamicPcdBuildDataArray.size(); index ++) { for (index = 0; index < dynamicPcdBuildDataArray.size(); index ++) {
try { tokenSpaceStrRet = this.getGuidInfoFromSpd(dynamicPcdBuildDataArray.get(index).getTokenSpaceGuidCName());
tokenSpaceStrRet = GlobalData.getGuidInfoFromCname(dynamicPcdBuildDataArray.get(index).getTokenSpaceGuidCName());
} catch (Exception e) {
throw new PlatformPcdPreprocessException ("Fail to get token space guid for token " + dynamicPcdBuildDataArray.get(index).getCName());
}
if (tokenSpaceStrRet == null) { if (tokenSpaceStrRet == null) {
throw new PlatformPcdPreprocessException ("Fail to get token space guid for token " + dynamicPcdBuildDataArray.get(index).getCName()); exceptionString = "Fail to get token space guid for token " + dynamicPcdBuildDataArray.get(index).getCName();
putError(exceptionString);
continue;
} }
dynamicPrimaryKey = Token.getPrimaryKeyString(dynamicPcdBuildDataArray.get(index).getCName(), dynamicPrimaryKey = Token.getPrimaryKeyString(dynamicPcdBuildDataArray.get(index).getCName(),
@ -655,6 +664,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
dynamicPcdBuildDefinitions = fpdDocInstance.getPlatformSurfaceArea().getDynamicPcdBuildDefinitions(); dynamicPcdBuildDefinitions = fpdDocInstance.getPlatformSurfaceArea().getDynamicPcdBuildDefinitions();
if (dynamicPcdBuildDefinitions == null) { if (dynamicPcdBuildDefinitions == null) {
putError("There is no <DynamicPcdBuildDefinitions> in FPD file!");
return null; return null;
} }

View File

@ -42,6 +42,24 @@ public abstract class PlatformPcdPreprocessAction {
/// ///
private MemoryDatabaseManager pcdDbManager; private MemoryDatabaseManager pcdDbManager;
///
/// Errors string when perform preprocess
///
private String errorString;
///
/// the count of errors when perform preprocess
///
private int errorCount;
/**
Default contructor function
**/
public PlatformPcdPreprocessAction() {
pcdDbManager = null;
errorString = null;
}
/** /**
Set parameter pcdDbManager Set parameter pcdDbManager
@ -130,6 +148,25 @@ public abstract class PlatformPcdPreprocessAction {
getAllDynamicPcdInfoFromFpd() getAllDynamicPcdInfoFromFpd()
throws PlatformPcdPreprocessException; throws PlatformPcdPreprocessException;
/**
Return the error string after preprocess
@return String error string
**/
public String getErrorString() {
return errorString;
}
public void putError(String error) {
if (errorString == null) {
errorString = "### ERROR[" + errorCount + "] ###\r\n" + error + "\r\n\r\n";
} else {
errorString += "### ERROR[" + errorCount + "] ###\r\n" + error + "\r\n\r\n";
}
errorCount++;
}
/** /**
Collect all PCD information from FPD file into PCD memory database. Collect all PCD information from FPD file into PCD memory database.
@ -193,9 +230,13 @@ public abstract class PlatformPcdPreprocessAction {
tokenSpaceStrRet = getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName()); tokenSpaceStrRet = getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName());
if (tokenSpaceStrRet == null) { if (tokenSpaceStrRet == null) {
throw new PlatformPcdPreprocessException( putError("Fail to get Token space guid for token" + pcdBuildData.getCName() +
"Fail to get Token space guid for token" + pcdBuildData.getCName() + " from all SPD files. You must have an <GuidDeclaration> for this token space Guid");
" from all SPD files. You must have an <GuidDeclaration> for this token space Guid"); //
// Do not break preprocess, continues to analysis.
// All errors will be summary to be shown.
//
continue;
} }
primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(), tokenSpaceStrRet[1]); primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(), tokenSpaceStrRet[1]);
@ -215,7 +256,12 @@ public abstract class PlatformPcdPreprocessAction {
"datum type of this PCD entry is not BOOLEAN!", "datum type of this PCD entry is not BOOLEAN!",
pcdBuildData.getCName(), pcdBuildData.getCName(),
moduleName); moduleName);
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
//
// Do not break preprocess, continues to analysis.
// All errors will be summary to be shown.
//
continue;
} }
// //
@ -231,7 +277,12 @@ public abstract class PlatformPcdPreprocessAction {
exceptionString = String.format("In FPD file, there is no value for PCD entry %s in module %s!", exceptionString = String.format("In FPD file, there is no value for PCD entry %s in module %s!",
pcdBuildData.getCName(), pcdBuildData.getCName(),
moduleName); moduleName);
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
//
// Do not break preprocess, continues to analysis.
// All errors will be summary to be shown.
//
continue;
} }
// //
@ -242,7 +293,12 @@ public abstract class PlatformPcdPreprocessAction {
datum, datum,
datumType, datumType,
maxDatumSize)) != null) { maxDatumSize)) != null) {
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
//
// Do not break preprocess, continues to analysis.
// All errors will be summary to be shown.
//
continue;
} }
} }
@ -267,7 +323,12 @@ public abstract class PlatformPcdPreprocessAction {
pcdBuildData.getCName(), pcdBuildData.getCName(),
pcdBuildData.getDatumType().toString(), pcdBuildData.getDatumType().toString(),
Token.getStringOfdatumType(token.datumType)); Token.getStringOfdatumType(token.datumType));
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
//
// Do not break preprocess, continues to analysis.
// All errors will be summary to be shown.
//
continue;
} }
// //
@ -277,7 +338,12 @@ public abstract class PlatformPcdPreprocessAction {
exceptionString = String.format("In FPD file, the token number of PCD entry %s in module %s is different with same PCD entry in other modules!", exceptionString = String.format("In FPD file, the token number of PCD entry %s in module %s is different with same PCD entry in other modules!",
pcdBuildData.getCName(), pcdBuildData.getCName(),
moduleName); moduleName);
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
//
// Do not break preprocess, continues to analysis.
// All errors will be summary to be shown.
//
continue;
} }
// //
@ -288,7 +354,12 @@ public abstract class PlatformPcdPreprocessAction {
" is different with others module's", " is different with others module's",
token.cName, token.cName,
moduleName); moduleName);
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
//
// Do not break preprocess, continues to analysis.
// All errors will be summary to be shown.
//
continue;
} }
if (token.isDynamicPCD) { if (token.isDynamicPCD) {
@ -306,7 +377,12 @@ public abstract class PlatformPcdPreprocessAction {
"illega! You could no set <Value> in <ModuleSA> for a dynamic PCD!", "illega! You could no set <Value> in <ModuleSA> for a dynamic PCD!",
token.cName, token.cName,
moduleName); moduleName);
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
//
// Do not break preprocess, continues to analysis.
// All errors will be summary to be shown.
//
continue;
} }
} }
@ -318,7 +394,12 @@ public abstract class PlatformPcdPreprocessAction {
moduleName, moduleName,
maxDatumSize, maxDatumSize,
token.datumSize); token.datumSize);
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
//
// Do not break preprocess, continues to analysis.
// All errors will be summary to be shown.
//
continue;
} }
} }
@ -330,10 +411,13 @@ public abstract class PlatformPcdPreprocessAction {
tokenSpaceStrRet = this.getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName()); tokenSpaceStrRet = this.getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName());
if (tokenSpaceStrRet == null) { if (tokenSpaceStrRet == null) {
throw new PlatformPcdPreprocessException( putError("Fail to get Token space guid for token" + token.cName +
"Fail to get Token space guid for token" + token.cName + " from all SPD files. You must have an <GuidDeclaration> for this token space Guid");
" from all SPD files. You must have an <GuidDeclaration> for this token space Guid"); //
// Do not break preprocess, continues to analysis.
// All errors will be summary to be shown.
//
continue;
} }
token = new Token(pcdBuildData.getCName(), tokenSpaceStrRet[1]); token = new Token(pcdBuildData.getCName(), tokenSpaceStrRet[1]);
@ -348,10 +432,12 @@ public abstract class PlatformPcdPreprocessAction {
// For Dynamic and Dynamic Ex type, need find the dynamic information // For Dynamic and Dynamic Ex type, need find the dynamic information
// in <DynamicPcdBuildDefinition> section in FPD file. // in <DynamicPcdBuildDefinition> section in FPD file.
// //
updateDynamicInformation(moduleName, if (null == updateDynamicInformation(moduleName,
token, token,
datum, datum,
maxDatumSize); maxDatumSize)) {
continue;
}
} }
pcdDbManager.addTokenToDatabase(primaryKey, token); pcdDbManager.addTokenToDatabase(primaryKey, token);
@ -375,12 +461,13 @@ public abstract class PlatformPcdPreprocessAction {
datum, datum,
maxDatumSize); maxDatumSize);
if (!token.addUsageInstance(usageInstance)) { if (!token.addUsageInstance(usageInstance)) {
throw new PlatformPcdPreprocessException( putError(String.format("PCD %s for module %s(%s) has already exist in database, Please check all PCD build entries "+
String.format("PCD %s for module %s has already exist in database, Please check all PCD build entries "+ "in modules %s in <ModuleSA> to make sure no duplicated definitions in FPD file!",
"in modules %s in <ModuleSA> to make sure no duplicated definitions in FPD file!", token.cName,
token.cName, modules.get(index).usageId.moduleGuid,
moduleName, moduleName,
moduleName)); moduleName));
continue;
} }
} }
} }
@ -437,7 +524,8 @@ public abstract class PlatformPcdPreprocessAction {
"in FPD file, but it is required!", "in FPD file, but it is required!",
token.cName, token.cName,
moduleName); moduleName);
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
return null;
} }
token.datumSize = dynamicInfo.getMaxDatumSize(); token.datumSize = dynamicInfo.getMaxDatumSize();
@ -459,7 +547,8 @@ public abstract class PlatformPcdPreprocessAction {
moduleName, moduleName,
maxDatumSize, maxDatumSize,
dynamicInfo.getMaxDatumSize()); dynamicInfo.getMaxDatumSize());
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
return null;
} }
tokenNumber = Long.decode(dynamicInfo.getToken().toString()); tokenNumber = Long.decode(dynamicInfo.getToken().toString());
if (tokenNumber != token.tokenNumber) { if (tokenNumber != token.tokenNumber) {
@ -469,7 +558,8 @@ public abstract class PlatformPcdPreprocessAction {
moduleName, moduleName,
token.tokenNumber, token.tokenNumber,
tokenNumber); tokenNumber);
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
return null;
} }
token.dynamicExTokenNumber = tokenNumber; token.dynamicExTokenNumber = tokenNumber;
@ -499,7 +589,8 @@ public abstract class PlatformPcdPreprocessAction {
skuInfoList.get(index).getValue().toString(), skuInfoList.get(index).getValue().toString(),
token.datumType, token.datumType,
token.datumSize)) != null) { token.datumSize)) != null) {
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
return null;
} }
token.skuData.add(skuInstance); token.skuData.add(skuInstance);
@ -514,7 +605,8 @@ public abstract class PlatformPcdPreprocessAction {
exceptionString = "In FPD file, for dynamic PCD " + token.cName + ", the value in module " + moduleName + " is " + datum.toString() + " but the "+ exceptionString = "In FPD file, for dynamic PCD " + token.cName + ", the value in module " + moduleName + " is " + datum.toString() + " but the "+
"value of sku 0 data in <DynamicPcdBuildDefinition> is " + skuInstance.value.value + ". They are must be same!"+ "value of sku 0 data in <DynamicPcdBuildDefinition> is " + skuInstance.value.value + ". They are must be same!"+
" or you could not define value for a dynamic PCD in every <ModuleSA>!"; " or you could not define value for a dynamic PCD in every <ModuleSA>!";
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
return null;
} }
} }
continue; continue;
@ -530,9 +622,8 @@ public abstract class PlatformPcdPreprocessAction {
"file, who use HII, but there is no <VariableGuid> defined for Sku %d data!", "file, who use HII, but there is no <VariableGuid> defined for Sku %d data!",
token.cName, token.cName,
index); index);
if (exceptionString != null) { putError(exceptionString);
throw new PlatformPcdPreprocessException(exceptionString); return null;
}
} }
if (skuInfoList.get(index).getVariableOffset() == null) { if (skuInfoList.get(index).getVariableOffset() == null) {
@ -540,9 +631,8 @@ public abstract class PlatformPcdPreprocessAction {
"file, who use HII, but there is no <VariableOffset> defined for Sku %d data!", "file, who use HII, but there is no <VariableOffset> defined for Sku %d data!",
token.cName, token.cName,
index); index);
if (exceptionString != null) { putError(exceptionString);
throw new PlatformPcdPreprocessException(exceptionString); return null;
}
} }
if (skuInfoList.get(index).getHiiDefaultValue() == null) { if (skuInfoList.get(index).getHiiDefaultValue() == null) {
@ -550,9 +640,8 @@ public abstract class PlatformPcdPreprocessAction {
"file, who use HII, but there is no <HiiDefaultValue> defined for Sku %d data!", "file, who use HII, but there is no <HiiDefaultValue> defined for Sku %d data!",
token.cName, token.cName,
index); index);
if (exceptionString != null) { putError(exceptionString);
throw new PlatformPcdPreprocessException(exceptionString); return null;
}
} }
if (skuInfoList.get(index).getHiiDefaultValue() != null) { if (skuInfoList.get(index).getHiiDefaultValue() != null) {
@ -571,11 +660,11 @@ public abstract class PlatformPcdPreprocessAction {
offset = Integer.decode(skuInfoList.get(index).getVariableOffset()); offset = Integer.decode(skuInfoList.get(index).getVariableOffset());
if (offset > 0xFFFF) { if (offset > 0xFFFF) {
throw new PlatformPcdPreprocessException( putError(String.format("In FPD file, for dynamic PCD %s , the variable offset defined in sku %d data "+
String.format("In FPD file, for dynamic PCD %s , the variable offset defined in sku %d data "+ "exceed 64K, it is not allowed!",
"exceed 64K, it is not allowed!", token.cName,
token.cName, index));
index)); return null;
} }
// //
@ -583,10 +672,10 @@ public abstract class PlatformPcdPreprocessAction {
// //
variableGuidString = getGuidInfoFromSpd(skuInfoList.get(index).getVariableGuid().toString()); variableGuidString = getGuidInfoFromSpd(skuInfoList.get(index).getVariableGuid().toString());
if (variableGuidString == null) { if (variableGuidString == null) {
throw new PlatformPcdPreprocessException( putError(String.format("In FPD file, for dynamic PCD %s, the variable guid %s can be found in all SPD file!",
String.format("In FPD file, for dynamic PCD %s, the variable guid %s can be found in all SPD file!", token.cName,
token.cName, skuInfoList.get(index).getVariableGuid().toString()));
skuInfoList.get(index).getVariableGuid().toString())); return null;
} }
String variableStr = skuInfoList.get(index).getVariableName(); String variableStr = skuInfoList.get(index).getVariableName();
Pattern pattern = Pattern.compile("0x([a-fA-F0-9]){4}"); Pattern pattern = Pattern.compile("0x([a-fA-F0-9]){4}");
@ -614,14 +703,16 @@ public abstract class PlatformPcdPreprocessAction {
exceptionString = String.format("In FPD file, for dynamic PCD %s, the dynamic info must "+ exceptionString = String.format("In FPD file, for dynamic PCD %s, the dynamic info must "+
"be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.", "be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.",
token.cName); token.cName);
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
return null;
} }
if (!hasSkuId0) { if (!hasSkuId0) {
exceptionString = String.format("In FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions>, there are "+ exceptionString = String.format("In FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions>, there are "+
"no sku id = 0 data, which is required for every dynamic PCD", "no sku id = 0 data, which is required for every dynamic PCD",
token.cName); token.cName);
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
return null;
} }
return token; return token;
@ -660,7 +751,8 @@ public abstract class PlatformPcdPreprocessAction {
tokenSpaceStrRet = this.getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName()); tokenSpaceStrRet = this.getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName());
if (tokenSpaceStrRet == null) { if (tokenSpaceStrRet == null) {
throw new PlatformPcdPreprocessException("Fail to get Token space guid for token" + pcdBuildData.getCName()); putError("Fail to get Token space guid for token" + pcdBuildData.getCName());
continue;
} }
primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(), primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(),
@ -672,9 +764,9 @@ public abstract class PlatformPcdPreprocessAction {
pcdType = Token.getPcdTypeFromString(pcdBuildData.getItemType().toString()); pcdType = Token.getPcdTypeFromString(pcdBuildData.getItemType().toString());
if (pcdType != Token.PCD_TYPE.DYNAMIC_EX) { if (pcdType != Token.PCD_TYPE.DYNAMIC_EX) {
throw new PlatformPcdPreprocessException( putError(String.format("In FPD file, it not allowed for DYNAMIC PCD %s who is no used by any module",
String.format("In FPD file, it not allowed for DYNAMIC PCD %s who is no used by any module", pcdBuildData.getCName()));
pcdBuildData.getCName())); continue;
} }
// //
@ -696,7 +788,8 @@ public abstract class PlatformPcdPreprocessAction {
token.datumType, token.datumType,
token.datumSize); token.datumSize);
if (exceptionString != null) { if (exceptionString != null) {
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
continue;
} }
skuInfoList = pcdBuildData.getSkuInfoList(); skuInfoList = pcdBuildData.getSkuInfoList();
@ -724,7 +817,8 @@ public abstract class PlatformPcdPreprocessAction {
skuInfoList.get(index).getValue().toString(), skuInfoList.get(index).getValue().toString(),
token.datumType, token.datumType,
token.datumSize)) != null) { token.datumSize)) != null) {
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
continue;
} }
token.skuData.add(skuInstance); token.skuData.add(skuInstance);
@ -742,9 +836,8 @@ public abstract class PlatformPcdPreprocessAction {
"file, who use HII, but there is no <VariableGuid> defined for Sku %d data!", "file, who use HII, but there is no <VariableGuid> defined for Sku %d data!",
token.cName, token.cName,
index); index);
if (exceptionString != null) { putError(exceptionString);
throw new PlatformPcdPreprocessException(exceptionString); continue;
}
} }
if (skuInfoList.get(index).getVariableOffset() == null) { if (skuInfoList.get(index).getVariableOffset() == null) {
@ -752,9 +845,8 @@ public abstract class PlatformPcdPreprocessAction {
"file, who use HII, but there is no <VariableOffset> defined for Sku %d data!", "file, who use HII, but there is no <VariableOffset> defined for Sku %d data!",
token.cName, token.cName,
index); index);
if (exceptionString != null) { putError(exceptionString);
throw new PlatformPcdPreprocessException(exceptionString); continue;
}
} }
if (skuInfoList.get(index).getHiiDefaultValue() == null) { if (skuInfoList.get(index).getHiiDefaultValue() == null) {
@ -762,9 +854,8 @@ public abstract class PlatformPcdPreprocessAction {
"file, who use HII, but there is no <HiiDefaultValue> defined for Sku %d data!", "file, who use HII, but there is no <HiiDefaultValue> defined for Sku %d data!",
token.cName, token.cName,
index); index);
if (exceptionString != null) { putError(exceptionString);
throw new PlatformPcdPreprocessException(exceptionString); continue;
}
} }
if (skuInfoList.get(index).getHiiDefaultValue() != null) { if (skuInfoList.get(index).getHiiDefaultValue() != null) {
@ -778,16 +869,18 @@ public abstract class PlatformPcdPreprocessAction {
hiiDefaultValue, hiiDefaultValue,
token.datumType, token.datumType,
token.datumSize)) != null) { token.datumSize)) != null) {
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
continue;
} }
offset = Integer.decode(skuInfoList.get(index).getVariableOffset()); offset = Integer.decode(skuInfoList.get(index).getVariableOffset());
if (offset > 0xFFFF) { if (offset > 0xFFFF) {
throw new PlatformPcdPreprocessException( exceptionString = String.format("In FPD file, for dynamic PCD %s , the variable offset defined in sku %d data "+
String.format("In FPD file, for dynamic PCD %s , the variable offset defined in sku %d data "+
"exceed 64K, it is not allowed!", "exceed 64K, it is not allowed!",
token.cName, token.cName,
index)); index);
putError(exceptionString);
continue;
} }
// //
@ -795,10 +888,11 @@ public abstract class PlatformPcdPreprocessAction {
// //
variableGuidString = this.getGuidInfoFromSpd(skuInfoList.get(index).getVariableGuid().toString()); variableGuidString = this.getGuidInfoFromSpd(skuInfoList.get(index).getVariableGuid().toString());
if (variableGuidString == null) { if (variableGuidString == null) {
throw new PlatformPcdPreprocessException( exceptionString = String.format("In FPD file, for dynamic PCD %s, the variable guid %s can be found in all SPD file!",
String.format("In FPD file, for dynamic PCD %s, the variable guid %s can be found in all SPD file!", token.cName,
token.cName, skuInfoList.get(index).getVariableGuid().toString());
skuInfoList.get(index).getVariableGuid().toString())); putError(exceptionString);
continue;
} }
String variableStr = skuInfoList.get(index).getVariableName(); String variableStr = skuInfoList.get(index).getVariableName();
Pattern pattern = Pattern.compile("0x([a-fA-F0-9]){4}"); Pattern pattern = Pattern.compile("0x([a-fA-F0-9]){4}");
@ -826,14 +920,15 @@ public abstract class PlatformPcdPreprocessAction {
exceptionString = String.format("In FPD file, for dynamic PCD %s, the dynamic info must "+ exceptionString = String.format("In FPD file, for dynamic PCD %s, the dynamic info must "+
"be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.", "be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.",
token.cName); token.cName);
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
} }
if (!hasSkuId0) { if (!hasSkuId0) {
exceptionString = String.format("In FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions>, there are "+ exceptionString = String.format("In FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions>, there are "+
"no sku id = 0 data, which is required for every dynamic PCD", "no sku id = 0 data, which is required for every dynamic PCD",
token.cName); token.cName);
throw new PlatformPcdPreprocessException(exceptionString); putError(exceptionString);
continue;
} }
tokenArray.add(token); tokenArray.add(token);

View File

@ -235,6 +235,10 @@ public class MemoryDatabaseManager {
return getUsageInstanceArrayByKeyString(primaryKey); return getUsageInstanceArrayByKeyString(primaryKey);
} }
public void clearDatabase() {
memoryDatabase.clear();
}
/** /**
Get all PCD token for a usage instance according to primary key. Get all PCD token for a usage instance according to primary key.

View File

@ -41,8 +41,8 @@ public class ModulePcdInfoFromFpd {
**/ **/
public ModulePcdInfoFromFpd(UsageIdentification usageId, public ModulePcdInfoFromFpd(UsageIdentification usageId,
XmlObject pcdBuildDefinition) { PcdBuildDefinition pcdBuildDefinition) {
this.usageId = usageId; this.usageId = usageId;
this.pcdBuildDefinition = ((PcdBuildDefinitionDocument)pcdBuildDefinition).getPcdBuildDefinition(); this.pcdBuildDefinition = pcdBuildDefinition;
} }
} }