]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools:Make BaseTools support new rules to generate RAW FFS FILE
authorFan, ZhijuX <zhijux.fan@intel.com>
Wed, 29 May 2019 05:29:34 +0000 (13:29 +0800)
committerFeng, Bob C <bob.c.feng@intel.com>
Mon, 10 Jun 2019 11:48:50 +0000 (19:48 +0800)
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1765

If RAW FFS File Rule has no section for its data.For RAW FFS File,
directly call GenFfs tool to generate FFS file.

Ffs Rule:
[Rule.Common.USER_DEFINED.MicroCode]
  FILE RAW = $(NAMED_GUID) {
        $(INF_OUTPUT)/$(MODULE_NAME).bin
  }
[Rule.Common.USER_DEFINED.LOGO]
  FILE RAW = $(NAMED_GUID) {
                       |.bmp
  }

As shown in the rule above,if SectionType and FileType not defined,
FFS files are generated directly, and no other type of file is
generated.

The patch is to make the BaseTools support these two rules

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
BaseTools/Source/Python/Common/DataType.py
BaseTools/Source/Python/GenFds/EfiSection.py
BaseTools/Source/Python/GenFds/FdfParser.py
BaseTools/Source/Python/GenFds/FfsInfStatement.py
BaseTools/Source/Python/GenFds/Section.py

index 7cd67bc01a93ca66aa4eb19d60a2226130afbe01..83ec36c2350d77f4b119f2c441d93892da7a7e2b 100644 (file)
@@ -122,6 +122,7 @@ BINARY_FILE_TYPE_VER = 'VER'
 BINARY_FILE_TYPE_UI = 'UI'\r
 BINARY_FILE_TYPE_BIN = 'BIN'\r
 BINARY_FILE_TYPE_FV = 'FV'\r
+BINARY_FILE_TYPE_RAW = 'RAW_BINARY'\r
 \r
 PLATFORM_COMPONENT_TYPE_LIBRARY_CLASS = 'LIBRARY_CLASS'\r
 PLATFORM_COMPONENT_TYPE_MODULE = 'MODULE'\r
index 302f244fafc9968377c39bd6b6308936b4d8345c..74f176cfef2f9833169f1c2b7994ee1c2385ff71 100644 (file)
@@ -93,7 +93,7 @@ class EfiSection (EfiSectionClassObject):
                 if '.depex' in SuffixMap:\r
                     FileList.append(Filename)\r
         else:\r
-            FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FileType, self.FileExtension, Dict, IsMakefile=IsMakefile)\r
+            FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FileType, self.FileExtension, Dict, IsMakefile=IsMakefile, SectionType=SectionType)\r
             if IsSect :\r
                 return FileList, self.Alignment\r
 \r
@@ -217,6 +217,26 @@ class EfiSection (EfiSectionClassObject):
                                                      Ui=StringData, IsMakefile=IsMakefile)\r
                 OutputFileList.append(OutputFile)\r
 \r
+        #\r
+        # If Section Type is BINARY_FILE_TYPE_RAW\r
+        #\r
+        elif SectionType == BINARY_FILE_TYPE_RAW:\r
+            """If File List is empty"""\r
+            if FileList == []:\r
+                if self.Optional == True:\r
+                    GenFdsGlobalVariable.VerboseLogger("Optional Section don't exist!")\r
+                    return [], None\r
+                else:\r
+                    EdkLogger.error("GenFds", GENFDS_ERROR, "Output file for %s section could not be found for %s" % (SectionType, InfFileName))\r
+\r
+            elif len(FileList) > 1:\r
+                EdkLogger.error("GenFds", GENFDS_ERROR,\r
+                                "Files suffixed with %s are not allowed to have more than one file in %s[Binaries] section" % (\r
+                                self.FileExtension, InfFileName))\r
+            else:\r
+                for File in FileList:\r
+                    File = GenFdsGlobalVariable.MacroExtend(File, Dict)\r
+                    OutputFileList.append(File)\r
 \r
         else:\r
             """If File List is empty"""\r
index ea1c3eeb3047363f5ff6f30f81b73d46617a1b7c..fb5fd85e0a825ebf3341e2ca706af9b0b37b57c3 100644 (file)
@@ -3749,8 +3749,19 @@ class FdfParser:
     #\r
     def _GetEfiSection(self, Obj):\r
         OldPos = self.GetFileBufferPos()\r
+        EfiSectionObj = EfiSection()\r
         if not self._GetNextWord():\r
-            return False\r
+            CurrentLine = self._CurrentLine()[self.CurrentOffsetWithinLine:].split()[0].strip()\r
+            if self._Token == '{' and Obj.FvFileType == "RAW" and TAB_SPLIT in CurrentLine:\r
+                if self._IsToken(TAB_VALUE_SPLIT):\r
+                    EfiSectionObj.FileExtension = self._GetFileExtension()\r
+                elif self._GetNextToken():\r
+                    EfiSectionObj.FileName = self._Token\r
+                EfiSectionObj.SectionType = BINARY_FILE_TYPE_RAW\r
+                Obj.SectionList.append(EfiSectionObj)\r
+                return True\r
+            else:\r
+                return False\r
         SectionName = self._Token\r
 \r
         if SectionName not in {\r
@@ -3816,7 +3827,6 @@ class FdfParser:
             Obj.SectionList.append(FvImageSectionObj)\r
             return True\r
 \r
-        EfiSectionObj = EfiSection()\r
         EfiSectionObj.SectionType = SectionName\r
 \r
         if not self._GetNextToken():\r
index 78dd7cd51af3bc776eac804e78b44828fee92d50..cd3b0f647793da01772e6fee4a98e3c576a6026d 100644 (file)
@@ -147,7 +147,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
     #   @param  self        The object pointer\r
     #   @param  Dict        dictionary contains macro and value pair\r
     #\r
-    def __InfParse__(self, Dict = {}):\r
+    def __InfParse__(self, Dict = None, IsGenFfs=False):\r
 \r
         GenFdsGlobalVariable.VerboseLogger( " Begine parsing INf file : %s" %self.InfFileName)\r
 \r
@@ -348,7 +348,10 @@ class FfsInfStatement(FfsInfStatementClassObject):
         #\r
         # Set OutputPath = ${WorkSpace}\Build\Fv\Ffs\${ModuleGuid}+ ${ModuleName}\\r
         #\r
-\r
+        if IsGenFfs:\r
+            Rule = self.__GetRule__()\r
+            if GlobalData.gGuidPatternEnd.match(Rule.NameGuid):\r
+                self.ModuleGuid = Rule.NameGuid\r
         self.OutputPath = os.path.join(GenFdsGlobalVariable.FfsDir, \\r
                                        self.ModuleGuid + self.BaseName)\r
         if not os.path.exists(self.OutputPath) :\r
@@ -438,7 +441,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
         # Parse Inf file get Module related information\r
         #\r
 \r
-        self.__InfParse__(Dict)\r
+        self.__InfParse__(Dict, IsGenFfs=True)\r
         Arch = self.GetCurrentArch()\r
         SrcFile = mws.join( GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName);\r
         DestFile = os.path.join( self.OutputPath, self.ModuleGuid + '.ffs')\r
index c49a1ac84bca13ca3d42356545bc5b6a40e4b626..b2389566349855b8bedb9f22d5dbfa99c9ba968d 100644 (file)
@@ -106,7 +106,7 @@ class Section (SectionClassObject):
     #   @param  Dict        dictionary contains macro and its value\r
     #   @retval tuple       (File list, boolean)\r
     #\r
-    def GetFileList(FfsInf, FileType, FileExtension, Dict = {}, IsMakefile=False):\r
+    def GetFileList(FfsInf, FileType, FileExtension, Dict = None, IsMakefile=False, SectionType=None):\r
         IsSect = FileType in Section.SectFileType\r
 \r
         if FileExtension is not None:\r
@@ -134,6 +134,11 @@ class Section (SectionClassObject):
                 else:\r
                     GenFdsGlobalVariable.InfLogger ("\nCurrent ARCH \'%s\' of File %s is not in the Support Arch Scope of %s specified by INF %s in FDF" %(FfsInf.CurrentArch, File.File, File.Arch, FfsInf.InfFileName))\r
 \r
+        elif FileType is None and SectionType == BINARY_FILE_TYPE_RAW:\r
+            for File in FfsInf.BinFileList:\r
+                if File.Ext == Suffix:\r
+                    FileList.append(File.Path)\r
+\r
         if (not IsMakefile and Suffix is not None and os.path.exists(FfsInf.EfiOutputPath)) or (IsMakefile and Suffix is not None):\r
             #\r
             # Get Makefile path and time stamp\r