from GlobalData import *\r
from BuildToolError import *\r
\r
+gHexVerPatt = re.compile('0x[a-f0-9]{4}[a-f0-9]{4}$',re.IGNORECASE)\r
+gHumanReadableVerPatt = re.compile(r'([1-9][0-9]*|0)\.[0-9]{1,2}$')\r
+\r
## GetSplitValueList\r
#\r
# Get a value list from a string with multiple values splited with SplitTag\r
String = CleanString(String)\r
return String[String.find(Key + ' ') + len(Key + ' ') : ]\r
\r
+## GetHexVerValue\r
+#\r
+# Get a Hex Version Value\r
+#\r
+# @param VerString: The version string to be parsed\r
+#\r
+#\r
+# @retval: If VerString is incorrectly formatted, return "None" which will break the build.\r
+# If VerString is correctly formatted, return a Hex value of the Version Number (0xmmmmnnnn)\r
+# where mmmm is the major number and nnnn is the adjusted minor number.\r
+#\r
+def GetHexVerValue(VerString):\r
+ VerString = CleanString(VerString)\r
+\r
+ if gHumanReadableVerPatt.match(VerString):\r
+ ValueList = VerString.split('.')\r
+ Major = ValueList[0]\r
+ Minor = ValueList[1]\r
+ if len(Minor) == 1:\r
+ Minor += '0'\r
+ DeciValue = (int(Major) << 16) + int(Minor);\r
+ return "0x%08x"%DeciValue\r
+ elif gHexVerPatt.match(VerString):\r
+ return VerString\r
+ else:\r
+ return None\r
+\r
+\r
## GetSingleValueOfKeyFromLines\r
#\r
# Parse multiple strings as below to get value of each definition line\r