// Check does the BaseName, Guid, FileType set value.\r
//\r
if (this.baseName.equals("")) {\r
- throw new BuildException ("Must set BaseName!\n");\r
+ throw new BuildException ("Must set OutputFileBasename!\n");\r
}\r
\r
if (this.ffsFileGuid.equals("")) {\r
if (fileSize == ffsHeader.getSize()) {\r
throw new BuildException (\r
"FFS_ATTRIB_TAIL_PRESENT=TRUE is " +\r
- "invalid for 0-length files"\r
+ "invalid for zero length files"\r
); \r
}\r
fileSize = fileSize + 2;\r
This function is to set ffsAligment \r
@param ffsAligment The value of ffsAligment.\r
**/\r
- public void setFfsAttribDataAlignment(int ffsAligment) {\r
- this.ffsAttribDataAlignment = ffsAligment;\r
- if (this.ffsAttribDataAlignment > 7) {\r
- throw new BuildException ("FFS_ALIGMENT Scope is 0-7");\r
+ public void setFfsAttribDataAlignment(String ffsAligment) {\r
+ this.ffsAttribDataAlignment = stringToInt(ffsAligment.replaceAll(" ", "").toLowerCase());\r
+ if (this.ffsAttribDataAlignment < 0 || this.ffsAttribDataAlignment > 7) {\r
+ throw new BuildException ("FFS_ATTRIB_DATA_ALIGMENT must be an integer value from 0 through 7, inclusive");\r
} else {\r
attributes |= (((byte)this.ffsAttribDataAlignment) << 3);\r
}\r
\r
byte[] buffer = new byte[16];\r
if (GuidStr.length()!=36) {\r
- throw new BuildException ("Guid length is not correct!");\r
+ throw new BuildException ("The GUID length [" + GuidStr.length() + "] is not correct!");\r
}\r
\r
\r
SplitStr = GuidStr.split("-");\r
if (SplitStr.length != 5) {\r
- throw new BuildException ("Guid type is not correct!");\r
+ throw new BuildException ("The GUID format is not correct!");\r
}\r
\r
\r
public void setModuleType(String moduleType) {\r
this.moduleType = moduleType;\r
}\r
+\r
+ /**\r
+ Convert a string to a integer.\r
+ \r
+ @param intString The string representing a integer\r
+ \r
+ @retval int The value of integer represented by the\r
+ given string; -1 is returned if the format\r
+ of the string is wrong.\r
+ **/\r
+ private int stringToInt(String intString) {\r
+ int value;\r
+ int hexPrefixPos = intString.indexOf("0x");\r
+ int radix = 10;\r
+ String intStringNoPrefix;\r
+\r
+ if (hexPrefixPos >= 0) {\r
+ radix = 16;\r
+ intStringNoPrefix = intString.substring(hexPrefixPos + 2, intString.length());\r
+ } else {\r
+ intStringNoPrefix = intString;\r
+ }\r
+\r
+ try {\r
+ value = Integer.parseInt(intStringNoPrefix, radix);\r
+ } catch (NumberFormatException e) {\r
+ log("Incorrect format of int [" + intString + "]. -1 is assumed");\r
+ return -1;\r
+ }\r
+\r
+ return value;\r
+ }\r
}\r