]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/Build: Better DSC arch filtering
authorThomas Palmer <thomas.palmer@hpe.com>
Wed, 27 Apr 2016 22:32:17 +0000 (06:32 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Fri, 29 Apr 2016 06:53:27 +0000 (14:53 +0800)
Description:
When building for any specific architecture, the build script today is loading
DSC sections for other architectures not in the build. The build process should
disregard DSC sections that are not relevant to the build.

My previous patch only fixed issue for one section type (Components). This
patch will handle all section types by updating the MetaFileParser class, which
now takes a Arch argument and will filter the DSC table results as they are
returned from the database.  The database still contains all information from
DSCs for when builds support multiple arch's

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Thomas Palmer <thomas.palmer@hpe.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/Workspace/MetaFileParser.py
BaseTools/Source/Python/Workspace/WorkspaceDatabase.py

index 2811fd1ba31e62bdb0cb5330cbac6f999266f20c..209f47c9ebda7f3792d867ac7f988de76e5b2f06 100644 (file)
@@ -2,7 +2,7 @@
 # This file is used to parse meta files\r
 #\r
 # Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>\r
-# Copyright (c) 2015, Hewlett Packard Enterprise Development, L.P.<BR>\r
+# (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -144,14 +144,15 @@ class MetaFileParser(object):
     #\r
     #   @param      FilePath        The path of platform description file\r
     #   @param      FileType        The raw data of DSC file\r
+    #   @param      Arch            Default Arch value for filtering sections\r
     #   @param      Table           Database used to retrieve module/package information\r
-    #   @param      Macros          Macros used for replacement in file\r
     #   @param      Owner           Owner ID (for sub-section parsing)\r
     #   @param      From            ID from which the data comes (for !INCLUDE directive)\r
     #\r
-    def __init__(self, FilePath, FileType, Table, Owner= -1, From= -1):\r
+    def __init__(self, FilePath, FileType, Arch, Table, Owner= -1, From= -1):\r
         self._Table = Table\r
         self._RawTable = Table\r
+        self._Arch = Arch\r
         self._FileType = FileType\r
         self.MetaFile = FilePath\r
         self._FileDir = self.MetaFile.Dir\r
@@ -211,6 +212,15 @@ class MetaFileParser(object):
     def _SetFinished(self, Value):\r
         self._Finished = Value\r
 \r
+    ## Remove records that do not match given Filter Arch\r
+    def _FilterRecordList(self, RecordList, FilterArch):\r
+        NewRecordList = []\r
+        for Record in RecordList:\r
+            Arch = Record[3]\r
+            if Arch == 'COMMON' or Arch == FilterArch:\r
+                NewRecordList.append(Record)\r
+        return NewRecordList\r
+\r
     ## Use [] style to query data in table, just for readability\r
     #\r
     #   DataInfo = [data_type, scope1(arch), scope2(platform/moduletype)]\r
@@ -230,13 +240,13 @@ class MetaFileParser(object):
 \r
         # No specific ARCH or Platform given, use raw data\r
         if self._RawTable and (len(DataInfo) == 1 or DataInfo[1] == None):\r
-            return self._RawTable.Query(*DataInfo)\r
+            return self._FilterRecordList(self._RawTable.Query(*DataInfo), self._Arch)\r
 \r
         # Do post-process if necessary\r
         if not self._PostProcessed:\r
             self._PostProcess()\r
 \r
-        return self._Table.Query(*DataInfo)\r
+        return self._FilterRecordList(self._Table.Query(*DataInfo), DataInfo[1])\r
 \r
     ## Data parser for the common format in different type of file\r
     #\r
@@ -490,14 +500,14 @@ class InfParser(MetaFileParser):
     #\r
     #   @param      FilePath        The path of module description file\r
     #   @param      FileType        The raw data of DSC file\r
+    #   @param      Arch            Default Arch value for filtering sections\r
     #   @param      Table           Database used to retrieve module/package information\r
-    #   @param      Macros          Macros used for replacement in file\r
     #\r
-    def __init__(self, FilePath, FileType, Table):\r
+    def __init__(self, FilePath, FileType, Arch, Table):\r
         # prevent re-initialization\r
         if hasattr(self, "_Table"):\r
             return\r
-        MetaFileParser.__init__(self, FilePath, FileType, Table)\r
+        MetaFileParser.__init__(self, FilePath, FileType, Arch, Table)\r
         self.PcdsDict = {}\r
 \r
     ## Parser starter\r
@@ -848,16 +858,16 @@ class DscParser(MetaFileParser):
     #\r
     #   @param      FilePath        The path of platform description file\r
     #   @param      FileType        The raw data of DSC file\r
+    #   @param      Arch            Default Arch value for filtering sections\r
     #   @param      Table           Database used to retrieve module/package information\r
-    #   @param      Macros          Macros used for replacement in file\r
     #   @param      Owner           Owner ID (for sub-section parsing)\r
     #   @param      From            ID from which the data comes (for !INCLUDE directive)\r
     #\r
-    def __init__(self, FilePath, FileType, Table, Owner= -1, From= -1):\r
+    def __init__(self, FilePath, FileType, Arch, Table, Owner= -1, From= -1):\r
         # prevent re-initialization\r
         if hasattr(self, "_Table"):\r
             return\r
-        MetaFileParser.__init__(self, FilePath, FileType, Table, Owner, From)\r
+        MetaFileParser.__init__(self, FilePath, FileType, Arch, Table, Owner, From)\r
         self._Version = 0x00010005  # Only EDK2 dsc file is supported\r
         # to store conditional directive evaluation result\r
         self._DirectiveStack = []\r
@@ -1481,7 +1491,7 @@ class DscParser(MetaFileParser):
 \r
             IncludedFileTable = MetaFileStorage(self._Table.Cur, IncludedFile1, MODEL_FILE_DSC, False)\r
             Owner = self._Content[self._ContentIndex - 1][0]\r
-            Parser = DscParser(IncludedFile1, self._FileType, IncludedFileTable,\r
+            Parser = DscParser(IncludedFile1, self._FileType, self._Arch, IncludedFileTable,\r
                                Owner=Owner, From=Owner)\r
 \r
             # Does not allow lower level included file to include upper level included file\r
@@ -1614,14 +1624,14 @@ class DecParser(MetaFileParser):
     #\r
     #   @param      FilePath        The path of platform description file\r
     #   @param      FileType        The raw data of DSC file\r
+    #   @param      Arch            Default Arch value for filtering sections\r
     #   @param      Table           Database used to retrieve module/package information\r
-    #   @param      Macros          Macros used for replacement in file\r
     #\r
-    def __init__(self, FilePath, FileType, Table):\r
+    def __init__(self, FilePath, FileType, Arch, Table):\r
         # prevent re-initialization\r
         if hasattr(self, "_Table"):\r
             return\r
-        MetaFileParser.__init__(self, FilePath, FileType, Table, -1)\r
+        MetaFileParser.__init__(self, FilePath, FileType, Arch, Table, -1)\r
         self._Comments = []\r
         self._Version = 0x00010005  # Only EDK2 dec file is supported\r
         self._AllPCDs = [] # Only for check duplicate PCD\r
index 2e6c68e33aaef2a1961c1a02b4589f9d61c88ba8..7cd00046888303f9aef35abfde1cb4348d4504ad 100644 (file)
@@ -545,12 +545,6 @@ class DscBuildData(PlatformBuildClassObject):
         for Record in RecordList:\r
             DuplicatedFile = False\r
 \r
-            # process only records COMMON and self.Arch\r
-            SectionArch = Record[3].upper()\r
-            if SectionArch != 'COMMON':\r
-                if SectionArch != self.Arch:\r
-                    continue\r
-\r
             ModuleFile = PathClass(NormPath(Record[0], Macros), GlobalData.gWorkspace, Arch=self._Arch)\r
             ModuleId = Record[5]\r
             LineNo = Record[6]\r
@@ -2859,6 +2853,7 @@ class WorkspaceDatabase(object):
             MetaFile = self._FILE_PARSER_[FileType](\r
                                 FilePath, \r
                                 FileType, \r
+                                Arch,\r
                                 MetaFileStorage(self.WorkspaceDb.Cur, FilePath, FileType)\r
                                 )\r
             # alwasy do post-process, in case of macros change\r