public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 3/3] BaseTools: fix --genfds-multi-thread generate makefile issue
@ 2018-04-10  1:12 Feng, YunhuaX
  2018-04-11  6:33 ` Zhu, Yonghong
  0 siblings, 1 reply; 2+ messages in thread
From: Feng, YunhuaX @ 2018-04-10  1:12 UTC (permalink / raw)
  To: edk2-devel@lists.01.org; +Cc: Zhu, Yonghong, Gao, Liming

1. when inf file is binary module, not generate makefile,
  so need generate ffs with previous method.
2. generate Ui section maybe override and the string is not
  $(MODULE_NAME)
  like as:
  INF  RuleOverride = UI MdeModulePkg/Application/UiApp/UiApp.inf
3. Trim generate incorrect Offset.raw when some vfr not generate .lst
   file in Debug directory, Trim get the VFR name with the .c files
   replacement.
4. fix some depex file not generate issue

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
 BaseTools/Source/Python/GenFds/EfiSection.py           | 12 ++++++++++--
 BaseTools/Source/Python/GenFds/FfsInfStatement.py      |  4 +++-
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py |  6 ++++--
 BaseTools/Source/Python/GenFds/GuidSection.py          |  2 ++
 BaseTools/Source/Python/Trim/Trim.py                   |  2 +-
 5 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py
index 5029ec7a18..e6323c7879 100644
--- a/BaseTools/Source/Python/GenFds/EfiSection.py
+++ b/BaseTools/Source/Python/GenFds/EfiSection.py
@@ -62,10 +62,11 @@ class EfiSection (EfiSectionClassObject):
             InfFileName = FfsInf.InfFileName
             SectionType = FfsInf.__ExtendMacro__(self.SectionType)
             Filename = FfsInf.__ExtendMacro__(self.FileName)
             BuildNum = FfsInf.__ExtendMacro__(self.BuildNum)
             StringData = FfsInf.__ExtendMacro__(self.StringData)
+            ModuleNameStr = FfsInf.__ExtendMacro__('$(MODULE_NAME)')
             NoStrip = True
             if FfsInf.ModuleType in ('SEC', 'PEI_CORE', 'PEIM') and SectionType in ('TE', 'PE32'):
                 if FfsInf.KeepReloc != None:
                     NoStrip = FfsInf.KeepReloc
                 elif FfsInf.KeepRelocFromRule != None:
@@ -89,12 +90,13 @@ class EfiSection (EfiSectionClassObject):
 
             if not self.Optional:
                 FileList.append(Filename)
             elif os.path.exists(Filename):
                 FileList.append(Filename)
-            elif '.depex' in FfsInf.FinalTargetSuffixMap or FfsInf.Depex:
-                if IsMakefile:
+            elif IsMakefile:
+                SuffixMap = FfsInf.GetFinalTargetSuffixMap()
+                if '.depex' in SuffixMap:
                     FileList.append(Filename)
         else:
             FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FileType, self.FileExtension, Dict, IsMakefile=IsMakefile)
             if IsSect :
                 return FileList, self.Alignment
@@ -177,10 +179,12 @@ class EfiSection (EfiSectionClassObject):
                 StringData = FfsInf.Ui
                 InfOverrideUiString = True
 
             if InfOverrideUiString:
                 Num = SecNum
+                if IsMakefile and StringData == ModuleNameStr:
+                    StringData = "$(MODULE_NAME)"
                 OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
                                                      Ui=StringData, IsMakefile=IsMakefile)
                 OutputFileList.append(OutputFile)
 
@@ -190,10 +194,12 @@ class EfiSection (EfiSectionClassObject):
                     Num = '%s.%d' %(SecNum , Index)
                     OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
                     f = open(File, 'r')
                     UiString = f.read()
                     f.close()
+                    if IsMakefile and UiString == ModuleNameStr:
+                        UiString = "$(MODULE_NAME)"
                     GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
                                                         Ui=UiString, IsMakefile=IsMakefile)
                     OutputFileList.append(OutputFile)
             else:
                 if StringData != None and len(StringData) > 0:
@@ -206,10 +212,12 @@ class EfiSection (EfiSectionClassObject):
                         return '', None
                     else:
                         EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s miss UI Section value" %InfFileName)
 
                 Num = SecNum
+                if IsMakefile and StringData == ModuleNameStr:
+                    StringData = "$(MODULE_NAME)"
                 OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
                                                      Ui=StringData, IsMakefile=IsMakefile)
                 OutputFileList.append(OutputFile)
 
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index a348233911..84450ef3fe 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -500,13 +500,15 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM or SMM_CORE FV file type", File=self.InfFileName)
         #
         # For the rule only has simpleFile
         #
         MakefilePath = None
+        if self.IsBinaryModule:
+            IsMakefile = False
         if IsMakefile:
             MakefilePath = self.InfFileName, Arch
-        if isinstance (Rule, RuleSimpleFile.RuleSimpleFile) :
+        if isinstance (Rule, RuleSimpleFile.RuleSimpleFile):
             SectionOutputList = self.__GenSimpleFileSection__(Rule, IsMakefile=IsMakefile)
             FfsOutput = self.__GenSimpleFileFfs__(Rule, SectionOutputList, MakefilePath=MakefilePath)
             return FfsOutput
         #
         # For Rule has ComplexFile
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index 97e20753ae..6437e5fa30 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -462,13 +462,15 @@ class GenFdsGlobalVariable:
 
         CommandFile = Output + '.txt'
         if Ui not in [None, '']:
             #Cmd += ["-n", '"' + Ui + '"']
             if IsMakefile:
-                Cmd += ["-n", "$(MODULE_NAME)"]
+                if Ui == "$(MODULE_NAME)":
+                    Cmd += ['-n', Ui]
+                else:
+                    Cmd += ["-n", '"' + Ui + '"']
                 Cmd += ["-o", Output]
-                #SaveFileOnChange(CommandFile, ' '.join(Cmd), False)
                 if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:
                     GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip())
             else:
                 SectionData = array.array('B', [0, 0, 0, 0])
                 SectionData.fromstring(Ui.encode("utf_16_le"))
diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py b/BaseTools/Source/Python/GenFds/GuidSection.py
index ea737bb9a7..b8612be05f 100644
--- a/BaseTools/Source/Python/GenFds/GuidSection.py
+++ b/BaseTools/Source/Python/GenFds/GuidSection.py
@@ -270,9 +270,11 @@ class GuidSection(GuidSectionClassObject) :
             if 'PROCESSING_REQUIRED' in Attribute:
                 # reset guided section alignment to none for the processed required guided data
                 self.Alignment = None
                 self.IncludeFvSection = False
                 self.ProcessRequired = "TRUE"
+            if IsMakefile and self.Alignment.strip() == '0':
+                self.Alignment = '1'
             return OutputFileList, self.Alignment
 
 
 
diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python/Trim/Trim.py
index d1e40b025c..b98c8ff779 100644
--- a/BaseTools/Source/Python/Trim/Trim.py
+++ b/BaseTools/Source/Python/Trim/Trim.py
@@ -435,11 +435,11 @@ def GenerateVfrBinSec(ModuleName, DebugDir, OutputFile):
     VfrNameList = []
     if os.path.isdir(DebugDir):
         for CurrentDir, Dirs, Files in os.walk(DebugDir):
             for FileName in Files:
                 Name, Ext = os.path.splitext(FileName)
-                if Ext == '.lst':
+                if Ext == '.c' and Name != 'AutoGen':
                     VfrNameList.append (Name + 'Bin')
 
     VfrNameList.append (ModuleName + 'Strings')
 
     EfiFileName = os.path.join(DebugDir, ModuleName + '.efi')
-- 
2.12.2.windows.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/3] BaseTools: fix --genfds-multi-thread generate makefile issue
  2018-04-10  1:12 [PATCH 3/3] BaseTools: fix --genfds-multi-thread generate makefile issue Feng, YunhuaX
@ 2018-04-11  6:33 ` Zhu, Yonghong
  0 siblings, 0 replies; 2+ messages in thread
From: Zhu, Yonghong @ 2018-04-11  6:33 UTC (permalink / raw)
  To: Feng, YunhuaX, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Feng, YunhuaX 
Sent: Tuesday, April 10, 2018 9:13 AM
To: edk2-devel@lists.01.org
Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [PATCH 3/3] BaseTools: fix --genfds-multi-thread generate makefile issue

1. when inf file is binary module, not generate makefile,
  so need generate ffs with previous method.
2. generate Ui section maybe override and the string is not
  $(MODULE_NAME)
  like as:
  INF  RuleOverride = UI MdeModulePkg/Application/UiApp/UiApp.inf
3. Trim generate incorrect Offset.raw when some vfr not generate .lst
   file in Debug directory, Trim get the VFR name with the .c files
   replacement.
4. fix some depex file not generate issue

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
 BaseTools/Source/Python/GenFds/EfiSection.py           | 12 ++++++++++--
 BaseTools/Source/Python/GenFds/FfsInfStatement.py      |  4 +++-
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py |  6 ++++--
 BaseTools/Source/Python/GenFds/GuidSection.py          |  2 ++
 BaseTools/Source/Python/Trim/Trim.py                   |  2 +-
 5 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py
index 5029ec7a18..e6323c7879 100644
--- a/BaseTools/Source/Python/GenFds/EfiSection.py
+++ b/BaseTools/Source/Python/GenFds/EfiSection.py
@@ -62,10 +62,11 @@ class EfiSection (EfiSectionClassObject):
             InfFileName = FfsInf.InfFileName
             SectionType = FfsInf.__ExtendMacro__(self.SectionType)
             Filename = FfsInf.__ExtendMacro__(self.FileName)
             BuildNum = FfsInf.__ExtendMacro__(self.BuildNum)
             StringData = FfsInf.__ExtendMacro__(self.StringData)
+            ModuleNameStr = FfsInf.__ExtendMacro__('$(MODULE_NAME)')
             NoStrip = True
             if FfsInf.ModuleType in ('SEC', 'PEI_CORE', 'PEIM') and SectionType in ('TE', 'PE32'):
                 if FfsInf.KeepReloc != None:
                     NoStrip = FfsInf.KeepReloc
                 elif FfsInf.KeepRelocFromRule != None:
@@ -89,12 +90,13 @@ class EfiSection (EfiSectionClassObject):
 
             if not self.Optional:
                 FileList.append(Filename)
             elif os.path.exists(Filename):
                 FileList.append(Filename)
-            elif '.depex' in FfsInf.FinalTargetSuffixMap or FfsInf.Depex:
-                if IsMakefile:
+            elif IsMakefile:
+                SuffixMap = FfsInf.GetFinalTargetSuffixMap()
+                if '.depex' in SuffixMap:
                     FileList.append(Filename)
         else:
             FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FileType, self.FileExtension, Dict, IsMakefile=IsMakefile)
             if IsSect :
                 return FileList, self.Alignment @@ -177,10 +179,12 @@ class EfiSection (EfiSectionClassObject):
                 StringData = FfsInf.Ui
                 InfOverrideUiString = True
 
             if InfOverrideUiString:
                 Num = SecNum
+                if IsMakefile and StringData == ModuleNameStr:
+                    StringData = "$(MODULE_NAME)"
                 OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
                                                      Ui=StringData, IsMakefile=IsMakefile)
                 OutputFileList.append(OutputFile)
 
@@ -190,10 +194,12 @@ class EfiSection (EfiSectionClassObject):
                     Num = '%s.%d' %(SecNum , Index)
                     OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
                     f = open(File, 'r')
                     UiString = f.read()
                     f.close()
+                    if IsMakefile and UiString == ModuleNameStr:
+                        UiString = "$(MODULE_NAME)"
                     GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
                                                         Ui=UiString, IsMakefile=IsMakefile)
                     OutputFileList.append(OutputFile)
             else:
                 if StringData != None and len(StringData) > 0:
