[Patch] BaseTools: Clean the ffs folder before generating files in it

Bob Feng

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2965

The content in Guid.xref depends on the files under the corresponding
ffs folder.(refer to the commit 5e9256cd7f54ffd6f1fd9837df92a911fcd2d7c2)
To make Guid.xref update in the incremental build,
clean the files under that ffs folder before generating files in it.

Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
BaseTools/Source/Python/GenFds/FfsFileStatement.py | 3 +++
1 file changed, 3 insertions(+)

diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
index 9fb62b0a91..1c6e59bac7 100644
--- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
@@ -19,10 +19,11 @@ from Common.Misc import GuidStructureByteArrayToGuidString, SaveFileOnChange
import Common.LongFilePathOs as os
from .GuidSection import GuidSection
from .FvImageSection import FvImageSection
from .Ffs import FdfFvFileTypeToFileType
from .GenFdsGlobalVariable import GenFdsGlobalVariable
+import shutil

## generate FFS from FILE
class FileStatement (FileStatementClassObject):
@@ -65,10 +66,12 @@ class FileStatement (FileStatementClassObject):

Str = self.NameGuid
if FvName:
Str += FvName
OutputDir = os.path.join(GenFdsGlobalVariable.FfsDir, Str)
+ if os.path.exists(OutputDir):
+ shutil.rmtree(OutputDir)
if not os.path.exists(OutputDir):

if Dict is None:
Dict = {}

Join devel@edk2.groups.io to automatically receive all group messages.