[edk2-devel] [PATCH 1/2] BaseTools:Fix GenFds multi-thread build fails if enable build cache
Fan, ZhijuX
zhijux.fan at intel.com
Mon Jul 29 06:02:03 UTC 2019
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1923
The GenFds multi-thread will build fail if enable the build cache.
1. First, produce the build cache:
edk2>build -p OvmfPkg\OvmfPkgIa32X64.dsc -a IA32 -a X64 -t VS2015x86 -n 5
--genfds-multi-thread --hash --binary-destination=BinCache
2. Remove the build folder:
edk2>rmdir Build /s /q
3. Clean build with build cache and GenFds multi-thread enabled together:
edk2>build -p OvmfPkg\OvmfPkgIa32X64.dsc -a IA32 -a X64 -t VS2015x86 -n 5
--genfds-multi-thread --hash --binary-source=BinCache
If disable GenFds multi-thread, the build cache can work well
This patch is going to fix that issue.
Cc: Bob Feng <bob.c.feng at intel.com>
Cc: Liming Gao <liming.gao at intel.com>
Cc: Steven Shi <steven.shi at intel.com>
Signed-off-by: Zhiju.Fan <zhijux.fan at intel.com>
---
BaseTools/Source/Python/AutoGen/ModuleAutoGen.py | 41 +++++++++++++++++-------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
index 36bbaffa56..4bb72eb10d 100644
--- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
@@ -1249,6 +1249,7 @@ class ModuleAutoGen(AutoGen):
retVal = set()
OutputDir = self.OutputDir.replace('\\', '/').strip('/')
DebugDir = self.DebugDir.replace('\\', '/').strip('/')
+ FfsOutputDir = self.FfsOutputDir.replace('\\', '/').rstrip('/')
for Item in self.CodaTargetList:
File = Item.Target.Path.replace('\\', '/').strip('/').replace(DebugDir, '').replace(OutputDir, '').strip('/')
retVal.add(File)
@@ -1264,6 +1265,11 @@ class ModuleAutoGen(AutoGen):
if File.lower().endswith('.pdb'):
retVal.add(File)
+ for Root, Dirs, Files in os.walk(FfsOutputDir):
+ for File in Files:
+ if File.lower().endswith('.ffs'):
+ retVal.add(File)
+
return retVal
## Create AsBuilt INF file the module
@@ -1594,8 +1600,16 @@ class ModuleAutoGen(AutoGen):
self.IsAsBuiltInfCreated = True
+ def CacheCopyFile(self, OriginDir, CopyDir, File):
+ sub_dir = os.path.relpath(File, CopyDir)
+ destination_file = os.path.join(OriginDir, sub_dir)
+ destination_dir = os.path.dirname(destination_file)
+ CreateDirectory(destination_dir)
+ CopyFileOnChange(File, destination_dir)
+
def CopyModuleToCache(self):
FileDir = path.join(GlobalData.gBinCacheDest, self.PlatformInfo.Name, self.BuildTarget + "_" + self.ToolChain, self.Arch, self.SourceDir, self.MetaFile.BaseName)
+ FfsDir = path.join(GlobalData.gBinCacheDest, self.PlatformInfo.OutputDir, self.BuildTarget + "_" + self.ToolChain, TAB_FV_DIRECTORY, "Ffs", self.Guid + self.Name)
CreateDirectory (FileDir)
HashFile = path.join(self.BuildDir, self.Name + '.hash')
if os.path.exists(HashFile):
@@ -1609,13 +1623,15 @@ class ModuleAutoGen(AutoGen):
for File in self.OutputFile:
File = str(File)
if not os.path.isabs(File):
- File = os.path.join(self.OutputDir, File)
+ NewFile = os.path.join(self.OutputDir, File)
+ if not os.path.exists(NewFile):
+ NewFile = os.path.join(self.FfsOutputDir, File)
+ File = NewFile
if os.path.exists(File):
- sub_dir = os.path.relpath(File, self.OutputDir)
- destination_file = os.path.join(FileDir, sub_dir)
- destination_dir = os.path.dirname(destination_file)
- CreateDirectory(destination_dir)
- CopyFileOnChange(File, destination_dir)
+ if File.endswith('.ffs'):
+ self.CacheCopyFile(FfsDir, self.FfsOutputDir, File)
+ else:
+ self.CacheCopyFile(FileDir, self.OutputDir, File)
def AttemptModuleCacheCopy(self):
# If library or Module is binary do not skip by hash
@@ -1626,6 +1642,7 @@ class ModuleAutoGen(AutoGen):
if '.inc' in str(f_ext):
return False
FileDir = path.join(GlobalData.gBinCacheSource, self.PlatformInfo.Name, self.BuildTarget + "_" + self.ToolChain, self.Arch, self.SourceDir, self.MetaFile.BaseName)
+ FfsDir = path.join(GlobalData.gBinCacheSource, self.PlatformInfo.OutputDir, self.BuildTarget + "_" + self.ToolChain, TAB_FV_DIRECTORY, "Ffs", self.Guid + self.Name)
HashFile = path.join(FileDir, self.Name + '.hash')
if os.path.exists(HashFile):
f = open(HashFile, 'r')
@@ -1640,11 +1657,13 @@ class ModuleAutoGen(AutoGen):
CopyFileOnChange(HashFile, self.BuildDir)
else:
File = path.join(root, f)
- sub_dir = os.path.relpath(File, FileDir)
- destination_file = os.path.join(self.OutputDir, sub_dir)
- destination_dir = os.path.dirname(destination_file)
- CreateDirectory(destination_dir)
- CopyFileOnChange(File, destination_dir)
+ self.CacheCopyFile(self.OutputDir, FileDir, File)
+ if GlobalData.gEnableGenfdsMultiThread and os.path.exists(FfsDir):
+ for root, dir, files in os.walk(FfsDir):
+ for f in files:
+ File = path.join(root, f)
+ self.CacheCopyFile(self.FfsOutputDir, FfsDir, File)
+
if self.Name == "PcdPeim" or self.Name == "PcdDxe":
CreatePcdDatabaseCode(self, TemplateString(), TemplateString())
return True
--
2.14.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#44477): https://edk2.groups.io/g/devel/message/44477
Mute This Topic: https://groups.io/mt/32639533/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 5344 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20190729/f53106b1/attachment.bin>
More information about the edk2-devel-archive
mailing list