Skip to content

Commit

Permalink
BaseTools: Resolve regex syntax warnings
Browse files Browse the repository at this point in the history
Switches regex patterns to raw text to resolve python 3.12 syntax
warnings in regards to invalid escape sequences, as is suggested by the
re (regex) module in python.

Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Joey Vagedes <joey.vagedes@gmail.com>
Reviewed-by: Rebecca Cran <rebecca@bsdio.com>
  • Loading branch information
bexcran committed Feb 11, 2024
1 parent 7d9df27 commit 29e0483
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 60 deletions.
2 changes: 1 addition & 1 deletion edk2basetools/AmlToC/AmlToC.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import sys
import os

__description__ = """
__description__ = r"""
Convert an AML file to a .c file containing the AML bytecode stored in a C
array. By default, Tables\Dsdt.aml will generate Tables\Dsdt.c.
Tables\Dsdt.c will contain a C array named "dsdt_aml_code" that contains
Expand Down
2 changes: 1 addition & 1 deletion edk2basetools/AutoGen/BuildEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class BuildRule:
_SubSectionList = [_InputFile, _OutputFile, _Command]

_PATH_SEP = "(+)"
_FileTypePattern = re.compile("^[_a-zA-Z][_\-0-9a-zA-Z]*$")
_FileTypePattern = re.compile(r"^[_a-zA-Z][_\-0-9a-zA-Z]*$")
_BinaryFileRule = FileBuildRule(TAB_DEFAULT_BINARY_FILE, [], [os.path.join("$(OUTPUT_DIR)", "${s_name}")],
["$(CP) ${src} ${dst}"], [])

Expand Down
2 changes: 1 addition & 1 deletion edk2basetools/AutoGen/GenDepex.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class DependencyExpression:
#
# open and close brace must be taken as individual tokens
#
TokenPattern = re.compile("(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+)")
TokenPattern = re.compile(r"(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+)")

## Constructor
#
Expand Down
2 changes: 1 addition & 1 deletion edk2basetools/AutoGen/GenMake.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
gIncludePattern = re.compile(r"^[ \t]*[#%]?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:\(?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)", re.MULTILINE | re.UNICODE | re.IGNORECASE)

## Regular expression for matching macro used in header file inclusion
gMacroPattern = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE)
gMacroPattern = re.compile(r"([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE)

gIsFileMap = {}

Expand Down
2 changes: 1 addition & 1 deletion edk2basetools/AutoGen/IdfClassObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from edk2basetools.Common.GlobalData import gIdentifierPattern
from .UniClassObject import StripComments

IMAGE_TOKEN = re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)
IMAGE_TOKEN = re.compile(r'IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)

#
# Value of different image information block types
Expand Down
4 changes: 2 additions & 2 deletions edk2basetools/AutoGen/ModuleAutoGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
#
# Match name = variable
#
gEfiVarStoreNamePattern = re.compile("\s*name\s*=\s*(\w+)")
gEfiVarStoreNamePattern = re.compile(r"\s*name\s*=\s*(\w+)")
#
# The format of guid in efivarstore statement likes following and must be correct:
# guid = {0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13, 0x02, 0x11, 0x3D}}
#
gEfiVarStoreGuidPattern = re.compile("\s*guid\s*=\s*({.*?{.*?}\s*})")
gEfiVarStoreGuidPattern = re.compile(r"\s*guid\s*=\s*({.*?{.*?}\s*})")

#
# Template string to generic AsBuilt INF
Expand Down
2 changes: 1 addition & 1 deletion edk2basetools/AutoGen/StrGather.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
COMMENT_NOT_REFERENCED = ' ' + COMMENT + NOT_REFERENCED
CHAR_ARRAY_DEFIN = 'unsigned char'
COMMON_FILE_NAME = 'Strings'
STRING_TOKEN = re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)
STRING_TOKEN = re.compile(r'STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)

EFI_HII_ARRAY_SIZE_LENGTH = 4
EFI_HII_PACKAGE_HEADER_LENGTH = 4
Expand Down
2 changes: 1 addition & 1 deletion edk2basetools/AutoGen/WorkspaceAutoGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import json

## Regular expression for splitting Dependency Expression string into tokens
gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")
gDepexTokenPattern = re.compile(r"(\(|\)|\w+| \S+\.inf)")

## Regular expression for match: PCD(xxxx.yyy)
gPCDAsGuidPattern = re.compile(r"^PCD\(.+\..+\)$")
Expand Down
16 changes: 8 additions & 8 deletions edk2basetools/Common/Expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).'

