public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Fan, ZhijuX" <zhijux.fan@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Gao, Liming" <liming.gao@intel.com>,
	"Feng, Bob C" <bob.c.feng@intel.com>,
	"Shi, Steven" <steven.shi@intel.com>
Subject: [PATCH 1/2] BaseTools:Fix GenFds multi-thread build fails if enable build cache
Date: Mon, 29 Jul 2019 06:02:03 +0000	[thread overview]
Message-ID: <FAD0D7E0AE0FA54D987F6E72435CAFD50AFA54BD@SHSMSX101.ccr.corp.intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 6076 bytes --]

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@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Steven Shi <steven.shi@intel.com>
Signed-off-by: Zhiju.Fan <zhijux.fan@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


[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 5344 bytes --]

                 reply	other threads:[~2019-07-29  6:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=FAD0D7E0AE0FA54D987F6E72435CAFD50AFA54BD@SHSMSX101.ccr.corp.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