Re: [edk2] [Patch] BaseTools: Remove EDKI related logic from Trim tool

2019-03-19 Thread Gao, Liming
Reviewed-by: Liming Gao 

>-Original Message-
>From: Feng, Bob C
>Sent: Friday, March 15, 2019 11:22 PM
>To: edk2-devel@lists.01.org
>Cc: Feng, Bob C ; Gao, Liming 
>Subject: [Patch] 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 
>Cc: Liming Gao 
>---
> 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,
>-\\1\\2
>-\\1  };
>-\\1  (**PeiServices).InstallPpi (PeiServices, );
>-\\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,
>-\\1\\2
>-\\1  };
>-\\1  (**PeiServices).InstallPpi (PeiServices, );
>-\\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_B
>OOT[^,]*,((?:[^;]+\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  SourceFile or directory to be trimmed
>-# @param  TargetFile 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 

[edk2] [Patch] BaseTools: Remove EDKI related logic from Trim tool

2019-03-15 Thread Feng, Bob C
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 
Cc: Liming Gao 
---
 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,
-\\1\\2
-\\1  };
-\\1  (**PeiServices).InstallPpi (PeiServices, );
-\\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,
-\\1\\2
-\\1  };
-\\1  (**PeiServices).InstallPpi (PeiServices, );
-\\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  SourceFile or directory to be trimmed
-# @param  TargetFile 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),
-# ,
-# <*>
-#   };
-#   (**PeiServices).InstallPpi (PeiServices, );
-#
-#   <*>Modify(<*>)
-#   =>  PeiLibPciCfgModify (<*>)
-#
-#   gRT->ReportStatusCode (<*>)
-#   => EfiLibReportStatusCode (<*>)
-#
-#   #include 
-#   =>