@@ -206,10 +212,12 @@ class EfiSection (EfiSectionClassObject):
                         return '', None
                     else:
                         EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s miss UI Section value" %InfFileName)
 
                 Num = SecNum
+                if IsMakefile and StringData == ModuleNameStr:
+                    StringData = "$(MODULE_NAME)"
                 OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
                                                      Ui=StringData, IsMakefile=IsMakefile)
                 OutputFileList.append(OutputFile)
 
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index a348233911..84450ef3fe 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -500,13 +500,15 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM or SMM_CORE FV file type", File=self.InfFileName)
         #
         # For the rule only has simpleFile
         #
         MakefilePath = None
+        if self.IsBinaryModule:
+            IsMakefile = False
         if IsMakefile:
             MakefilePath = self.InfFileName, Arch
-        if isinstance (Rule, RuleSimpleFile.RuleSimpleFile) :
+        if isinstance (Rule, RuleSimpleFile.RuleSimpleFile):
             SectionOutputList = self.__GenSimpleFileSection__(Rule, IsMakefile=IsMakefile)
             FfsOutput = self.__GenSimpleFileFfs__(Rule, SectionOutputList, MakefilePath=MakefilePath)
             return FfsOutput
         #
         # For Rule has ComplexFile
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index 97e20753ae..6437e5fa30 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -462,13 +462,15 @@ class GenFdsGlobalVariable:
 
         CommandFile = Output + '.txt'
         if Ui not in [None, '']:
             #Cmd += ["-n", '"' + Ui + '"']
             if IsMakefile:
-                Cmd += ["-n", "$(MODULE_NAME)"]
+                if Ui == "$(MODULE_NAME)":
+                    Cmd += ['-n', Ui]
+                else:
+                    Cmd += ["-n", '"' + Ui + '"']
                 Cmd += ["-o", Output]
-                #SaveFileOnChange(CommandFile, ' '.join(Cmd), False)
                 if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:
                     GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip())
             else:
                 SectionData = array.array('B', [0, 0, 0, 0])
                 SectionData.fromstring(Ui.encode("utf_16_le"))
diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py b/BaseTools/Source/Python/GenFds/GuidSection.py
index ea737bb9a7..b8612be05f 100644
--- a/BaseTools/Source/Python/GenFds/GuidSection.py
+++ b/BaseTools/Source/Python/GenFds/GuidSection.py
@@ -270,9 +270,11 @@ class GuidSection(GuidSectionClassObject) :
             if 'PROCESSING_REQUIRED' in Attribute:
                 # reset guided section alignment to none for the processed required guided data
                 self.Alignment = None
                 self.IncludeFvSection = False
                 self.ProcessRequired = "TRUE"
+            if IsMakefile and self.Alignment.strip() == '0':
+                self.Alignment = '1'
             return OutputFileList, self.Alignment
 
 
 
diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python/Trim/Trim.py
index d1e40b025c..b98c8ff779 100644
--- a/BaseTools/Source/Python/Trim/Trim.py
+++ b/BaseTools/Source/Python/Trim/Trim.py
@@ -435,11 +435,11 @@ def GenerateVfrBinSec(ModuleName, DebugDir, OutputFile):
     VfrNameList = []
     if os.path.isdir(DebugDir):
         for CurrentDir, Dirs, Files in os.walk(DebugDir):
             for FileName in Files:
                 Name, Ext = os.path.splitext(FileName)
-                if Ext == '.lst':
+                if Ext == '.c' and Name != 'AutoGen':
                     VfrNameList.append (Name + 'Bin')
 
     VfrNameList.append (ModuleName + 'Strings')
 
     EfiFileName = os.path.join(DebugDir, ModuleName + '.efi')
--
2.12.2.windows.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-04-11  6:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-10  1:12 [PATCH 3/3] BaseTools: fix --genfds-multi-thread generate makefile issue Feng, YunhuaX
2018-04-11  6:33 ` Zhu, Yonghong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox