X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FAutoGen%2FAutoGen.py;h=a4e36d1a2fb4f3a47157f932157d7a7e8a86f222;hp=b8d8d194156286154c4184a4e9688d60ceeb8876;hb=1563349a967d7e02c43492ba853babb9c660a083;hpb=d98cce8e6364296909135ba27b53d3b31bff73d2 diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index b8d8d19415..a4e36d1a2f 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -256,12 +256,6 @@ class WorkspaceAutoGen(AutoGen): def _InitWorker(self, WorkspaceDir, ActivePlatform, Target, Toolchain, ArchList, MetaFileDb, BuildConfig, ToolDefinition, FlashDefinitionFile='', Fds=None, Fvs=None, Caps=None, SkuId='', UniFlag=None, Progress=None, BuildModule=None): - if Fds is None: - Fds = [] - if Fvs is None: - Fvs = [] - if Caps is None: - Caps = [] self.BuildDatabase = MetaFileDb self.MetaFile = ActivePlatform self.WorkspaceDir = WorkspaceDir @@ -276,9 +270,9 @@ class WorkspaceAutoGen(AutoGen): self.TargetTxt = BuildConfig self.ToolDef = ToolDefinition self.FdfFile = FlashDefinitionFile - self.FdTargetList = Fds - self.FvTargetList = Fvs - self.CapTargetList = Caps + self.FdTargetList = Fds if Fds else [] + self.FvTargetList = Fvs if Fvs else [] + self.CapTargetList = Caps if Caps else [] self.AutoGenObjectList = [] self._BuildDir = None self._FvDir = None @@ -361,13 +355,12 @@ class WorkspaceAutoGen(AutoGen): # but the path (self.MetaFile.Path) is the real path for key in self.FdfProfile.InfDict: if key == 'ArchTBD': - Platform_cache = {} MetaFile_cache = {} for Arch in self.ArchList: - Platform_cache[Arch] = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain] + Current_Platform_cache = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain] MetaFile_cache[Arch] = set() - for Pkey in Platform_cache[Arch].Modules: - MetaFile_cache[Arch].add(Platform_cache[Arch].Modules[Pkey].MetaFile) + for Pkey in Current_Platform_cache.Modules: + MetaFile_cache[Arch].add(Current_Platform_cache.Modules[Pkey].MetaFile) for Inf in self.FdfProfile.InfDict[key]: ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch) for Arch in self.ArchList: @@ -410,7 +403,8 @@ class WorkspaceAutoGen(AutoGen): # apply SKU and inject PCDs from Flash Definition file for Arch in self.ArchList: Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain] - + PlatformPcds = Platform.Pcds + self._GuidDict = Platform._GuidDict SourcePcdDict = {'DynamicEx':set(), 'PatchableInModule':set(),'Dynamic':set(),'FixedAtBuild':set()} BinaryPcdDict = {'DynamicEx':set(), 'PatchableInModule':set()} SourcePcdDict_Keys = SourcePcdDict.keys() @@ -1295,7 +1289,7 @@ class PlatformAutoGen(AutoGen): if DscPcd.Type != "FixedAtBuild": continue if key in ShareFixedAtBuildPcdsSameValue and ShareFixedAtBuildPcdsSameValue[key]: - LibAuto.ConstPcd[key] = Pcd.DefaultValue + LibAuto.ConstPcd[key] = FixedAtBuildPcds[key] def CollectVariables(self, DynamicPcdSet): @@ -1456,13 +1450,10 @@ class PlatformAutoGen(AutoGen): self._NonDynaPcdList_.remove (self._NonDynaPcdList_[Index]) PcdFromModule.Pending = False self._NonDynaPcdList_.append (PcdFromModule) - # Parse the DynamicEx PCD from the AsBuild INF module list of FDF. - DscModuleList = [] - for ModuleInf in self.Platform.Modules.keys(): - DscModuleList.append (os.path.normpath(ModuleInf.Path)) + DscModuleSet = {os.path.normpath(ModuleInf.Path) for ModuleInf in self.Platform.Modules} # add the PCD from modules that listed in FDF but not in DSC to Database for InfName in FdfModuleList: - if InfName not in DscModuleList: + if InfName not in DscModuleSet: InfClass = PathClass(InfName) M = self.BuildDatabase[InfClass, self.Arch, self.BuildTarget, self.ToolChain] # If a module INF in FDF but not in current arch's DSC module list, it must be module (either binary or source) @@ -2352,17 +2343,16 @@ class PlatformAutoGen(AutoGen): ToPcd.Type, Module, FromPcd.Type), File=self.MetaFile) - if FromPcd.MaxDatumSize not in [None, '']: + if FromPcd.MaxDatumSize: ToPcd.MaxDatumSize = FromPcd.MaxDatumSize - if FromPcd.DefaultValue not in [None, '']: + ToPcd.MaxSizeUserSet = FromPcd.MaxDatumSize + if FromPcd.DefaultValue: ToPcd.DefaultValue = FromPcd.DefaultValue - if FromPcd.TokenValue not in [None, '']: + if FromPcd.TokenValue: ToPcd.TokenValue = FromPcd.TokenValue - if FromPcd.MaxDatumSize not in [None, '']: - ToPcd.MaxDatumSize = FromPcd.MaxDatumSize - if FromPcd.DatumType not in [None, '']: + if FromPcd.DatumType: ToPcd.DatumType = FromPcd.DatumType - if FromPcd.SkuInfoList not in [None, '', []]: + if FromPcd.SkuInfoList: ToPcd.SkuInfoList = FromPcd.SkuInfoList # Add Flexible PCD format parse if ToPcd.DefaultValue: @@ -2458,6 +2448,7 @@ class PlatformAutoGen(AutoGen): for Name, Guid in Pcds: Pcd = Pcds[Name, Guid] if Pcd.DatumType == "VOID*" and Pcd.MaxDatumSize in ['', None]: + Pcd.MaxSizeUserSet = None Value = Pcd.DefaultValue if Value in [None, '']: Pcd.MaxDatumSize = '1' @@ -2688,40 +2679,31 @@ class PlatformAutoGen(AutoGen): AllTools = set(ModuleOptions.keys() + PlatformOptions.keys() + PlatformModuleOptions.keys() + ModuleTypeOptions.keys() + self.ToolDefinition.keys()) - BuildOptions = {} + BuildOptions = defaultdict(lambda: defaultdict(str)) for Tool in AllTools: - if Tool not in BuildOptions: - BuildOptions[Tool] = {} - for Options in [self.ToolDefinition, ModuleOptions, PlatformOptions, ModuleTypeOptions, PlatformModuleOptions]: if Tool not in Options: continue for Attr in Options[Tool]: - Value = Options[Tool][Attr] # # Do not generate it in Makefile # if Attr == TAB_TOD_DEFINES_BUILDRULEORDER: continue - if Attr not in BuildOptions[Tool]: - BuildOptions[Tool][Attr] = "" + Value = Options[Tool][Attr] # check if override is indicated if Value.startswith('='): - ToolPath = Value[1:] - ToolPath = mws.handleWsMacro(ToolPath) - BuildOptions[Tool][Attr] = ToolPath + BuildOptions[Tool][Attr] = mws.handleWsMacro(Value[1:]) else: - Value = mws.handleWsMacro(Value) if Attr != 'PATH': - BuildOptions[Tool][Attr] += " " + Value + BuildOptions[Tool][Attr] += " " + mws.handleWsMacro(Value) else: - BuildOptions[Tool][Attr] = Value + BuildOptions[Tool][Attr] = mws.handleWsMacro(Value) + if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag is not None: # # Override UNI flag only for EDK module. # - if 'BUILD' not in BuildOptions: - BuildOptions['BUILD'] = {} BuildOptions['BUILD']['FLAGS'] = self.Workspace.UniFlag return BuildOptions, BuildRuleOrder @@ -2799,7 +2781,7 @@ class ModuleAutoGen(AutoGen): self.Workspace = Workspace self.WorkspaceDir = Workspace.WorkspaceDir - + self._GuidDict = Workspace._GuidDict self.MetaFile = ModuleFile self.PlatformInfo = PlatformAutoGen(Workspace, PlatformFile, Target, Toolchain, Arch) @@ -3789,7 +3771,7 @@ class ModuleAutoGen(AutoGen): if not self.SourceFileList: return [] - NameGuids = [] + NameGuids = set() for SrcFile in self.SourceFileList: if SrcFile.Ext.lower() != '.vfr': continue @@ -3821,7 +3803,7 @@ class ModuleAutoGen(AutoGen): if not Guid: break NameArray = ConvertStringToByteArray('L"' + Name.group(1) + '"') - NameGuids.append((NameArray, GuidStructureStringToGuidString(Guid.group(1)))) + NameGuids.add((NameArray, GuidStructureStringToGuidString(Guid.group(1)))) Pos = Content.find('efivarstore', Name.end()) if not NameGuids: return [] @@ -3896,7 +3878,6 @@ class ModuleAutoGen(AutoGen): VfrGuid = [0xb4, 0x7c, 0xbc, 0xd0, 0x47, 0x6a, 0x5f, 0x49, 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2] VfrGuid = [chr(ItemGuid) for ItemGuid in VfrGuid] fStringIO.write(''.join(VfrGuid)) - type (Item[1]) VfrValue = pack ('Q', int (Item[1], 16)) fStringIO.write (VfrValue) # @@ -3915,7 +3896,7 @@ class ModuleAutoGen(AutoGen): ## Create AsBuilt INF file the module # def CreateAsBuiltInf(self, IsOnlyCopy = False): - self.OutputFile = [] + self.OutputFile = set() if IsOnlyCopy: if GlobalData.gBinCacheDest: self.CopyModuleToCache() @@ -3933,11 +3914,11 @@ class ModuleAutoGen(AutoGen): return # Skip the following code for modules with no source files - if self.SourceFileList is None or self.SourceFileList == []: + if not self.SourceFileList: return # Skip the following code for modules without any binary files - if self.BinaryFileList <> None and self.BinaryFileList <> []: + if not self.BinaryFileList: return ### TODO: How to handles mixed source and binary modules @@ -4056,8 +4037,7 @@ class ModuleAutoGen(AutoGen): DebugDir = self.DebugDir.replace('\\', '/').strip('/') for Item in self.CodaTargetList: File = Item.Target.Path.replace('\\', '/').strip('/').replace(DebugDir, '').replace(OutputDir, '').strip('/') - if File not in self.OutputFile: - self.OutputFile.append(File) + self.OutputFile.add(File) if os.path.isabs(File): File = File.replace('\\', '/').strip('/').replace(OutputDir, '').strip('/') if Item.Target.Ext.lower() == '.aml': @@ -4069,8 +4049,7 @@ class ModuleAutoGen(AutoGen): else: AsBuiltInfDict['binary_item'] += ['BIN|' + File] if self.DepexGenerated: - if self.Name + '.depex' not in self.OutputFile: - self.OutputFile.append(self.Name + '.depex') + self.OutputFile.add(self.Name + '.depex') if self.ModuleType in ['PEIM']: AsBuiltInfDict['binary_item'] += ['PEI_DEPEX|' + self.Name + '.depex'] if self.ModuleType in ['DXE_DRIVER', 'DXE_RUNTIME_DRIVER', 'DXE_SAL_DRIVER', 'UEFI_DRIVER']: @@ -4081,15 +4060,13 @@ class ModuleAutoGen(AutoGen): Bin = self._GenOffsetBin() if Bin: AsBuiltInfDict['binary_item'] += ['BIN|%s' % Bin] - if Bin not in self.OutputFile: - self.OutputFile.append(Bin) + self.OutputFile.add(Bin) for Root, Dirs, Files in os.walk(OutputDir): for File in Files: if File.lower().endswith('.pdb'): AsBuiltInfDict['binary_item'] += ['DISPOSABLE|' + File] - if File not in self.OutputFile: - self.OutputFile.append(File) + self.OutputFile.add(File) HeaderComments = self.Module.HeaderComments StartPos = 0 for Index in range(len(HeaderComments)): @@ -4173,9 +4150,12 @@ class ModuleAutoGen(AutoGen): Padding = Padding * 2 ArraySize = ArraySize / 2 if ArraySize < (len(PcdValue) + 1): - EdkLogger.error("build", AUTOGEN_ERROR, + if Pcd.MaxSizeUserSet: + EdkLogger.error("build", AUTOGEN_ERROR, "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName) ) + else: + ArraySize = len(PcdValue) + 1 if ArraySize > len(PcdValue) + 1: NewValue = NewValue + Padding * (ArraySize - len(PcdValue) - 1) PcdValue = NewValue + Padding.strip().rstrip(',') + '}' @@ -4183,9 +4163,12 @@ class ModuleAutoGen(AutoGen): PcdValue = PcdValue.rstrip('}') + ', 0x00' * (ArraySize - len(PcdValue.split(','))) PcdValue += '}' else: - EdkLogger.error("build", AUTOGEN_ERROR, + if Pcd.MaxSizeUserSet: + EdkLogger.error("build", AUTOGEN_ERROR, "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName) ) + else: + ArraySize = len(PcdValue) + 1 PcdItem = '%s.%s|%s|0x%X' % \ (Pcd.TokenSpaceGuidCName, TokenCName, PcdValue, PatchPcd[1]) PcdComments = '' @@ -4195,7 +4178,7 @@ class ModuleAutoGen(AutoGen): PcdItem = PcdComments + '\n ' + PcdItem AsBuiltInfDict['patchablepcd_item'].append(PcdItem) - HiiPcds = [] + HiiPcds = set() for Pcd in Pcds + VfrPcds: PcdComments = '' PcdCommentList = [] @@ -4218,8 +4201,7 @@ class ModuleAutoGen(AutoGen): # if (SkuId, Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in HiiPcds: continue - else: - HiiPcds.append((SkuId, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)) + HiiPcds.add((SkuId, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)) if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdComments: PcdCommentList = self._PcdComments[Pcd.TokenSpaceGuidCName, Pcd.TokenCName][:] if HiiInfo: