From b303ea726e1c8ed240dad2bce54821318567eab3 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Mon, 9 Nov 2009 11:47:35 +0000 Subject: Sync tool code to BuildTools project r1739. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9397 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/AutoGen/AutoGen.py | 404 +++++++++++++++++++++- BaseTools/Source/Python/AutoGen/GenC.py | 118 ++++--- BaseTools/Source/Python/AutoGen/GenDepex.py | 2 +- BaseTools/Source/Python/AutoGen/StrGather.py | 106 ++++-- BaseTools/Source/Python/AutoGen/UniClassObject.py | 10 + 5 files changed, 535 insertions(+), 105 deletions(-) (limited to 'BaseTools/Source/Python/AutoGen') diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 647e1d0052..9594ef0cae 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -21,6 +21,7 @@ import copy import GenC import GenMake import GenDepex +from StringIO import StringIO from StrGather import * from BuildEngine import BuildRule @@ -48,8 +49,8 @@ gBuildRuleFile = 'Conf/build_rule.txt' gAutoGenCodeFileName = "AutoGen.c" gAutoGenHeaderFileName = "AutoGen.h" gAutoGenStringFileName = "%(module_name)sStrDefs.h" +gAutoGenStringFormFileName = "%(module_name)sStrDefs.hpk" gAutoGenDepexFileName = "%(module_name)s.depex" -gAutoGenSmmDepexFileName = "%(module_name)s.smm" ## Base class for AutoGen # @@ -137,7 +138,8 @@ class WorkspaceAutoGen(AutoGen): # @param SkuId SKU id from command line # def _Init(self, WorkspaceDir, ActivePlatform, Target, Toolchain, ArchList, MetaFileDb, - BuildConfig, ToolDefinition, FlashDefinitionFile='', Fds=[], Fvs=[], SkuId=''): + BuildConfig, ToolDefinition, FlashDefinitionFile='', Fds=[], Fvs=[], SkuId='', + ReportFile=None, ReportType=None): self.MetaFile = ActivePlatform.MetaFile self.WorkspaceDir = WorkspaceDir self.Platform = ActivePlatform @@ -145,6 +147,8 @@ class WorkspaceAutoGen(AutoGen): self.ToolChain = Toolchain self.ArchList = ArchList self.SkuId = SkuId + self.ReportFile = ReportFile + self.ReportType = ReportType self.BuildDatabase = MetaFileDb self.TargetTxt = BuildConfig @@ -181,6 +185,325 @@ class WorkspaceAutoGen(AutoGen): Pa.CollectPlatformDynamicPcds() self.AutoGenObjectList.append(Pa) + AllPcds = {} + MaxLen = 0 + for Pcd in Pa._DynaPcdList_ + Pa._NonDynaPcdList_: + if Pcd.TokenSpaceGuidCName not in AllPcds: + AllPcds[Pcd.TokenSpaceGuidCName] = {} + if Pcd.Type not in AllPcds[Pcd.TokenSpaceGuidCName]: + AllPcds[Pcd.TokenSpaceGuidCName][Pcd.Type] = [] + AllPcds[Pcd.TokenSpaceGuidCName][Pcd.Type] += [Pcd] + if len(Pcd.TokenCName) > MaxLen: + MaxLen = len(Pcd.TokenCName) + + if self.ReportFile <> None: + try: + if os.path.exists(self.ReportFile): + os.remove(self.ReportFile) + + Fd = open(self.ReportFile, "w") + + Fd.write ('===============================================================================\n') + Fd.write ('Platform Configuration Database Report\n') + Fd.write ('===============================================================================\n') + Fd.write (' *P - Platform scoped PCD override in DSC file\n') + Fd.write (' *F - Platform scoped PCD override in FDF file\n') + Fd.write (' *M - Module scoped PCD override in DSC file\n') + Fd.write (' *C - Library has a constructor\n') + Fd.write (' *D - Library has a destructor\n') + Fd.write (' *CD - Library has both a constructor and a destructor\n') + Fd.write ('===============================================================================\n') + Fd.write ('\n') + Fd.write ('===============================================================================\n') + Fd.write ('PLATFORM: %s\n' % (ActivePlatform.MetaFile)) + Fd.write ('===============================================================================\n') + for Key in AllPcds: + Fd.write ('%s\n' % (Key)) + for Type in AllPcds[Key]: + TypeName = '' + DecType = Type + if Type == 'FixedAtBuild': + TypeName = 'FIXED' + if Type == 'PatchableInModule': + TypeName = 'PATCH' + if Type == 'FeatureFlag': + TypeName = 'FLAG' + if Type == 'Dynamic': + TypeName = 'DYN' + if Type == 'DynamicHii': + TypeName = 'DYNHII' + DecType = 'Dynamic' + if Type == 'DynamicVpd': + TypeName = 'DYNVPD' + DecType = 'Dynamic' + if Type == 'DynamicEx': + TypeName = 'DEX' + DecType = 'Dynamic' + if Type == 'DynamicExHii': + TypeName = 'DEXHII' + DecType = 'Dynamic' + if Type == 'DynamicExVpd': + TypeName = 'DEXVPD' + DecType = 'Dynamic' + for Pcd in AllPcds[Key][Type]: + + DecDefaultValue = None + for F in Pa.Platform.Modules.keys(): + for Package in Pa.Platform.Modules[F].M.Module.Packages: + if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, DecType) in Package.Pcds: + if DecDefaultValue == None: + DecDefaultValue = Package.Pcds[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, DecType].DefaultValue + + DscDefaultValue = None + if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in self.BuildDatabase.WorkspaceDb.PlatformList[0].Pcds: + DscDefaultValue = self.BuildDatabase.WorkspaceDb.PlatformList[0].Pcds[(Pcd.TokenCName, Pcd.TokenSpaceGuidCName)].DefaultValue + + if Pcd.DatumType in ('UINT8', 'UINT16', 'UINT32', 'UINT64'): + if Pcd.DefaultValue.strip()[0:2].upper() == '0X': + PcdDefaultValueNumber = int(Pcd.DefaultValue.strip(), 16) + else: + PcdDefaultValueNumber = int(Pcd.DefaultValue.strip()) + + if DecDefaultValue == None: + DecMatch = True + else: + if DecDefaultValue.strip()[0:2].upper() == '0X': + DecDefaultValueNumber = int(DecDefaultValue.strip(), 16) + else: + DecDefaultValueNumber = int(DecDefaultValue.strip()) + DecMatch = (DecDefaultValueNumber == PcdDefaultValueNumber) + + if DscDefaultValue == None: + DscMatch = True + else: + if DscDefaultValue.strip()[0:2].upper() == '0X': + DscDefaultValueNumber = int(DscDefaultValue.strip(), 16) + else: + DscDefaultValueNumber = int(DscDefaultValue.strip()) + DscMatch = (DscDefaultValueNumber == PcdDefaultValueNumber) + else: + if DecDefaultValue == None: + DecMatch = True + else: + DecMatch = (DecDefaultValue == Pcd.DefaultValue) + + if DscDefaultValue == None: + DscMatch = True + else: + DscMatch = (DscDefaultValue == Pcd.DefaultValue) + + if DecMatch: + Fd.write (' %-*s: %6s %10s = %-22s\n' % (MaxLen + 2, Pcd.TokenCName, TypeName, '('+Pcd.DatumType+')', Pcd.DefaultValue)) + else: + if DscMatch: + if (Pcd.TokenCName, Key) in PcdSet: + Fd.write (' *F %-*s: %6s %10s = %-22s\n' % (MaxLen + 2, Pcd.TokenCName, TypeName, '('+Pcd.DatumType+')', Pcd.DefaultValue)) + else: + Fd.write (' *P %-*s: %6s %10s = %-22s\n' % (MaxLen + 2, Pcd.TokenCName, TypeName, '('+Pcd.DatumType+')', Pcd.DefaultValue)) + + for F in Pa.Platform.Modules.keys(): + for ModulePcd in Pa.Platform.Modules[F].M.ModulePcdList + Pa.Platform.Modules[F].M.LibraryPcdList: + if ModulePcd.TokenSpaceGuidCName <> Pcd.TokenSpaceGuidCName: + continue + if ModulePcd.TokenCName <> Pcd.TokenCName: + continue + if Pcd.DatumType in ('UINT8', 'UINT16', 'UINT32', 'UINT64'): + if ModulePcd.DefaultValue.strip()[0:2].upper() == '0X': + ModulePcdDefaultValueNumber = int(ModulePcd.DefaultValue.strip(), 16) + else: + ModulePcdDefaultValueNumber = int(ModulePcd.DefaultValue.strip()) + Match = (ModulePcdDefaultValueNumber == PcdDefaultValueNumber) + else: + Match = (ModulePcd.DefaultValue == Pcd.DefaultValue) + if Match: + continue + Fd.write (' *M %*s = %s\n' % (MaxLen + 21, str(F).split('\\')[-1], ModulePcd.DefaultValue)) + + if not DecMatch and DscMatch and DecDefaultValue <> None: + Fd.write (' %*s = %s\n' % (MaxLen + 21, 'DEC DEFAULT', DecDefaultValue)) + + Fd.write ('\n') + + Fd.write ('===============================================================================\n') + Fd.write ('===============================================================================\n') + + for F in Pa.Platform.Modules.keys(): + Fd.write ('\n') + Fd.write ('===============================================================================\n') + Fd.write ('MODULE: %s\n' % (F)) + Fd.write ('===============================================================================\n') + + Fd.write ('PLATFORM CONFIGURATION DATABASE\n') + Fd.write ('-------------------------------------------------------------------------------\n') + ModuleFirst = True + for Key in AllPcds: + First = True + for Type in AllPcds[Key]: + TypeName = '' + DecType = Type + if Type == 'FixedAtBuild': + TypeName = 'FIXED' + if Type == 'PatchableInModule': + TypeName = 'PATCH' + if Type == 'FeatureFlag': + TypeName = 'FLAG' + if Type == 'Dynamic': + TypeName = 'DYN' + if Type == 'DynamicHii': + TypeName = 'DYNHII' + DecType = 'Dynamic' + if Type == 'DynamicVpd': + TypeName = 'DYNVPD' + DecType = 'Dynamic' + if Type == 'DynamicEx': + TypeName = 'DEX' + DecType = 'Dynamic' + if Type == 'DynamicExHii': + TypeName = 'DEXHII' + DecType = 'Dynamic' + if Type == 'DynamicExVpd': + TypeName = 'DEXVPD' + DecType = 'Dynamic' + for Pcd in AllPcds[Key][Type]: + for ModulePcd in Pa.Platform.Modules[F].M.ModulePcdList + Pa.Platform.Modules[F].M.LibraryPcdList: + if ModulePcd.TokenSpaceGuidCName <> Pcd.TokenSpaceGuidCName: + continue + if ModulePcd.TokenCName <> Pcd.TokenCName: + continue + if ModulePcd.Type <> Pcd.Type: + continue + if First: + if ModuleFirst: + ModuleFirst = False + else: + Fd.write ('\n') + Fd.write ('%s\n' % (Key)) + First = False + + InfDefaultValue = ModulePcd.InfDefaultValue + if InfDefaultValue == '': + InfDefaultValue = None + + DecDefaultValue = None + for Package in Pa.Platform.Modules[F].M.Module.Packages: + if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, DecType) in Package.Pcds: + if DecDefaultValue == None: + DecDefaultValue = Package.Pcds[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, DecType].DefaultValue + + DscDefaultValue = None + if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in self.BuildDatabase.WorkspaceDb.PlatformList[0].Pcds: + DscDefaultValue = self.BuildDatabase.WorkspaceDb.PlatformList[0].Pcds[(Pcd.TokenCName, Pcd.TokenSpaceGuidCName)].DefaultValue + + DscModuleOverrideDefaultValue = None + if F in self.BuildDatabase.WorkspaceDb.PlatformList[0].Modules: + if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in self.BuildDatabase.WorkspaceDb.PlatformList[0].Modules[F].Pcds: + DscModuleOverrideDefaultValue = self.BuildDatabase.WorkspaceDb.PlatformList[0].Modules[F].Pcds[(Pcd.TokenCName, Pcd.TokenSpaceGuidCName)].DefaultValue + + if Pcd.DatumType in ('UINT8', 'UINT16', 'UINT32', 'UINT64'): + if ModulePcd.DefaultValue.strip()[0:2].upper() == '0X': + ModulePcdDefaultValueNumber = int(ModulePcd.DefaultValue.strip(), 16) + else: + ModulePcdDefaultValueNumber = int(ModulePcd.DefaultValue.strip()) + + if DecDefaultValue == None: + DecMatch = True + else: + if DecDefaultValue.strip()[0:2].upper() == '0X': + DecDefaultValueNumber = int(DecDefaultValue.strip(), 16) + else: + DecDefaultValueNumber = int(DecDefaultValue.strip()) + DecMatch = (DecDefaultValueNumber == ModulePcdDefaultValueNumber) + + if InfDefaultValue == None: + InfMatch = True + else: + if InfDefaultValue.strip()[0:2].upper() == '0X': + InfDefaultValueNumber = int(InfDefaultValue.strip(), 16) + else: + InfDefaultValueNumber = int(InfDefaultValue.strip()) + InfMatch = (InfDefaultValueNumber == ModulePcdDefaultValueNumber) + + if DscDefaultValue == None: + DscMatch = True + else: + if DscDefaultValue.strip()[0:2].upper() == '0X': + DscDefaultValueNumber = int(DscDefaultValue.strip(), 16) + else: + DscDefaultValueNumber = int(DscDefaultValue.strip()) + DscMatch = (DscDefaultValueNumber == ModulePcdDefaultValueNumber) + else: + if DecDefaultValue == None: + DecMatch = True + else: + DecMatch = (DecDefaultValue == ModulePcd.DefaultValue) + + if InfDefaultValue == None: + InfMatch = True + else: + InfMatch = (InfDefaultValue == ModulePcd.DefaultValue) + + if DscDefaultValue == None: + DscMatch = True + else: + DscMatch = (DscDefaultValue == ModulePcd.DefaultValue) + + if DecMatch and InfMatch: + Fd.write (' %-*s: %6s %10s = %-22s\n' % (MaxLen, Pcd.TokenCName, TypeName, '('+Pcd.DatumType+')', ModulePcd.DefaultValue)) + else: + if DscMatch and DscModuleOverrideDefaultValue == None: + if (Pcd.TokenCName, Key) in PcdSet: + Fd.write (' *F %-*s: %6s %10s = %-22s\n' % (MaxLen, Pcd.TokenCName, TypeName, '('+Pcd.DatumType+')', ModulePcd.DefaultValue)) + else: + Fd.write (' *P %-*s: %6s %10s = %-22s\n' % (MaxLen, Pcd.TokenCName, TypeName, '('+Pcd.DatumType+')', ModulePcd.DefaultValue)) + else: + Fd.write (' *M %-*s: %6s %10s = %-22s\n' % (MaxLen, Pcd.TokenCName, TypeName, '('+Pcd.DatumType+')', ModulePcd.DefaultValue)) + if DscDefaultValue <> None: + Fd.write (' %*s = %s\n' % (MaxLen + 19, 'DSC DEFAULT', DscDefaultValue)) + if InfDefaultValue <> None: + Fd.write (' %*s = %s\n' % (MaxLen + 19, 'INF DEFAULT', InfDefaultValue)) + if DecDefaultValue <> None and not DecMatch: + Fd.write (' %*s = %s\n' % (MaxLen + 19, 'DEC DEFAULT', DecDefaultValue)) + Fd.write ('-------------------------------------------------------------------------------\n') + Fd.write ('LIBRARIES\n') + Fd.write ('-------------------------------------------------------------------------------\n') + for Lib in Pa.Platform.Modules[F].M.DependentLibraryList: + if len(Lib.ConstructorList) > 0: + if len(Lib.DestructorList) > 0: + Fd.write (' *CD') + else: + Fd.write (' *C ') + else: + if len(Lib.DestructorList) > 0: + Fd.write (' *D ') + else: + Fd.write (' ') + Fd.write (' %s\n' % (Lib)) + for Depex in Lib.DepexExpression[Pa.Platform.Modules[F].M.Arch, Pa.Platform.Modules[F].M.ModuleType]: + Fd.write (' DEPEX = %s\n' % (Depex)) + Fd.write ('-------------------------------------------------------------------------------\n') + + Fd.write ('MODULE DEPENDENCY EXPRESSION\n') + if len(Pa.Platform.Modules[F].M.Module.DepexExpression[Pa.Platform.Modules[F].M.Arch, Pa.Platform.Modules[F].M.ModuleType]) == 0: + Fd.write (' NONE\n') + else: + for Depex in Pa.Platform.Modules[F].M.Module.DepexExpression[Pa.Platform.Modules[F].M.Arch, Pa.Platform.Modules[F].M.ModuleType]: + Fd.write (' %s\n' % (Depex)) + Fd.write ('-------------------------------------------------------------------------------\n') + + Fd.write ('MODULE + LIBRARY DEPENDENCY EXPRESSION\n') + if Pa.Platform.Modules[F].M.ModuleType in Pa.Platform.Modules[F].M.DepexExpressionList: + if Pa.Platform.Modules[F].M.DepexExpressionList[Pa.Platform.Modules[F].M.ModuleType] == '': + Fd.write (' NONE\n') + else: + Fd.write (' %s\n' % (Pa.Platform.Modules[F].M.DepexExpressionList[Pa.Platform.Modules[F].M.ModuleType])) + else: + Fd.write (' NONE\n') + Fd.write ('-------------------------------------------------------------------------------\n') + + Fd.close() + except: + EdkLogger.error(None, FILE_OPEN_FAILURE, ExtraData=self.ReportFile) + self._BuildDir = None self._FvDir = None self._MakeFileDir = None @@ -421,6 +744,9 @@ class PlatformAutoGen(AutoGen): for F in self.Platform.Modules.keys(): M = ModuleAutoGen(self.Workspace, F, self.BuildTarget, self.ToolChain, self.Arch, self.MetaFile) #GuidValue.update(M.Guids) + + self.Platform.Modules[F].M = M + for PcdFromModule in M.ModulePcdList+M.LibraryPcdList: # make sure that the "VOID*" kind of datum has MaxDatumSize set if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize == None: @@ -1260,6 +1586,7 @@ class ModuleAutoGen(AutoGen): self._ProtocolList = None self._PpiList = None self._DepexList = None + self._DepexExpressionList = None self._BuildOption = None self._BuildTargets = None self._IntroBuildTargetList = None @@ -1433,11 +1760,7 @@ class ModuleAutoGen(AutoGen): if self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes: return self._DepexList - if self.ModuleType == "DXE_SMM_DRIVER": - self._DepexList["DXE_DRIVER"] = [] - self._DepexList["SMM_DRIVER"] = [] - else: - self._DepexList[self.ModuleType] = [] + self._DepexList[self.ModuleType] = [] for ModuleType in self._DepexList: DepexList = self._DepexList[ModuleType] @@ -1463,6 +1786,42 @@ class ModuleAutoGen(AutoGen): EdkLogger.verbose('') return self._DepexList + ## Merge dependency expression + # + # @retval list The token list of the dependency expression after parsed + # + def _GetDepexExpressionTokenList(self): + if self._DepexExpressionList == None: + self._DepexExpressionList = {} + if self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes: + return self._DepexExpressionList + + self._DepexExpressionList[self.ModuleType] = '' + + for ModuleType in self._DepexExpressionList: + DepexExpressionList = self._DepexExpressionList[ModuleType] + # + # Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion + # + for M in [self.Module] + self.DependentLibraryList: + Inherited = False + for D in M.DepexExpression[self.Arch, ModuleType]: + if DepexExpressionList != '': + DepexExpressionList += ' AND ' + DepexExpressionList += '(' + DepexExpressionList += D + DepexExpressionList = DepexExpressionList.rstrip('END').strip() + DepexExpressionList += ')' + Inherited = True + if Inherited: + EdkLogger.verbose("DEPEX[%s] (+%s) = %s" % (self.Name, M.BaseName, DepexExpressionList)) + if 'BEFORE' in DepexExpressionList or 'AFTER' in DepexExpressionList: + break + if len(DepexExpressionList) > 0: + EdkLogger.verbose('') + self._DepexExpressionList[ModuleType] = DepexExpressionList + return self._DepexExpressionList + ## Return the list of specification version required for the module # # @retval list The list of specification defined in module file @@ -1580,12 +1939,12 @@ class ModuleAutoGen(AutoGen): if Source != File: CreateDirectory(Source.Dir) - if FileType in self.BuildRules: + if File.IsBinary and File == Source: + RuleObject = self.BuildRules[TAB_DEFAULT_BINARY_FILE] + elif FileType in self.BuildRules: RuleObject = self.BuildRules[FileType] elif Source.Ext in self.BuildRules: RuleObject = self.BuildRules[Source.Ext] - elif File.IsBinary and File == Source: - RuleObject = self.BuildRules[TAB_DEFAULT_BINARY_FILE] else: # stop at no more rules if LastTarget: @@ -1599,7 +1958,8 @@ class ModuleAutoGen(AutoGen): # stop at STATIC_LIBRARY for library if self.IsLibrary and FileType == TAB_STATIC_LIBRARY: - self._FinalBuildTargetList.add(LastTarget) + if LastTarget: + self._FinalBuildTargetList.add(LastTarget) break Target = RuleObject.Apply(Source) @@ -1668,12 +2028,17 @@ class ModuleAutoGen(AutoGen): # @retval list The list of auto-generated file # def _GetAutoGenFileList(self): + UniStringAutoGenC = True + UniStringBinBuffer = None + if self.BuildType == 'UEFI_HII': + UniStringBinBuffer = StringIO() + UniStringAutoGenC = False if self._AutoGenFileList == None: self._AutoGenFileList = {} AutoGenC = TemplateString() AutoGenH = TemplateString() StringH = TemplateString() - GenC.CreateCode(self, AutoGenC, AutoGenH, StringH) + GenC.CreateCode(self, AutoGenC, AutoGenH, StringH, UniStringAutoGenC, UniStringBinBuffer) if str(AutoGenC) != "" and TAB_C_CODE_FILE in self.FileTypes: AutoFile = PathClass(gAutoGenCodeFileName, self.DebugDir) self._AutoGenFileList[AutoFile] = str(AutoGenC) @@ -1686,6 +2051,13 @@ class ModuleAutoGen(AutoGen): AutoFile = PathClass(gAutoGenStringFileName % {"module_name":self.Name}, self.DebugDir) self._AutoGenFileList[AutoFile] = str(StringH) self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE) + if UniStringBinBuffer != None and UniStringBinBuffer.getvalue() != "": + AutoFile = PathClass(gAutoGenStringFormFileName % {"module_name":self.Name}, self.OutputDir) + self._AutoGenFileList[AutoFile] = UniStringBinBuffer.getvalue() + AutoFile.IsBinary = True + self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE) + if UniStringBinBuffer != None: + UniStringBinBuffer.close() return self._AutoGenFileList ## Return the list of library modules explicitly or implicityly used by this module @@ -1838,7 +2210,7 @@ class ModuleAutoGen(AutoGen): IgoredAutoGenList = [] for File in self.AutoGenFileList: - if GenC.Generate(File.Path, self.AutoGenFileList[File]): + if GenC.Generate(File.Path, self.AutoGenFileList[File], File.IsBinary): #Ignore R8 AutoGen.c if self.AutoGenVersion < 0x00010005 and File.Name == 'AutoGen.c': continue @@ -1855,10 +2227,7 @@ class ModuleAutoGen(AutoGen): if len(self.DepexList[ModuleType]) == 0: continue Dpx = GenDepex.DependencyExpression(self.DepexList[ModuleType], ModuleType, True) - if ModuleType == 'SMM_DRIVER': - DpxFile = gAutoGenSmmDepexFileName % {"module_name" : self.Name} - else: - DpxFile = gAutoGenDepexFileName % {"module_name" : self.Name} + DpxFile = gAutoGenDepexFileName % {"module_name" : self.Name} if Dpx.Generate(path.join(self.OutputDir, DpxFile)): AutoGenList.append(str(DpxFile)) @@ -1947,6 +2316,7 @@ class ModuleAutoGen(AutoGen): ProtocolList = property(_GetProtocolList) PpiList = property(_GetPpiList) DepexList = property(_GetDepexTokenList) + DepexExpressionList = property(_GetDepexExpressionTokenList) BuildOption = property(_GetModuleBuildOption) BuildCommand = property(_GetBuildCommand) diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index b62a12708b..0a2bb623d8 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -383,28 +383,6 @@ ${Function} ( ${END} """) -## SMM_CORE Entry Point Templates -gSmmCoreEntryPointString = TemplateString(""" -const UINT32 _gUefiDriverRevision = 0; -${BEGIN} -EFI_STATUS -${Function} ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - -EFI_STATUS -EFIAPI -ProcessModuleEntryPointList ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - return ${Function} (ImageHandle, SystemTable); -} -${END} -""") - gPeimEntryPointString = [ TemplateString(""" GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = ${PiSpecVersion}; @@ -461,6 +439,35 @@ ${END} """) ] +## SMM_CORE Entry Point Templates +gSmmCoreEntryPointPrototype = TemplateString(""" +${BEGIN} +EFI_STATUS +EFIAPI +${Function} ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +${END} +""") + +gSmmCoreEntryPointString = TemplateString(""" +${BEGIN} +const UINT32 _gUefiDriverRevision = ${EfiSpecVersion}; +const UINT32 _gDxeRevision = ${PiSpecVersion}; + +EFI_STATUS +EFIAPI +ProcessModuleEntryPointList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return ${Function} (ImageHandle, SystemTable); +} +${END} +""") + ## DXE SMM Entry Point Templates gDxeSmmEntryPointPrototype = TemplateString(""" ${BEGIN} @@ -890,8 +897,7 @@ gModuleTypeHeaderFile = { "DXE_SAL_DRIVER" : ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"], "UEFI_DRIVER" : ["Uefi.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"], "UEFI_APPLICATION" : ["Uefi.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiApplicationEntryPoint.h"], - "SMM_DRIVER" : ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmDriverEntryPoint.h"], - "SMM_CORE" : ["PiDxe.h", "Library/DebugLib.h"], + "SMM_CORE" : ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiDriverEntryPoint.h"], "USER_DEFINED" : [gBasicHeaderFile] } @@ -1504,7 +1510,7 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH): ConstructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict)) ConstructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict)) elif Lib.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER', - 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION', 'SMM_DRIVER', 'SMM_CORE']: + 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']: ConstructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict)) ConstructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict)) @@ -1530,7 +1536,7 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH): elif Info.ModuleType in ['PEI_CORE','PEIM']: AutoGenC.Append(gLibraryString['PEI'].Replace(Dict)) elif Info.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER', - 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION', 'SMM_DRIVER', 'SMM_CORE']: + 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']: AutoGenC.Append(gLibraryString['DXE'].Replace(Dict)) ## Create code for library destructor @@ -1561,7 +1567,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH): DestructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict)) DestructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict)) elif Lib.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER', - 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION', 'SMM_DRIVER', 'SMM_CORE']: + 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION', 'SMM_CORE']: DestructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict)) DestructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict)) @@ -1587,7 +1593,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH): elif Info.ModuleType in ['PEI_CORE','PEIM']: AutoGenC.Append(gLibraryString['PEI'].Replace(Dict)) elif Info.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER', - 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION', 'SMM_DRIVER', 'SMM_CORE']: + 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']: AutoGenC.Append(gLibraryString['DXE'].Replace(Dict)) @@ -1635,26 +1641,25 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): AutoGenH.Append(gDxeCoreEntryPointPrototype.Replace(Dict)) elif Info.ModuleType == 'SMM_CORE': AutoGenC.Append(gSmmCoreEntryPointString.Replace(Dict)) + AutoGenH.Append(gSmmCoreEntryPointPrototype.Replace(Dict)) elif Info.ModuleType == 'PEIM': if NumEntryPoints < 2: AutoGenC.Append(gPeimEntryPointString[NumEntryPoints].Replace(Dict)) else: AutoGenC.Append(gPeimEntryPointString[2].Replace(Dict)) AutoGenH.Append(gPeimEntryPointPrototype.Replace(Dict)) - elif Info.ModuleType in ['DXE_RUNTIME_DRIVER','DXE_DRIVER','DXE_SMM_DRIVER', - 'DXE_SAL_DRIVER','UEFI_DRIVER', 'SMM_DRIVER']: - if Info.ModuleType in ['DXE_SMM_DRIVER', 'SMM_DRIVER']: - if NumEntryPoints == 0: - AutoGenC.Append(gDxeSmmEntryPointString[0].Replace(Dict)) - else: - AutoGenC.Append(gDxeSmmEntryPointString[1].Replace(Dict)) - AutoGenH.Append(gDxeSmmEntryPointPrototype.Replace(Dict)) + elif Info.ModuleType in ['DXE_RUNTIME_DRIVER','DXE_DRIVER','DXE_SAL_DRIVER','UEFI_DRIVER']: + if NumEntryPoints < 2: + AutoGenC.Append(gUefiDriverEntryPointString[NumEntryPoints].Replace(Dict)) else: - if NumEntryPoints < 2: - AutoGenC.Append(gUefiDriverEntryPointString[NumEntryPoints].Replace(Dict)) - else: - AutoGenC.Append(gUefiDriverEntryPointString[2].Replace(Dict)) - AutoGenH.Append(gUefiDriverEntryPointPrototype.Replace(Dict)) + AutoGenC.Append(gUefiDriverEntryPointString[2].Replace(Dict)) + AutoGenH.Append(gUefiDriverEntryPointPrototype.Replace(Dict)) + elif Info.ModuleType == 'DXE_SMM_DRIVER': + if NumEntryPoints == 0: + AutoGenC.Append(gDxeSmmEntryPointString[0].Replace(Dict)) + else: + AutoGenC.Append(gDxeSmmEntryPointString[1].Replace(Dict)) + AutoGenH.Append(gDxeSmmEntryPointPrototype.Replace(Dict)) elif Info.ModuleType == 'UEFI_APPLICATION': if NumEntryPoints < 2: AutoGenC.Append(gUefiApplicationEntryPointString[NumEntryPoints].Replace(Dict)) @@ -1782,8 +1787,10 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH): # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code # @param AutoGenH The TemplateString object for header file +# @param UniGenCFlag UniString is generated into AutoGen C file when it is set to True +# @param UniGenBinBuffer Buffer to store uni string package data # -def CreateUnicodeStringCode(Info, AutoGenC, AutoGenH): +def CreateUnicodeStringCode(Info, AutoGenC, AutoGenH, UniGenCFlag, UniGenBinBuffer): WorkingDir = os.getcwd() os.chdir(Info.WorkspaceDir) @@ -1823,13 +1830,15 @@ def CreateUnicodeStringCode(Info, AutoGenC, AutoGenH): else: ShellMode = False - Header, Code = GetStringFiles(Info.UnicodeFileList, SrcList, IncList, ['.uni', '.inf'], Info.Name, CompatibleMode, ShellMode) - AutoGenC.Append("\n//\n//Unicode String Pack Definition\n//\n") - AutoGenC.Append(Code) - AutoGenC.Append("\n") + Header, Code = GetStringFiles(Info.UnicodeFileList, SrcList, IncList, ['.uni', '.inf'], Info.Name, CompatibleMode, ShellMode, UniGenCFlag, UniGenBinBuffer) + if CompatibleMode or UniGenCFlag: + AutoGenC.Append("\n//\n//Unicode String Pack Definition\n//\n") + AutoGenC.Append(Code) + AutoGenC.Append("\n") AutoGenH.Append("\n//\n//Unicode String ID\n//\n") AutoGenH.Append(Header) - AutoGenH.Append("\n#define STRING_ARRAY_NAME %sStrings\n" % Info.Name) + if CompatibleMode or UniGenCFlag: + AutoGenH.Append("\n#define STRING_ARRAY_NAME %sStrings\n" % Info.Name) os.chdir(WorkingDir) ## Create common code @@ -1890,8 +1899,10 @@ def CreateFooterCode(Info, AutoGenC, AutoGenH): # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code # @param AutoGenH The TemplateString object for header file +# @param UniGenCFlag UniString is generated into AutoGen C file when it is set to True +# @param UniGenBinBuffer Buffer to store uni string package data # -def CreateCode(Info, AutoGenC, AutoGenH, StringH): +def CreateCode(Info, AutoGenC, AutoGenH, StringH, UniGenCFlag, UniGenBinBuffer): CreateHeaderCode(Info, AutoGenC, AutoGenH) if Info.AutoGenVersion >= 0x00010005: @@ -1908,7 +1919,7 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH): FileName = "%sStrDefs.h" % Info.Name StringH.Append(gAutoGenHeaderString.Replace({'FileName':FileName})) StringH.Append(gAutoGenHPrologueString.Replace({'File':'STRDEFS', 'Guid':Info.Guid.replace('-','_')})) - CreateUnicodeStringCode(Info, AutoGenC, StringH) + CreateUnicodeStringCode(Info, AutoGenC, StringH, UniGenCFlag, UniGenBinBuffer) StringH.Append("\n#endif\n") AutoGenH.Append('#include "%s"\n' % FileName) @@ -1920,12 +1931,13 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH): ## Create the code file # -# @param FilePath The path of code file -# @param Content The content of code file +# @param FilePath The path of code file +# @param Content The content of code file +# @param IsBinaryFile The flag indicating if the file is binary file or not # # @retval True If file content is changed or file doesn't exist # @retval False If the file exists and the content is not changed # -def Generate(FilePath, Content): - return SaveFileOnChange(FilePath, Content, False) +def Generate(FilePath, Content, IsBinaryFile): + return SaveFileOnChange(FilePath, Content, IsBinaryFile) diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py b/BaseTools/Source/Python/AutoGen/GenDepex.py index a3d07b83f2..9ee615cdc8 100644 --- a/BaseTools/Source/Python/AutoGen/GenDepex.py +++ b/BaseTools/Source/Python/AutoGen/GenDepex.py @@ -41,7 +41,7 @@ gType2Phase = { "DXE_SAL_DRIVER" : "DXE", "UEFI_DRIVER" : "DXE", "UEFI_APPLICATION" : "DXE", - "SMM_DRIVER" : "DXE", + "SMM_CORE" : "DXE", } ## Convert dependency expression string into EFI internal representation diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Source/Python/AutoGen/StrGather.py index 0f644445dc..903ac3cd0d 100644 --- a/BaseTools/Source/Python/AutoGen/StrGather.py +++ b/BaseTools/Source/Python/AutoGen/StrGather.py @@ -18,6 +18,8 @@ import re import Common.EdkLogger as EdkLogger from Common.BuildToolError import * from UniClassObject import * +from StringIO import StringIO +from struct import pack ## # Static definitions @@ -60,6 +62,7 @@ OFFSET = 'offset' STRING = 'string' TO = 'to' STRING_TOKEN = re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE) +COMPATIBLE_STRING_TOKEN = re.compile('STRING_TOKEN *\(([A-Za-z0-9_]+) *\)', re.MULTILINE | re.UNICODE) EFI_HII_ARRAY_SIZE_LENGTH = 4 EFI_HII_PACKAGE_HEADER_LENGTH = 4 @@ -151,12 +154,14 @@ def CreateHFileHeader(BaseName): # # Create content of .h file # -# @param BaseName: The basename of strings -# @param UniObjectClass: A UniObjectClass instance +# @param BaseName: The basename of strings +# @param UniObjectClass A UniObjectClass instance +# @param IsCompatibleMode Compatible mode +# @param UniGenCFlag UniString is generated into AutoGen C file when it is set to True # # @retval Str: A string of .h file content # -def CreateHFileContent(BaseName, UniObjectClass): +def CreateHFileContent(BaseName, UniObjectClass, IsCompatibleMode, UniGenCFlag): Str = '' ValueStartPtr = 60 Line = COMMENT_DEFINE_STR + ' ' + LANGUAGE_NAME_STRING_NAME + ' ' * (ValueStartPtr - len(DEFINE_STR + LANGUAGE_NAME_STRING_NAME)) + DecToHexStr(0, 4) + COMMENT_NOT_REFERENCED @@ -182,21 +187,24 @@ def CreateHFileContent(BaseName, UniObjectClass): Line = COMMENT_DEFINE_STR + ' ' + Name + ' ' * (ValueStartPtr - len(DEFINE_STR + Name)) + DecToHexStr(Token, 4) + COMMENT_NOT_REFERENCED Str = WriteLine(Str, Line) - Str = WriteLine(Str, '') - Str = WriteLine(Str, 'extern unsigned char ' + BaseName + 'Strings[];') + Str = WriteLine(Str, '') + if IsCompatibleMode or UniGenCFlag: + Str = WriteLine(Str, 'extern unsigned char ' + BaseName + 'Strings[];') return Str ## Create a complete .h file # # Create a complet .h file with file header and file content # -# @param BaseName: The basename of strings -# @param UniObjectClass: A UniObjectClass instance +# @param BaseName: The basename of strings +# @param UniObjectClass A UniObjectClass instance +# @param IsCompatibleMode Compatible mode +# @param UniGenCFlag UniString is generated into AutoGen C file when it is set to True # # @retval Str: A string of complete .h file # -def CreateHFile(BaseName, UniObjectClass): - HFile = WriteLine('', CreateHFileContent(BaseName, UniObjectClass)) +def CreateHFile(BaseName, UniObjectClass, IsCompatibleMode, UniGenCFlag): + HFile = WriteLine('', CreateHFileContent(BaseName, UniObjectClass, IsCompatibleMode, UniGenCFlag)) return HFile @@ -213,6 +221,15 @@ def CreateCFileHeader(): return Str +## Create a buffer to store all items in an array +# +# @param BinBuffer Buffer to contain Binary data. +# @param Array: The array need to be formatted +# +def CreateBinBuffer(BinBuffer, Array): + for Item in Array: + BinBuffer.write(pack("B", int(Item,16))) + ## Create a formatted string all items in an array # # Use ',' to join each item in an array, and break an new line when reaching the width (default is 16) @@ -260,12 +277,14 @@ def CreateCFileStringValue(Value): # # Create content of .c file # -# @param BaseName: The basename of strings -# @param UniObjectClass: A UniObjectClass instance +# @param BaseName: The basename of strings +# @param UniObjectClass A UniObjectClass instance +# @param IsCompatibleMode Compatible mode +# @param UniBinBuffer UniBinBuffer to contain UniBinary data. # # @retval Str: A string of .c file content # -def CreateCFileContent(BaseName, UniObjectClass, IsCompatibleMode): +def CreateCFileContent(BaseName, UniObjectClass, IsCompatibleMode, UniBinBuffer=None): # # Init array length # @@ -280,9 +299,10 @@ def CreateCFileContent(BaseName, UniObjectClass, IsCompatibleMode): Language = UniObjectClass.LanguageDef[IndexI][0] LangPrintName = UniObjectClass.LanguageDef[IndexI][1] + StringBuffer = StringIO() StrStringValue = '' ArrayLength = 0 - NumberOfUseOhterLangDef = 0 + NumberOfUseOtherLangDef = 0 Index = 0 for IndexJ in range(1, len(UniObjectClass.OrderedStringList[UniObjectClass.LanguageDef[IndexI][0]])): Item = UniObjectClass.FindByToken(IndexJ, Language) @@ -294,18 +314,19 @@ def CreateCFileContent(BaseName, UniObjectClass, IsCompatibleMode): UseOtherLangDef = Item.UseOtherLangDef if UseOtherLangDef != '' and Referenced: - NumberOfUseOhterLangDef = NumberOfUseOhterLangDef + 1 + NumberOfUseOtherLangDef = NumberOfUseOtherLangDef + 1 Index = Index + 1 else: - if NumberOfUseOhterLangDef > 0: - StrStringValue = WriteLine(StrStringValue, CreateArrayItem([StringSkipType] + DecToHexList(NumberOfUseOhterLangDef, 4))) - NumberOfUseOhterLangDef = 0 + if NumberOfUseOtherLangDef > 0: + StrStringValue = WriteLine(StrStringValue, CreateArrayItem([StringSkipType] + DecToHexList(NumberOfUseOtherLangDef, 4))) + CreateBinBuffer (StringBuffer, ([StringSkipType] + DecToHexList(NumberOfUseOtherLangDef, 4))) + NumberOfUseOtherLangDef = 0 ArrayLength = ArrayLength + 3 if Referenced and Item.Token > 0: Index = Index + 1 StrStringValue = WriteLine(StrStringValue, "// %s: %s:%s" % (DecToHexStr(Index, 4), Name, DecToHexStr(Token, 4))) StrStringValue = Write(StrStringValue, CreateCFileStringValue(Value)) - Offset = Offset + Length + CreateBinBuffer (StringBuffer, [StringBlockType] + Value) ArrayLength = ArrayLength + Item.Length + 1 # 1 is for the length of string type # @@ -340,6 +361,15 @@ def CreateCFileContent(BaseName, UniObjectClass, IsCompatibleMode): # Add an EFI_HII_SIBT_END at last # Str = WriteLine(Str, ' ' + EFI_HII_SIBT_END + ",") + + # + # Create binary UNI string + # + if UniBinBuffer: + CreateBinBuffer (UniBinBuffer, List) + UniBinBuffer.write (StringBuffer.getvalue()) + UniBinBuffer.write (pack("B", int(EFI_HII_SIBT_END,16))) + StringBuffer.close() # # Create line for string variable name @@ -347,19 +377,18 @@ def CreateCFileContent(BaseName, UniObjectClass, IsCompatibleMode): # AllStr = WriteLine('', CHAR_ARRAY_DEFIN + ' ' + BaseName + COMMON_FILE_NAME + '[] = {\n' ) - # - # Create FRAMEWORK_EFI_HII_PACK_HEADER in compatible mode - # if IsCompatibleMode: + # + # Create FRAMEWORK_EFI_HII_PACK_HEADER in compatible mode + # AllStr = WriteLine(AllStr, '// FRAMEWORK PACKAGE HEADER Length') AllStr = WriteLine(AllStr, CreateArrayItem(DecToHexList(TotalLength + 2)) + '\n') AllStr = WriteLine(AllStr, '// FRAMEWORK PACKAGE HEADER Type') AllStr = WriteLine(AllStr, CreateArrayItem(DecToHexList(2, 4)) + '\n') - - # - # Create whole array length in UEFI mode - # - if not IsCompatibleMode: + else: + # + # Create whole array length in UEFI mode + # AllStr = WriteLine(AllStr, '// STRGATHER_OUTPUT_HEADER') AllStr = WriteLine(AllStr, CreateArrayItem(DecToHexList(TotalLength)) + '\n') @@ -384,8 +413,9 @@ def CreateCFileEnd(): # # Create a complete .c file # -# @param BaseName: The basename of strings -# @param UniObjectClass: A UniObjectClass instance +# @param BaseName: The basename of strings +# @param UniObjectClass A UniObjectClass instance +# @param IsCompatibleMode Compatible Mode # # @retval CFile: A string of complete .c file # @@ -447,10 +477,11 @@ def GetFileList(SourceFileList, IncludeList, SkipList): # # @param UniObjectClass: Input UniObjectClass # @param FileList: Search path list +# @param IsCompatibleMode Compatible Mode # # @retval UniObjectClass: UniObjectClass after searched # -def SearchString(UniObjectClass, FileList): +def SearchString(UniObjectClass, FileList, IsCompatibleMode): if FileList == []: return UniObjectClass @@ -458,7 +489,10 @@ def SearchString(UniObjectClass, FileList): if os.path.isfile(File): Lines = open(File, 'r') for Line in Lines: - StringTokenList = STRING_TOKEN.findall(Line) + if not IsCompatibleMode: + StringTokenList = STRING_TOKEN.findall(Line) + else: + StringTokenList = COMPATIBLE_STRING_TOKEN.findall(Line) for StrName in StringTokenList: EdkLogger.debug(EdkLogger.DEBUG_5, "Found string identifier: " + StrName) UniObjectClass.SetStringReferenced(StrName) @@ -472,7 +506,7 @@ def SearchString(UniObjectClass, FileList): # This function is used for UEFI2.1 spec # # -def GetStringFiles(UniFilList, SourceFileList, IncludeList, SkipList, BaseName, IsCompatibleMode = False, ShellMode = False): +def GetStringFiles(UniFilList, SourceFileList, IncludeList, SkipList, BaseName, IsCompatibleMode = False, ShellMode = False, UniGenCFlag = True, UniGenBinBuffer = None): Status = True ErrorMessage = '' @@ -489,10 +523,14 @@ def GetStringFiles(UniFilList, SourceFileList, IncludeList, SkipList, BaseName, FileList = GetFileList(SourceFileList, IncludeList, SkipList) - Uni = SearchString(Uni, FileList) + Uni = SearchString(Uni, FileList, IsCompatibleMode) - HFile = CreateHFile(BaseName, Uni) - CFile = CreateCFile(BaseName, Uni, IsCompatibleMode) + HFile = CreateHFile(BaseName, Uni, IsCompatibleMode, UniGenCFlag) + CFile = None + if IsCompatibleMode or UniGenCFlag: + CFile = CreateCFile(BaseName, Uni, IsCompatibleMode) + if UniGenBinBuffer: + CreateCFileContent(BaseName, Uni, IsCompatibleMode, UniGenBinBuffer) return HFile, CFile diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py index 412fa72df0..dcfa264025 100644 --- a/BaseTools/Source/Python/AutoGen/UniClassObject.py +++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py @@ -234,6 +234,11 @@ class UniFileClassObject(object): Value = '' Name = Item.split()[1] + # Check the string name is the upper character + if not self.IsCompatibleMode and Name != '': + MatchString = re.match('[A-Z0-9_]+', Name, re.UNICODE) + if MatchString == None or MatchString.end(0) != len(Name): + EdkLogger.error('Unicode File Parser', FORMAT_INVALID, 'The string token name %s defined in UNI file %s contains the invalid lower case character.' %(Name, self.File)) LanguageList = Item.split(u'#language ') for IndexI in range(len(LanguageList)): if IndexI == 0: @@ -365,6 +370,11 @@ class UniFileClassObject(object): break # Value = Value.replace(u'\r\n', u'') Language = GetLanguageCode(Language, self.IsCompatibleMode, self.File) + # Check the string name is the upper character + if not self.IsCompatibleMode and Name != '': + MatchString = re.match('[A-Z0-9_]+', Name, re.UNICODE) + if MatchString == None or MatchString.end(0) != len(Name): + EdkLogger.error('Unicode File Parser', FORMAT_INVALID, 'The string token name %s defined in UNI file %s contains the invalid lower case character.' %(Name, self.File)) self.AddStringToList(Name, Language, Value) continue -- cgit v1.2.3