__ValidString = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$')
_ReLabel = re.compile('LABEL\((\w+)\)')
_ReOffset = re.compile('OFFSET_OF\((\w+)\)')
_ReLabel = re.compile(r'LABEL\((\w+)\)')
_ReOffset = re.compile(r'OFFSET_OF\((\w+)\)')
PcdPattern = re.compile(r'^[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]*$')

## SplitString
Expand Down Expand Up @@ -242,10 +242,10 @@ class ValueExpression(BaseExpression):


SymbolPattern = re.compile("("
"\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|"
"&&|\|\||!(?!=)|"
"(?<=\W)AND(?=\W)|(?<=\W)OR(?=\W)|(?<=\W)NOT(?=\W)|(?<=\W)XOR(?=\W)|"
"(?<=\W)EQ(?=\W)|(?<=\W)NE(?=\W)|(?<=\W)GT(?=\W)|(?<=\W)LT(?=\W)|(?<=\W)GE(?=\W)|(?<=\W)LE(?=\W)"
r"\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|"
r"&&|\|\||!(?!=)|"
r"(?<=\W)AND(?=\W)|(?<=\W)OR(?=\W)|(?<=\W)NOT(?=\W)|(?<=\W)XOR(?=\W)|"
r"(?<=\W)EQ(?=\W)|(?<=\W)NE(?=\W)|(?<=\W)GT(?=\W)|(?<=\W)LT(?=\W)|(?<=\W)GE(?=\W)|(?<=\W)LE(?=\W)"
")")

@staticmethod
Expand Down Expand Up @@ -737,7 +737,7 @@ def _GetSingleToken(self):
self._Token = "'" + UStr + "'"
return self._Token
elif Expr.startswith('UINT'):
Re = re.compile('(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)')
Re = re.compile(r'(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)')
try:
RetValue = Re.search(Expr).group(1)
except:
Expand Down Expand Up @@ -975,7 +975,7 @@ def __call__(self, RealValue=False, Depth=0):
TokenSpaceGuidName = ''
if Item.startswith(TAB_GUID) and Item.endswith(')'):
try:
TokenSpaceGuidName = re.search('GUID\((\w+)\)', Item).group(1)
TokenSpaceGuidName = re.search(r'GUID\((\w+)\)', Item).group(1)
except:
pass
if TokenSpaceGuidName and TokenSpaceGuidName in self._Symb:
Expand Down
4 changes: 2 additions & 2 deletions edk2basetools/Common/GlobalData.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
gGuidDict = {}

# definition for a MACRO name. used to create regular expressions below.
_MacroNamePattern = "[A-Z][A-Z0-9_]*"
_MacroNamePattern = r"[A-Z][A-Z0-9_]*"

## Regular expression for matching macro used in DSC/DEC/INF file inclusion
gMacroRefPattern = re.compile("\$\(({})\)".format(_MacroNamePattern), re.UNICODE)
gMacroRefPattern = re.compile(r"\$\(({})\)".format(_MacroNamePattern), re.UNICODE)
gMacroDefPattern = re.compile("^(DEFINE|EDK_GLOBAL)[ \t]+")
gMacroNamePattern = re.compile("^{}$".format(_MacroNamePattern))

Expand Down
24 changes: 12 additions & 12 deletions edk2basetools/Common/Misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@
from edk2basetools.Common.caching import cached_property
import struct

ArrayIndex = re.compile("\[\s*[0-9a-fA-FxX]*\s*\]")
ArrayIndex = re.compile(r"\[\s*[0-9a-fA-FxX]*\s*\]")
## Regular expression used to find out place holders in string template
gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE)
gPlaceholderPattern = re.compile(r"\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE)

## regular expressions for map file processing
startPatternGeneral = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class")
addressPatternGeneral = re.compile("^Address[' ']+Publics by Value[' ']+Rva\+Base")
valuePatternGcc = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
pcdPatternGcc = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
secReGeneral = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)
startPatternGeneral = re.compile(r"^Start[' ']+Length[' ']+Name[' ']+Class")
addressPatternGeneral = re.compile(r"^Address[' ']+Publics by Value[' ']+Rva\+Base")
valuePatternGcc = re.compile(r'^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
pcdPatternGcc = re.compile(r'^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
secReGeneral = re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)

StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')

Expand Down Expand Up @@ -82,7 +82,7 @@ def GetVariableOffset(mapfilepath, efifilepath, varnames):

if len(lines) == 0: return None
firstline = lines[0].strip()
if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', firstline):
if re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', firstline):
return _parseForXcodeAndClang9(lines, efifilepath, varnames)
if (firstline.startswith("Archive member included ") and
firstline.endswith(" file (symbol)")):
Expand All @@ -96,15 +96,15 @@ def _parseForXcodeAndClang9(lines, efifilepath, varnames):
ret = []
for line in lines:
line = line.strip()
if status == 0 and (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
if status == 0 and (re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
or line == "# Symbols:"):
status = 1
continue
if status == 1 and len(line) != 0:
for varname in varnames:
if varname in line:
# cannot pregenerate this RegEx since it uses varname from varnames.
m = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' % varname, line)
m = re.match(r'^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' % varname, line)
if m is not None:
ret.append((varname, m.group(1)))
return ret
Expand Down Expand Up @@ -170,7 +170,7 @@ def _parseGeneral(lines, efifilepath, varnames):
status = 0 #0 - beginning of file; 1 - PE section definition; 2 - symbol table
secs = [] # key = section name
varoffset = []
symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$-]+) +([\da-fA-F]+)', re.UNICODE)
symRe = re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$-]+) +([\da-fA-F]+)', re.UNICODE)

for line in lines:
line = line.strip()
Expand Down Expand Up @@ -1926,4 +1926,4 @@ def CopyDict(ori_dict):
# Remove the c/c++ comments: // and /* */
#
def RemoveCComments(ctext):
return re.sub('//.*?\n|/\*.*?\*/', '\n', ctext, flags=re.S)
return re.sub(r'//.*?\n|/\*.*?\*/', '\n', ctext, flags=re.S)
6 changes: 3 additions & 3 deletions edk2basetools/Common/ToolDefClassObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
##
# Static variables used for pattern
#
gMacroRefPattern = re.compile('(DEF\([^\(\)]+\))')
gEnvRefPattern = re.compile('(ENV\([^\(\)]+\))')
gMacroDefPattern = re.compile("DEFINE\s+([^\s]+)")
gMacroRefPattern = re.compile(r'(DEF\([^\(\)]+\))')
gEnvRefPattern = re.compile(r'(ENV\([^\(\)]+\))')
gMacroDefPattern = re.compile(r"DEFINE\s+([^\s]+)")
gDefaultToolsDefFile = "tools_def.txt"

## ToolDefClassObject
Expand Down
10 changes: 5 additions & 5 deletions edk2basetools/GenFds/FdfParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@
ALIGNMENT_NOAUTO = ALIGNMENTS - {"Auto"}
CR_LB_SET = {T_CHAR_CR, TAB_LINE_BREAK}

RegionSizePattern = compile("\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size>(?:0x|0X)?[a-fA-F0-9]+)\s*")
RegionSizeGuidPattern = compile("\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P<size>\w+\.\w+[\.\w\[\]]*)\s*")
RegionOffsetPcdPattern = compile("\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*$")
ShortcutPcdPattern = compile("\s*\w+\s*=\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<name>\w+\.\w+)\s*")
BaseAddrValuePattern = compile('^0[xX][0-9a-fA-F]+')
RegionSizePattern = compile(r"\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size>(?:0x|0X)?[a-fA-F0-9]+)\s*")
RegionSizeGuidPattern = compile(r"\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P<size>\w+\.\w+[\.\w\[\]]*)\s*")
RegionOffsetPcdPattern = compile(r"\s*(?P<base>\w+\.\w+[\.\w\[\]]*)\s*$")
ShortcutPcdPattern = compile(r"\s*\w+\s*=\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<name>\w+\.\w+)\s*")
BaseAddrValuePattern = compile(r'^0[xX][0-9a-fA-F]+')
FileExtensionPattern = compile(r'([a-zA-Z][a-zA-Z0-9]*)')
TokenFindPattern = compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
AllIncludeFileList = []
Expand Down
2 changes: 1 addition & 1 deletion edk2basetools/GenFds/GenFds.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj):
if not os.path.exists(FfsPath[0]):
continue
MatchDict = {}
ReFileEnds = compile('\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.txt)$|\S+(.raw.txt)$|\S+(.ffs.txt)$')
ReFileEnds = compile(r'\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.txt)$|\S+(.raw.txt)$|\S+(.ffs.txt)$')
FileList = os.listdir(FfsPath[0])
for File in FileList:
Match = ReFileEnds.search(File)
Expand Down
12 changes: 6 additions & 6 deletions edk2basetools/GenPatchPcdTable/GenPatchPcdTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#====================================== Internal Libraries ========================================

#============================================== Code ===============================================
symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<>]+) +([\da-fA-F]+)', re.UNICODE)
symRe = re.compile(r'^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<>]+) +([\da-fA-F]+)', re.UNICODE)

def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
""" Parse map file to get binary patch pcd information
Expand All @@ -49,7 +49,7 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath):

if len(lines) == 0: return None
firstline = lines[0].strip()
if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', firstline):
if re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', firstline):
return _parseForXcodeAndClang9(lines, efifilepath)
if (firstline.startswith("Archive member included ") and
firstline.endswith(" file (symbol)")):
Expand All @@ -59,12 +59,12 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
return _parseGeneral(lines, efifilepath)

def _parseForXcodeAndClang9(lines, efifilepath):
valuePattern = re.compile('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))')
valuePattern = re.compile(r'^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))')
status = 0
pcds = []
for line in lines:
line = line.strip()
if status == 0 and (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
if status == 0 and (re.match(r'^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \
or line == "# Symbols:"):
status = 1
continue
Expand All @@ -77,7 +77,7 @@ def _parseForXcodeAndClang9(lines, efifilepath):

def _parseForGCC(lines, efifilepath):
""" Parse map file generated by GCC linker """
dataPattern = re.compile('^.data._gPcd_BinaryPatch_([\w_\d]+)$')
dataPattern = re.compile(r'^.data._gPcd_BinaryPatch_([\w_\d]+)$')
status = 0
imageBase = -1
sections = []
Expand Down Expand Up @@ -136,7 +136,7 @@ def _parseGeneral(lines, efifilepath):
status = 0 #0 - beginning of file; 1 - PE section definition; 2 - symbol table
secs = [] # key = section name
bPcds = []
symPattern = re.compile('^[_]+gPcd_BinaryPatch_([\w]+)')
symPattern = re.compile(r'^[_]+gPcd_BinaryPatch_([\w]+)')

for line in lines:
line = line.strip()
Expand Down
18 changes: 9 additions & 9 deletions edk2basetools/Trim/Trim.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,30 @@
__copyright__ = "Copyright (c) 2007-2018, Intel Corporation. All rights reserved."

## Regular expression for matching Line Control directive like "#line xxx"
gLineControlDirective = re.compile('^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"')
gLineControlDirective = re.compile(r'^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"')
## Regular expression for matching "typedef struct"
gTypedefPattern = re.compile("^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", re.MULTILINE)
gTypedefPattern = re.compile(r"^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", re.MULTILINE)
## Regular expression for matching "#pragma pack"
gPragmaPattern = re.compile("^\s*#pragma\s+pack", re.MULTILINE)
gPragmaPattern = re.compile(r"^\s*#pragma\s+pack", re.MULTILINE)
## Regular expression for matching "typedef"
gTypedef_SinglePattern = re.compile("^\s*typedef", re.MULTILINE)
gTypedef_SinglePattern = re.compile(r"^\s*typedef", re.MULTILINE)
## Regular expression for matching "typedef struct, typedef union, struct, union"
gTypedef_MulPattern = re.compile("^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{]*$", re.MULTILINE)
gTypedef_MulPattern = re.compile(r"^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{]*$", re.MULTILINE)

#
# The following number pattern match will only match if following criteria is met:
# There is leading non-(alphanumeric or _) character, and no following alphanumeric or _
# as the pattern is greedily match, so it is ok for the gDecNumberPattern or gHexNumberPattern to grab the maximum match
#
## Regular expression for matching HEX number
gHexNumberPattern = re.compile("(?<=[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=$|[^a-zA-Z0-9_]))?")
gHexNumberPattern = re.compile(r"(?<=[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=$|[^a-zA-Z0-9_]))?")
## Regular expression for matching decimal number with 'U' postfix
gDecNumberPattern = re.compile("(?<=[^a-zA-Z0-9_])([0-9]+)U(?=$|[^a-zA-Z0-9_])")
gDecNumberPattern = re.compile(r"(?<=[^a-zA-Z0-9_])([0-9]+)U(?=$|[^a-zA-Z0-9_])")
## Regular expression for matching constant with 'ULL' 'LL' postfix
gLongNumberPattern = re.compile("(?<=[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL(?=$|[^a-zA-Z0-9_])")
gLongNumberPattern = re.compile(r"(?<=[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL(?=$|[^a-zA-Z0-9_])")

## Regular expression for matching "Include ()" in asl file
gAslIncludePattern = re.compile("^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)", re.MULTILINE)
gAslIncludePattern = re.compile(r"^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)", re.MULTILINE)
## Regular expression for matching C style #include "XXX.asl" in asl file
gAslCIncludePattern = re.compile(r'^(\s*)#include\s*[<"]\s*([-\\/\w.]+)\s*([>"])', re.MULTILINE)
## Patterns used to convert EDK conventions to EDK2 ECP conventions
Expand Down
8 changes: 4 additions & 4 deletions edk2basetools/Workspace/DscBuildData.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _IsFieldValueAnArray (Value):

WindowsCFLAGS = 'CFLAGS = $(CFLAGS) /wd4200 /wd4034 /wd4101 '
LinuxCFLAGS = 'CFLAGS += -Wno-pointer-to-int-cast -Wno-unused-variable '
PcdMakefileEnd = '''
PcdMakefileEnd = r'''
!INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common
!INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app
'''
Expand All @@ -110,7 +110,7 @@ def _IsFieldValueAnArray (Value):
variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
SkuIdPattern = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$')
## regular expressions for finding decimal and hex numbers
Pattern = re.compile('^[1-9]\d*|0$')
Pattern = re.compile(r'^[1-9]\d*|0$')
HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')
## Regular expression for finding header file inclusions
from edk2basetools.AutoGen.GenMake import gIncludePattern
Expand Down Expand Up @@ -2840,7 +2840,7 @@ def GenerateByteArrayValue (self, StructuredPcds):
# start generating makefile
MakeApp = PcdMakefileHeader
if sys.platform == "win32":
MakeApp = MakeApp + 'APPFILE = %s\%s.exe\n' % (self.OutputPath, PcdValueInitName) + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s\%s.obj %s.obj\n' % (self.OutputPath, PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) + 'INC = '
MakeApp = MakeApp + r'APPFILE = %s\%s.exe\n' % (self.OutputPath, PcdValueInitName) + r'APPNAME = %s\n' % (PcdValueInitName) + r'OBJECTS = %s\%s.obj %s.obj\n' % (self.OutputPath, PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) + 'INC = '
else:
MakeApp = MakeApp + PcdGccMakefile
MakeApp = MakeApp + 'APPFILE = %s/%s\n' % (self.OutputPath, PcdValueInitName) + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s/%s.o %s.o\n' % (self.OutputPath, PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) + \
Expand Down Expand Up @@ -2950,7 +2950,7 @@ def GenerateByteArrayValue (self, StructuredPcds):
MakeApp += "$(OBJECTS) : %s\n" % include_file
if sys.platform == "win32":
PcdValueCommonPath = os.path.normpath(mws.join(GlobalData.gGlobalDefines["EDK_TOOLS_PATH"], "Source\C\Common\PcdValueCommon.c"))
MakeApp = MakeApp + '%s\PcdValueCommon.c : %s\n' % (self.OutputPath, PcdValueCommonPath)
MakeApp = MakeApp + r'%s\PcdValueCommon.c : %s\n' % (self.OutputPath, PcdValueCommonPath)
MakeApp = MakeApp + '\tcopy /y %s $@\n' % (PcdValueCommonPath)
else:
PcdValueCommonPath = os.path.normpath(mws.join(GlobalData.gGlobalDefines["EDK_TOOLS_PATH"], "Source/C/Common/PcdValueCommon.c"))
Expand Down
2 changes: 1 addition & 1 deletion edk2basetools/Workspace/MetaFileParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1897,7 +1897,7 @@ def _SectionHeaderParser(self):
self._SectionType = []
ArchList = set()
PrivateList = set()
Line = re.sub(',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine)
Line = re.sub(r',[\s]*', TAB_COMMA_SPLIT, self._CurrentLine)
for Item in Line[1:-1].split(TAB_COMMA_SPLIT):
if Item == '':
EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR,
Expand Down

0 comments on commit 29e0483

Please sign in to comment.