]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools:Enhance the way to handling included dsc file
authorFan, ZhijuX <zhijux.fan@intel.com>
Tue, 3 Dec 2019 09:04:25 +0000 (17:04 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 4 Dec 2019 07:56:55 +0000 (07:56 +0000)
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=2400

In Dsc Parser, included dsc file is parsed always no matter
if its condition is False

  gUefiOvmfPkgTokenSpaceGuid.test1|FALSE
!if gUefiOvmfPkgTokenSpaceGuid.test1 == FALSE
  !include OvmfPkg/test1.dsc
!else
  !include OvmfPkg/test2.dsc
!endif

The patch avoids processing redundant dsc files and improves
the way Tool handles them.

In the above case, since the conditional result is FALSE,
"test2.dsc" is not parsed.

Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
BaseTools/Source/Python/Workspace/MetaFileParser.py

index 8a665b118ec89017b23893295cca41aa22d8bcca..a3b6edbd15ee5bf79cef0ac1fc5e53db30356c91 100644 (file)
@@ -1612,46 +1612,47 @@ class DscParser(MetaFileParser):
             # First search the include file under the same directory as DSC file\r
             #\r
             IncludedFile1 = PathClass(IncludedFile, self.MetaFile.Dir)\r
-            ErrorCode, ErrorInfo1 = IncludedFile1.Validate()\r
-            if ErrorCode != 0:\r
-                #\r
-                # Also search file under the WORKSPACE directory\r
-                #\r
-                IncludedFile1 = PathClass(IncludedFile, GlobalData.gWorkspace)\r
-                ErrorCode, ErrorInfo2 = IncludedFile1.Validate()\r
+            if self._Enabled:\r
+                ErrorCode, ErrorInfo1 = IncludedFile1.Validate()\r
                 if ErrorCode != 0:\r
-                    EdkLogger.error('parser', ErrorCode, File=self._FileWithError,\r
-                                    Line=self._LineIndex + 1, ExtraData=ErrorInfo1 + "\n" + ErrorInfo2)\r
-\r
-            self._FileWithError = IncludedFile1\r
-\r
-            FromItem = self._Content[self._ContentIndex - 1][0]\r
-            if self._InSubsection:\r
-                Owner = self._Content[self._ContentIndex - 1][8]\r
-            else:\r
-                Owner = self._Content[self._ContentIndex - 1][0]\r
-            IncludedFileTable = MetaFileStorage(self._RawTable.DB, IncludedFile1, MODEL_FILE_DSC, False, FromItem=FromItem)\r
-            Parser = DscParser(IncludedFile1, self._FileType, self._Arch, IncludedFileTable,\r
-                               Owner=Owner, From=FromItem)\r
-\r
-            self.IncludedFiles.add (IncludedFile1)\r
-\r
-            # set the parser status with current status\r
-            Parser._SectionName = self._SectionName\r
-            Parser._SubsectionType = self._SubsectionType\r
-            Parser._InSubsection = self._InSubsection\r
-            Parser._SectionType = self._SectionType\r
-            Parser._Scope = self._Scope\r
-            Parser._Enabled = self._Enabled\r
-            # Parse the included file\r
-            Parser.StartParse()\r
-            # Insert all records in the table for the included file into dsc file table\r
-            Records = IncludedFileTable.GetAll()\r
-            if Records:\r
-                self._Content[self._ContentIndex:self._ContentIndex] = Records\r
-                self._Content.pop(self._ContentIndex - 1)\r
-                self._ValueList = None\r
-                self._ContentIndex -= 1\r
+                    #\r
+                    # Also search file under the WORKSPACE directory\r
+                    #\r
+                    IncludedFile1 = PathClass(IncludedFile, GlobalData.gWorkspace)\r
+                    ErrorCode, ErrorInfo2 = IncludedFile1.Validate()\r
+                    if ErrorCode != 0:\r
+                        EdkLogger.error('parser', ErrorCode, File=self._FileWithError,\r
+                                        Line=self._LineIndex + 1, ExtraData=ErrorInfo1 + "\n" + ErrorInfo2)\r
+\r
+                self._FileWithError = IncludedFile1\r
+\r
+                FromItem = self._Content[self._ContentIndex - 1][0]\r
+                if self._InSubsection:\r
+                    Owner = self._Content[self._ContentIndex - 1][8]\r
+                else:\r
+                    Owner = self._Content[self._ContentIndex - 1][0]\r
+                IncludedFileTable = MetaFileStorage(self._RawTable.DB, IncludedFile1, MODEL_FILE_DSC, False, FromItem=FromItem)\r
+                Parser = DscParser(IncludedFile1, self._FileType, self._Arch, IncludedFileTable,\r
+                                   Owner=Owner, From=FromItem)\r
+\r
+                self.IncludedFiles.add (IncludedFile1)\r
+\r
+                # set the parser status with current status\r
+                Parser._SectionName = self._SectionName\r
+                Parser._SubsectionType = self._SubsectionType\r
+                Parser._InSubsection = self._InSubsection\r
+                Parser._SectionType = self._SectionType\r
+                Parser._Scope = self._Scope\r
+                Parser._Enabled = self._Enabled\r
+                # Parse the included file\r
+                Parser.StartParse()\r
+                # Insert all records in the table for the included file into dsc file table\r
+                Records = IncludedFileTable.GetAll()\r
+                if Records:\r
+                    self._Content[self._ContentIndex:self._ContentIndex] = Records\r
+                    self._Content.pop(self._ContentIndex - 1)\r
+                    self._ValueList = None\r
+                    self._ContentIndex -= 1\r
 \r
     def __ProcessPackages(self):\r
         self._ValueList[0] = ReplaceMacro(self._ValueList[0], self._Macros)\r