summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/Workspace/MetaFileParser.py
diff options
context:
space:
mode:
authorCarsey, Jaben <jaben.carsey@intel.com>2018-04-20 23:51:24 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-04-26 14:35:36 +0800
commit3e4faa268e2fafb119fdf5f48a9fcc111f9dc62e (patch)
tree51114fbe63388fa5b2dc1ccf31f0d9e25484ea12 /BaseTools/Source/Python/Workspace/MetaFileParser.py
parentef42ef7e6dd70112ce2af1757e765b7bcde7a70a (diff)
downloadedk2-3e4faa268e2fafb119fdf5f48a9fcc111f9dc62e.tar.gz
edk2-3e4faa268e2fafb119fdf5f48a9fcc111f9dc62e.tar.bz2
edk2-3e4faa268e2fafb119fdf5f48a9fcc111f9dc62e.zip
BaseTools: Workspace - refactor RegEx to minimize multiple compiling
Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/Workspace/MetaFileParser.py')
-rw-r--r--BaseTools/Source/Python/Workspace/MetaFileParser.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 322ed38449..550359f9ab 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -35,6 +35,10 @@ from Common.LongFilePathSupport import OpenLongFilePath as open
from MetaFileTable import MetaFileStorage
from MetaFileCommentParser import CheckInfComment
+## RegEx for finding file versions
+hexVersionPattern = re.compile(r'0[xX][\da-f-A-F]{5,8}')
+decVersionPattern = re.compile(r'\d+\.\d+')
+
## A decorator used to parse macro definition
def ParseMacro(Parser):
def MacroParser(self):
@@ -366,9 +370,9 @@ class MetaFileParser(object):
EdkLogger.error("Parser", FORMAT_INVALID, "%s not defined" % (Macro), ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
# Sometimes, we need to make differences between EDK and EDK2 modules
if Name == 'INF_VERSION':
- if re.match(r'0[xX][\da-f-A-F]{5,8}', Value):
+ if hexVersionPattern.match(Value):
self._Version = int(Value, 0)
- elif re.match(r'\d+\.\d+', Value):
+ elif decVersionPattern.match(Value):
ValueList = Value.split('.')
Major = '%04o' % int(ValueList[0], 0)
Minor = '%04o' % int(ValueList[1], 0)