mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 23:54:02 +02:00
Shutdown the PCD's datum verification when building, it can save 2 minutes for full building by using JDK 1.5.06.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1196 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
20c5c53fd7
commit
4d1939b86f
@ -260,315 +260,10 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
|
|||||||
String datum,
|
String datum,
|
||||||
Token.DATUM_TYPE datumType,
|
Token.DATUM_TYPE datumType,
|
||||||
int maxDatumSize) {
|
int maxDatumSize) {
|
||||||
String exceptionString = null;
|
//
|
||||||
int value;
|
// In building system, datum should not be checked, the checking work
|
||||||
BigInteger value64;
|
// should be done by wizard tools or PCD verification tools.
|
||||||
String subStr;
|
//
|
||||||
int index;
|
|
||||||
|
|
||||||
if (moduleName == null) {
|
|
||||||
moduleName = "section <DynamicPcdBuildDefinitions>";
|
|
||||||
} else {
|
|
||||||
moduleName = "module " + moduleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxDatumSize == 0) {
|
|
||||||
exceptionString = String.format("[FPD file error] You maybe miss <MaxDatumSize> for PCD %s in %s",
|
|
||||||
cName,
|
|
||||||
moduleName);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (datumType) {
|
|
||||||
case UINT8:
|
|
||||||
if (maxDatumSize != 1) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum type of PCD data %s in %s "+
|
|
||||||
"is UINT8, but datum size is %d, they are not matched!",
|
|
||||||
cName,
|
|
||||||
moduleName,
|
|
||||||
maxDatumSize);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (datum != null) {
|
|
||||||
try {
|
|
||||||
value = Integer.decode(datum);
|
|
||||||
} catch (NumberFormatException nfeExp) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is not valid "+
|
|
||||||
"digital format of UINT8",
|
|
||||||
cName,
|
|
||||||
moduleName);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
if (value > 0xFF) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is %s exceed"+
|
|
||||||
" the max size of UINT8 - 0xFF",
|
|
||||||
cName,
|
|
||||||
moduleName,
|
|
||||||
datum);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case UINT16:
|
|
||||||
if (maxDatumSize != 2) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum type of PCD data %s in %s "+
|
|
||||||
"is UINT16, but datum size is %d, they are not matched!",
|
|
||||||
cName,
|
|
||||||
moduleName,
|
|
||||||
maxDatumSize);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
if (datum != null) {
|
|
||||||
try {
|
|
||||||
value = Integer.decode(datum);
|
|
||||||
} catch (NumberFormatException nfeExp) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is "+
|
|
||||||
"not valid digital of UINT16",
|
|
||||||
cName,
|
|
||||||
moduleName);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
if (value > 0xFFFF) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is %s "+
|
|
||||||
"which exceed the range of UINT16 - 0xFFFF",
|
|
||||||
cName,
|
|
||||||
moduleName,
|
|
||||||
datum);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case UINT32:
|
|
||||||
if (maxDatumSize != 4) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum type of PCD data %s in %s "+
|
|
||||||
"is UINT32, but datum size is %d, they are not matched!",
|
|
||||||
cName,
|
|
||||||
moduleName,
|
|
||||||
maxDatumSize);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (datum != null) {
|
|
||||||
try {
|
|
||||||
if (datum.length() > 2) {
|
|
||||||
if ((datum.charAt(0) == '0') &&
|
|
||||||
((datum.charAt(1) == 'x') || (datum.charAt(1) == 'X'))){
|
|
||||||
subStr = datum.substring(2, datum.length());
|
|
||||||
value64 = new BigInteger(subStr, 16);
|
|
||||||
} else {
|
|
||||||
value64 = new BigInteger(datum);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
value64 = new BigInteger(datum);
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException nfeExp) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is not "+
|
|
||||||
"valid digital of UINT32",
|
|
||||||
cName,
|
|
||||||
moduleName);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value64.bitLength() > 32) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is %s which "+
|
|
||||||
"exceed the range of UINT32 - 0xFFFFFFFF",
|
|
||||||
cName,
|
|
||||||
moduleName,
|
|
||||||
datum);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case UINT64:
|
|
||||||
if (maxDatumSize != 8) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum type of PCD data %s in %s "+
|
|
||||||
"is UINT64, but datum size is %d, they are not matched!",
|
|
||||||
cName,
|
|
||||||
moduleName,
|
|
||||||
maxDatumSize);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (datum != null) {
|
|
||||||
try {
|
|
||||||
if (datum.length() > 2) {
|
|
||||||
if ((datum.charAt(0) == '0') &&
|
|
||||||
((datum.charAt(1) == 'x') || (datum.charAt(1) == 'X'))){
|
|
||||||
subStr = datum.substring(2, datum.length());
|
|
||||||
value64 = new BigInteger(subStr, 16);
|
|
||||||
} else {
|
|
||||||
value64 = new BigInteger(datum);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
value64 = new BigInteger(datum);
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException nfeExp) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is not valid"+
|
|
||||||
" digital of UINT64",
|
|
||||||
cName,
|
|
||||||
moduleName);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value64.bitLength() > 64) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is %s "+
|
|
||||||
"exceed the range of UINT64 - 0xFFFFFFFFFFFFFFFF",
|
|
||||||
cName,
|
|
||||||
moduleName,
|
|
||||||
datum);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case BOOLEAN:
|
|
||||||
if (maxDatumSize != 1) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum type of PCD data %s in %s "+
|
|
||||||
"is BOOLEAN, but datum size is %d, they are not matched!",
|
|
||||||
cName,
|
|
||||||
moduleName,
|
|
||||||
maxDatumSize);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (datum != null) {
|
|
||||||
if (!(datum.equalsIgnoreCase("TRUE") ||
|
|
||||||
datum.equalsIgnoreCase("FALSE"))) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum type of PCD data %s in %s "+
|
|
||||||
"is BOOELAN, but value is not 'true'/'TRUE' or 'FALSE'/'false'",
|
|
||||||
cName,
|
|
||||||
moduleName);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case POINTER:
|
|
||||||
if (datum == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
char ch = datum.charAt(0);
|
|
||||||
int start, end;
|
|
||||||
String strValue;
|
|
||||||
//
|
|
||||||
// For void* type PCD, only three datum is support:
|
|
||||||
// 1) Unicode: string with start char is "L"
|
|
||||||
// 2) Ansci: String start char is ""
|
|
||||||
// 3) byte array: String start char "{"
|
|
||||||
//
|
|
||||||
if (ch == 'L') {
|
|
||||||
start = datum.indexOf('\"');
|
|
||||||
end = datum.lastIndexOf('\"');
|
|
||||||
if ((start > end) ||
|
|
||||||
(end > datum.length())||
|
|
||||||
((start == end) && (datum.length() > 0))) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID* and datum is "+
|
|
||||||
"a UNICODE string because start with L\", but format maybe"+
|
|
||||||
"is not right, correct UNICODE string is L\"...\"!",
|
|
||||||
cName,
|
|
||||||
moduleName);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
|
|
||||||
strValue = datum.substring(start + 1, end);
|
|
||||||
if ((strValue.length() * 2) > maxDatumSize) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and datum is "+
|
|
||||||
"a UNICODE string, but the datum size is %d exceed to <MaxDatumSize> : %d",
|
|
||||||
cName,
|
|
||||||
moduleName,
|
|
||||||
strValue.length() * 2,
|
|
||||||
maxDatumSize);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
} else if (ch == '\"'){
|
|
||||||
start = datum.indexOf('\"');
|
|
||||||
end = datum.lastIndexOf('\"');
|
|
||||||
if ((start > end) ||
|
|
||||||
(end > datum.length())||
|
|
||||||
((start == end) && (datum.length() > 0))) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID* and datum is "+
|
|
||||||
"a ANSCII string because start with \", but format maybe"+
|
|
||||||
"is not right, correct ANSIC string is \"...\"!",
|
|
||||||
cName,
|
|
||||||
moduleName);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
strValue = datum.substring(start + 1, end);
|
|
||||||
if ((strValue.length()) > maxDatumSize) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and datum is "+
|
|
||||||
"a ANSCI string, but the datum size is %d which exceed to <MaxDatumSize> : %d",
|
|
||||||
cName,
|
|
||||||
moduleName,
|
|
||||||
strValue.length(),
|
|
||||||
maxDatumSize);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
} else if (ch =='{') {
|
|
||||||
String[] strValueArray;
|
|
||||||
|
|
||||||
start = datum.indexOf('{');
|
|
||||||
end = datum.lastIndexOf('}');
|
|
||||||
strValue = datum.substring(start + 1, end);
|
|
||||||
strValue = strValue.trim();
|
|
||||||
if (strValue.length() == 0) {
|
|
||||||
exceptionString = String.format ("[FPD file error] The datum type of PCD %s in %s is VOID*, and "+
|
|
||||||
"it is byte array in fact, but '{}' is not valid for NULL datam but"+
|
|
||||||
" need use '{0}'",
|
|
||||||
cName,
|
|
||||||
moduleName);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
strValueArray = strValue.split(",");
|
|
||||||
for (index = 0; index < strValueArray.length; index ++) {
|
|
||||||
try{
|
|
||||||
value = Integer.decode(strValueArray[index].trim());
|
|
||||||
} catch (NumberFormatException nfeEx) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and "+
|
|
||||||
"it is byte array in fact. For every byte in array should be a valid"+
|
|
||||||
"byte digital, but element %s is not a valid byte digital!",
|
|
||||||
cName,
|
|
||||||
moduleName,
|
|
||||||
strValueArray[index]);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
if (value > 0xFF) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, "+
|
|
||||||
"it is byte array in fact. But the element of %s exceed the byte range",
|
|
||||||
cName,
|
|
||||||
moduleName,
|
|
||||||
strValueArray[index]);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strValueArray.length > maxDatumSize) {
|
|
||||||
exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and datum is byte"+
|
|
||||||
"array, but the number of bytes is %d which exceed to <MaxDatumSzie> : %d!",
|
|
||||||
cName,
|
|
||||||
moduleName,
|
|
||||||
strValueArray.length,
|
|
||||||
maxDatumSize);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
} 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"+
|
|
||||||
"1) UNICODE string: like L\"xxxx\";\r\n"+
|
|
||||||
"2) ANSIC string: like \"xxx\";\r\n"+
|
|
||||||
"3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
|
|
||||||
"But the datum in seems does not following above format!",
|
|
||||||
cName,
|
|
||||||
moduleName);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
exceptionString = String.format("[FPD file error] For PCD entry %s in %s, datum type is unknown, it should be one of "+
|
|
||||||
"UINT8, UINT16, UINT32, UINT64, VOID*, BOOLEAN",
|
|
||||||
cName,
|
|
||||||
moduleName);
|
|
||||||
return exceptionString;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user