bug-fixing for rule update.
authorjlin16 <jlin16@7335b38e-4728-0410-8992-fb3ffe349368>
Fri, 7 Sep 2007 06:27:51 +0000 (06:27 +0000)
committerjlin16 <jlin16@7335b38e-4728-0410-8992-fb3ffe349368>
Fri, 7 Sep 2007 06:27:51 +0000 (06:27 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@692 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/GenFds/CompressSection.py
Source/Python/GenFds/EfiSection.py
Source/Python/GenFds/FdfParser.py
Source/Python/GenFds/FfsInfStatement.py
Source/Python/GenFds/GuidSection.py
Source/Python/GenFds/Section.py

index f22f119..7b67d4b 100755 (executable)
@@ -28,11 +28,12 @@ class CompressSection (CompressSectionClassObject) :
         for Sect in self.SectionList:\r
             Index = Index + 1\r
             SecIndex = '%s.%d' %(SecNum, Index)\r
-            sect, align = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf)\r
-            if sect != None:\r
-                SectFiles = SectFiles + \\r
-                            ' '       + \\r
-                            sect\r
+            ReturnSectList, align = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf)\r
+            if ReturnSectList != []:\r
+                for file in ReturnSectList:\r
+                   SectFiles = SectFiles + \\r
+                               ' '       + \\r
+                               file\r
                         \r
 \r
         OutputFile = OutputPath + \\r
index 700d50e..d71a6b1 100644 (file)
@@ -30,7 +30,7 @@ class EfiSection (EfiSectionClassObject):
             BuildNum = self.BuildNum\r
             VerstionNum = self.VersionNum\r
             InfFileName = ''\r
-\r
+            \r
         FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FileType, self.FileExtension)\r
         if IsSect :\r
             return FileList, self.Alignment\r
@@ -39,15 +39,18 @@ class EfiSection (EfiSectionClassObject):
         """If the file name was pointed out, add it in FileList"""\r
         if FileList == []:\r
             if Filename != None:\r
-                FileList.append(Filename)\r
-            \r
+                if not self.Optional:\r
+                    FileList.append(Filename)\r
+                elif os.path.exists(Filename):                 \r
+                    FileList.append(Filename)\r
+        \r
         """ If Section type is 'VERSION'"""\r
         OutputFileList = []\r
         if SectionType == 'VERSION':\r
             if FileList != []:\r
                 for File in FileList:\r
                     Index = Index + 1\r
-                    Num = '%s.%d' %SecNum %Index\r
+                    Num = '%s.%d' %(SecNum , Index)\r
                     OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))\r
                     f = open (File, 'r')\r
                     VerString = f.read()\r
@@ -88,7 +91,7 @@ class EfiSection (EfiSectionClassObject):
                     else:\r
                         raise Exception ("File: %s miss Version Section value" %InfFileName)\r
                 Num = SecNum\r
-                OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))\r
+                OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))\r
                 GenSectionCmd = 'GenSec -o '                + \\r
                                      OutputFile                 + \\r
                                      ' -s EFI_SECTION_VERSION'  + \\r
@@ -104,7 +107,7 @@ class EfiSection (EfiSectionClassObject):
             if FileList != []:\r
                 for File in FileList:\r
                     Index = Index + 1\r
-                    Num = '%s.%d' %SecNum %Index\r
+                    Num = '%s.%d' %(SecNum , Index)\r
                     OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))\r
                     f = open (File, 'r')\r
                     UiString = f.read()\r
@@ -135,7 +138,7 @@ class EfiSection (EfiSectionClassObject):
                     else:\r
                         raise Exception ("File: %s miss UI Section value" %InfFileName)\r
                 Num = SecNum\r
-                OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))\r
+                OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))\r
                 GenSectionCmd = 'GenSec -o '                       + \\r
                                  OutputFile                        + \\r
                                  ' -s EFI_SECTION_USER_INTERFACE'  + \\r
@@ -159,7 +162,7 @@ class EfiSection (EfiSectionClassObject):
                 for File in FileList:\r
                     """ Copy Map file to FFS output path """\r
                     Index = Index + 1\r
-                    Num = '%s.%d' %SecNum %Index\r
+                    Num = '%s.%d' %(SecNum , Index)\r
                     OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))\r
                     File = GenFdsGlobalVariable.ExtendMarco(File)\r
                     if File[(len(File)-4):] == '.efi':\r
@@ -191,4 +194,4 @@ class EfiSection (EfiSectionClassObject):
                     GenFdsGlobalVariable.CallExternalTool(GenSectionCmd, "GenSection Failed !")\r
                     OutputFileList.append(OutputFile)\r
             \r
-        return OutputFile , self.Alignment\r
+        return OutputFileList, self.Alignment\r
index bb1e38b..cd34706 100644 (file)
@@ -1542,7 +1542,7 @@ class FdfParser:
             p = re.compile(r'([a-zA-Z][a-zA-Z0-9]*)')\r
             if p.match(self.__Token):\r
                 ext = self.__Token                            \r
-                return ext    \r
+                return '.' + ext    \r
             else:\r
 #                    self.__UndoToken()\r
                 raise Warning("Unknown file extension At Line %d" % self.CurrentLineNumber)\r
index b19d0d3..c83495a 100644 (file)
@@ -221,14 +221,14 @@ class FfsInfStatement(FfsInfStatementClassObject):
         else:\r
             FileList, IsSect = Section.Section.GetFileList(self, '', Rule.FileExtension)\r
 \r
-        Index = 0\r
+        Index = 1\r
         SectionType     = Rule.SectionType\r
         if FileList != [] :\r
             for File in FileList:\r
-                SecNum = '%d'Index\r
+                SecNum = '%d' %Index\r
                 GenSecOutputFile= self.__ExtendMarco__(Rule.NameGuid) + \\r
-                              Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + Index\r
-                Index = Index + 1\r
+                              Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum   \r
+                Index = Index + 1             \r
                 OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)\r
                 genSectionCmd = 'GenSec -o '                                + \\r
                                  OutputFile                                 + \\r
@@ -242,8 +242,9 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 GenFdsGlobalVariable.CallExternalTool(genSectionCmd, "Gensection Failed!")\r
                 OutputFileList.append(GenSecOutputFile)\r
         else:\r
+            SecNum = '%d' %Index\r
             GenSecOutputFile= self.__ExtendMarco__(Rule.NameGuid) + \\r
-                              Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + Index\r
+                              Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum\r
             OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)\r
             \r
             genSectionCmd = 'GenSec -o '                                + \\r
@@ -301,7 +302,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
     \r
     def __GenComplexFileSection__(self, Rule):\r
         SectFiles = ''\r
-        Index = 0\r
+        Index = 1\r
         for Sect in Rule.SectionList:\r
            SecIndex = '%d' %Index\r
            SecList  = []\r
@@ -312,12 +313,12 @@ class FfsInfStatement(FfsInfStatementClassObject):
            for SecName in  SectList :\r
                SectFiles = SectFiles    + \\r
                            ' -i '       + \\r
-                           secName\r
+                           SecName\r
                if Align != None:\r
                    SectFiles = SectFiles + \\r
                                ' -n '    + \\r
                                Align\r
-               Index = Index + 1\r
+           Index = Index + 1\r
         return SectFiles\r
 \r
     def __GenComplexFileFfs__(self, Rule, InputFile):\r
index ec991d6..5f5c4ea 100755 (executable)
@@ -27,11 +27,12 @@ class GuidSection(GuidSectionClassObject) :
         for Sect in self.SectionList:\r
             Index = Index + 1\r
             SecIndex = '%s.%d' %(SecNum,Index)\r
-            sect, align = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList,FfsInf)\r
-            if sect != None:\r
-                SectFile = SectFile + \\r
-                           '  '     + \\r
-                           sect\r
+            ReturnSectList, align = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList,FfsInf)\r
+            if ReturnSectList != []:\r
+                for file in ReturnSectList:\r
+                    SectFile = SectFile + \\r
+                               '  '     + \\r
+                               file\r
                        \r
 \r
         OutputFile = OutputPath + \\r
@@ -56,7 +57,9 @@ class GuidSection(GuidSectionClassObject) :
                              SectFile\r
                              \r
             GenFdsGlobalVariable.CallExternalTool(GenSectionCmd, "GenSection Failed!")\r
-            return OutputFile, self.Alignment\r
+            OutputFileList = []\r
+            OutputFileList.append(OutputFile)\r
+            return OutputFileList, self.Alignment\r
         else:\r
             #\r
             # Call GenSection with DUMMY section type.\r
index 949d9c1..5c6b8c7 100755 (executable)
@@ -1,4 +1,5 @@
 from CommonDataClass.FdfClassObject import SectionClassObject\r
+import os\r
 \r
 class Section (SectionClassObject):\r
     SectionType = {\r
@@ -66,9 +67,9 @@ class Section (SectionClassObject):
         if FileExtension != None:\r
             suffix = FileExtension\r
         elif IsSect :\r
-            suffix = Section.SectionType[FileType]\r
+            suffix = Section.SectionType.get(FileType)\r
         else:\r
-            suffix = Section.BinFileType[FileType]\r
+            suffix = Section.BinFileType.get(FileType)\r
         if FfsInf == None:\r
             raise Exception ('Dont have Inf File!')\r
         \r
@@ -79,7 +80,7 @@ class Section (SectionClassObject):
             for file in os.listdir(FfsInf.EfiOutputPath):\r
                 Name, Ext = os.path.splitext(file)\r
                 if Ext == suffix:\r
-                   FileList.append(FfsInf.EfiOutputPath, file)\r
+                   FileList.append(os.path.join(FfsInf.EfiOutputPath, file))\r
                    \r
         return FileList, IsSect\r
     GetFileList = staticmethod(GetFileList)\r