X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FWorkspace%2FDscBuildData.py;h=2cc920696d63eda405a8b1192f2b37f7da29a319;hp=8fe4d4f5cbe193581e6539e7e1508fa665b1e7fa;hb=a6c910e3583c0124e4ba0d42004003fff036e160;hpb=c8ae65ac5218973e473ba1ba4bd5f9ccb547a219 diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 8fe4d4f5cb..2cc920696d 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -279,8 +279,6 @@ class DscBuildData(PlatformBuildClassObject): ## handle Override Path of Module def _HandleOverridePath(self): RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch] - Macros = self._Macros - Macros["EDK_SOURCE"] = GlobalData.gEcpSource for Record in RecordList: ModuleId = Record[6] LineNo = Record[7] @@ -298,7 +296,7 @@ class DscBuildData(PlatformBuildClassObject): ## Get current effective macros def _GetMacros(self): - if self.__Macros == None: + if self.__Macros is None: self.__Macros = {} self.__Macros.update(GlobalData.gPlatformDefines) self.__Macros.update(GlobalData.gGlobalDefines) @@ -368,7 +366,7 @@ class DscBuildData(PlatformBuildClassObject): elif Name == TAB_DSC_DEFINES_BUILD_TARGETS: self._BuildTargets = GetSplitValueList(Record[2]) elif Name == TAB_DSC_DEFINES_SKUID_IDENTIFIER: - if self._SkuName == None: + if self._SkuName is None: self._SkuName = Record[2] if GlobalData.gSKUID_CMD: self._SkuName = GlobalData.gSKUID_CMD @@ -427,76 +425,76 @@ class DscBuildData(PlatformBuildClassObject): ## Retrieve platform name def _GetPlatformName(self): - if self._PlatformName == None: - if self._Header == None: + if self._PlatformName is None: + if self._Header is None: self._GetHeaderInfo() - if self._PlatformName == None: + if self._PlatformName is None: EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No PLATFORM_NAME", File=self.MetaFile) return self._PlatformName ## 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 PLATFORM_GUID", File=self.MetaFile) return self._Guid ## Retrieve platform 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: EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No PLATFORM_VERSION", File=self.MetaFile) return self._Version ## Retrieve platform description file version def _GetDscSpec(self): - if self._DscSpecification == None: - if self._Header == None: + if self._DscSpecification is None: + if self._Header is None: self._GetHeaderInfo() - if self._DscSpecification == None: + if self._DscSpecification is None: EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No DSC_SPECIFICATION", File=self.MetaFile) return self._DscSpecification ## Retrieve OUTPUT_DIRECTORY def _GetOutpuDir(self): - if self._OutputDirectory == None: - if self._Header == None: + if self._OutputDirectory is None: + if self._Header is None: self._GetHeaderInfo() - if self._OutputDirectory == None: + if self._OutputDirectory is None: self._OutputDirectory = os.path.join("Build", self._PlatformName) return self._OutputDirectory ## Retrieve SUPPORTED_ARCHITECTURES def _GetSupArch(self): - if self._SupArchList == None: - if self._Header == None: + if self._SupArchList is None: + if self._Header is None: self._GetHeaderInfo() - if self._SupArchList == None: + if self._SupArchList is None: EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No SUPPORTED_ARCHITECTURES", File=self.MetaFile) return self._SupArchList ## Retrieve BUILD_TARGETS def _GetBuildTarget(self): - if self._BuildTargets == None: - if self._Header == None: + if self._BuildTargets is None: + if self._Header is None: self._GetHeaderInfo() - if self._BuildTargets == None: + if self._BuildTargets is None: EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No BUILD_TARGETS", File=self.MetaFile) return self._BuildTargets def _GetPcdInfoFlag(self): - if self._PcdInfoFlag == None or self._PcdInfoFlag.upper() == 'FALSE': + if self._PcdInfoFlag is None or self._PcdInfoFlag.upper() == 'FALSE': return False elif self._PcdInfoFlag.upper() == 'TRUE': return True else: return False def _GetVarCheckFlag(self): - if self._VarCheckFlag == None or self._VarCheckFlag.upper() == 'FALSE': + if self._VarCheckFlag is None or self._VarCheckFlag.upper() == 'FALSE': return False elif self._VarCheckFlag.upper() == 'TRUE': return True @@ -505,10 +503,10 @@ class DscBuildData(PlatformBuildClassObject): # # Retrieve SKUID_IDENTIFIER def _GetSkuName(self): - if self._SkuName == None: - if self._Header == None: + if self._SkuName is None: + if self._Header is None: self._GetHeaderInfo() - if self._SkuName == None: + if self._SkuName is None: self._SkuName = 'DEFAULT' return self._SkuName @@ -517,72 +515,72 @@ class DscBuildData(PlatformBuildClassObject): self._SkuName = Value def _GetFdfFile(self): - if self._FlashDefinition == None: - if self._Header == None: + if self._FlashDefinition is None: + if self._Header is None: self._GetHeaderInfo() - if self._FlashDefinition == None: + if self._FlashDefinition is None: self._FlashDefinition = '' return self._FlashDefinition def _GetPrebuild(self): - if self._Prebuild == None: - if self._Header == None: + if self._Prebuild is None: + if self._Header is None: self._GetHeaderInfo() - if self._Prebuild == None: + if self._Prebuild is None: self._Prebuild = '' return self._Prebuild def _GetPostbuild(self): - if self._Postbuild == None: - if self._Header == None: + if self._Postbuild is None: + if self._Header is None: self._GetHeaderInfo() - if self._Postbuild == None: + if self._Postbuild is None: self._Postbuild = '' return self._Postbuild ## Retrieve FLASH_DEFINITION def _GetBuildNumber(self): - if self._BuildNumber == None: - if self._Header == None: + if self._BuildNumber is None: + if self._Header is None: self._GetHeaderInfo() - if self._BuildNumber == None: + if self._BuildNumber is None: self._BuildNumber = '' return self._BuildNumber ## Retrieve MAKEFILE_NAME def _GetMakefileName(self): - if self._MakefileName == None: - if self._Header == None: + if self._MakefileName is None: + if self._Header is None: self._GetHeaderInfo() - if self._MakefileName == None: + if self._MakefileName is None: self._MakefileName = '' return self._MakefileName ## Retrieve BsBaseAddress def _GetBsBaseAddress(self): - if self._BsBaseAddress == None: - if self._Header == None: + if self._BsBaseAddress is None: + if self._Header is None: self._GetHeaderInfo() - if self._BsBaseAddress == None: + if self._BsBaseAddress is None: self._BsBaseAddress = '' return self._BsBaseAddress ## Retrieve RtBaseAddress def _GetRtBaseAddress(self): - if self._RtBaseAddress == None: - if self._Header == None: + if self._RtBaseAddress is None: + if self._Header is None: self._GetHeaderInfo() - if self._RtBaseAddress == None: + if self._RtBaseAddress is None: self._RtBaseAddress = '' return self._RtBaseAddress ## Retrieve the top address for the load fix address def _GetLoadFixAddress(self): - if self._LoadFixAddress == None: - if self._Header == None: + if self._LoadFixAddress is None: + if self._Header is None: self._GetHeaderInfo() - if self._LoadFixAddress == None: + if self._LoadFixAddress is None: self._LoadFixAddress = self._Macros.get(TAB_FIX_LOAD_TOP_MEMORY_ADDRESS, '0') try: @@ -608,34 +606,34 @@ class DscBuildData(PlatformBuildClassObject): ## Retrieve RFCLanguage filter def _GetRFCLanguages(self): - if self._RFCLanguages == None: - if self._Header == None: + if self._RFCLanguages is None: + if self._Header is None: self._GetHeaderInfo() - if self._RFCLanguages == None: + if self._RFCLanguages is None: self._RFCLanguages = [] return self._RFCLanguages ## Retrieve ISOLanguage filter def _GetISOLanguages(self): - if self._ISOLanguages == None: - if self._Header == None: + if self._ISOLanguages is None: + if self._Header is None: self._GetHeaderInfo() - if self._ISOLanguages == None: + if self._ISOLanguages is None: self._ISOLanguages = [] return self._ISOLanguages ## Retrieve the GUID string for VPD tool def _GetVpdToolGuid(self): - if self._VpdToolGuid == None: - if self._Header == None: + if self._VpdToolGuid is None: + if self._Header is None: self._GetHeaderInfo() - if self._VpdToolGuid == None: + if self._VpdToolGuid is None: self._VpdToolGuid = '' return self._VpdToolGuid ## Retrieve [SkuIds] section information def _GetSkuIds(self): - if self._SkuIds == None: - self._SkuIds = sdict() + if self._SkuIds is None: + self._SkuIds = OrderedDict() RecordList = self._RawData[MODEL_EFI_SKU_ID, self._Arch] for Record in RecordList: if Record[0] in [None, '']: @@ -646,7 +644,7 @@ class DscBuildData(PlatformBuildClassObject): File=self.MetaFile, Line=Record[-1]) Pattern = re.compile('^[1-9]\d*|0$') HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$') - if Pattern.match(Record[0]) == None and HexPattern.match(Record[0]) == None: + if Pattern.match(Record[0]) is None and HexPattern.match(Record[0]) is None: EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID number is invalid. It only support Integer and HexNumber", File=self.MetaFile, Line=Record[-1]) if not IsValidWord(Record[1]): @@ -661,8 +659,8 @@ class DscBuildData(PlatformBuildClassObject): def ToInt(self,intstr): return int(intstr,16) if intstr.upper().startswith("0X") else int(intstr) def _GetDefaultStores(self): - if self.DefaultStores == None: - self.DefaultStores = sdict() + if self.DefaultStores is None: + self.DefaultStores = OrderedDict() RecordList = self._RawData[MODEL_EFI_DEFAULT_STORES, self._Arch] for Record in RecordList: if Record[0] in [None, '']: @@ -673,7 +671,7 @@ class DscBuildData(PlatformBuildClassObject): File=self.MetaFile, Line=Record[-1]) Pattern = re.compile('^[1-9]\d*|0$') HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$') - if Pattern.match(Record[0]) == None and HexPattern.match(Record[0]) == None: + if Pattern.match(Record[0]) is None and HexPattern.match(Record[0]) is None: EdkLogger.error('build', FORMAT_INVALID, "The format of the DefaultStores ID number is invalid. It only support Integer and HexNumber", File=self.MetaFile, Line=Record[-1]) if not IsValidWord(Record[1]): @@ -689,10 +687,10 @@ class DscBuildData(PlatformBuildClassObject): ## Retrieve [Components] section information def _GetModules(self): - if self._Modules != None: + if self._Modules is not None: return self._Modules - self._Modules = sdict() + self._Modules = OrderedDict() RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch] Macros = self._Macros Macros["EDK_SOURCE"] = GlobalData.gEcpSource @@ -788,13 +786,13 @@ class DscBuildData(PlatformBuildClassObject): ## Retrieve all possible library instances used in this platform def _GetLibraryInstances(self): - if self._LibraryInstances == None: + if self._LibraryInstances is None: self._GetLibraryClasses() return self._LibraryInstances ## Retrieve [LibraryClasses] information def _GetLibraryClasses(self): - if self._LibraryClasses == None: + if self._LibraryClasses is None: self._LibraryInstances = [] # # tdict is a special dict kind of type, used for selecting correct @@ -832,7 +830,7 @@ class DscBuildData(PlatformBuildClassObject): # try all possible module types for ModuleType in SUP_MODULE_LIST: LibraryInstance = LibraryClassDict[self._Arch, ModuleType, LibraryClass] - if LibraryInstance == None: + if LibraryInstance is None: continue self._LibraryClasses[LibraryClass, ModuleType] = LibraryInstance @@ -859,7 +857,7 @@ class DscBuildData(PlatformBuildClassObject): return self._LibraryClasses def _ValidatePcd(self, PcdCName, TokenSpaceGuid, Setting, PcdType, LineNo): - if self._DecPcds == None: + if self._DecPcds is None: FdfInfList = [] if GlobalData.gFdfParser: @@ -947,10 +945,10 @@ class DscBuildData(PlatformBuildClassObject): for pcd in HiiPcd: for skuid in pcd.SkuInfoList: skuobj = pcd.SkuInfoList.get(skuid) - if "STANDARD" not in skuobj.DefaultStoreDict: + if TAB_DEFAULT_STORES_DEFAULT not in skuobj.DefaultStoreDict: PcdDefaultStoreSet = set([defaultstorename for defaultstorename in skuobj.DefaultStoreDict]) mindefaultstorename = DefaultStoreMgr.GetMin(PcdDefaultStoreSet) - skuobj.DefaultStoreDict['STANDARD'] = copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename]) + skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename]) return Pcds def RecoverCommandLinePcd(self): @@ -1121,8 +1119,8 @@ class DscBuildData(PlatformBuildClassObject): ## Retrieve all PCD settings in platform def _GetPcds(self): - if self._Pcds == None: - self._Pcds = sdict() + if self._Pcds is None: + self._Pcds = OrderedDict() self.__ParsePcdFromCommandLine() self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD)) self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE)) @@ -1143,21 +1141,10 @@ class DscBuildData(PlatformBuildClassObject): self.RecoverCommandLinePcd() return self._Pcds - def _dumpPcdInfo(self,Pcds): - for pcd in Pcds: - pcdobj = Pcds[pcd] - if not pcdobj.TokenCName.startswith("Test"): - continue - for skuid in pcdobj.SkuInfoList: - if pcdobj.Type in (self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]): - for storename in pcdobj.SkuInfoList[skuid].DefaultStoreDict: - print "PcdCName: %s, SkuName: %s, StoreName: %s, Value: %s" % (".".join((pcdobj.TokenSpaceGuidCName, pcdobj.TokenCName)), skuid,storename,str(pcdobj.SkuInfoList[skuid].DefaultStoreDict[storename])) - else: - print "PcdCName: %s, SkuName: %s, Value: %s" % (".".join((pcdobj.TokenSpaceGuidCName, pcdobj.TokenCName)), skuid,str(pcdobj.SkuInfoList[skuid].DefaultValue)) ## Retrieve [BuildOptions] def _GetBuildOptions(self): - if self._BuildOptions == None: - self._BuildOptions = sdict() + if self._BuildOptions is None: + self._BuildOptions = OrderedDict() # # Retrieve build option for EDKII and EDK style module # @@ -1178,10 +1165,10 @@ class DscBuildData(PlatformBuildClassObject): return self._BuildOptions def GetBuildOptionsByModuleType(self, Edk, ModuleType): - if self._ModuleTypeOptions == None: - self._ModuleTypeOptions = sdict() + if self._ModuleTypeOptions is None: + self._ModuleTypeOptions = OrderedDict() if (Edk, ModuleType) not in self._ModuleTypeOptions: - options = sdict() + options = OrderedDict() self._ModuleTypeOptions[Edk, ModuleType] = options DriverType = '%s.%s' % (Edk, ModuleType) CommonDriverType = '%s.%s' % ('COMMON', ModuleType) @@ -1325,7 +1312,7 @@ class DscBuildData(PlatformBuildClassObject): str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} for str_pcd_data in StrPcdSet[str_pcd]: if str_pcd_data[3] in SkuIds: - str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:],LineNo=str_pcd_data[5]) + str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],TAB_DEFAULT_STORES_DEFAULT if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:],LineNo=str_pcd_data[5]) S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str else: EdkLogger.error('build', PARSER_ERROR, @@ -1359,7 +1346,7 @@ class DscBuildData(PlatformBuildClassObject): NoDefault = True break nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid) - stru_pcd.SkuOverrideValues[skuid] = copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid]) if not NoDefault else copy.deepcopy({defaultstorename: stru_pcd.DefaultValues for defaultstorename in DefaultStores} if DefaultStores else {'STANDARD':stru_pcd.DefaultValues}) + stru_pcd.SkuOverrideValues[skuid] = copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid]) if not NoDefault else copy.deepcopy({defaultstorename: stru_pcd.DefaultValues for defaultstorename in DefaultStores} if DefaultStores else {TAB_DEFAULT_STORES_DEFAULT:stru_pcd.DefaultValues}) if not NoDefault: stru_pcd.ValueChain[(skuid,'')]= (nextskuid,'') if stru_pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: @@ -1446,7 +1433,7 @@ class DscBuildData(PlatformBuildClassObject): # @retval a dict object contains settings of given PCD type # def _GetPcd(self, Type): - Pcds = sdict() + Pcds = OrderedDict() # # tdict is a special dict kind of type, used for selecting correct # PCD settings for certain ARCH @@ -1457,7 +1444,7 @@ class DscBuildData(PlatformBuildClassObject): PcdSet = set() # Find out all possible PCD candidates for self._Arch RecordList = self._RawData[Type, self._Arch] - PcdValueDict = sdict() + PcdValueDict = OrderedDict() for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList: SkuName = SkuName.upper() SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName @@ -1471,7 +1458,7 @@ class DscBuildData(PlatformBuildClassObject): for PcdCName, TokenSpaceGuid, SkuName, Dummy4 in PcdSet: Setting = PcdDict[self._Arch, PcdCName, TokenSpaceGuid, SkuName] - if Setting == None: + if Setting is None: continue PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) if (PcdCName, TokenSpaceGuid) in PcdValueDict: @@ -1509,26 +1496,6 @@ class DscBuildData(PlatformBuildClassObject): return Pcds - def __UNICODE2OCTList(self,Value): - Value = Value.strip() - Value = Value[2:-1] - List = [] - for Item in Value: - Temp = '%04X' % ord(Item) - List.append('0x' + Temp[2:4]) - List.append('0x' + Temp[0:2]) - List.append('0x00') - List.append('0x00') - return List - def __STRING2OCTList(self,Value): - OCTList = [] - Value = Value.strip('"') - for char in Value: - Temp = '%02X' % ord(char) - OCTList.append('0x' + Temp) - OCTList.append('0x00') - return OCTList - def GetStructurePcdMaxSize(self, str_pcd): pcd_default_value = str_pcd.DefaultValue sku_values = [skuobj.HiiDefaultValue if str_pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]] else skuobj.DefaultValue for skuobj in str_pcd.SkuInfoList.values()] @@ -1744,10 +1711,10 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + ' UINT32 FieldSize;\n' CApp = CApp + ' CHAR8 *Value;\n' - CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % ('DEFAULT', 'STANDARD') + CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % ('DEFAULT', TAB_DEFAULT_STORES_DEFAULT) inherit_OverrideValues = Pcd.SkuOverrideValues[SkuName] - if (SkuName,DefaultStoreName) == ('DEFAULT','STANDARD'): - pcddefaultvalue = Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue + if (SkuName,DefaultStoreName) == ('DEFAULT',TAB_DEFAULT_STORES_DEFAULT): + pcddefaultvalue = Pcd.DefaultFromDSC.get('DEFAULT',{}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue else: if not Pcd.DscRawValue: # handle the case that structure pcd is not appear in DSC @@ -1766,14 +1733,14 @@ class DscBuildData(PlatformBuildClassObject): (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList)) Value, ValueSize = ParseFieldValue (FieldList) - if (SkuName,DefaultStoreName) == ('DEFAULT','STANDARD'): + if (SkuName,DefaultStoreName) == ('DEFAULT',TAB_DEFAULT_STORES_DEFAULT): if isinstance(Value, str): - CApp = CApp + ' Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) + CApp = CApp + ' Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC.get('DEFAULT',{}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) elif IsArray: # # Use memcpy() to copy value into field # - CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) + CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC.get('DEFAULT',{}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize) else: if isinstance(Value, str): @@ -1785,7 +1752,7 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DscRawValue.get(SkuName,{}).get(DefaultStoreName)) CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize) continue - if (SkuName,DefaultStoreName) == ('DEFAULT','STANDARD') or (( (SkuName,'') not in Pcd.ValueChain) and ( (SkuName,DefaultStoreName) not in Pcd.ValueChain )): + if (SkuName,DefaultStoreName) == ('DEFAULT',TAB_DEFAULT_STORES_DEFAULT) or (( (SkuName,'') not in Pcd.ValueChain) and ( (SkuName,DefaultStoreName) not in Pcd.ValueChain )): for FieldName in FieldList: IsArray = IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: @@ -1941,7 +1908,7 @@ class DscBuildData(PlatformBuildClassObject): if Pcd.Type not in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: for skuname in self.SkuIdMgr.GetSkuChain(SkuName): - storeset = [DefaultStoreName] if DefaultStoreName == 'STANDARD' else ['STANDARD', DefaultStoreName] + storeset = [DefaultStoreName] if DefaultStoreName == TAB_DEFAULT_STORES_DEFAULT else [TAB_DEFAULT_STORES_DEFAULT, DefaultStoreName] for defaultstorenameitem in storeset: CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (skuname, defaultstorenameitem) CApp = CApp + self.GenerateInitValueStatement(Pcd,skuname,defaultstorenameitem) @@ -1949,7 +1916,7 @@ class DscBuildData(PlatformBuildClassObject): break else: CApp = CApp + "// SkuName: %s, DefaultStoreName: STANDARD \n" % self.SkuIdMgr.SystemSkuId - CApp = CApp + self.GenerateInitValueStatement(Pcd,self.SkuIdMgr.SystemSkuId,"STANDARD") + CApp = CApp + self.GenerateInitValueStatement(Pcd,self.SkuIdMgr.SystemSkuId,TAB_DEFAULT_STORES_DEFAULT) CApp = CApp + self.GenerateCommandLineValueStatement(Pcd) # # Set new PCD value and size @@ -1991,7 +1958,7 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + self.GenerateCommandLineValue(Pcd) if not Pcd.SkuOverrideValues or Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: - CApp = CApp + self.GenerateInitValueFunction(Pcd,self.SkuIdMgr.SystemSkuId, 'STANDARD') + CApp = CApp + self.GenerateInitValueFunction(Pcd,self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT) else: for SkuName in self.SkuIdMgr.SkuOverrideOrder(): if SkuName not in Pcd.SkuOverrideValues: @@ -2000,7 +1967,7 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + self.GenerateInitValueFunction(Pcd,SkuName,DefaultStoreName) if not Pcd.SkuOverrideValues or Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: - InitByteValue, CApp = self.GenerateInitializeFunc(self.SkuIdMgr.SystemSkuId, 'STANDARD', Pcd, InitByteValue, CApp) + InitByteValue, CApp = self.GenerateInitializeFunc(self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT, Pcd, InitByteValue, CApp) else: for SkuName in self.SkuIdMgr.SkuOverrideOrder(): if SkuName not in Pcd.SkuOverrideValues: @@ -2016,7 +1983,7 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + '{\n' for Pcd in StructuredPcds.values(): if not Pcd.SkuOverrideValues or Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: - CApp = CApp + ' Initialize_%s_%s_%s_%s();\n' % (self.SkuIdMgr.SystemSkuId, 'STANDARD', Pcd.TokenSpaceGuidCName, Pcd.TokenCName) + CApp = CApp + ' Initialize_%s_%s_%s_%s();\n' % (self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, Pcd.TokenCName) else: for SkuName in self.SkuIdMgr.SkuOverrideOrder(): if SkuName not in Pcd.SkuOverrideValues: @@ -2047,7 +2014,9 @@ class DscBuildData(PlatformBuildClassObject): continue if Cache.Includes: if str(Cache.MetaFile.Path) not in PlatformInc: - PlatformInc[str(Cache.MetaFile.Path)] = Cache.CommonIncludes + PlatformInc[str(Cache.MetaFile.Path)] = [] + PlatformInc[str(Cache.MetaFile.Path)].append (os.path.dirname(Cache.MetaFile.Path)) + PlatformInc[str(Cache.MetaFile.Path)].extend (Cache.CommonIncludes) PcdDependDEC = [] for Pcd in StructuredPcds.values(): @@ -2228,7 +2197,7 @@ class DscBuildData(PlatformBuildClassObject): def _GetDynamicPcd(self, Type): - Pcds = sdict() + Pcds = OrderedDict() # # tdict is a special dict kind of type, used for selecting correct # PCD settings for certain ARCH and SKU @@ -2254,7 +2223,7 @@ class DscBuildData(PlatformBuildClassObject): for PcdCName, TokenSpaceGuid, SkuName, Dummy4 in PcdList: Setting = PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceGuid] - if Setting == None: + if Setting is None: continue PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) @@ -2290,7 +2259,7 @@ class DscBuildData(PlatformBuildClassObject): pcdDecObject = self._DecPcds[pcd.TokenCName, pcd.TokenSpaceGuidCName] # Only fix the value while no value provided in DSC file. for sku in pcd.SkuInfoList.values(): - if (sku.DefaultValue == "" or sku.DefaultValue==None): + if not sku.DefaultValue: sku.DefaultValue = pcdDecObject.DefaultValue if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys(): valuefromDec = pcdDecObject.DefaultValue @@ -2338,14 +2307,14 @@ class DscBuildData(PlatformBuildClassObject): if Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: if self.SkuIdMgr.SystemSkuId not in Pcd.DscRawValue: Pcd.DscRawValue[self.SkuIdMgr.SystemSkuId] = {} - Pcd.DscRawValue[self.SkuIdMgr.SystemSkuId]['STANDARD'] = Pcd.DefaultValue + Pcd.DscRawValue[self.SkuIdMgr.SystemSkuId][TAB_DEFAULT_STORES_DEFAULT] = Pcd.DefaultValue for skuname in Pcd.SkuInfoList: Pcd.DscRawValue[skuname] = {} if Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: for defaultstore in Pcd.SkuInfoList[skuname].DefaultStoreDict: Pcd.DscRawValue[skuname][defaultstore] = Pcd.SkuInfoList[skuname].DefaultStoreDict[defaultstore] else: - Pcd.DscRawValue[skuname]['STANDARD'] = Pcd.SkuInfoList[skuname].DefaultValue + Pcd.DscRawValue[skuname][TAB_DEFAULT_STORES_DEFAULT] = Pcd.SkuInfoList[skuname].DefaultValue def CompletePcdValues(self,PcdSet): Pcds = {} DefaultStoreObj = DefaultStore(self._GetDefaultStores()) @@ -2393,7 +2362,7 @@ class DscBuildData(PlatformBuildClassObject): VariableAttrs = {} - Pcds = sdict() + Pcds = OrderedDict() # # tdict is a special dict kind of type, used for selecting correct # PCD settings for certain ARCH and SKU @@ -2410,7 +2379,7 @@ class DscBuildData(PlatformBuildClassObject): SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName DefaultStore = DefaultStore.upper() if DefaultStore == "COMMON": - DefaultStore = "STANDARD" + DefaultStore = TAB_DEFAULT_STORES_DEFAULT if SkuName not in AvailableSkuIdSet: EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName, File=self.MetaFile, Line=Dummy5) @@ -2426,7 +2395,7 @@ class DscBuildData(PlatformBuildClassObject): for PcdCName, TokenSpaceGuid, SkuName,DefaultStore, Dummy4 in PcdSet: Setting = PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceGuid,DefaultStore] - if Setting == None: + if Setting is None: continue VariableName, VariableGuid, VariableOffset, DefaultValue, VarAttribute = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) @@ -2496,7 +2465,7 @@ class DscBuildData(PlatformBuildClassObject): pcd.DatumType = pcdDecObject.DatumType # Only fix the value while no value provided in DSC file. for sku in pcd.SkuInfoList.values(): - if (sku.HiiDefaultValue == "" or sku.HiiDefaultValue == None): + if (sku.HiiDefaultValue == "" or sku.HiiDefaultValue is None): sku.HiiDefaultValue = pcdDecObject.DefaultValue for default_store in sku.DefaultStoreDict: sku.DefaultStoreDict[default_store]=pcdDecObject.DefaultValue @@ -2555,7 +2524,7 @@ class DscBuildData(PlatformBuildClassObject): def _GetDynamicVpdPcd(self, Type): - Pcds = sdict() + Pcds = OrderedDict() # # tdict is a special dict kind of type, used for selecting correct # PCD settings for certain ARCH and SKU @@ -2580,7 +2549,7 @@ class DscBuildData(PlatformBuildClassObject): # Remove redundant PCD candidates, per the ARCH and SKU for PcdCName, TokenSpaceGuid, SkuName, Dummy4 in PcdList: Setting = PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceGuid] - if Setting == None: + if Setting is None: continue # # For the VOID* type, it can have optional data of MaxDatumSize and InitialValue @@ -2622,7 +2591,7 @@ class DscBuildData(PlatformBuildClassObject): pcd.DatumType = pcdDecObject.DatumType # Only fix the value while no value provided in DSC file. for sku in pcd.SkuInfoList.values(): - if (sku.DefaultValue == "" or sku.DefaultValue==None): + if not sku.DefaultValue: sku.DefaultValue = pcdDecObject.DefaultValue if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys(): valuefromDec = pcdDecObject.DefaultValue @@ -2689,7 +2658,7 @@ class DscBuildData(PlatformBuildClassObject): self.Pcds[Name, Guid].DefaultValue = Value @property def DecPcds(self): - if self._DecPcds == None: + if self._DecPcds is None: FdfInfList = [] if GlobalData.gFdfParser: FdfInfList = GlobalData.gFdfParser.Profile.InfList