diff options
Diffstat (limited to 'BaseTools')
27 files changed, 161 insertions, 136 deletions
diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template index 0f110fbb4a..14f3b643c4 100755 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -2017,7 +2017,7 @@ DEFINE CLANGDWARF_X64_DLINK2_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0x22 DEFINE CLANGDWARF_IA32_TARGET = -target i686-pc-linux-gnu
DEFINE CLANGDWARF_X64_TARGET = -target x86_64-pc-linux-gnu
-DEFINE CLANGDWARF_WARNING_OVERRIDES = -Wno-parentheses-equality -Wno-empty-body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-unaligned-access -Wno-unneeded-internal-declaration
+DEFINE CLANGDWARF_WARNING_OVERRIDES = -Wno-parentheses-equality -Wno-empty-body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-unaligned-access
DEFINE CLANGDWARF_ALL_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) DEF(CLANGDWARF_WARNING_OVERRIDES) -fno-stack-protector -mms-bitfields -Wno-address -Wno-shift-negative-value -Wno-unknown-pragmas -Wno-incompatible-library-redeclaration -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -msoft-float -mno-implicit-float -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -funsigned-char -fno-ms-extensions -Wno-null-dereference
###########################
diff --git a/BaseTools/Plugin/CodeQL/CodeQlAnalyzePlugin.py b/BaseTools/Plugin/CodeQL/CodeQlAnalyzePlugin.py index 9734478f8b..88a533cafe 100644 --- a/BaseTools/Plugin/CodeQL/CodeQlAnalyzePlugin.py +++ b/BaseTools/Plugin/CodeQL/CodeQlAnalyzePlugin.py @@ -3,6 +3,7 @@ # A build plugin that analyzes a CodeQL database.
#
# Copyright (c) Microsoft Corporation. All rights reserved.
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
@@ -78,6 +79,11 @@ class CodeQlAnalyzePlugin(IUefiBuildPlugin): # Packages are allowed to specify package-specific query specifiers
# in the package CI YAML file that override the global query specifier.
audit_only = False
+ global_audit_only = builder.env.GetValue("STUART_CODEQL_AUDIT_ONLY")
+ if global_audit_only:
+ if global_audit_only.strip().lower() == "true":
+ audit_only = True
+
query_specifiers = None
package_config_file = Path(os.path.join(
self.package_path, self.package + ".ci.yaml"))
@@ -94,11 +100,6 @@ class CodeQlAnalyzePlugin(IUefiBuildPlugin): f"{str(package_config_file)}")
query_specifiers = plugin_data["QuerySpecifiers"]
- global_audit_only = builder.env.GetValue("STUART_CODEQL_AUDIT_ONLY")
- if global_audit_only:
- if global_audit_only.strip().lower() == "true":
- audit_only = True
-
if audit_only:
logging.info(f"CodeQL Analyze plugin is in audit only mode for "
f"{self.package} ({self.target}).")
diff --git a/BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain_plug_in.yaml b/BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain_plug_in.yaml deleted file mode 100644 index 39c378a926..0000000000 --- a/BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain_plug_in.yaml +++ /dev/null @@ -1,12 +0,0 @@ -## @file
-# Build Plugin used to set the path
-# for the GCC5 ARM/AARCH64 downloaded compilers
-#
-# Copyright (c) Microsoft Corporation.
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-##
-{
- "scope": "global-nix",
- "name": "Linux GCC5 Tool Chain Support",
- "module": "LinuxGcc5ToolChain"
-}
diff --git a/BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain.py b/BaseTools/Plugin/LinuxGccToolChain/LinuxGccToolChain.py index 57866a5159..e7ef3df3b6 100644 --- a/BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain.py +++ b/BaseTools/Plugin/LinuxGccToolChain/LinuxGccToolChain.py @@ -1,7 +1,8 @@ -# @file LinuxGcc5ToolChain.py
-# Plugin to configures paths for GCC5 ARM/AARCH64 Toolchain
+# @file LinuxGccToolChain.py
+# Plugin to configures paths for GCC/GCC5 ARM/AARCH64/RISCV/LOONGARCH64 Toolchain
##
-# This plugin works in conjuncture with the tools_def
+# This plugin sets environment variables used in tools_def.template to specify the GCC compiler
+# for the requested build architecture.
#
# Copyright (c) Microsoft Corporation
# Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
@@ -14,110 +15,120 @@ from edk2toolext.environment.plugintypes.uefi_build_plugin import IUefiBuildPlug from edk2toolext.environment import shell_environment
-class LinuxGcc5ToolChain(IUefiBuildPlugin):
+class LinuxGccToolChain(IUefiBuildPlugin):
def do_post_build(self, thebuilder):
return 0
def do_pre_build(self, thebuilder):
- self.Logger = logging.getLogger("LinuxGcc5ToolChain")
+ self.Logger = logging.getLogger("LinuxGccToolChain")
#
- # GCC5 - The ARM and AARCH64 compilers need their paths set if available
- if thebuilder.env.GetValue("TOOL_CHAIN_TAG") == "GCC5":
+ # In order to keep this plugin backwards compatible with the older GCC5 toolchain tag,
+ # we support setting either the GCC5 or GCC set of env variables required
+ #
+ toolchain = "GCC"
+
+ #
+ # GCC - The non-x86 compilers need their paths set if available. To make this more stable, check for
+ # any substring of GCC in the TOOL_CHAIN_TAG to get the right compiler
+ #
+ if "GCC" in thebuilder.env.GetValue("TOOL_CHAIN_TAG"):
+ if "GCC5" in thebuilder.env.GetValue("TOOL_CHAIN_TAG"):
+ toolchain = "GCC5"
# Start with AARACH64 compiler
- ret = self._check_aarch64()
+ ret = self._check_aarch64(toolchain)
if ret != 0:
self.Logger.critical("Failed in check aarch64")
return ret
# Check arm compiler
- ret = self._check_arm()
+ ret = self._check_arm(toolchain)
if ret != 0:
self.Logger.critical("Failed in check arm")
return ret
# Check RISCV64 compiler
- ret = self._check_riscv64()
+ ret = self._check_riscv64(toolchain)
if ret != 0:
self.Logger.critical("Failed in check riscv64")
return ret
# Check LoongArch64 compiler
- ret = self._check_loongarch64()
+ ret = self._check_loongarch64(toolchain)
if ret != 0:
self.Logger.critical("Failed in check loongarch64")
return ret
return 0
- def _check_arm(self):
+ def _check_arm(self, toolchain):
# check to see if full path already configured
- if shell_environment.GetEnvironment().get_shell_var("GCC5_ARM_PREFIX") is not None:
- self.Logger.info("GCC5_ARM_PREFIX is already set.")
+ if shell_environment.GetEnvironment().get_shell_var(toolchain + "_ARM_PREFIX") is not None:
+ self.Logger.info(toolchain + "_ARM_PREFIX is already set.")
else:
# now check for install dir. If set then set the Prefix
- install_path = shell_environment.GetEnvironment().get_shell_var("GCC5_ARM_INSTALL")
+ install_path = shell_environment.GetEnvironment().get_shell_var(toolchain + "_ARM_INSTALL")
if install_path is None:
return 0
- # make GCC5_ARM_PREFIX to align with tools_def.txt
+ # make the PREFIX to align with tools_def.txt
prefix = os.path.join(install_path, "bin", "arm-none-linux-gnueabihf-")
- shell_environment.GetEnvironment().set_shell_var("GCC5_ARM_PREFIX", prefix)
+ shell_environment.GetEnvironment().set_shell_var(toolchain + "_ARM_PREFIX", prefix)
# now confirm it exists
- if not os.path.exists(shell_environment.GetEnvironment().get_shell_var("GCC5_ARM_PREFIX") + "gcc"):
- self.Logger.error("Path for GCC5_ARM_PREFIX toolchain is invalid")
+ if not os.path.exists(shell_environment.GetEnvironment().get_shell_var(toolchain + "_ARM_PREFIX") + "gcc"):
+ self.Logger.error("Path for " + toolchain + "_ARM_PREFIX toolchain is invalid")
return -2
return 0
- def _check_aarch64(self):
+ def _check_aarch64(self, toolchain):
# check to see if full path already configured
- if shell_environment.GetEnvironment().get_shell_var("GCC5_AARCH64_PREFIX") is not None:
- self.Logger.info("GCC5_AARCH64_PREFIX is already set.")
+ if shell_environment.GetEnvironment().get_shell_var(toolchain + "_AARCH64_PREFIX") is not None:
+ self.Logger.info(toolchain + "_AARCH64_PREFIX is already set.")
else:
# now check for install dir. If set then set the Prefix
install_path = shell_environment.GetEnvironment(
- ).get_shell_var("GCC5_AARCH64_INSTALL")
+ ).get_shell_var(toolchain + "_AARCH64_INSTALL")
if install_path is None:
return 0
- # make GCC5_AARCH64_PREFIX to align with tools_def.txt
+ # make PREFIX to align with tools_def.txt
prefix = os.path.join(install_path, "bin", "aarch64-none-linux-gnu-")
- shell_environment.GetEnvironment().set_shell_var("GCC5_AARCH64_PREFIX", prefix)
+ shell_environment.GetEnvironment().set_shell_var(toolchain + "_AARCH64_PREFIX", prefix)
# now confirm it exists
- if not os.path.exists(shell_environment.GetEnvironment().get_shell_var("GCC5_AARCH64_PREFIX") + "gcc"):
+ if not os.path.exists(shell_environment.GetEnvironment().get_shell_var(toolchain + "_AARCH64_PREFIX") + "gcc"):
self.Logger.error(
- "Path for GCC5_AARCH64_PREFIX toolchain is invalid")
+ "Path for " + toolchain + "_AARCH64_PREFIX toolchain is invalid")
return -2
return 0
- def _check_riscv64(self):
+ def _check_riscv64(self, toolchain):
# now check for install dir. If set then set the Prefix
install_path = shell_environment.GetEnvironment(
- ).get_shell_var("GCC5_RISCV64_INSTALL")
+ ).get_shell_var(toolchain + "_RISCV64_INSTALL")
if install_path is None:
return 0
# check to see if full path already configured
- if shell_environment.GetEnvironment().get_shell_var("GCC5_RISCV64_PREFIX") is not None:
- self.Logger.info("GCC5_RISCV64_PREFIX is already set.")
+ if shell_environment.GetEnvironment().get_shell_var(toolchain + "_RISCV64_PREFIX") is not None:
+ self.Logger.info(toolchain + "_RISCV64_PREFIX is already set.")
else:
- # make GCC5_RISCV64_PREFIX to align with tools_def.txt
+ # make PREFIX to align with tools_def.txt
prefix = os.path.join(install_path, "bin", "riscv64-unknown-elf-")
- shell_environment.GetEnvironment().set_shell_var("GCC5_RISCV64_PREFIX", prefix)
+ shell_environment.GetEnvironment().set_shell_var(toolchain + "_RISCV64_PREFIX", prefix)
# now confirm it exists
- if not os.path.exists(shell_environment.GetEnvironment().get_shell_var("GCC5_RISCV64_PREFIX") + "gcc"):
+ if not os.path.exists(shell_environment.GetEnvironment().get_shell_var(toolchain + "_RISCV64_PREFIX") + "gcc"):
self.Logger.error(
- "Path for GCC5_RISCV64_PREFIX toolchain is invalid")
+ "Path for " + toolchain + "_RISCV64_PREFIX toolchain is invalid")
return -2
# Check if LD_LIBRARY_PATH is set for the libraries of RISC-V GCC toolchain
@@ -129,26 +140,26 @@ class LinuxGcc5ToolChain(IUefiBuildPlugin): return 0
- def _check_loongarch64(self):
+ def _check_loongarch64(self, toolchain):
# check to see if full path already configured
- if shell_environment.GetEnvironment().get_shell_var("GCC5_LOONGARCH64_PREFIX") is not None:
- self.Logger.info("GCC5_LOONGARCH64_PREFIX is already set.")
+ if shell_environment.GetEnvironment().get_shell_var(toolchain + "_LOONGARCH64_PREFIX") is not None:
+ self.Logger.info(toolchain + "_LOONGARCH64_PREFIX is already set.")
else:
# now check for install dir. If set then set the Prefix
install_path = shell_environment.GetEnvironment(
- ).get_shell_var("GCC5_LOONGARCH64_INSTALL")
+ ).get_shell_var(toolchain + "_LOONGARCH64_INSTALL")
if install_path is None:
return 0
- # make GCC5_LOONGARCH64_PREFIX to align with tools_def.txt
+ # make PREFIX to align with tools_def.txt
prefix = os.path.join(install_path, "bin", "loongarch64-unknown-linux-gnu-")
- shell_environment.GetEnvironment().set_shell_var("GCC5_LOONGARCH64_PREFIX", prefix)
+ shell_environment.GetEnvironment().set_shell_var(toolchain + "_LOONGARCH64_PREFIX", prefix)
# now confirm it exists
- if not os.path.exists(shell_environment.GetEnvironment().get_shell_var("GCC5_LOONGARCH64_PREFIX") + "gcc"):
+ if not os.path.exists(shell_environment.GetEnvironment().get_shell_var(toolchain + "_LOONGARCH64_PREFIX") + "gcc"):
self.Logger.error(
- "Path for GCC5_LOONGARCH64_PREFIX toolchain is invalid")
+ "Path for " + toolchain + "_LOONGARCH64_PREFIX toolchain is invalid")
return -2
return 0
diff --git a/BaseTools/Plugin/LinuxGccToolChain/LinuxGccToolChain_plug_in.yaml b/BaseTools/Plugin/LinuxGccToolChain/LinuxGccToolChain_plug_in.yaml new file mode 100644 index 0000000000..dd1e14c34d --- /dev/null +++ b/BaseTools/Plugin/LinuxGccToolChain/LinuxGccToolChain_plug_in.yaml @@ -0,0 +1,12 @@ +## @file
+# This plugin sets environment variables used in tools_def.template to specify the GCC compiler
+# for the requested build architecture.
+#
+# Copyright (c) Microsoft Corporation.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+{
+ "scope": "global-nix",
+ "name": "Linux GCC Tool Chain Support",
+ "module": "LinuxGccToolChain"
+}
diff --git a/BaseTools/Scripts/SetupGit.py b/BaseTools/Scripts/SetupGit.py index 5f93124967..9014eb584c 100644 --- a/BaseTools/Scripts/SetupGit.py +++ b/BaseTools/Scripts/SetupGit.py @@ -150,7 +150,7 @@ if __name__ == '__main__': action='store_true',
required=False)
PARSER.add_argument('-n', '--name', type=str, metavar='repo',
- choices=['edk2', 'edk2-platforms', 'edk2-non-osi'],
+ choices=['edk2', 'edk2-platforms', 'edk2-non-osi', 'edk2-test'],
help='set the repo name to configure for, if not '
'detected automatically',
required=False)
diff --git a/BaseTools/Source/C/Common/Decompress.c b/BaseTools/Source/C/Common/Decompress.c index 0f2bdbffa7..0cf0c4a0a8 100644 --- a/BaseTools/Source/C/Common/Decompress.c +++ b/BaseTools/Source/C/Common/Decompress.c @@ -15,7 +15,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //
// Decompression algorithm begins here
//
+#ifndef UINT8_MAX
#define UINT8_MAX 0xff
+#endif
#define BITBUFSIZ 32
#define MAXMATCH 256
#define THRESHOLD 3
diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c index 9d04fc612e..897045b2be 100644 --- a/BaseTools/Source/C/GenFw/Elf64Convert.c +++ b/BaseTools/Source/C/GenFw/Elf64Convert.c @@ -1482,9 +1482,18 @@ WriteSections64 ( - (SecOffset - SecShdr->sh_addr));
VerboseMsg ("Relocation: 0x%08X", *(UINT32 *)Targ);
break;
+ case R_X86_64_REX_GOTPCRELX:
+ //
+ // This is a relaxable GOTPCREL relocation, and the linker may have
+ // applied this relaxation without updating the relocation type.
+ // In the position independent code model, only transformations
+ // from MOV to LEA are possible for REX-prefixed instructions.
+ //
+ if (Targ[-2] == 0x8d) { // LEA
+ break;
+ }
case R_X86_64_GOTPCREL:
case R_X86_64_GOTPCRELX:
- case R_X86_64_REX_GOTPCRELX:
VerboseMsg ("R_X86_64_GOTPCREL family");
VerboseMsg ("Offset: 0x%08X, Addend: 0x%08X",
(UINT32)(SecOffset + (Rel->r_offset - SecShdr->sh_addr)),
diff --git a/BaseTools/Source/C/Include/Common/BaseTypes.h b/BaseTools/Source/C/Include/Common/BaseTypes.h index e669da894c..5093a2f1f9 100644 --- a/BaseTools/Source/C/Include/Common/BaseTypes.h +++ b/BaseTools/Source/C/Include/Common/BaseTypes.h @@ -4,6 +4,8 @@ This file is stand alone self consistent set of definitions.
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -202,7 +204,7 @@ typedef UINTN RETURN_STATUS; #define ENCODE_ERROR(a) ((RETURN_STATUS)(MAX_BIT | (a)))
#define ENCODE_WARNING(a) ((RETURN_STATUS)(a))
-#define RETURN_ERROR(a) (((INTN)(RETURN_STATUS)(a)) < 0)
+#define RETURN_ERROR(a) (((RETURN_STATUS)(a)) >= MAX_BIT)
#define RETURN_SUCCESS 0
#define RETURN_LOAD_ERROR ENCODE_ERROR (1)
diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py index 4561961141..160e803764 100644 --- a/BaseTools/Source/Python/Ecc/Check.py +++ b/BaseTools/Source/Python/Ecc/Check.py @@ -1092,7 +1092,7 @@ class Check(object): RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)
for Record in RecordSet:
Path = Record[1]
- Path = Path.upper().replace('\X64', '').replace('\IA32', '').replace('\EBC', '').replace('\IPF', '').replace('\ARM', '')
+ Path = Path.upper().replace(r'\X64', '').replace(r'\IA32', '').replace(r'\EBC', '').replace(r'\IPF', '').replace(r'\ARM', '')
if Path in InfPathList:
if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_MODULE_FILE_NO_USE, Record[2]):
EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_MODULE_FILE_NO_USE, OtherMsg="The source file [%s] is existing in module directory but it is not described in INF file." % (Record[2]), BelongsToTable='File', BelongsToItem=Record[0])
diff --git a/BaseTools/Source/Python/Ecc/Configuration.py b/BaseTools/Source/Python/Ecc/Configuration.py index d4aab1d131..9a9ca49eee 100644 --- a/BaseTools/Source/Python/Ecc/Configuration.py +++ b/BaseTools/Source/Python/Ecc/Configuration.py @@ -432,7 +432,7 @@ class Configuration(object): # test that our dict and out class still match in contents.
#
if __name__ == '__main__':
- myconfig = Configuration("BaseTools\Source\Python\Ecc\config.ini")
+ myconfig = Configuration(r"BaseTools\Source\Python\Ecc\config.ini")
for each in myconfig.__dict__:
if each == "Filename":
continue
diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 2d98ac5ead..2ef2847b1b 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -1841,14 +1841,14 @@ class DecParser(MetaFileParser): if EccGlobalData.gConfig.UniCheckPCDInfo == '1' or EccGlobalData.gConfig.UniCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
# check Description, Prompt information
- PatternDesc = re.compile('##\s*([\x21-\x7E\s]*)', re.S)
- PatternPrompt = re.compile('#\s+@Prompt\s+([\x21-\x7E\s]*)', re.S)
+ PatternDesc = re.compile(r'##\s*([\x21-\x7E\s]*)', re.S)
+ PatternPrompt = re.compile(r'#\s+@Prompt\s+([\x21-\x7E\s]*)', re.S)
Description = None
Prompt = None
# check @ValidRange, @ValidList and @Expression format valid
ErrorCodeValid = '0x0 <= %s <= 0xFFFFFFFF'
- PatternValidRangeIn = '(NOT)?\s*(\d+\s*-\s*\d+|0[xX][a-fA-F0-9]+\s*-\s*0[xX][a-fA-F0-9]+|LT\s*\d+|LT\s*0[xX][a-fA-F0-9]+|GT\s*\d+|GT\s*0[xX][a-fA-F0-9]+|LE\s*\d+|LE\s*0[xX][a-fA-F0-9]+|GE\s*\d+|GE\s*0[xX][a-fA-F0-9]+|XOR\s*\d+|XOR\s*0[xX][a-fA-F0-9]+|EQ\s*\d+|EQ\s*0[xX][a-fA-F0-9]+)'
- PatternValidRng = re.compile('^' + '(NOT)?\s*' + PatternValidRangeIn + '$')
+ PatternValidRangeIn = r'(NOT)?\s*(\d+\s*-\s*\d+|0[xX][a-fA-F0-9]+\s*-\s*0[xX][a-fA-F0-9]+|LT\s*\d+|LT\s*0[xX][a-fA-F0-9]+|GT\s*\d+|GT\s*0[xX][a-fA-F0-9]+|LE\s*\d+|LE\s*0[xX][a-fA-F0-9]+|GE\s*\d+|GE\s*0[xX][a-fA-F0-9]+|XOR\s*\d+|XOR\s*0[xX][a-fA-F0-9]+|EQ\s*\d+|EQ\s*0[xX][a-fA-F0-9]+)'
+ PatternValidRng = re.compile('^' + r'(NOT)?\s*' + PatternValidRangeIn + '$')
for Comment in self._Comments:
Comm = Comment[0].strip()
if not Comm:
@@ -2071,7 +2071,7 @@ class UniParser(object): def CheckKeyValid(self, Key, Contents=None):
if not Contents:
Contents = self.FileIn
- KeyPattern = re.compile('#string\s+%s\s+.*?#language.*?".*?"' % Key, re.S)
+ KeyPattern = re.compile(r'#string\s+%s\s+.*?#language.*?".*?"' % Key, re.S)
if KeyPattern.search(Contents):
return True
return False
diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc/c.py index 61ad084fcc..0ebdc1a996 100644 --- a/BaseTools/Source/Python/Ecc/c.py +++ b/BaseTools/Source/Python/Ecc/c.py @@ -43,7 +43,7 @@ def GetArrayPattern(): return p
def GetTypedefFuncPointerPattern():
- p = re.compile('[_\w\s]*\([\w\s]*\*+\s*[_\w]+\s*\)\s*\(.*\)', re.DOTALL)
+ p = re.compile(r'[_\w\s]*\([\w\s]*\*+\s*[_\w]+\s*\)\s*\(.*\)', re.DOTALL)
return p
def GetDB():
diff --git a/BaseTools/Source/Python/Eot/EotGlobalData.py b/BaseTools/Source/Python/Eot/EotGlobalData.py index 3218f86f44..887a7a2595 100644 --- a/BaseTools/Source/Python/Eot/EotGlobalData.py +++ b/BaseTools/Source/Python/Eot/EotGlobalData.py @@ -11,7 +11,7 @@ from Common.LongFilePathSupport import OpenLongFilePath as open gEFI_SOURCE = ''
gEDK_SOURCE = ''
gWORKSPACE = ''
-gSHELL_INF = 'Application\Shell'
+gSHELL_INF = r'Application\Shell'
gMAKE_FILE = ''
gDSC_FILE = ''
gFV_FILE = []
diff --git a/BaseTools/Source/Python/Eot/c.py b/BaseTools/Source/Python/Eot/c.py index dd9530fed6..a85564d600 100644 --- a/BaseTools/Source/Python/Eot/c.py +++ b/BaseTools/Source/Python/Eot/c.py @@ -54,7 +54,7 @@ def GetArrayPattern(): # @return p: the pattern of function pointer
#
def GetTypedefFuncPointerPattern():
- p = re.compile('[_\w\s]*\([\w\s]*\*+\s*[_\w]+\s*\)\s*\(.*\)', re.DOTALL)
+ p = re.compile(r'[_\w\s]*\([\w\s]*\*+\s*[_\w]+\s*\)\s*\(.*\)', re.DOTALL)
return p
## GetDB() method
diff --git a/BaseTools/Source/Python/UPT/Library/CommentParsing.py b/BaseTools/Source/Python/UPT/Library/CommentParsing.py index 7ba9830d34..7b1ce05493 100644 --- a/BaseTools/Source/Python/UPT/Library/CommentParsing.py +++ b/BaseTools/Source/Python/UPT/Library/CommentParsing.py @@ -238,7 +238,7 @@ def ParseDecPcdGenericComment (GenericComment, ContainerFile, TokenSpaceGuidCNam #
# To replace Macro
#
- MACRO_PATTERN = '[\t\s]*\$\([A-Z][_A-Z0-9]*\)'
+ MACRO_PATTERN = r'[\t\s]*\$\([A-Z][_A-Z0-9]*\)'
MatchedStrs = re.findall(MACRO_PATTERN, Comment)
for MatchedStr in MatchedStrs:
if MatchedStr:
diff --git a/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py b/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py index 7718ca12e5..2c0750efe4 100644 --- a/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py +++ b/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py @@ -66,13 +66,13 @@ class _ExprError(Exception): ## _ExprBase
#
class _ExprBase:
- HEX_PATTERN = '[\t\s]*0[xX][a-fA-F0-9]+'
- INT_PATTERN = '[\t\s]*[0-9]+'
- MACRO_PATTERN = '[\t\s]*\$\(([A-Z][_A-Z0-9]*)\)'
+ HEX_PATTERN = r'[\t\s]*0[xX][a-fA-F0-9]+'
+ INT_PATTERN = r'[\t\s]*[0-9]+'
+ MACRO_PATTERN = r'[\t\s]*\$\(([A-Z][_A-Z0-9]*)\)'
PCD_PATTERN = \
- '[\t\s]*[_a-zA-Z][a-zA-Z0-9_]*[\t\s]*\.[\t\s]*[_a-zA-Z][a-zA-Z0-9_]*'
- QUOTED_PATTERN = '[\t\s]*L?"[^"]*"'
- BOOL_PATTERN = '[\t\s]*(true|True|TRUE|false|False|FALSE)'
+ r'[\t\s]*[_a-zA-Z][a-zA-Z0-9_]*[\t\s]*\.[\t\s]*[_a-zA-Z][a-zA-Z0-9_]*'
+ QUOTED_PATTERN = r'[\t\s]*L?"[^"]*"'
+ BOOL_PATTERN = r'[\t\s]*(true|True|TRUE|false|False|FALSE)'
def __init__(self, Token):
self.Token = Token
self.Index = 0
@@ -303,9 +303,9 @@ class _LogicalExpressionParser(_ExprBase): ## _ValidRangeExpressionParser
#
class _ValidRangeExpressionParser(_ExprBase):
- INT_RANGE_PATTERN = '[\t\s]*[0-9]+[\t\s]*-[\t\s]*[0-9]+'
+ INT_RANGE_PATTERN = r'[\t\s]*[0-9]+[\t\s]*-[\t\s]*[0-9]+'
HEX_RANGE_PATTERN = \
- '[\t\s]*0[xX][a-fA-F0-9]+[\t\s]*-[\t\s]*0[xX][a-fA-F0-9]+'
+ r'[\t\s]*0[xX][a-fA-F0-9]+[\t\s]*-[\t\s]*0[xX][a-fA-F0-9]+'
def __init__(self, Token):
_ExprBase.__init__(self, Token)
self.Parens = 0
@@ -407,7 +407,7 @@ class _ValidRangeExpressionParser(_ExprBase): ## _ValidListExpressionParser
#
class _ValidListExpressionParser(_ExprBase):
- VALID_LIST_PATTERN = '(0[xX][0-9a-fA-F]+|[0-9]+)([\t\s]*,[\t\s]*(0[xX][0-9a-fA-F]+|[0-9]+))*'
+ VALID_LIST_PATTERN = r'(0[xX][0-9a-fA-F]+|[0-9]+)([\t\s]*,[\t\s]*(0[xX][0-9a-fA-F]+|[0-9]+))*'
def __init__(self, Token):
_ExprBase.__init__(self, Token)
self.NUM = 1
diff --git a/BaseTools/Source/Python/UPT/Library/Misc.py b/BaseTools/Source/Python/UPT/Library/Misc.py index 77ba3584e0..f3688de4b1 100644 --- a/BaseTools/Source/Python/UPT/Library/Misc.py +++ b/BaseTools/Source/Python/UPT/Library/Misc.py @@ -69,11 +69,11 @@ def GuidStringToGuidStructureString(Guid): def CheckGuidRegFormat(GuidValue):
## Regular expression used to find out register format of GUID
#
- RegFormatGuidPattern = re.compile("^\s*([0-9a-fA-F]){8}-"
+ RegFormatGuidPattern = re.compile(r"^\s*([0-9a-fA-F]){8}-"
"([0-9a-fA-F]){4}-"
"([0-9a-fA-F]){4}-"
"([0-9a-fA-F]){4}-"
- "([0-9a-fA-F]){12}\s*$")
+ r"([0-9a-fA-F]){12}\s*$")
if RegFormatGuidPattern.match(GuidValue):
return True
@@ -837,8 +837,8 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo): ST.ERR_FILE_OPEN_FAILURE,
File=FullFileName)
- ReFileGuidPattern = re.compile("^\s*FILE_GUID\s*=.*$")
- ReVerStringPattern = re.compile("^\s*VERSION_STRING\s*=.*$")
+ ReFileGuidPattern = re.compile(r"^\s*FILE_GUID\s*=.*$")
+ ReVerStringPattern = re.compile(r"^\s*VERSION_STRING\s*=.*$")
FileLinesList = ProcessLineExtender(FileLinesList)
@@ -978,7 +978,7 @@ def ValidateUNIFilePath(Path): #
# Check if the file name is valid according to the DEC and INF specification
#
- Pattern = '[a-zA-Z0-9_][a-zA-Z0-9_\-\.]*'
+ Pattern = r'[a-zA-Z0-9_][a-zA-Z0-9_\-\.]*'
FileName = Path.replace(Suffix, '')
InvalidCh = re.sub(Pattern, '', FileName)
if InvalidCh:
diff --git a/BaseTools/Source/Python/UPT/Library/StringUtils.py b/BaseTools/Source/Python/UPT/Library/StringUtils.py index fbc5177caf..a6f47d0dd7 100644 --- a/BaseTools/Source/Python/UPT/Library/StringUtils.py +++ b/BaseTools/Source/Python/UPT/Library/StringUtils.py @@ -23,7 +23,7 @@ from Logger import StringTable as ST #
# Regular expression for matching macro used in DSC/DEC/INF file inclusion
#
-gMACRO_PATTERN = re.compile("\$\(([_A-Z][_A-Z0-9]*)\)", re.UNICODE)
+gMACRO_PATTERN = re.compile(r"\$\(([_A-Z][_A-Z0-9]*)\)", re.UNICODE)
## GetSplitValueList
#
diff --git a/BaseTools/Source/Python/UPT/Parser/DecParserMisc.py b/BaseTools/Source/Python/UPT/Parser/DecParserMisc.py index 27990467d1..92dbcaaabe 100644 --- a/BaseTools/Source/Python/UPT/Parser/DecParserMisc.py +++ b/BaseTools/Source/Python/UPT/Parser/DecParserMisc.py @@ -25,7 +25,7 @@ from Library.ExpressionValidate import IsValidStringTest from Library.Misc import CheckGuidRegFormat
TOOL_NAME = 'DecParser'
-VERSION_PATTERN = '[0-9]+(\.[0-9]+)?'
+VERSION_PATTERN = r'[0-9]+(\.[0-9]+)?'
CVAR_PATTERN = '[_a-zA-Z][a-zA-Z0-9_]*'
PCD_TOKEN_PATTERN = '(0[xX]0*[a-fA-F0-9]{1,8})|([0-9]+)'
MACRO_PATTERN = '[A-Z][_A-Z0-9]*'
diff --git a/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py b/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py index 992b609120..fb646191b1 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py +++ b/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py @@ -53,12 +53,12 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo, CurrentInfFileName): #
# To deal with library instance specified by GUID and version
#
- RegFormatGuidPattern = re.compile("\s*([0-9a-fA-F]){8}-"
+ RegFormatGuidPattern = re.compile(r"\s*([0-9a-fA-F]){8}-"
"([0-9a-fA-F]){4}-"
"([0-9a-fA-F]){4}-"
"([0-9a-fA-F]){4}-"
- "([0-9a-fA-F]){12}\s*")
- VersionPattern = re.compile('[\t\s]*\d+(\.\d+)?[\t\s]*')
+ r"([0-9a-fA-F]){12}\s*")
+ VersionPattern = re.compile(r'[\t\s]*\d+(\.\d+)?[\t\s]*')
GuidMatchedObj = RegFormatGuidPattern.search(String)
if String.upper().startswith('GUID') and GuidMatchedObj and 'Version' in String:
@@ -75,8 +75,8 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo, CurrentInfFileName): FileLinesList = GetFileLineContent(String, WorkSpace, LineNo, OriginalString)
- ReFindFileGuidPattern = re.compile("^\s*FILE_GUID\s*=.*$")
- ReFindVerStringPattern = re.compile("^\s*VERSION_STRING\s*=.*$")
+ ReFindFileGuidPattern = re.compile(r"^\s*FILE_GUID\s*=.*$")
+ ReFindVerStringPattern = re.compile(r"^\s*VERSION_STRING\s*=.*$")
for Line in FileLinesList:
if ReFindFileGuidPattern.match(Line):
@@ -106,8 +106,8 @@ def GetPackageListInfo(FileNameString, WorkSpace, LineNo): FileLinesList = GetFileLineContent(FileNameString, WorkSpace, LineNo, '')
- RePackageHeader = re.compile('^\s*\[Packages.*\].*$')
- ReDefineHeader = re.compile('^\s*\[Defines].*$')
+ RePackageHeader = re.compile(r'^\s*\[Packages.*\].*$')
+ ReDefineHeader = re.compile(r'^\s*\[Defines].*$')
PackageHederFlag = False
DefineHeaderFlag = False
@@ -255,8 +255,8 @@ def GetGuidVerFormLibInstance(Guid, Version, WorkSpace, CurrentInfFileName): FileLinesList = InfFileObj.readlines()
FileLinesList = ProcessLineExtender(FileLinesList)
- ReFindFileGuidPattern = re.compile("^\s*FILE_GUID\s*=.*$")
- ReFindVerStringPattern = re.compile("^\s*VERSION_STRING\s*=.*$")
+ ReFindFileGuidPattern = re.compile(r"^\s*FILE_GUID\s*=.*$")
+ ReFindVerStringPattern = re.compile(r"^\s*VERSION_STRING\s*=.*$")
for Line in FileLinesList:
if ReFindFileGuidPattern.match(Line):
diff --git a/BaseTools/Source/Python/UPT/Parser/InfDefineSectionParser.py b/BaseTools/Source/Python/UPT/Parser/InfDefineSectionParser.py index a63e40e617..9edcc2cb3f 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfDefineSectionParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfDefineSectionParser.py @@ -40,7 +40,7 @@ def GetValidateArchList(LineContent): TempArch = GetSplitValueList(TempArch, '(', 1)[0]
- ArchList = re.split('\s+', TempArch)
+ ArchList = re.split(r'\s+', TempArch)
NewArchList = []
for Arch in ArchList:
if IsValidArch(Arch):
diff --git a/BaseTools/Source/Python/UPT/Parser/InfParserMisc.py b/BaseTools/Source/Python/UPT/Parser/InfParserMisc.py index d01ae9aa02..eb768b9a12 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfParserMisc.py +++ b/BaseTools/Source/Python/UPT/Parser/InfParserMisc.py @@ -109,7 +109,7 @@ def InfExpandMacro(Content, LineInfo, GlobalMacros=None, SectionMacros=None, Fla return Content
else:
for Macro in MacroUsed:
- gQuotedMacro = re.compile(".*\".*\$\(%s\).*\".*"%(Macro))
+ gQuotedMacro = re.compile(r".*\".*\$\(%s\).*\".*"%(Macro))
if not gQuotedMacro.match(Content):
#
# Still have MACROs can't be expanded.
@@ -130,8 +130,8 @@ def IsBinaryInf(FileLineList): if not FileLineList:
return False
- ReIsSourcesSection = re.compile("^\s*\[Sources.*\]\s.*$", re.IGNORECASE)
- ReIsBinarySection = re.compile("^\s*\[Binaries.*\]\s.*$", re.IGNORECASE)
+ ReIsSourcesSection = re.compile(r"^\s*\[Sources.*\]\s.*$", re.IGNORECASE)
+ ReIsBinarySection = re.compile(r"^\s*\[Binaries.*\]\s.*$", re.IGNORECASE)
BinarySectionFoundFlag = False
for Line in FileLineList:
@@ -155,7 +155,7 @@ def IsBinaryInf(FileLineList): # @return Flag
#
def IsLibInstanceInfo(String):
- ReIsLibInstance = re.compile("^\s*##\s*@LIB_INSTANCES\s*$")
+ ReIsLibInstance = re.compile(r"^\s*##\s*@LIB_INSTANCES\s*$")
if ReIsLibInstance.match(String):
return True
else:
@@ -171,7 +171,7 @@ def IsLibInstanceInfo(String): # @return Flag
#
def IsAsBuildOptionInfo(String):
- ReIsAsBuildInstance = re.compile("^\s*##\s*@AsBuilt\s*$")
+ ReIsAsBuildInstance = re.compile(r"^\s*##\s*@AsBuilt\s*$")
if ReIsAsBuildInstance.match(String):
return True
else:
diff --git a/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py b/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py index da92fe5d3e..b1f8135bc7 100644 --- a/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py +++ b/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py @@ -747,12 +747,12 @@ class DecPomAlignment(PackageObject): #
# deal with "NOT EQ", "NOT LT", "NOT GT", "NOT LE", "NOT GE", "NOT NOT"
#
- NOTNOT_Pattern = '[\t\s]*NOT[\t\s]+NOT[\t\s]*'
- NOTGE_Pattern = '[\t\s]*NOT[\t\s]+GE[\t\s]*'
- NOTLE_Pattern = '[\t\s]*NOT[\t\s]+LE[\t\s]*'
- NOTGT_Pattern = '[\t\s]*NOT[\t\s]+GT[\t\s]*'
- NOTLT_Pattern = '[\t\s]*NOT[\t\s]+LT[\t\s]*'
- NOTEQ_Pattern = '[\t\s]*NOT[\t\s]+EQ[\t\s]*'
+ NOTNOT_Pattern = r'[\t\s]*NOT[\t\s]+NOT[\t\s]*'
+ NOTGE_Pattern = r'[\t\s]*NOT[\t\s]+GE[\t\s]*'
+ NOTLE_Pattern = r'[\t\s]*NOT[\t\s]+LE[\t\s]*'
+ NOTGT_Pattern = r'[\t\s]*NOT[\t\s]+GT[\t\s]*'
+ NOTLT_Pattern = r'[\t\s]*NOT[\t\s]+LT[\t\s]*'
+ NOTEQ_Pattern = r'[\t\s]*NOT[\t\s]+EQ[\t\s]*'
ReplaceValue = re.compile(NOTNOT_Pattern).sub('', ReplaceValue)
ReplaceValue = re.compile(NOTLT_Pattern).sub('x >= ', ReplaceValue)
ReplaceValue = re.compile(NOTGT_Pattern).sub('x <= ', ReplaceValue)
@@ -785,7 +785,7 @@ class DecPomAlignment(PackageObject): if ReplaceValue.find('!') >= 0 and ReplaceValue[ReplaceValue.index('!') + 1] != '=':
ReplaceValue = ReplaceValue.replace('!', ' not ')
if '.' in ReplaceValue:
- Pattern = '[a-zA-Z0-9]{1,}\.[a-zA-Z0-9]{1,}'
+ Pattern = r'[a-zA-Z0-9]{1,}\.[a-zA-Z0-9]{1,}'
MatchedList = re.findall(Pattern, ReplaceValue)
for MatchedItem in MatchedList:
if MatchedItem not in self.PcdDefaultValueDict:
@@ -814,7 +814,7 @@ class DecPomAlignment(PackageObject): #
# Delete the 'L' prefix of a quoted string, this operation is for eval()
#
- QUOTED_PATTERN = '[\t\s]*L?"[^"]*"'
+ QUOTED_PATTERN = r'[\t\s]*L?"[^"]*"'
QuotedMatchedObj = re.search(QUOTED_PATTERN, Expression)
if QuotedMatchedObj:
MatchedStr = QuotedMatchedObj.group().strip()
@@ -847,7 +847,7 @@ class DecPomAlignment(PackageObject): #
# Delete the 'L' prefix of a quoted string, this operation is for eval()
#
- QUOTED_PATTERN = '[\t\s]*L?"[^"]*"'
+ QUOTED_PATTERN = r'[\t\s]*L?"[^"]*"'
QuotedMatchedObj = re.search(QUOTED_PATTERN, DefaultValue)
if QuotedMatchedObj:
MatchedStr = QuotedMatchedObj.group().strip()
diff --git a/BaseTools/Source/Python/UPT/Xml/IniToXml.py b/BaseTools/Source/Python/UPT/Xml/IniToXml.py index 3dc4001313..2c01c97fa5 100644 --- a/BaseTools/Source/Python/UPT/Xml/IniToXml.py +++ b/BaseTools/Source/Python/UPT/Xml/IniToXml.py @@ -200,9 +200,9 @@ def ValidateRegValues(Key, Value): ('[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}'
'-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}',
ST.ERR_GUID_VALUE % Value),
- 'Version' : ('[0-9]+(\.[0-9]+)?', ST.ERR_VERSION_VALUE % \
+ 'Version' : (r'[0-9]+(\.[0-9]+)?', ST.ERR_VERSION_VALUE % \
(Key, Value)),
- 'XmlSpecification' : ('1\.1', ST.ERR_VERSION_XMLSPEC % Value)
+ 'XmlSpecification' : (r'1\.1', ST.ERR_VERSION_XMLSPEC % Value)
}
if Key not in ValidateMap:
return True, ''
diff --git a/BaseTools/Source/Python/UPT/Xml/PcdXml.py b/BaseTools/Source/Python/UPT/Xml/PcdXml.py index bbcee45a01..ca95c820c9 100644 --- a/BaseTools/Source/Python/UPT/Xml/PcdXml.py +++ b/BaseTools/Source/Python/UPT/Xml/PcdXml.py @@ -100,11 +100,11 @@ class PcdErrorXml(object): def TransferValidRange2Expr(self, TokenSpaceGuidCName, CName, ValidRange):
if self.Expression:
pass
- INT_RANGE_PATTERN1 = '[\t\s]*[0-9]+[\t\s]*-[\t\s]*[0-9]+'
- INT_RANGE_PATTERN2 = '[\t\s]*(LT|GT|LE|GE|XOR|EQ)[\t\s]+\d+[\t\s]*'
+ INT_RANGE_PATTERN1 = r'[\t\s]*[0-9]+[\t\s]*-[\t\s]*[0-9]+'
+ INT_RANGE_PATTERN2 = r'[\t\s]*(LT|GT|LE|GE|XOR|EQ)[\t\s]+\d+[\t\s]*'
HEX_RANGE_PATTERN1 = \
- '[\t\s]*0[xX][a-fA-F0-9]+[\t\s]*-[\t\s]*0[xX][a-fA-F0-9]+'
- HEX_RANGE_PATTERN2 = '[\t\s]*(LT|GT|LE|GE|XOR|EQ)[\t\s]+0[xX][a-fA-F0-9]+[\t\s]*'
+ r'[\t\s]*0[xX][a-fA-F0-9]+[\t\s]*-[\t\s]*0[xX][a-fA-F0-9]+'
+ HEX_RANGE_PATTERN2 = r'[\t\s]*(LT|GT|LE|GE|XOR|EQ)[\t\s]+0[xX][a-fA-F0-9]+[\t\s]*'
IntMatch1 = re.compile(INT_RANGE_PATTERN1)
IntMatch2 = re.compile(INT_RANGE_PATTERN2)
HexMatch1 = re.compile(HEX_RANGE_PATTERN1)
@@ -158,18 +158,18 @@ class PcdErrorXml(object): pass
PCD_PATTERN = \
- '[\t\s]*[_a-zA-Z][a-zA-Z0-9_]*[\t\s]*\.[\t\s]*[_a-zA-Z][a-zA-Z0-9_]*[\t\s]*'
+ r'[\t\s]*[_a-zA-Z][a-zA-Z0-9_]*[\t\s]*\.[\t\s]*[_a-zA-Z][a-zA-Z0-9_]*[\t\s]*'
IntPattern1 = \
- '[\t\s]*\([\t\s]*'+PCD_PATTERN+'[\t\s]+GE[\t\s]+\d+[\t\s]*\)[\t\s]+AND[\t\s]+\([\t\s]*'+\
- PCD_PATTERN+'[\t\s]+LE[\t\s]+\d+[\t\s]*\)'
+ r'[\t\s]*\([\t\s]*'+PCD_PATTERN+r'[\t\s]+GE[\t\s]+\d+[\t\s]*\)[\t\s]+AND[\t\s]+\([\t\s]*'+\
+ PCD_PATTERN+r'[\t\s]+LE[\t\s]+\d+[\t\s]*\)'
IntPattern1 = IntPattern1.replace(' ', '')
- IntPattern2 = '[\t\s]*'+PCD_PATTERN+'[\t\s]+(LT|GT|LE|GE|XOR|EQ)[\t\s]+\d+[\t\s]*'
+ IntPattern2 = r'[\t\s]*'+PCD_PATTERN+r'[\t\s]+(LT|GT|LE|GE|XOR|EQ)[\t\s]+\d+[\t\s]*'
HexPattern1 = \
- '[\t\s]*\([\t\s]*'+PCD_PATTERN+'[\t\s]+GE[\t\s]+0[xX][0-9a-fA-F]+[\t\s]*\)[\t\s]+AND[\t\s]+\([\t\s]*'+\
- PCD_PATTERN+'[\t\s]+LE[\t\s]+0[xX][0-9a-fA-F]+[\t\s]*\)'
+ r'[\t\s]*\([\t\s]*'+PCD_PATTERN+r'[\t\s]+GE[\t\s]+0[xX][0-9a-fA-F]+[\t\s]*\)[\t\s]+AND[\t\s]+\([\t\s]*'+\
+ PCD_PATTERN+r'[\t\s]+LE[\t\s]+0[xX][0-9a-fA-F]+[\t\s]*\)'
HexPattern1 = HexPattern1.replace(' ', '')
- HexPattern2 = '[\t\s]*'+PCD_PATTERN+'[\t\s]+(LT|GT|LE|GE|XOR|EQ)[\t\s]+0[xX][0-9a-zA-Z]+[\t\s]*'
+ HexPattern2 = r'[\t\s]*'+PCD_PATTERN+r'[\t\s]+(LT|GT|LE|GE|XOR|EQ)[\t\s]+0[xX][0-9a-zA-Z]+[\t\s]*'
#
# Do the Hex1 conversion
@@ -180,7 +180,7 @@ class PcdErrorXml(object): #
# To match items on both sides of '-'
#
- RangeItemList = re.compile('[\t\s]*0[xX][0-9a-fA-F]+[\t\s]*').findall(HexMatchedItem)
+ RangeItemList = re.compile(r'[\t\s]*0[xX][0-9a-fA-F]+[\t\s]*').findall(HexMatchedItem)
if RangeItemList and len(RangeItemList) == 2:
HexRangeDict[HexMatchedItem] = RangeItemList
@@ -204,7 +204,7 @@ class PcdErrorXml(object): #
# To match items on both sides of '-'
#
- RangeItemList = re.compile('[\t\s]*\d+[\t\s]*').findall(MatchedItem)
+ RangeItemList = re.compile(r'[\t\s]*\d+[\t\s]*').findall(MatchedItem)
if RangeItemList and len(RangeItemList) == 2:
IntRangeDict[MatchedItem] = RangeItemList
diff --git a/BaseTools/Source/Python/UPT/Xml/XmlParser.py b/BaseTools/Source/Python/UPT/Xml/XmlParser.py index 8e22a280f6..f239588831 100644 --- a/BaseTools/Source/Python/UPT/Xml/XmlParser.py +++ b/BaseTools/Source/Python/UPT/Xml/XmlParser.py @@ -281,33 +281,33 @@ class DistributionPackageXml(object): #
XmlContent = \
re.sub(r'[\s\r\n]*SupArchList[\s\r\n]*=[\s\r\n]*"[\s\r\n]*COMMON'
- '[\s\r\n]*"', '', XmlContent)
+ r'[\s\r\n]*"', '', XmlContent)
XmlContent = \
re.sub(r'[\s\r\n]*SupArchList[\s\r\n]*=[\s\r\n]*"[\s\r\n]*common'
- '[\s\r\n]*"', '', XmlContent)
+ r'[\s\r\n]*"', '', XmlContent)
#
# Remove <SupArchList> COMMON </SupArchList>
#
XmlContent = \
re.sub(r'[\s\r\n]*<SupArchList>[\s\r\n]*COMMON[\s\r\n]*'
- '</SupArchList>[\s\r\n]*', '', XmlContent)
+ r'</SupArchList>[\s\r\n]*', '', XmlContent)
#
# Remove <SupArchList> common </SupArchList>
#
XmlContent = \
re.sub(r'[\s\r\n]*<SupArchList>[\s\r\n]*'
- 'common[\s\r\n]*</SupArchList>[\s\r\n]*', '', XmlContent)
+ r'common[\s\r\n]*</SupArchList>[\s\r\n]*', '', XmlContent)
#
# Remove SupModList="COMMON" or "common"
#
XmlContent = \
re.sub(r'[\s\r\n]*SupModList[\s\r\n]*=[\s\r\n]*"[\s\r\n]*COMMON'
- '[\s\r\n]*"', '', XmlContent)
+ r'[\s\r\n]*"', '', XmlContent)
XmlContent = \
re.sub(r'[\s\r\n]*SupModList[\s\r\n]*=[\s\r\n]*"[\s\r\n]*common'
- '[\s\r\n]*"', '', XmlContent)
+ r'[\s\r\n]*"', '', XmlContent)
return XmlContent
|