[edk2] [Patch] BaseTools: Fix the bug that same region print twice in the build log

Yonghong Zhu posted 1 patch 7 years, 3 months ago
Failed in applying to current master (apply log)
BaseTools/Source/Python/GenFds/Fd.py | 58 ++++++++++++++++++++----------------
1 file changed, 32 insertions(+), 26 deletions(-)
[edk2] [Patch] BaseTools: Fix the bug that same region print twice in the build log
Posted by Yonghong Zhu 7 years, 3 months ago
This patch fixed the bug that same region print twice in the build log.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/Python/GenFds/Fd.py | 58 ++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 26 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python/GenFds/Fd.py
index 684b5ce..f330a7e 100644
--- a/BaseTools/Source/Python/GenFds/Fd.py
+++ b/BaseTools/Source/Python/GenFds/Fd.py
@@ -1,9 +1,9 @@
 ## @file
 # process FD generation
 #
-#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
 #  which accompanies this distribution.  The full text of the license may be found at
 #  http://opensource.org/licenses/bsd-license.php
@@ -65,36 +65,42 @@ class FD(FDClassObject):
             GenFdsGlobalVariable.VerboseLogger(FvObj)
 
         GenFdsGlobalVariable.VerboseLogger('################### Gen VTF ####################')
         self.GenVtfFile()
 
-        TempFdBuffer = StringIO.StringIO('')
-        PreviousRegionStart = -1
-        PreviousRegionSize = 1
-        
-        for RegionObj in self.RegionList :
+        HasCapsuleRegion = False
+        for RegionObj in self.RegionList:
             if RegionObj.RegionType == 'CAPSULE':
