summaryrefslogtreecommitdiffstats
path: root/BaseTools
diff options
context:
space:
mode:
authorFeng, Bob C <bob.c.feng@intel.com>2019-03-04 15:05:15 +0800
committerFeng, Bob C <bob.c.feng@intel.com>2019-03-24 16:12:37 +0800
commitf293841f9335c4d5d391279b498a0e09f0cc87da (patch)
tree3f6aeba49b24e08dd25385163158a4f16fc8885e /BaseTools
parent210bd16aff81f6746033dfc0c4cc7c463349bce0 (diff)
downloadedk2-f293841f9335c4d5d391279b498a0e09f0cc87da.tar.gz
edk2-f293841f9335c4d5d391279b498a0e09f0cc87da.tar.bz2
edk2-f293841f9335c4d5d391279b498a0e09f0cc87da.zip
BaseTools: Remove EDKI related logic from Trim tool
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1350 Remove EDKI related logic from Trim tool. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/Python/Trim/Trim.py160
1 files changed, 0 insertions, 160 deletions
diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python/Trim/Trim.py
index 825ed3e5d5..228779b5a9 100644
--- a/BaseTools/Source/Python/Trim/Trim.py
+++ b/BaseTools/Source/Python/Trim/Trim.py
@@ -61,70 +61,6 @@ gAslIncludePattern = re.compile("^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)", re.M
## 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
-gImportCodePatterns = [
- [
- re.compile('^(\s*)\(\*\*PeiServices\)\.PciCfg\s*=\s*([^;\s]+);', re.MULTILINE),
- '''\\1{
-\\1 STATIC EFI_PEI_PPI_DESCRIPTOR gEcpPeiPciCfgPpiList = {
-\\1 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
-\\1 &gEcpPeiPciCfgPpiGuid,
-\\1 \\2
-\\1 };
-\\1 (**PeiServices).InstallPpi (PeiServices, &gEcpPeiPciCfgPpiList);
-\\1}'''
- ],
-
- [
- re.compile('^(\s*)\(\*PeiServices\)->PciCfg\s*=\s*([^;\s]+);', re.MULTILINE),
- '''\\1{
-\\1 STATIC EFI_PEI_PPI_DESCRIPTOR gEcpPeiPciCfgPpiList = {
-\\1 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
-\\1 &gEcpPeiPciCfgPpiGuid,
-\\1 \\2
-\\1 };
-\\1 (**PeiServices).InstallPpi (PeiServices, &gEcpPeiPciCfgPpiList);
-\\1}'''
- ],
-
- [
- re.compile("(\s*).+->Modify[\s\n]*\(", re.MULTILINE),
- '\\1PeiLibPciCfgModify ('
- ],
-
- [
- re.compile("(\W*)gRT->ReportStatusCode[\s\n]*\(", re.MULTILINE),
- '\\1EfiLibReportStatusCode ('
- ],
-
- [
- re.compile('#include\s+EFI_GUID_DEFINITION\s*\(FirmwareFileSystem\)', re.MULTILINE),
- '#include EFI_GUID_DEFINITION (FirmwareFileSystem)\n#include EFI_GUID_DEFINITION (FirmwareFileSystem2)'
- ],
-
- [
- re.compile('gEfiFirmwareFileSystemGuid', re.MULTILINE),
- 'gEfiFirmwareFileSystem2Guid'
- ],
-
- [
- re.compile('EFI_FVH_REVISION', re.MULTILINE),
- 'EFI_FVH_PI_REVISION'
- ],
-
- [
- re.compile("(\s*)\S*CreateEvent\s*\([\s\n]*EFI_EVENT_SIGNAL_READY_TO_BOOT[^,]*,((?:[^;]+\n)+)(\s*\));", re.MULTILINE),
- '\\1EfiCreateEventReadyToBoot (\\2\\3;'
- ],
-
- [
- re.compile("(\s*)\S*CreateEvent\s*\([\s\n]*EFI_EVENT_SIGNAL_LEGACY_BOOT[^,]*,((?:[^;]+\n)+)(\s*\));", re.MULTILINE),
- '\\1EfiCreateEventLegacyBoot (\\2\\3;'
- ],
-# [
-# re.compile("(\W)(PEI_PCI_CFG_PPI)(\W)", re.MULTILINE),
-# '\\1ECP_\\2\\3'
-# ]
-]
## file cache to avoid circular include in ASL file
gIncludedAslFile = []
@@ -494,97 +430,6 @@ def GenerateVfrBinSec(ModuleName, DebugDir, OutputFile):
fStringIO.close ()
fInputfile.close ()
-## Trim EDK source code file(s)
-#
-#
-# @param Source File or directory to be trimmed
-# @param Target File or directory to store the trimmed content
-#
-def TrimEdkSources(Source, Target):
- if os.path.isdir(Source):
- for CurrentDir, Dirs, Files in os.walk(Source):
- if '.svn' in Dirs:
- Dirs.remove('.svn')
- elif "CVS" in Dirs:
- Dirs.remove("CVS")
-
- for FileName in Files:
- Dummy, Ext = os.path.splitext(FileName)
- if Ext.upper() not in ['.C', '.H']: continue
- if Target is None or Target == '':
- TrimEdkSourceCode(
- os.path.join(CurrentDir, FileName),
- os.path.join(CurrentDir, FileName)
- )
- else:
- TrimEdkSourceCode(
- os.path.join(CurrentDir, FileName),
- os.path.join(Target, CurrentDir[len(Source)+1:], FileName)
- )
- else:
- TrimEdkSourceCode(Source, Target)
-
-## Trim one EDK source code file
-#
-# Do following replacement:
-#
-# (**PeiServices\).PciCfg = <*>;
-# => {
-# STATIC EFI_PEI_PPI_DESCRIPTOR gEcpPeiPciCfgPpiList = {
-# (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
-# &gEcpPeiPciCfgPpiGuid,
-# <*>
-# };
-# (**PeiServices).InstallPpi (PeiServices, &gEcpPeiPciCfgPpiList);
-#
-# <*>Modify(<*>)
-# => PeiLibPciCfgModify (<*>)
-#
-# gRT->ReportStatusCode (<*>)
-# => EfiLibReportStatusCode (<*>)
-#
-# #include <LoadFile\.h>
-# => #include <FvLoadFile.h>
-#
-# CreateEvent (EFI_EVENT_SIGNAL_READY_TO_BOOT, <*>)
-# => EfiCreateEventReadyToBoot (<*>)
-#
-# CreateEvent (EFI_EVENT_SIGNAL_LEGACY_BOOT, <*>)
-# => EfiCreateEventLegacyBoot (<*>)
-#
-# @param Source File to be trimmed
-# @param Target File to store the trimmed content
-#
-def TrimEdkSourceCode(Source, Target):
- EdkLogger.verbose("\t%s -> %s" % (Source, Target))
- CreateDirectory(os.path.dirname(Target))
-
- try:
- f = open (Source, 'r')
- except:
- EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=Source)
- # read whole file
- Lines = f.read()
- f.close()
-
- NewLines = None
- for Re, Repl in gImportCodePatterns:
- if NewLines is None:
- NewLines = Re.sub(Repl, Lines)
- else:
- NewLines = Re.sub(Repl, NewLines)
-
- # save all lines if trimmed
- if Source == Target and NewLines == Lines:
- return
-
- try:
- f = open (Target, 'w')
- except:
- EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=Target)
- f.write(NewLines)
- f.close()
-
## Parse command line options
#
@@ -603,9 +448,6 @@ def Options():
help="The input file is EFI image"),
make_option("-a", "--asl-file", dest="FileType", const="Asl", action="store_const",
help="The input file is ASL file"),
- make_option("-8", "--Edk-source-code", dest="FileType", const="EdkSourceCode", action="store_const",
- help="The input file is source code for Edk to be trimmed for ECP"),
-
make_option("-c", "--convert-hex", dest="ConvertHex", action="store_true",
help="Convert standard hex format (0xabcd) to MASM format (abcdh)"),
@@ -680,8 +522,6 @@ def Main():
if CommandOptions.OutputFile is None:
CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii'
TrimAslFile(InputFile, CommandOptions.OutputFile, CommandOptions.IncludePathFile)
- elif CommandOptions.FileType == "EdkSourceCode":
- TrimEdkSources(InputFile, CommandOptions.OutputFile)
elif CommandOptions.FileType == "VfrOffsetBin":
GenerateVfrBinSec(CommandOptions.ModuleName, CommandOptions.DebugDir, CommandOptions.OutputFile)
else :