]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Workspace/DecBuildData.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / DecBuildData.py
index 31ee13eca91f665b06f24e9916a252b57dcd8b2e..d58d88eca754c97530f186a2e8d8595c822bea10 100644 (file)
@@ -3,21 +3,17 @@
 #\r
 # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # (C) Copyright 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
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 from Common.StringUtils import *\r
 from Common.DataType import *\r
 from Common.Misc import *\r
 from types import *\r
 from collections import OrderedDict\r
-\r
+from CommonDataClass.DataClass import *\r
 from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, PcdClassObject\r
+from Common.GlobalData import gGlobalDefines\r
+from re import compile\r
 \r
 ## Platform build information from DEC file\r
 #\r
@@ -109,7 +105,7 @@ class DecBuildData(PackageBuildClassObject):
     @property\r
     def _Macros(self):\r
         if self._MacroDict is None:\r
-            self._MacroDict = dict(GlobalData.gGlobalDefines)\r
+            self._MacroDict = dict(gGlobalDefines)\r
         return self._MacroDict\r
 \r
     ## Get architecture\r
@@ -119,7 +115,7 @@ class DecBuildData(PackageBuildClassObject):
 \r
     ## Retrieve all information in [Defines] section\r
     #\r
-    #   (Retriving all [Defines] information in one-shot is just to save time.)\r
+    #   (Retrieving all [Defines] information in one-shot is just to save time.)\r
     #\r
     def _GetHeaderInfo(self):\r
         RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch]\r
@@ -165,7 +161,7 @@ class DecBuildData(PackageBuildClassObject):
         if self._Protocols is None:\r
             #\r
             # tdict is a special kind of dict, used for selecting correct\r
-            # protocol defition for given ARCH\r
+            # protocol definition for given ARCH\r
             #\r
             ProtocolDict = tdict(True)\r
             PrivateProtocolDict = tdict(True)\r
@@ -208,7 +204,7 @@ class DecBuildData(PackageBuildClassObject):
         if self._Ppis is None:\r
             #\r
             # tdict is a special kind of dict, used for selecting correct\r
-            # PPI defition for given ARCH\r
+            # PPI definition for given ARCH\r
             #\r
             PpiDict = tdict(True)\r
             PrivatePpiDict = tdict(True)\r
@@ -251,7 +247,7 @@ class DecBuildData(PackageBuildClassObject):
         if self._Guids is None:\r
             #\r
             # tdict is a special kind of dict, used for selecting correct\r
-            # GUID defition for given ARCH\r
+            # GUID definition for given ARCH\r
             #\r
             GuidDict = tdict(True)\r
             PrivateGuidDict = tdict(True)\r
@@ -298,7 +294,6 @@ class DecBuildData(PackageBuildClassObject):
             PublicInclues = []\r
             RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch]\r
             Macros = self._Macros\r
-            Macros["EDK_SOURCE"] = GlobalData.gEcpSource\r
             for Record in RecordList:\r
                 File = PathClass(NormPath(Record[0], Macros), self._PackageDir, Arch=self._Arch)\r
                 LineNo = Record[-1]\r
@@ -361,6 +356,21 @@ class DecBuildData(PackageBuildClassObject):
             self._Pcds.update(self._GetPcd(MODEL_PCD_DYNAMIC_EX))\r
         return self._Pcds\r
 \r
+    def ParsePcdName(self,TokenCName):\r
+        TokenCName = TokenCName.strip()\r
+        if TokenCName.startswith("["):\r
+            if "." in TokenCName:\r
+                Demesionattr = TokenCName[:TokenCName.index(".")]\r
+                Fields = TokenCName[TokenCName.index(".")+1:]\r
+            else:\r
+                Demesionattr = TokenCName\r
+                Fields = ""\r
+        else:\r
+            Demesionattr = ""\r
+            Fields = TokenCName\r
+\r
+        return Demesionattr,Fields\r
+\r
     def ProcessStructurePcd(self, StructurePcdRawDataSet):\r
         s_pcd_set = OrderedDict()\r
         for s_pcd, LineNo in StructurePcdRawDataSet:\r
@@ -373,6 +383,8 @@ class DecBuildData(PackageBuildClassObject):
             dep_pkgs = []\r
             struct_pcd = StructurePcd()\r
             for item, LineNo in s_pcd_set[pcdname]:\r
+                if not item.TokenCName:\r
+                    continue\r
                 if "<HeaderFiles>" in item.TokenCName:\r
                     struct_pcd.StructuredPcdIncludeFile.append(item.DefaultValue)\r
                 elif "<Packages>" in item.TokenCName:\r
@@ -385,7 +397,8 @@ class DecBuildData(PackageBuildClassObject):
                     struct_pcd.PkgPath = self.MetaFile.File\r
                     struct_pcd.SetDecDefaultValue(item.DefaultValue)\r
                 else:\r
-                    struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue, self.MetaFile.File, LineNo)\r
+                    DemesionAttr, Fields = self.ParsePcdName(item.TokenCName)\r
+                    struct_pcd.AddDefaultValue(Fields, item.DefaultValue, self.MetaFile.File, LineNo,DemesionAttr)\r
 \r
             struct_pcd.PackageDecs = dep_pkgs\r
             str_pcd_set.append(struct_pcd)\r
@@ -446,15 +459,13 @@ class DecBuildData(PackageBuildClassObject):
         StructurePcds = self.ProcessStructurePcd(StrPcdSet)\r
         for pcd in StructurePcds:\r
             Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd\r
-        StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')\r
+        StructPattern = compile(r'[_a-zA-Z][0-9A-Za-z_]*$')\r
         for pcd in Pcds.values():\r
             if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
-                if StructPattern.match(pcd.DatumType) is None:\r
+                if not pcd.IsAggregateDatumType():\r
                     EdkLogger.error('build', FORMAT_INVALID, "DatumType only support BOOLEAN, UINT8, UINT16, UINT32, UINT64, VOID* or a valid struct name.", DefinitionPosition[pcd][0], DefinitionPosition[pcd][1])\r
-        for struct_pcd in Pcds.values():\r
-            if isinstance(struct_pcd, StructurePcd) and not struct_pcd.StructuredPcdIncludeFile:\r
-                EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName, DefinitionPosition[struct_pcd][0], DefinitionPosition[struct_pcd][1] ))\r
-\r
+                elif not pcd.IsArray() and not pcd.StructuredPcdIncludeFile:\r
+                    EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (pcd.TokenSpaceGuidCName, pcd.TokenCName, pcd.DefinitionPosition[0], pcd.DefinitionPosition[1] ))\r
         return Pcds\r
 \r
     @property\r