-                continue
-            if RegionObj.Offset + RegionObj.Size <= PreviousRegionStart:
-                pass
-            elif RegionObj.Offset <= PreviousRegionStart or (RegionObj.Offset >=PreviousRegionStart and RegionObj.Offset < PreviousRegionStart + PreviousRegionSize):
-                pass
-            elif RegionObj.Offset > PreviousRegionStart + PreviousRegionSize:
-                GenFdsGlobalVariable.InfLogger('Padding region starting from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionSize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize)))
-                PadRegion = Region.Region()
-                PadRegion.Offset = PreviousRegionStart + PreviousRegionSize
-                PadRegion.Size = RegionObj.Offset - PadRegion.Offset
-                PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
-            PreviousRegionStart = RegionObj.Offset
-            PreviousRegionSize = RegionObj.Size
-            #
-            # Call each region's AddToBuffer function
-            #
-            if PreviousRegionSize > self.Size:
-                pass
-            GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')
-            RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
+                HasCapsuleRegion = True
+                break
+        if HasCapsuleRegion:
+            TempFdBuffer = StringIO.StringIO('')
+            PreviousRegionStart = -1
+            PreviousRegionSize = 1
+
+            for RegionObj in self.RegionList :
+                if RegionObj.RegionType == 'CAPSULE':
+                    continue
+                if RegionObj.Offset + RegionObj.Size <= PreviousRegionStart:
+                    pass
+                elif RegionObj.Offset <= PreviousRegionStart or (RegionObj.Offset >=PreviousRegionStart and RegionObj.Offset < PreviousRegionStart + PreviousRegionSize):
+                    pass
+                elif RegionObj.Offset > PreviousRegionStart + PreviousRegionSize:
+                    GenFdsGlobalVariable.InfLogger('Padding region starting from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionSize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize)))
+                    PadRegion = Region.Region()
+                    PadRegion.Offset = PreviousRegionStart + PreviousRegionSize
+                    PadRegion.Size = RegionObj.Offset - PadRegion.Offset
+                    PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
+                PreviousRegionStart = RegionObj.Offset
+                PreviousRegionSize = RegionObj.Size
+                #
+                # Call each region's AddToBuffer function
+                #
+                if PreviousRegionSize > self.Size:
+                    pass
+                GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')
+                RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
         
         FdBuffer = StringIO.StringIO('')
         PreviousRegionStart = -1
         PreviousRegionSize = 1
         for RegionObj in self.RegionList :
-- 
2.6.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch] BaseTools: Fix the bug that same region print twice in the build log
Posted by Gao, Liming 7 years, 3 months ago
Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: Zhu, Yonghong
>Sent: Tuesday, September 05, 2017 4:43 PM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>
>Subject: [Patch] BaseTools: Fix the bug that same region print twice in the
>build log
>
>This patch fixed the bug that same region print twice in the build log.
>
>Cc: Liming Gao <liming.gao@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
>---
> BaseTools/Source/Python/GenFds/Fd.py | 58 ++++++++++++++++++++------
>----------
> 1 file changed, 32 insertions(+), 26 deletions(-)
>
>diff --git a/BaseTools/Source/Python/GenFds/Fd.py
>b/BaseTools/Source/Python/GenFds/Fd.py
>index 684b5ce..f330a7e 100644
>--- a/BaseTools/Source/Python/GenFds/Fd.py
>+++ b/BaseTools/Source/Python/GenFds/Fd.py
>@@ -1,9 +1,9 @@
> ## @file
> # process FD generation
> #
>-#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
>+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
> #
> #  This program and the accompanying materials
> #  are licensed and made available under the terms and conditions of the BSD
>License
> #  which accompanies this distribution.  The full text of the license may be
>found at
> #  http://opensource.org/licenses/bsd-license.php
>@@ -65,36 +65,42 @@ class FD(FDClassObject):
>             GenFdsGlobalVariable.VerboseLogger(FvObj)
>
>         GenFdsGlobalVariable.VerboseLogger('################### Gen VTF
>####################')
>         self.GenVtfFile()
>
>-        TempFdBuffer = StringIO.StringIO('')
>-        PreviousRegionStart = -1
>-        PreviousRegionSize = 1
>-
>-        for RegionObj in self.RegionList :
>+        HasCapsuleRegion = False
>+        for RegionObj in self.RegionList:
>             if RegionObj.RegionType == 'CAPSULE':
>-                continue
>-            if RegionObj.Offset + RegionObj.Size <= PreviousRegionStart:
>-                pass
>-            elif RegionObj.Offset <= PreviousRegionStart or
>(RegionObj.Offset >=PreviousRegionStart and RegionObj.Offset <
>PreviousRegionStart + PreviousRegionSize):
>-                pass
>-            elif RegionObj.Offset > PreviousRegionStart + PreviousRegionSize:
>-                GenFdsGlobalVariable.InfLogger('Padding region starting from offset
>0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionSize,
>RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize)))
>-                PadRegion = Region.Region()
>-                PadRegion.Offset = PreviousRegionStart + PreviousRegionSize
>-                PadRegion.Size = RegionObj.Offset - PadRegion.Offset
>-                PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress,
>self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict,
>self.DefineVarDict)
>-            PreviousRegionStart = RegionObj.Offset
>-            PreviousRegionSize = RegionObj.Size
>-            #
>-            # Call each region's AddToBuffer function
>-            #
>-            if PreviousRegionSize > self.Size:
>-                pass
>-            GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer
>function')
>-            RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress,
>self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict,
>self.DefineVarDict)
>+                HasCapsuleRegion = True
>+                break
>+        if HasCapsuleRegion:
>+            TempFdBuffer = StringIO.StringIO('')
>+            PreviousRegionStart = -1
>+            PreviousRegionSize = 1
>+
>+            for RegionObj in self.RegionList :
>+                if RegionObj.RegionType == 'CAPSULE':
>+                    continue
>+                if RegionObj.Offset + RegionObj.Size <= PreviousRegionStart:
>+                    pass
>+                elif RegionObj.Offset <= PreviousRegionStart or
>(RegionObj.Offset >=PreviousRegionStart and RegionObj.Offset <
>PreviousRegionStart + PreviousRegionSize):
>+                    pass
>+                elif RegionObj.Offset > PreviousRegionStart + PreviousRegionSize:
>+                    GenFdsGlobalVariable.InfLogger('Padding region starting from
>offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionSize,
>RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize)))
>+                    PadRegion = Region.Region()
>+                    PadRegion.Offset = PreviousRegionStart + PreviousRegionSize
>+                    PadRegion.Size = RegionObj.Offset - PadRegion.Offset
>+                    PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress,
>self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict,
>self.DefineVarDict)
>+                PreviousRegionStart = RegionObj.Offset
>+                PreviousRegionSize = RegionObj.Size
>+                #
>+                # Call each region's AddToBuffer function
>+                #
>+                if PreviousRegionSize > self.Size:
>+                    pass
>+                GenFdsGlobalVariable.VerboseLogger('Call each region\'s
>AddToBuffer function')
>+                RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress,
>self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict,
>self.DefineVarDict)
>
>         FdBuffer = StringIO.StringIO('')
>         PreviousRegionStart = -1
>         PreviousRegionSize = 1
>         for RegionObj in self.RegionList :
>--
>2.6.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel