License header updated to match correct format.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yingke Liu <yingke.d.liu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15971 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Yingke Liu
2014-08-28 13:53:34 +00:00
committed by yingke
parent cb9ec399fe
commit 97fa0ee9b1
135 changed files with 1189 additions and 869 deletions

View File

@ -18,7 +18,7 @@
from Ffs import Ffs
import Section
import subprocess
import os
import Common.LongFilePathOs as os
from GenFdsGlobalVariable import GenFdsGlobalVariable
from CommonDataClass.FdfClass import CompressSectionClassObject

View File

@ -24,6 +24,7 @@ from CommonDataClass.FdfClass import DepexSectionClassObject
from AutoGen.GenDepex import DependencyExpression
from Common import EdkLogger
from Common.BuildToolError import *
from Common.Misc import PathClass
## generate data section
#
@ -38,10 +39,22 @@ class DepexSection (DepexSectionClassObject):
def __FindGuidValue(self, CName):
for Arch in GenFdsGlobalVariable.ArchList:
for PkgDb in GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform,
Arch,
GenFdsGlobalVariable.TargetName,
GenFdsGlobalVariable.ToolChainTag):
PkgList = GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform,
Arch,
GenFdsGlobalVariable.TargetName,
GenFdsGlobalVariable.ToolChainTag)
for Inf in GenFdsGlobalVariable.FdfParser.Profile.InfList:
ModuleFile = PathClass(Inf, GenFdsGlobalVariable.WorkSpaceDir)
ModuleData = GenFdsGlobalVariable.WorkSpace.BuildObject[
ModuleFile,
Arch,
GenFdsGlobalVariable.TargetName,
GenFdsGlobalVariable.ToolChainTag
]
for Pkg in ModuleData.Packages:
if Pkg not in PkgList:
PkgList.append(Pkg)
for PkgDb in PkgList:
if CName in PkgDb.Ppis:
return PkgDb.Ppis[CName]
if CName in PkgDb.Protocols:

View File

@ -1,7 +1,7 @@
## @file
# process rule section generation
#
# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -211,10 +211,10 @@ class EfiSection (EfiSectionClassObject):
"""If File List is empty"""
if FileList == [] :
if self.Optional == True:
GenFdsGlobalVariable.VerboseLogger( "Optional Section don't exist!")
return [], None
GenFdsGlobalVariable.VerboseLogger("Optional Section don't exist!")
return [], None
else:
EdkLogger.error("GenFds", GENFDS_ERROR, "Output file for %s section could not be found for %s" % (SectionType, InfFileName))
EdkLogger.error("GenFds", GENFDS_ERROR, "Output file for %s section could not be found for %s" % (SectionType, InfFileName))
else:
"""Convert the File to Section file one by one """

View File

@ -218,6 +218,7 @@ class FdfParser:
self.CurrentFvName = None
self.__Token = ""
self.__SkippedChars = ""
GlobalData.gFdfParser = self
# Used to section info
self.__CurSection = []
@ -2356,6 +2357,9 @@ class FdfParser:
ffsInf.CurrentLineNum = self.CurrentLineNumber
ffsInf.CurrentLineContent = self.__CurrentLine()
#Replace $(SAPCE) with real space
ffsInf.InfFileName = ffsInf.InfFileName.replace('$(SPACE)', ' ')
if ffsInf.InfFileName.replace('$(WORKSPACE)', '').find('$') == -1:
#do case sensitive check for file path
ErrorCode, ErrorInfo = PathClass(NormPath(ffsInf.InfFileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
@ -2391,6 +2395,12 @@ class FdfParser:
# @param FfsInfObj for whom option is got
#
def __GetInfOptions(self, FfsInfObj):
if self.__IsKeyword("FILE_GUID"):
if not self.__IsToken("="):
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
if not self.__GetNextGuid():
raise Warning("expected GUID value", self.FileName, self.CurrentLineNumber)
FfsInfObj.OverrideGuid = self.__Token
if self.__IsKeyword( "RuleOverride"):
if not self.__IsToken( "="):
@ -2426,8 +2436,8 @@ class FdfParser:
if self.__GetNextToken():
p = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
if p.match(self.__Token):
p = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\))')
if p.match(self.__Token) and p.match(self.__Token).span()[1] == len(self.__Token):
FfsInfObj.KeyStringList.append(self.__Token)
if not self.__IsToken(","):
return
@ -2576,7 +2586,7 @@ class FdfParser:
else:
FfsFileObj.CurrentLineNum = self.CurrentLineNumber
FfsFileObj.CurrentLineContent = self.__CurrentLine()
FfsFileObj.FileName = self.__Token
FfsFileObj.FileName = self.__Token.replace('$(SPACE)', ' ')
self.__VerifyFile(FfsFileObj.FileName)
if not self.__IsToken( "}"):

View File

@ -92,6 +92,8 @@ class FileStatement (FileStatementClassObject) :
elif self.FileName != None:
self.FileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
#Replace $(SAPCE) with real space
self.FileName = self.FileName.replace('$(SPACE)', ' ')
SectionFiles = [GenFdsGlobalVariable.MacroExtend(self.FileName, Dict)]
else:

View File

@ -30,6 +30,7 @@ from CommonDataClass.FdfClass import FfsInfStatementClassObject
from Common.String import *
from Common.Misc import PathClass
from Common.Misc import GuidStructureByteArrayToGuidString
from Common.Misc import ProcessDuplicatedInf
from Common import EdkLogger
from Common.BuildToolError import *
from GuidSection import GuidSection
@ -64,6 +65,8 @@ class FfsInfStatement(FfsInfStatementClassObject):
self.CurrentLineContent = None
self.FileName = None
self.InfFileName = None
self.OverrideGuid = None
self.PatchedBinFile = ''
## GetFinalTargetSuffixMap() method
#
@ -145,7 +148,9 @@ class FfsInfStatement(FfsInfStatementClassObject):
GenFdsGlobalVariable.VerboseLogger( " Begine parsing INf file : %s" %self.InfFileName)
self.InfFileName = self.InfFileName.replace('$(WORKSPACE)', '')
if self.InfFileName[0] == '\\' or self.InfFileName[0] == '/' :
if len(self.InfFileName) > 1 and self.InfFileName[0] == '\\' and self.InfFileName[1] == '\\':
pass
elif self.InfFileName[0] == '\\' or self.InfFileName[0] == '/' :
self.InfFileName = self.InfFileName[1:]
if self.InfFileName.find('$') == -1:
@ -164,7 +169,9 @@ class FfsInfStatement(FfsInfStatementClassObject):
ErrorCode, ErrorInfo = PathClassObj.Validate(".inf")
if ErrorCode != 0:
EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
if self.OverrideGuid:
PathClassObj = ProcessDuplicatedInf(PathClassObj, self.OverrideGuid, GenFdsGlobalVariable.WorkSpaceDir)
if self.CurrentArch != None:
Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
@ -199,6 +206,9 @@ class FfsInfStatement(FfsInfStatementClassObject):
"INF %s specified in FDF could not be found in build ARCH %s!" \
% (self.InfFileName, GenFdsGlobalVariable.ArchList))
if self.OverrideGuid:
self.ModuleGuid = self.OverrideGuid
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))
@ -285,8 +295,8 @@ class FfsInfStatement(FfsInfStatementClassObject):
or PcdValueInImg > FfsInfStatement._MAX_SIZE_TYPE[Pcd.DatumType]:
EdkLogger.error("GenFds", GENFDS_ERROR, "The size of %s type PCD '%s.%s' doesn't match its data type." \
% (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
Pcd.DefaultValue = DefaultValue
self.PatchPcds.append(Pcd)
self.PatchPcds.append((Pcd, DefaultValue))
self.InfModule = Inf
self.PcdIsDriver = Inf.PcdIsDriver
self.IsBinaryModule = Inf.IsBinaryModule
@ -308,7 +318,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
self.EfiOutputPath = self.__GetEFIOutPutPath__()
GenFdsGlobalVariable.VerboseLogger( "ModuelEFIPath: " + self.EfiOutputPath)
## PatchEfiFile
## PatchEfiFile
#
# Patch EFI file with patch PCD
#
@ -316,18 +326,25 @@ class FfsInfStatement(FfsInfStatementClassObject):
# @retval: Full path of patched EFI file: self.OutputPath + EfiFile base name
# If passed in file does not end with efi, return as is
#
def PatchEfiFile(self, EfiFile):
if os.path.splitext(EfiFile)[1].lower() != '.efi':
return EfiFile
def PatchEfiFile(self, EfiFile, FileType):
if not self.PatchPcds:
return EfiFile
if FileType != 'PE32' and self.ModuleType != "USER_DEFINED":
return EfiFile
if self.PatchedBinFile:
EdkLogger.error("GenFds", GENFDS_ERROR,
'Only one binary file can be patched:\n'
' a binary file has been patched: %s\n'
' current file: %s' % (self.PatchedBinFile, EfiFile),
File=self.InfFileName)
Basename = os.path.basename(EfiFile)
Output = os.path.join(self.OutputPath, Basename)
CopyLongFilePath(EfiFile, Output)
for Pcd in self.PatchPcds:
RetVal, RetStr = PatchBinaryFile(Output, int(Pcd.Offset, 0), Pcd.DatumType, Pcd.DefaultValue, Pcd.MaxDatumSize)
for Pcd, Value in self.PatchPcds:
RetVal, RetStr = PatchBinaryFile(Output, int(Pcd.Offset, 0), Pcd.DatumType, Value, Pcd.MaxDatumSize)
if RetVal:
EdkLogger.error("GenFds", GENFDS_ERROR, RetStr, File=self.InfFileName)
self.PatchedBinFile = os.path.normpath(EfiFile)
return Output
## GenFfs() method
#
@ -349,7 +366,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
#
# Allow binary type module not specify override rule in FDF file.
#
if len(self.BinFileList) >0 and not self.InDsc:
if len(self.BinFileList) > 0:
if self.Rule == None or self.Rule == "":
self.Rule = "BINARY"
@ -568,6 +585,8 @@ class FfsInfStatement(FfsInfStatementClassObject):
(ModulePath, FileName) = os.path.split(self.InfFileName)
Index = FileName.rfind('.')
FileName = FileName[0:Index]
if self.OverrideGuid:
FileName = self.OverrideGuid
Arch = "NoneArch"
if self.CurrentArch != None:
Arch = self.CurrentArch

View File

@ -36,6 +36,7 @@ from Common import EdkLogger
from Common.String import *
from Common.Misc import DirCache,PathClass
from Common.Misc import SaveFileOnChange
from Common.Misc import ClearDuplicatedInf
from Common.Misc import GuidStructureStringToGuidString
from Common.BuildVersion import gBUILD_VERSION
@ -149,15 +150,36 @@ def main():
GenFdsGlobalVariable.ActivePlatform = PathClass(NormPath(ActivePlatform), Workspace)
BuildConfigurationFile = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, "Conf/target.txt"))
if (Options.ConfDirectory):
# Get alternate Conf location, if it is absolute, then just use the absolute directory name
ConfDirectoryPath = os.path.normpath(Options.ConfDirectory)
if ConfDirectoryPath.startswith('"'):
ConfDirectoryPath = ConfDirectoryPath[1:]
if ConfDirectoryPath.endswith('"'):
ConfDirectoryPath = ConfDirectoryPath[:-1]
if not os.path.isabs(ConfDirectoryPath):
# Since alternate directory name is not absolute, the alternate directory is located within the WORKSPACE
# This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf
ConfDirectoryPath = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ConfDirectoryPath)
else:
# Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf
ConfDirectoryPath = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, 'Conf')
GenFdsGlobalVariable.ConfDir = ConfDirectoryPath
BuildConfigurationFile = os.path.normpath(os.path.join(ConfDirectoryPath, "target.txt"))
if os.path.isfile(BuildConfigurationFile) == True:
TargetTxtClassObject.TargetTxtClassObject(BuildConfigurationFile)
else:
EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=BuildConfigurationFile)
#Set global flag for build mode
GlobalData.gIgnoreSource = Options.IgnoreSources
if Options.Macros:
for Pair in Options.Macros:
Pair = Pair.strip('"')
if Pair.startswith('"'):
Pair = Pair[1:]
if Pair.endswith('"'):
Pair = Pair[:-1]
List = Pair.split('=')
if len(List) == 2:
if List[0].strip() == "EFI_SOURCE":
@ -177,7 +199,8 @@ def main():
os.environ["WORKSPACE"] = Workspace
"""call Workspace build create database"""
BuildWorkSpace = WorkspaceDatabase(None)
GlobalData.gDatabasePath = os.path.normpath(os.path.join(ConfDirectoryPath, GlobalData.gDatabasePath))
BuildWorkSpace = WorkspaceDatabase(GlobalData.gDatabasePath)
BuildWorkSpace.InitDatabase()
#
@ -276,11 +299,13 @@ def main():
"\nPython",
CODE_ERROR,
"Tools code failure",
ExtraData="Please send email to edk2-buildtools-devel@lists.sourceforge.net for help, attaching following call stack trace!\n",
ExtraData="Please send email to edk2-devel@lists.sourceforge.net for help, attaching following call stack trace!\n",
RaiseError=False
)
EdkLogger.quiet(traceback.format_exc())
ReturnCode = CODE_ERROR
finally:
ClearDuplicatedInf()
return ReturnCode
gParamCheck = []
@ -321,6 +346,9 @@ def myOptionParser():
action="callback", callback=SingleCheckCallback)
Parser.add_option("-D", "--define", action="append", type="string", dest="Macros", help="Macro: \"Name [= Value]\".")
Parser.add_option("-s", "--specifyaddress", dest="FixedAddress", action="store_true", type=None, help="Specify driver load address.")
Parser.add_option("--conf", action="store", type="string", dest="ConfDirectory", help="Specify the customized Conf directory.")
Parser.add_option("--ignore-sources", action="store_true", dest="IgnoreSources", default=False, help="Focus to a binary build and ignore all source files")
(Options, args) = Parser.parse_args()
return Options

View File

@ -45,6 +45,7 @@ class GenFdsGlobalVariable:
LibDir = ''
WorkSpace = None
WorkSpaceDir = ''
ConfDir = ''
EdkSourceDir = ''
OutputDirFromDscDict = {}
TargetName = ''
@ -88,7 +89,7 @@ class GenFdsGlobalVariable:
def __LoadBuildRule():
if GenFdsGlobalVariable.__BuildRuleDatabase:
return GenFdsGlobalVariable.__BuildRuleDatabase
BuildConfigurationFile = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, "Conf/target.txt"))
BuildConfigurationFile = os.path.normpath(os.path.join(GenFdsGlobalVariable.ConfDir, "target.txt"))
TargetTxt = TargetTxtClassObject()
if os.path.isfile(BuildConfigurationFile) == True:
TargetTxt.LoadTargetTxtFile(BuildConfigurationFile)
@ -201,11 +202,13 @@ class GenFdsGlobalVariable:
TargetList = set()
FileList = []
for File in Inf.Sources:
if File.TagName in ("", "*", GenFdsGlobalVariable.ToolChainTag) and \
File.ToolChainFamily in ("", "*", GenFdsGlobalVariable.ToolChainFamily):
FileList.append((File, DataType.TAB_UNKNOWN_FILE))
if not Inf.IsBinaryModule:
for File in Inf.Sources:
if File.TagName in ("", "*", GenFdsGlobalVariable.ToolChainTag) and \
File.ToolChainFamily in ("", "*", GenFdsGlobalVariable.ToolChainFamily):
FileList.append((File, DataType.TAB_UNKNOWN_FILE))
for File in Inf.Binaries:
if File.Target in ['COMMON', '*', GenFdsGlobalVariable.TargetName]:
FileList.append((File, File.Type))
@ -645,7 +648,8 @@ class GenFdsGlobalVariable:
'$(EDK_SOURCE)' : GenFdsGlobalVariable.EdkSourceDir,
# '$(OUTPUT_DIRECTORY)': GenFdsGlobalVariable.OutputDirFromDsc,
'$(TARGET)' : GenFdsGlobalVariable.TargetName,
'$(TOOL_CHAIN_TAG)' : GenFdsGlobalVariable.ToolChainTag
'$(TOOL_CHAIN_TAG)' : GenFdsGlobalVariable.ToolChainTag,
'$(SPACE)' : ' '
}
OutputDir = GenFdsGlobalVariable.OutputDirFromDscDict[GenFdsGlobalVariable.ArchList[0]]
if Arch != 'COMMON' and Arch in GenFdsGlobalVariable.ArchList:

View File

@ -198,7 +198,7 @@ class GuidSection(GuidSectionClassObject) :
HeaderLength = str(self.ExtraHeaderSize)
if self.ProcessRequired == "NONE" and HeaderLength == None:
if TempFileSize > InputFileSize and TempFileSize % 4 == 0:
if TempFileSize > InputFileSize:
FileHandleIn.seek(0)
BufferIn = FileHandleIn.read()
FileHandleOut.seek(0)
@ -247,15 +247,15 @@ class GuidSection(GuidSectionClassObject) :
if self.KeyStringList == None or self.KeyStringList == []:
Target = GenFdsGlobalVariable.TargetName
ToolChain = GenFdsGlobalVariable.ToolChainTag
ToolDb = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.WorkSpaceDir).ToolsDefTxtDatabase
ToolDb = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDatabase
if ToolChain not in ToolDb['TOOL_CHAIN_TAG']:
EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find external tool because tool tag %s is not defined in tools_def.txt!" % ToolChain)
self.KeyStringList = [Target+'_'+ToolChain+'_'+self.CurrentArchList[0]]
for Arch in self.CurrentArchList:
if Target+'_'+ToolChain+'_'+Arch not in self.KeyStringList:
self.KeyStringList.append(Target+'_'+ToolChain+'_'+Arch)
ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.WorkSpaceDir).ToolsDefTxtDictionary
if Target + '_' + ToolChain + '_' + Arch not in self.KeyStringList:
self.KeyStringList.append(Target + '_' + ToolChain + '_' + Arch)
ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary
ToolPathTmp = None
for ToolDef in ToolDefinition.items():
if self.NameGuid == ToolDef[1]:

View File

@ -129,9 +129,11 @@ 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 (int(FfsInf.PiSpecVersion, 16) >= 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') \
or (FileType == 'TE'and File.Type == 'PE32'):
if '*' in FfsInf.TargetOverrideList or File.Target == '*' or File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOverrideList == []:
FileList.append(FfsInf.PatchEfiFile(File.Path))
FileList.append(FfsInf.PatchEfiFile(File.Path, File.Type))
else:
GenFdsGlobalVariable.InfLogger ("\nBuild Target \'%s\' of File %s is not in the Scope of %s specified by INF %s in FDF" %(File.Target, File.File, FfsInf.TargetOverrideList, FfsInf.InfFileName))
else: