From: "Feng, Bob C" <bob.c.feng@intel.com>
To: edk2-devel@lists.01.org
Cc: Bob Feng <bob.c.feng@intel.com>, Liming Gao <liming.gao@intel.com>
Subject: [Patch] BaseTools: Remove EDKI related logic from Trim tool
Date: Fri, 15 Mar 2019 23:22:26 +0800 [thread overview]
Message-ID: <20190315152226.9788-1-bob.c.feng@intel.com> (raw)
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>
---
BaseTools/Source/Python/Trim/Trim.py | 160 ---------------------------
1 file changed, 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
@@ -59,74 +59,10 @@ gLongNumberPattern = re.compile("(?<=[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?L
## Regular expression for matching "Include ()" in asl file
gAslIncludePattern = re.compile("^(\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
-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 = []
## Trim preprocessed source code
@@ -492,101 +428,10 @@ def GenerateVfrBinSec(ModuleName, DebugDir, OutputFile):
EdkLogger.error("Trim", FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the file been locked or using by other applications." %OutputFile, None)
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
#
# Using standard Python module optparse to parse command line option of this tool.
#
@@ -601,13 +446,10 @@ def Options():
help="The input file is preprocessed VFR file"),
make_option("--Vfr-Uni-Offset", dest="FileType", const="VfrOffsetBin", action="store_const",
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)"),
make_option("-l", "--trim-long", dest="TrimLong", action="store_true",
help="Remove postfix of long number"),
@@ -678,12 +520,10 @@ def Main():
TrimPreprocessedVfr(InputFile, CommandOptions.OutputFile)
elif CommandOptions.FileType == "Asl":
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 :
if CommandOptions.OutputFile is None:
CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii'
--
2.18.0.windows.1
next reply other threads:[~2019-03-15 15:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-15 15:22 Feng, Bob C [this message]
2019-03-19 7:24 ` [Patch] BaseTools: Remove EDKI related logic from Trim tool Gao, Liming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190315152226.9788-1-bob.c.feng@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox