X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FWorkspace%2FDecBuildData.py;h=ccd6cc6a3754bff1a4492eac09b9990e22f7066e;hp=61f15086d0ae0f70e33801ef4539fcc721d5041b;hb=066c71544ed1c0e1a703b26982f9da60d21bcc5a;hpb=06140766c13fb9288a922990ffde77fca93fc71d diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index 61f15086d0..ccd6cc6a37 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -15,6 +15,7 @@ from Common.String import * from Common.DataType import * from Common.Misc import * from types import * +from collections import OrderedDict from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, PcdClassObject @@ -95,6 +96,7 @@ class DecBuildData(PackageBuildClassObject): self._Ppis = None self._Guids = None self._Includes = None + self._CommonIncludes = None self._LibraryClasses = None self._Pcds = None self.__Macros = None @@ -105,7 +107,7 @@ class DecBuildData(PackageBuildClassObject): ## Get current effective macros def _GetMacros(self): - if self.__Macros == None: + if self.__Macros is None: self.__Macros = {} self.__Macros.update(GlobalData.gGlobalDefines) return self.__Macros @@ -143,34 +145,34 @@ class DecBuildData(PackageBuildClassObject): ## Retrieve package name def _GetPackageName(self): - if self._PackageName == None: - if self._Header == None: + if self._PackageName is None: + if self._Header is None: self._GetHeaderInfo() - if self._PackageName == None: + if self._PackageName is None: EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "No PACKAGE_NAME", File=self.MetaFile) return self._PackageName ## Retrieve file guid def _GetFileGuid(self): - if self._Guid == None: - if self._Header == None: + if self._Guid is None: + if self._Header is None: self._GetHeaderInfo() - if self._Guid == None: + if self._Guid is None: EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "No PACKAGE_GUID", File=self.MetaFile) return self._Guid ## Retrieve package version def _GetVersion(self): - if self._Version == None: - if self._Header == None: + if self._Version is None: + if self._Header is None: self._GetHeaderInfo() - if self._Version == None: + if self._Version is None: self._Version = '' return self._Version ## Retrieve protocol definitions (name/value pairs) def _GetProtocol(self): - if self._Protocols == None: + if self._Protocols is None: # # tdict is a special kind of dict, used for selecting correct # protocol defition for given ARCH @@ -197,9 +199,9 @@ class DecBuildData(PackageBuildClassObject): if Name not in NameList: NameList.append(Name) ProtocolDict[Arch, Name] = Guid - # use sdict to keep the order - self._Protocols = sdict() - self._PrivateProtocols = sdict() + # use OrderedDict to keep the order + self._Protocols = OrderedDict() + self._PrivateProtocols = OrderedDict() for Name in NameList: # # limit the ARCH to self._Arch, if no self._Arch found, tdict @@ -212,7 +214,7 @@ class DecBuildData(PackageBuildClassObject): ## Retrieve PPI definitions (name/value pairs) def _GetPpi(self): - if self._Ppis == None: + if self._Ppis is None: # # tdict is a special kind of dict, used for selecting correct # PPI defition for given ARCH @@ -239,9 +241,9 @@ class DecBuildData(PackageBuildClassObject): if Name not in NameList: NameList.append(Name) PpiDict[Arch, Name] = Guid - # use sdict to keep the order - self._Ppis = sdict() - self._PrivatePpis = sdict() + # use OrderedDict to keep the order + self._Ppis = OrderedDict() + self._PrivatePpis = OrderedDict() for Name in NameList: # # limit the ARCH to self._Arch, if no self._Arch found, tdict @@ -254,7 +256,7 @@ class DecBuildData(PackageBuildClassObject): ## Retrieve GUID definitions (name/value pairs) def _GetGuid(self): - if self._Guids == None: + if self._Guids is None: # # tdict is a special kind of dict, used for selecting correct # GUID defition for given ARCH @@ -281,9 +283,9 @@ class DecBuildData(PackageBuildClassObject): if Name not in NameList: NameList.append(Name) GuidDict[Arch, Name] = Guid - # use sdict to keep the order - self._Guids = sdict() - self._PrivateGuids = sdict() + # use OrderedDict to keep the order + self._Guids = OrderedDict() + self._PrivateGuids = OrderedDict() for Name in NameList: # # limit the ARCH to self._Arch, if no self._Arch found, tdict @@ -296,7 +298,8 @@ class DecBuildData(PackageBuildClassObject): ## Retrieve public include paths declared in this package def _GetInclude(self): - if self._Includes == None: + if self._Includes is None or self._CommonIncludes is None: + self._CommonIncludes = [] self._Includes = [] self._PrivateIncludes = [] PublicInclues = [] @@ -324,12 +327,13 @@ class DecBuildData(PackageBuildClassObject): PublicInclues.append(File) if File in self._PrivateIncludes: EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % File, File=self.MetaFile, Line=LineNo) - + if Record[3] == "COMMON": + self._CommonIncludes.append(File) return self._Includes ## Retrieve library class declarations (not used in build at present) def _GetLibraryClass(self): - if self._LibraryClasses == None: + if self._LibraryClasses is None: # # tdict is a special kind of dict, used for selecting correct # library class declaration for given ARCH @@ -346,15 +350,15 @@ class DecBuildData(PackageBuildClassObject): EdkLogger.error('build', ErrorCode, ExtraData=ErrorInfo, File=self.MetaFile, Line=LineNo) LibraryClassSet.add(LibraryClass) LibraryClassDict[Arch, LibraryClass] = File - self._LibraryClasses = sdict() + self._LibraryClasses = OrderedDict() for LibraryClass in LibraryClassSet: self._LibraryClasses[LibraryClass] = LibraryClassDict[self._Arch, LibraryClass] return self._LibraryClasses ## Retrieve PCD declarations def _GetPcds(self): - if self._Pcds == None: - self._Pcds = sdict() + if self._Pcds is None: + self._Pcds = OrderedDict() self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD)) self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE)) self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG)) @@ -364,7 +368,7 @@ class DecBuildData(PackageBuildClassObject): def ProcessStructurePcd(self, StructurePcdRawDataSet): - s_pcd_set = dict() + s_pcd_set = OrderedDict() for s_pcd,LineNo in StructurePcdRawDataSet: if s_pcd.TokenSpaceGuidCName not in s_pcd_set: s_pcd_set[s_pcd.TokenSpaceGuidCName] = [] @@ -390,16 +394,12 @@ class DecBuildData(PackageBuildClassObject): struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue,self.MetaFile.File,LineNo) struct_pcd.PackageDecs = dep_pkgs - if not struct_pcd.StructuredPcdIncludeFile: - 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,self.MetaFile.File,LineNo )) - str_pcd_set.append(struct_pcd) - return str_pcd_set ## Retrieve PCD declarations for given type def _GetPcd(self, Type): - Pcds = sdict() + Pcds = OrderedDict() # # tdict is a special kind of dict, used for selecting correct # PCD declaration for given ARCH @@ -422,7 +422,7 @@ class DecBuildData(PackageBuildClassObject): # will automatically turn to 'common' ARCH and try again # Setting,LineNo = PcdDict[self._Arch, PcdCName, TokenSpaceGuid] - if Setting == None: + if Setting is None: continue DefaultValue, DatumType, TokenNumber = AnalyzePcdData(Setting) @@ -442,6 +442,7 @@ class DecBuildData(PackageBuildClassObject): list(validlists), list(expressions) ) + PcdObj.DefinitionPosition = (self.MetaFile.File,LineNo) if "." in TokenSpaceGuid: StrPcdSet.append((PcdObj,LineNo)) else: @@ -450,8 +451,21 @@ class DecBuildData(PackageBuildClassObject): StructurePcds = self.ProcessStructurePcd(StrPcdSet) for pcd in StructurePcds: Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd + StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$') + for pcd in Pcds.values(): + if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]: + if StructPattern.match(pcd.DatumType) is None: + EdkLogger.error('build', FORMAT_INVALID, "DatumType only support BOOLEAN, UINT8, UINT16, UINT32, UINT64, VOID* or a valid struct name.", pcd.DefinitionPosition[0],pcd.DefinitionPosition[1]) + for struct_pcd in Pcds.values(): + if isinstance(struct_pcd,StructurePcd) and not struct_pcd.StructuredPcdIncludeFile: + 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,struct_pcd.DefinitionPosition[0],struct_pcd.DefinitionPosition[1] )) return Pcds + @property + def CommonIncludes(self): + if self._CommonIncludes is None: + self.Includes + return self._CommonIncludes _Macros = property(_GetMacros)