From da92f27632d2c89fa8726948ac9b02461ca8b61e Mon Sep 17 00:00:00 2001 From: lgao4 Date: Wed, 11 May 2011 10:26:49 +0000 Subject: Sync BaseTools Branch (version r2149) to EDKII main trunk. BaseTool Branch: https://edk2-buildtools.svn.sourceforge.net/svnroot/edk2-buildtools/branches/Releases/BaseTools_r2100 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11640 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/AutoGen/AutoGen.py | 156 ++++++++++++++++- BaseTools/Source/Python/AutoGen/GenC.py | 44 +++-- BaseTools/Source/Python/AutoGen/GenMake.py | 2 +- BaseTools/Source/Python/AutoGen/UniClassObject.py | 27 ++- .../Source/Python/Common/ToolDefClassObject.py | 6 +- BaseTools/Source/Python/GenFds/FdfParser.py | 55 +++--- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 185 +++++++++++++++++++-- BaseTools/Source/Python/GenFds/Section.py | 4 +- .../Source/Python/Workspace/WorkspaceDatabase.py | 21 ++- BaseTools/Source/Python/build/BuildReport.py | 4 +- BaseTools/Source/Python/build/build.py | 41 +++-- 11 files changed, 466 insertions(+), 79 deletions(-) (limited to 'BaseTools/Source/Python') diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 4ecf2eafe7..8090a06bf8 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1,7 +1,7 @@ ## @file # Generate AutoGen.h, AutoGen.c and *.depex files # -# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -53,6 +53,39 @@ gAutoGenStringFileName = "%(module_name)sStrDefs.h" gAutoGenStringFormFileName = "%(module_name)sStrDefs.hpk" gAutoGenDepexFileName = "%(module_name)s.depex" +# +# Template string to generic AsBuilt INF +# +gAsBuiltInfHeaderString = TemplateString("""## @file +# ${module_name} +# +# DO NOT EDIT +# FILE auto-generated Binary INF +# +## + +[Defines] + INF_VERSION = 0x00010016 + BASE_NAME = ${module_name} + FILE_GUID = ${module_guid} + MODULE_TYPE = ${module_module_type} + VERSION_STRING = ${module_version_string}${BEGIN} + UEFI_SPECIFICATION_VERSION = ${module_uefi_specification_version}${END}${BEGIN} + PI_SPECIFICATION_VERSION = ${module_pi_specification_version}${END} + +[Packages]${BEGIN} + ${package_item}${END} + +[Binaries.${module_arch}]${BEGIN} + ${binary_item}${END} + +[PcdEx]${BEGIN} + ${pcd_item}${END} + +## @AsBuilt${BEGIN} +## ${flags_item}${END} +""") + ## Base class for AutoGen # # This class just implements the cache mechanism of AutoGen objects. @@ -499,6 +532,7 @@ class PlatformAutoGen(AutoGen): Ma = ModuleAutoGen(self.Workspace, ModuleFile, self.BuildTarget, self.ToolChain, self.Arch, self.MetaFile) Ma.CreateMakeFile(True) + Ma.CreateAsBuiltInf() # no need to create makefile for the platform more than once if self.IsMakeFileCreated: @@ -1036,9 +1070,14 @@ class PlatformAutoGen(AutoGen): PlatformModule = self.Platform.Modules[str(Module)] # add forced library instances (specified under LibraryClasses sections) - for LibraryClass in self.Platform.LibraryClasses.GetKeys(): - if LibraryClass.startswith("NULL"): - Module.LibraryClasses[LibraryClass] = self.Platform.LibraryClasses[LibraryClass] + # + # If a module has a MODULE_TYPE of USER_DEFINED, + # do not link in NULL library class instances from the global [LibraryClasses.*] sections. + # + if Module.ModuleType != SUP_MODULE_USER_DEFINED: + for LibraryClass in self.Platform.LibraryClasses.GetKeys(): + if LibraryClass.startswith("NULL") and self.Platform.LibraryClasses[LibraryClass, Module.ModuleType]: + Module.LibraryClasses[LibraryClass] = self.Platform.LibraryClasses[LibraryClass, Module.ModuleType] # add forced library instances (specified in module overrides) for LibraryClass in PlatformModule.LibraryClasses: @@ -1596,6 +1635,8 @@ class ModuleAutoGen(AutoGen): self.IsMakeFileCreated = False self.IsCodeFileCreated = False + self.IsAsBuiltInfCreated = False + self.DepexGenerated = False self.BuildDatabase = self.Workspace.BuildDatabase @@ -1987,6 +2028,9 @@ class ModuleAutoGen(AutoGen): CreateDirectory(Source.Dir) if File.IsBinary and File == Source and self._BinaryFileList != None and File in self._BinaryFileList: + # Skip all files that are not binary libraries + if not self.IsLibrary: + continue RuleObject = self.BuildRules[TAB_DEFAULT_BINARY_FILE] elif FileType in self.BuildRules: RuleObject = self.BuildRules[FileType] @@ -2214,6 +2258,107 @@ class ModuleAutoGen(AutoGen): self._IncludePathList.append(str(Inc)) return self._IncludePathList + ## Create AsBuilt INF file the module + # + def CreateAsBuiltInf(self): + if self.IsAsBuiltInfCreated: + return + + # Skip the following code for EDK I inf + if self.AutoGenVersion < 0x00010005: + return + + # Skip the following code for libraries + if self.IsLibrary: + return + + # Skip the following code for modules with no source files + if self.SourceFileList == None or self.SourceFileList == []: + return + + # Skip the following code for modules without any binary files + if self.BinaryFileList <> None and self.BinaryFileList <> []: + return + + ### TODO: How to handles mixed source and binary modules + + # Find all DynamicEx PCDs used by this module and dependent libraries + # Also find all packages that the DynamicEx PCDs depend on + Pcds = [] + Packages = [] + for Pcd in self.ModulePcdList + self.LibraryPcdList: + if Pcd.Type in GenC.gDynamicExPcd: + if Pcd not in Pcds: + Pcds += [Pcd] + for Package in self.DerivedPackageList: + if Package not in Packages: + if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'DynamicEx') in Package.Pcds: + Packages += [Package] + elif (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'Dynamic') in Package.Pcds: + Packages += [Package] + + ModuleType = self.ModuleType + if ModuleType == 'UEFI_DRIVER' and self.DepexGenerated: + ModuleType = 'DXE_DRIVER' + + AsBuiltInfDict = { + 'module_name' : self.Name, + 'module_guid' : self.Guid, + 'module_module_type' : ModuleType, + 'module_version_string' : self.Version, + 'module_uefi_specification_version' : [], + 'module_pi_specification_version' : [], + 'module_arch' : self.Arch, + 'package_item' : ['%s' % (Package.MetaFile.File.replace('\\','/')) for Package in Packages], + 'binary_item' : [], + 'pcd_item' : [], + 'flags_item' : [] + } + + if 'UEFI_SPECIFICATION_VERSION' in self.Specification: + AsBuiltInfDict['module_uefi_specification_version'] += [self.Specification['UEFI_SPECIFICATION_VERSION']] + if 'PI_SPECIFICATION_VERSION' in self.Specification: + AsBuiltInfDict['module_pi_specification_version'] += [self.Specification['PI_SPECIFICATION_VERSION']] + + OutputDir = self.OutputDir.replace('\\','/').strip('/') + if self.ModuleType in ['BASE', 'USER_DEFINED']: + for Item in self.CodaTargetList: + File = Item.Target.Path.replace('\\','/').strip('/').replace(OutputDir,'').strip('/') + if Item.Target.Ext.lower() == '.aml': + AsBuiltInfDict['binary_item'] += ['ASL|' + File] + elif Item.Target.Ext.lower() == '.acpi': + AsBuiltInfDict['binary_item'] += ['ACPI|' + File] + else: + AsBuiltInfDict['binary_item'] += ['BIN|' + File] + else: + for Item in self.CodaTargetList: + File = Item.Target.Path.replace('\\','/').strip('/').replace(OutputDir,'').strip('/') + if Item.Target.Ext.lower() == '.efi': + AsBuiltInfDict['binary_item'] += ['PE32|' + self.Name + '.efi'] + else: + AsBuiltInfDict['binary_item'] += ['BIN|' + File] + if self.DepexGenerated: + 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']: + AsBuiltInfDict['binary_item'] += ['DXE_DEPEX|' + self.Name + '.depex'] + if self.ModuleType in ['DXE_SMM_DRIVER']: + AsBuiltInfDict['binary_item'] += ['SMM_DEPEX|' + self.Name + '.depex'] + + for Pcd in Pcds: + AsBuiltInfDict['pcd_item'] += [Pcd.TokenSpaceGuidCName + '.' + Pcd.TokenCName] + + for Item in self.BuildOption: + if 'FLAGS' in self.BuildOption[Item]: + AsBuiltInfDict['flags_item'] += ['%s:%s_%s_%s_%s_FLAGS = %s' % (self.ToolChainFamily, self.BuildTarget, self.ToolChain, self.Arch, Item, self.BuildOption[Item]['FLAGS'].strip())] + + AsBuiltInf = TemplateString() + AsBuiltInf.Append(gAsBuiltInfHeaderString.Replace(AsBuiltInfDict)) + + SaveFileOnChange(os.path.join(self.OutputDir, self.Name + '.inf'), str(AsBuiltInf), False) + + self.IsAsBuiltInfCreated = True + ## Create makefile for the module and its dependent libraries # # @param CreateLibraryMakeFile Flag indicating if or not the makefiles of @@ -2278,6 +2423,9 @@ class ModuleAutoGen(AutoGen): Dpx = GenDepex.DependencyExpression(self.DepexList[ModuleType], ModuleType, True) DpxFile = gAutoGenDepexFileName % {"module_name" : self.Name} + if len(Dpx.PostfixNotation) <> 0: + self.DepexGenerated = True + if Dpx.Generate(path.join(self.OutputDir, DpxFile)): AutoGenList.append(str(DpxFile)) else: diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index 3c256c8b74..e6e8847623 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -1,7 +1,7 @@ ## @file # Routines for generating AutoGen.h and AutoGen.c # -# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -1098,6 +1098,10 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): ExtraData="[%s]" % str(Info)) TokenNumber = PcdTokenNumber[TokenCName, TokenSpaceGuidCName] + # If PCD is DynamicEx, then use TokenNumber declared in DEC file + if Pcd.Type in gDynamicExPcd: + TokenNumber = int(Pcd.TokenValue, 0) + if Pcd.Type not in gItemTypeStringDatabase: EdkLogger.error("build", AUTOGEN_ERROR, "Unknown PCD type [%s] of PCD %s.%s" % (Pcd.Type, Pcd.TokenSpaceGuidCName, Pcd.TokenCName), @@ -1677,11 +1681,11 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): if 'PI_SPECIFICATION_VERSION' in Info.Module.Specification: PiSpecVersion = Info.Module.Specification['PI_SPECIFICATION_VERSION'] else: - PiSpecVersion = 0 + PiSpecVersion = '0x00000000' if 'UEFI_SPECIFICATION_VERSION' in Info.Module.Specification: UefiSpecVersion = Info.Module.Specification['UEFI_SPECIFICATION_VERSION'] else: - UefiSpecVersion = 0 + UefiSpecVersion = '0x00000000' Dict = { 'Function' : Info.Module.ModuleEntryPointList, 'PiSpecVersion' : PiSpecVersion, @@ -1689,14 +1693,15 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): } if Info.ModuleType in ['PEI_CORE', 'DXE_CORE', 'SMM_CORE']: - if NumEntryPoints != 1: - EdkLogger.error( - "build", - AUTOGEN_ERROR, - '%s must have exactly one entry point' % Info.ModuleType, - File=str(Info), - ExtraData= ", ".join(Info.Module.ModuleEntryPointList) - ) + if Info.SourceFileList <> None and Info.SourceFileList <> []: + if NumEntryPoints != 1: + EdkLogger.error( + "build", + AUTOGEN_ERROR, + '%s must have exactly one entry point' % Info.ModuleType, + File=str(Info), + ExtraData= ", ".join(Info.Module.ModuleEntryPointList) + ) if Info.ModuleType == 'PEI_CORE': AutoGenC.Append(gPeiCoreEntryPointString.Replace(Dict)) AutoGenH.Append(gPeiCoreEntryPointPrototype.Replace(Dict)) @@ -1827,6 +1832,23 @@ def CreatePpiDefinitionCode(Info, AutoGenC, AutoGenH): # @param AutoGenH The TemplateString object for header file # def CreatePcdCode(Info, AutoGenC, AutoGenH): + + # Collect Token Space GUIDs used by DynamicEc PCDs + TokenSpaceList = [] + for Pcd in Info.ModulePcdList: + if Pcd.Type in gDynamicExPcd and Pcd.TokenSpaceGuidCName not in TokenSpaceList: + TokenSpaceList += [Pcd.TokenSpaceGuidCName] + + # Add extern declarations to AutoGen.h if one or more Token Space GUIDs were found + if TokenSpaceList <> []: + AutoGenH.Append("\n// Definition of PCD Token Space GUIDs used in this module\n\n") + if Info.ModuleType in ["USER_DEFINED", "BASE"]: + GuidType = "GUID" + else: + GuidType = "EFI_GUID" + for Item in TokenSpaceList: + AutoGenH.Append('extern %s %s;\n' % (GuidType, Item)) + if Info.IsLibrary: if Info.ModulePcdList: AutoGenH.Append("\n// PCD definitions\n") diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index 49ac33f47f..6396c612ad 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -493,7 +493,7 @@ cleanlib: # convert source files and binary files to build targets self.ResultFileList = [str(T.Target) for T in self._AutoGenObject.CodaTargetList] - if len(self.ResultFileList) == 0: + if len(self.ResultFileList) == 0 and len(self._AutoGenObject.SourceFileList) <> 0: EdkLogger.error("build", AUTOGEN_ERROR, "Nothing to build", ExtraData="[%s]" % str(self._AutoGenObject)) diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py index 1eb65c1e9a..1825c81d91 100644 --- a/BaseTools/Source/Python/AutoGen/UniClassObject.py +++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py @@ -121,7 +121,7 @@ def GetLanguageCode(LangName, IsCompatibleMode, File): if length == 3 and LangName.isalpha(): TempLangName = LangConvTable.get(LangName.lower()) if TempLangName != None: - return TempLangName + return TempLangName return LangName else: EdkLogger.error("Unicode File Parser", FORMAT_INVALID, "Invalid ISO 639-2 language code : %s" % LangName, File) @@ -298,13 +298,36 @@ class UniFileClassObject(object): # # Use unique identifier # + FindFlag = -1 + LineCount = 0 for Line in FileIn: + Line = FileIn[LineCount] + LineCount += 1 Line = Line.strip() # # Ignore comment line and empty line # if Line == u'' or Line.startswith(u'//'): continue + + # + # Process comment embeded in string define lines + # + FindFlag = Line.find(u'//') + if FindFlag != -1: + Line = Line.replace(Line[FindFlag:], u' ') + if FileIn[LineCount].strip().startswith('#language'): + Line = Line + FileIn[LineCount] + FileIn[LineCount-1] = Line + FileIn[LineCount] = os.linesep + LineCount -= 1 + for Index in xrange (LineCount + 1, len (FileIn) - 1): + if (Index == len(FileIn) -1): + FileIn[Index] = os.linesep + else: + FileIn[Index] = FileIn[Index + 1] + continue + Line = Line.replace(u'/langdef', u'#langdef') Line = Line.replace(u'/string', u'#string') Line = Line.replace(u'/language', u'#language') @@ -566,6 +589,6 @@ class UniFileClassObject(object): if __name__ == '__main__': EdkLogger.Initialize() EdkLogger.SetLevel(EdkLogger.DEBUG_0) - a = UniFileClassObject(['C:\\Edk\\Strings.uni', 'C:\\Edk\\Strings2.uni']) + a = UniFileClassObject([PathClass("C:\\Edk\\Strings.uni"), PathClass("C:\\Edk\\Strings2.uni")]) a.ReToken() a.ShowMe() diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseTools/Source/Python/Common/ToolDefClassObject.py index b5cd5ee435..0f49457449 100644 --- a/BaseTools/Source/Python/Common/ToolDefClassObject.py +++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py @@ -180,8 +180,10 @@ class ToolDefClassObject(object): EnvReference = gEnvRefPattern.findall(Value) for Ref in EnvReference: if Ref not in self.MacroDictionary: - return False, Ref - Value = Value.replace(Ref, self.MacroDictionary[Ref]) + Value = Value.replace(Ref, "") + else: + Value = Value.replace(Ref, self.MacroDictionary[Ref]) + MacroReference = gMacroRefPattern.findall(Value) for Ref in MacroReference: diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 52d32a9e98..9e7771dc7d 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -564,7 +564,17 @@ class FdfParser: self.Rewind() - + def __GetIfListCurrentItemStat(self, IfList): + if len(IfList) == 0: + return True + + for Item in IfList: + if Item[1] == False: + return False + + return True + + ## PreprocessConditionalStatement() method # # Preprocess conditional statement. @@ -577,27 +587,28 @@ class FdfParser: IfList = [] while self.__GetNextToken(): if self.__Token == 'DEFINE': - DefineLine = self.CurrentLineNumber - 1 - DefineOffset = self.CurrentOffsetWithinLine - len('DEFINE') - if not self.__GetNextToken(): - raise Warning("expected Macro name", self.FileName, self.CurrentLineNumber) - Macro = self.__Token - if not self.__IsToken( "="): - raise Warning("expected '='", self.FileName, self.CurrentLineNumber) - - if not self.__GetNextToken(): - raise Warning("expected value", self.FileName, self.CurrentLineNumber) - - if self.__GetStringData(): - pass - Value = self.__Token - if not Macro in InputMacroDict: - FileLineTuple = GetRealFileLine(self.FileName, DefineLine + 1) - MacProfile = MacroProfile(FileLineTuple[0], FileLineTuple[1]) - MacProfile.MacroName = Macro - MacProfile.MacroValue = Value - AllMacroList.append(MacProfile) - self.__WipeOffArea.append(((DefineLine, DefineOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1))) + if self.__GetIfListCurrentItemStat(IfList): + DefineLine = self.CurrentLineNumber - 1 + DefineOffset = self.CurrentOffsetWithinLine - len('DEFINE') + if not self.__GetNextToken(): + raise Warning("expected Macro name", self.FileName, self.CurrentLineNumber) + Macro = self.__Token + if not self.__IsToken( "="): + raise Warning("expected '='", self.FileName, self.CurrentLineNumber) + + if not self.__GetNextToken(): + raise Warning("expected value", self.FileName, self.CurrentLineNumber) + + if self.__GetStringData(): + pass + Value = self.__Token + if not Macro in InputMacroDict: + FileLineTuple = GetRealFileLine(self.FileName, DefineLine + 1) + MacProfile = MacroProfile(FileLineTuple[0], FileLineTuple[1]) + MacProfile.MacroName = Macro + MacProfile.MacroValue = Value + AllMacroList.append(MacProfile) + self.__WipeOffArea.append(((DefineLine, DefineOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1))) elif self.__Token in ('!ifdef', '!ifndef', '!if'): IfStartPos = (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - len(self.__Token)) diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index d2397e07da..2b556135d2 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -1,7 +1,7 @@ ## @file # process FFS generation from INF statement # -# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -18,6 +18,8 @@ import Rule import os import shutil +import StringIO +from struct import * from GenFdsGlobalVariable import GenFdsGlobalVariable import Ffs import subprocess @@ -50,7 +52,7 @@ class FfsInfStatement(FfsInfStatementClassObject): self.KeepRelocFromRule = None self.InDsc = True self.OptRomDefs = {} - self.PiSpecVersion = 0 + self.PiSpecVersion = '0x00000000' ## __InfParse() method # @@ -121,7 +123,7 @@ class FfsInfStatement(FfsInfStatementClassObject): if len(self.SourceFileList) != 0 and not self.InDsc: EdkLogger.warn("GenFds", GENFDS_ERROR, "Module %s NOT found in DSC file; Is it really a binary module?" % (self.InfFileName)) - if self.ModuleType == 'SMM_CORE' and self.PiSpecVersion < 0x0001000A: + if self.ModuleType == 'SMM_CORE' and int(self.PiSpecVersion, 16) < 0x0001000A: EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "SMM_CORE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x0001000A", File=self.InfFileName) if Inf._Defs != None and len(Inf._Defs) > 0: @@ -177,13 +179,13 @@ class FfsInfStatement(FfsInfStatementClassObject): # # Convert Fv File Type for PI1.1 SMM driver. # - if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion >= 0x0001000A: + if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) >= 0x0001000A: if Rule.FvFileType == 'DRIVER': Rule.FvFileType = 'SMM' # # Framework SMM Driver has no SMM FV file type # - if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion < 0x0001000A: + if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) < 0x0001000A: if Rule.FvFileType == 'SMM' or Rule.FvFileType == 'SMM_CORE': EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM or SMM_CORE FV file type", File=self.InfFileName) # @@ -409,9 +411,9 @@ class FfsInfStatement(FfsInfStatementClassObject): GenSecInputFile = None if Rule.FileName != None: GenSecInputFile = self.__ExtendMacro__(Rule.FileName) - if os.path.isabs(GenSecInputFile): - GenSecInputFile = os.path.normpath(GenSecInputFile) - else: + if os.path.isabs(GenSecInputFile): + GenSecInputFile = os.path.normpath(GenSecInputFile) + else: GenSecInputFile = os.path.normpath(os.path.join(self.EfiOutputPath, GenSecInputFile)) else: FileList, IsSect = Section.Section.GetFileList(self, '', Rule.FileExtension) @@ -421,13 +423,13 @@ class FfsInfStatement(FfsInfStatementClassObject): # # Convert Fv Section Type for PI1.1 SMM driver. # - if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion >= 0x0001000A: + if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) >= 0x0001000A: if SectionType == 'DXE_DEPEX': SectionType = 'SMM_DEPEX' # # Framework SMM Driver has no SMM_DEPEX section type # - if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion < 0x0001000A: + if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) < 0x0001000A: if SectionType == 'SMM_DEPEX': EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName) NoStrip = True @@ -583,19 +585,20 @@ class FfsInfStatement(FfsInfStatementClassObject): SectFiles = [] SectAlignments = [] Index = 1 + HasGneratedFlag = False for Sect in Rule.SectionList: SecIndex = '%d' %Index SectList = [] # # Convert Fv Section Type for PI1.1 SMM driver. # - if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion >= 0x0001000A: + if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) >= 0x0001000A: if Sect.SectionType == 'DXE_DEPEX': Sect.SectionType = 'SMM_DEPEX' # # Framework SMM Driver has no SMM_DEPEX section type # - if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion < 0x0001000A: + if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) < 0x0001000A: if Sect.SectionType == 'SMM_DEPEX': EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName) # @@ -613,6 +616,51 @@ class FfsInfStatement(FfsInfStatementClassObject): SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, Rule.KeyStringList, self) else : SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, self.KeyStringList, self) + + if not HasGneratedFlag: + UniVfrOffsetFileSection = "" + ModuleFileName = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName) + InfData = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(ModuleFileName), self.CurrentArch] + # + # Search the source list in InfData to find if there are .vfr file exist. + # + VfrUniBaseName = {} + VfrUniOffsetList = [] + for SourceFile in InfData.Sources: + if SourceFile.Type.upper() == ".VFR" : + # + # search the .map file to find the offset of vfr binary in the PE32+/TE file. + # + VfrUniBaseName[SourceFile.BaseName] = (SourceFile.BaseName + "Bin") + if SourceFile.Type.upper() == ".UNI" : + # + # search the .map file to find the offset of Uni strings binary in the PE32+/TE file. + # + VfrUniBaseName["UniOffsetName"] = (self.BaseName + "Strings") + + + if len(VfrUniBaseName) > 0: + VfrUniOffsetList = self.__GetBuildOutputMapFileVfrUniInfo(VfrUniBaseName) + # + # Generate the Raw data of raw section + # + os.path.join( self.OutputPath, self.BaseName + '.offset') + UniVfrOffsetFileName = os.path.join( self.OutputPath, self.BaseName + '.offset') + UniVfrOffsetFileSection = os.path.join( self.OutputPath, self.BaseName + 'Offset' + '.raw') + + self.__GenUniVfrOffsetFile (VfrUniOffsetList, UniVfrOffsetFileName) + + UniVfrOffsetFileNameList = [] + UniVfrOffsetFileNameList.append(UniVfrOffsetFileName) + """Call GenSection""" + GenFdsGlobalVariable.GenerateSection(UniVfrOffsetFileSection, + UniVfrOffsetFileNameList, + "EFI_SECTION_RAW" + ) + os.remove(UniVfrOffsetFileName) + SectList.append(UniVfrOffsetFileSection) + HasGneratedFlag = True + for SecName in SectList : SectFiles.append(SecName) SectAlignments.append(Align) @@ -672,3 +720,116 @@ class FfsInfStatement(FfsInfStatementClassObject): result += ('-a', Rule.Alignment) return result + + ## __GetBuildOutputMapFileVfrUniInfo() method + # + # Find the offset of UNI/INF object offset in the EFI image file. + # + # @param self The object pointer + # @param VfrUniBaseName A name list contain the UNI/INF object name. + # @retval RetValue A list contain offset of UNI/INF object. + # + def __GetBuildOutputMapFileVfrUniInfo(self, VfrUniBaseName): + + RetValue = [] + + MapFileName = os.path.join(self.EfiOutputPath, self.BaseName + ".map") + try: + fInputfile = open(MapFileName, "r", 0) + try: + FileLinesList = fInputfile.readlines() + except: + EdkLogger.error("GenFds", FILE_READ_FAILURE, "File read failed for %s" %MapFileName,None) + finally: + fInputfile.close() + except: + EdkLogger.error("GenFds", FILE_OPEN_FAILURE, "File open failed for %s" %MapFileName,None) + + IsHex = False + for eachLine in FileLinesList: + for eachName in VfrUniBaseName.values(): + if eachLine.find(eachName) != -1: + eachLine = eachLine.strip() + Element = eachLine.split() + # + # MSFT/ICC/EBC map file + # + if (len(Element) == 4): + try: + int (Element[2], 16) + IsHex = True + except: + IsHex = False + + if IsHex: + RetValue.append((eachName, Element[2])) + IsHex = False + # + # GCC map file + # + elif (len(Element) == 2) and Element[0].startswith("0x"): + RetValue.append((eachName, Element[0])) + + return RetValue + + ## __GenUniVfrOffsetFile() method + # + # Generate the offset file for the module which contain VFR or UNI file. + # + # @param self The object pointer + # @param VfrUniOffsetList A list contain the VFR/UNI offsets in the EFI image file. + # @param UniVfrOffsetFileName The output offset file name. + # + def __GenUniVfrOffsetFile(self, VfrUniOffsetList, UniVfrOffsetFileName): + + try: + fInputfile = open(UniVfrOffsetFileName, "wb+", 0) + except: + EdkLogger.error("GenFds", FILE_OPEN_FAILURE, "File open failed for %s" %UniVfrOffsetFileName,None) + + # Use a instance of StringIO to cache data + fStringIO = StringIO.StringIO('') + + for Item in VfrUniOffsetList: + if (Item[0].find("Strings") != -1): + # + # UNI offset in image. + # GUID + Offset + # { 0x8913c5e0, 0x33f6, 0x4d86, { 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66 } } + # + UniGuid = [0xe0, 0xc5, 0x13, 0x89, 0xf6, 0x33, 0x86, 0x4d, 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66] + UniGuid = [chr(ItemGuid) for ItemGuid in UniGuid] + fStringIO.write(''.join(UniGuid)) + UniValue = pack ('Q', int (Item[1], 16)) + fStringIO.write (UniValue) + else: + # + # VFR binary offset in image. + # GUID + Offset + # { 0xd0bc7cb4, 0x6a47, 0x495f, { 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2 } }; + # + 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) + + # + # write data into file. + # + try : + fInputfile.write (fStringIO.getvalue()) + except: + EdkLogger.error("GenFds", FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the file been locked or using by other applications." %UniVfrOffsetFileName,None) + + fStringIO.close () + fInputfile.close () + + + + + + + + diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py index 8c884b6e10..a6d3c6319d 100644 --- a/BaseTools/Source/Python/GenFds/Section.py +++ b/BaseTools/Source/Python/GenFds/Section.py @@ -1,7 +1,7 @@ ## @file # section base class # -# Copyright (c) 2007, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -129,7 +129,7 @@ class Section (SectionClassObject): if FileType != None: for File in FfsInf.BinFileList: if File.Arch == "COMMON" or FfsInf.CurrentArch == File.Arch: - if File.Type == FileType or (FfsInf.PiSpecVersion >= 0x0001000A and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX'): + if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX'): if '*' in FfsInf.TargetOverrideList or File.Target == '*' or File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOverrideList == []: FileList.append(File.Path) else: diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py index 4b00dff84d..4a97b8a93b 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py @@ -1,7 +1,7 @@ ## @file # This file is used to create a database used by build tool # -# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -1425,7 +1425,17 @@ class InfBuildData(ModuleBuildClassObject): if not self._ModuleType: EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "MODULE_TYPE is not given", File=self.MetaFile) - if (self._Specification == None) or (not 'PI_SPECIFICATION_VERSION' in self._Specification) or (self._Specification['PI_SPECIFICATION_VERSION'] < 0x0001000A): + if self._ModuleType not in SUP_MODULE_LIST: + RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch, self._Platform] + for Record in RecordList: + Name = Record[0] + if Name == "MODULE_TYPE": + LineNo = Record[6] + break + EdkLogger.error("build", FORMAT_NOT_SUPPORTED, + "MODULE_TYPE %s is not supported for EDK II, valid values are:\n %s" % (self._ModuleType,' '.join(l for l in SUP_MODULE_LIST)), + File=self.MetaFile, Line=LineNo) + if (self._Specification == None) or (not 'PI_SPECIFICATION_VERSION' in self._Specification) or (int(self._Specification['PI_SPECIFICATION_VERSION'], 16) < 0x0001000A): if self._ModuleType == SUP_MODULE_SMM_CORE: EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "SMM_CORE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x0001000A", File=self.MetaFile) if self._Defs and 'PCI_DEVICE_ID' in self._Defs and 'PCI_VENDOR_ID' in self._Defs \ @@ -1894,7 +1904,12 @@ class InfBuildData(ModuleBuildClassObject): if self._Depex == None: self._Depex = tdict(False, 2) RecordList = self._RawData[MODEL_EFI_DEPEX, self._Arch] - + + # If the module has only Binaries and no Sources, then ignore [Depex] + if self.Sources == None or self.Sources == []: + if self.Binaries <> None and self.Binaries <> []: + return self._Depex + # PEIM and DXE drivers must have a valid [Depex] section if len(self.LibraryClass) == 0 and len(RecordList) == 0: if self.ModuleType == 'DXE_DRIVER' or self.ModuleType == 'PEIM' or self.ModuleType == 'DXE_SMM_DRIVER' or \ diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index c5793ad057..13d28ff3ba 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -4,7 +4,7 @@ # This module contains the functionality to generate build report after # build all target completes successfully. # -# Copyright (c) 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -486,7 +486,7 @@ class ModuleReport(object): # if ModuleType == "DXE_SMM_DRIVER": PiSpec = M.Module.Specification.get("PI_SPECIFICATION_VERSION", "0x00010000") - if int(PiSpec, 0) >= 0x0001000A: + if int(PiSpec, 16) >= 0x0001000A: ModuleType = "SMM_DRIVER" self.DriverType = gDriverTypeMap.get(ModuleType, "0x2 (FREE_FORM)") self.UefiSpecVersion = M.Module.Specification.get("UEFI_SPECIFICATION_VERSION", "") diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py index 84f5636414..b794c0a361 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -1,7 +1,7 @@ ## @file # build a platform or a module # -# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -102,7 +102,8 @@ def CheckEnvVariable(): # # Check EFI_SOURCE (R8 build convention). EDK_SOURCE will always point to ECP # - os.environ["ECP_SOURCE"] = os.path.join(WorkspaceDir, GlobalData.gEdkCompatibilityPkg) + if "ECP_SOURCE" not in os.environ: + os.environ["ECP_SOURCE"] = os.path.join(WorkspaceDir, GlobalData.gEdkCompatibilityPkg) if "EFI_SOURCE" not in os.environ: os.environ["EFI_SOURCE"] = os.environ["ECP_SOURCE"] if "EDK_SOURCE" not in os.environ: @@ -888,7 +889,7 @@ class Build(): self.LoadFixAddress = int (LoadFixAddressString, 16) else: self.LoadFixAddress = int (LoadFixAddressString) - except: + except: EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_MEMORY_ADDRESS %s is not valid dec or hex string" % (LoadFixAddressString)) if self.LoadFixAddress < 0: EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_MEMORY_ADDRESS is set to the invalid negative value %s" % (LoadFixAddressString)) @@ -908,6 +909,8 @@ class Build(): self.FvList = [] else: FdfParserObj = FdfParser(str(self.Fdf)) + for key in self.Db._GlobalMacros: + InputMacroDict[key] = self.Db._GlobalMacros[key] FdfParserObj.ParseFile() for fvname in self.FvList: if fvname.upper() not in FdfParserObj.Profile.FvDict.keys(): @@ -974,6 +977,7 @@ class Build(): if not self.SkipAutoGen or Target == 'genmake': self.Progress.Start("Generating makefile") AutoGenObject.CreateMakeFile(CreateDepsMakeFile) + AutoGenObject.CreateAsBuiltInf() self.Progress.Stop("done!") if Target == "genmake": return True @@ -1007,8 +1011,8 @@ class Build(): InfFileNameList = ModuleList.keys() #InfFileNameList.sort() for InfFile in InfFileNameList: - sys.stdout.write (".") - sys.stdout.flush() + sys.stdout.write (".") + sys.stdout.flush() ModuleInfo = ModuleList[InfFile] ModuleName = ModuleInfo.BaseName ModuleOutputImage = ModuleInfo.Image.FileName @@ -1141,8 +1145,8 @@ class Build(): ## Collect MAP information of all modules # def _CollectModuleMapBuffer (self, MapBuffer, ModuleList): - sys.stdout.write ("Generate Load Module At Fix Address Map") - sys.stdout.flush() + sys.stdout.write ("Generate Load Module At Fix Address Map") + sys.stdout.flush() PatchEfiImageList = [] PeiModuleList = {} BtModuleList = {} @@ -1187,11 +1191,11 @@ class Build(): SmmModuleList[Module.MetaFile] = ImageInfo SmmSize += ImageInfo.Image.Size if Module.ModuleType == 'DXE_SMM_DRIVER': - PiSpecVersion = 0 - if 'PI_SPECIFICATION_VERSION' in Module.Module.Specification: - PiSpecVersion = Module.Module.Specification['PI_SPECIFICATION_VERSION'] + PiSpecVersion = '0x00000000' + if 'PI_SPECIFICATION_VERSION' in Module.Module.Specification: + PiSpecVersion = Module.Module.Specification['PI_SPECIFICATION_VERSION'] # for PI specification < PI1.1, DXE_SMM_DRIVER also runs as BOOT time driver. - if PiSpecVersion < 0x0001000A: + if int(PiSpecVersion, 16) < 0x0001000A: BtModuleList[Module.MetaFile] = ImageInfo BtSize += ImageInfo.Image.Size break @@ -1245,7 +1249,7 @@ class Build(): # # Get PCD offset in EFI image by GenPatchPcdTable function # - PcdTable = parsePcdInfoFromMapFile(EfiImageMap, EfiImage) + PcdTable = parsePcdInfoFromMapFile(EfiImageMap, EfiImage) # # Patch real PCD value by PatchPcdValue tool # @@ -1277,8 +1281,8 @@ class Build(): self._RebaseModule (MapBuffer, RtBaseAddr, RtModuleList, TopMemoryAddress == 0) self._RebaseModule (MapBuffer, 0x1000, SmmModuleList, AddrIsOffset = False, ModeIsSmm = True) MapBuffer.write('\n\n') - sys.stdout.write ("\n") - sys.stdout.flush() + sys.stdout.write ("\n") + sys.stdout.flush() ## Save platform Map file # @@ -1291,10 +1295,10 @@ class Build(): # Save address map into MAP file. # SaveFileOnChange(MapFilePath, MapBuffer.getvalue(), False) - MapBuffer.close() - if self.LoadFixAddress != 0: - sys.stdout.write ("\nLoad Module At Fix Address Map file can be found at %s\n" %(MapFilePath)) - sys.stdout.flush() + MapBuffer.close() + if self.LoadFixAddress != 0: + sys.stdout.write ("\nLoad Module At Fix Address Map file can be found at %s\n" %(MapFilePath)) + sys.stdout.flush() ## Build active platform for different build targets and different tool chains # @@ -1487,6 +1491,7 @@ class Build(): if not self.SkipAutoGen or self.Target == 'genmake': Ma.CreateMakeFile(True) + Ma.CreateAsBuiltInf() if self.Target == "genmake": continue self.Progress.Stop("done!") -- cgit v1.2.3