From 64b2609fcff9d6412eea4c74c8e74bed33dc3235 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Tue, 10 Apr 2012 07:18:20 +0000 Subject: Sync BaseTools Trunk (version r2518) to EDKII main trunk. Signed-off-by: Liming Gao git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13178 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/GenFds/FdfParser.py | 43 ++++++++++++++++++---- BaseTools/Source/Python/GenFds/Ffs.py | 1 + BaseTools/Source/Python/GenFds/GenFds.py | 11 ++++-- .../Source/Python/GenFds/GenFdsGlobalVariable.py | 4 +- 4 files changed, 45 insertions(+), 14 deletions(-) (limited to 'BaseTools/Source/Python/GenFds') diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 7a569e88dd..dc5c4fa034 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -77,6 +77,7 @@ SEPERATOR_TUPLE = ('=', '|', ',', '{', '}') RegionSizePattern = re.compile("\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*") RegionSizeGuidPattern = re.compile("\s*(?P\w+\.\w+)\s*\|\s*(?P\w+\.\w+)\s*") +ShortcutPcdPattern = re.compile("\s*\w+\s*=\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P\w+\.\w+)\s*") IncludeFileList = [] @@ -679,7 +680,7 @@ class FdfParser: PreIndex = 0 StartPos = CurLine.find('$(', PreIndex) EndPos = CurLine.find(')', StartPos+2) - while StartPos != -1 and EndPos != -1 and not (self.__Token == '!ifdef' or self.__Token == '!ifndef'): + while StartPos != -1 and EndPos != -1 and self.__Token not in ['!ifdef', '!ifndef', '!if', '!elseif']: MacroName = CurLine[StartPos+2 : EndPos] MacorValue = self.__GetMacroValue(MacroName) if MacorValue != None: @@ -711,6 +712,8 @@ class FdfParser: self.__SetMacroValue(Macro, Value) self.__WipeOffArea.append(((DefineLine, DefineOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1))) elif self.__Token == 'SET': + SetLine = self.CurrentLineNumber - 1 + SetOffset = self.CurrentOffsetWithinLine - len('SET') PcdPair = self.__GetNextPcdName() PcdName = "%s.%s" % (PcdPair[1], PcdPair[0]) if not self.__IsToken( "="): @@ -720,6 +723,12 @@ class FdfParser: Value = self.__EvaluateConditional(Value, self.CurrentLineNumber, 'eval', True) self.__PcdDict[PcdName] = Value + + self.Profile.PcdDict[PcdPair] = Value + FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber) + self.Profile.PcdFileLineDict[PcdPair] = FileLineTuple + + self.__WipeOffArea.append(((SetLine, SetOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1))) elif self.__Token in ('!ifdef', '!ifndef', '!if'): IfStartPos = (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - len(self.__Token)) IfList.append([IfStartPos, None, None]) @@ -773,6 +782,11 @@ class FdfParser: if self.CurrentLineNumber <= RegionLayoutLine: # Don't try the same line twice continue + SetPcd = ShortcutPcdPattern.match(self.Profile.FileLinesList[self.CurrentLineNumber - 1]) + if SetPcd: + self.__PcdDict[SetPcd.group('name')] = SetPcd.group('value') + RegionLayoutLine = self.CurrentLineNumber + continue RegionSize = RegionSizePattern.match(self.Profile.FileLinesList[self.CurrentLineNumber - 1]) if not RegionSize: RegionLayoutLine = self.CurrentLineNumber @@ -793,6 +807,7 @@ class FdfParser: MacroDict = {} # PCD macro + MacroDict.update(GlobalData.gPlatformPcds) MacroDict.update(self.__PcdDict) # Lowest priority @@ -838,7 +853,19 @@ class FdfParser: Line=Line) return Excpt.result except Exception, Excpt: - raise Warning("Invalid expression", *FileLineTuple) + if hasattr(Excpt, 'Pcd'): + if Excpt.Pcd in GlobalData.gPlatformOtherPcds: + Info = GlobalData.gPlatformOtherPcds[Excpt.Pcd] + raise Warning("Cannot use this PCD (%s) in an expression as" + " it must be defined in a [PcdsFixedAtBuild] or [PcdsFeatureFlag] section" + " of the DSC file (%s), and it is currently defined in this section:" + " %s, line #: %d." % (Excpt.Pcd, GlobalData.gPlatformOtherPcds['DSCFILE'], Info[0], Info[1]), + *FileLineTuple) + else: + raise Warning("PCD (%s) is not defined in DSC file (%s)" % (Excpt.Pcd, GlobalData.gPlatformOtherPcds['DSCFILE']), + *FileLineTuple) + else: + raise Warning(str(Excpt), *FileLineTuple) else: if Expression.startswith('$(') and Expression[-1] == ')': Expression = Expression[2:-1] @@ -2287,6 +2314,10 @@ class FdfParser: if not self.__GetNextToken(): raise Warning("expected INF file path", self.FileName, self.CurrentLineNumber) ffsInf.InfFileName = self.__Token + + ffsInf.CurrentLineNum = self.CurrentLineNumber + ffsInf.CurrentLineContent = self.__CurrentLine() + if ffsInf.InfFileName.replace('$(WORKSPACE)', '').find('$') == -1: #do case sensitive check for file path ErrorCode, ErrorInfo = PathClass(NormPath(ffsInf.InfFileName), GenFdsGlobalVariable.WorkSpaceDir).Validate() @@ -2306,9 +2337,6 @@ class FdfParser: else: raise Warning("Unknown reloc strip flag '%s'" % self.__Token, self.FileName, self.CurrentLineNumber) - ffsInf.CurrentLineNum = self.CurrentLineNumber - ffsInf.CurrentLineContent = self.__CurrentLine() - if ForCapsule: capsuleFfs = CapsuleData.CapsuleFfs() capsuleFfs.Ffs = ffsInf @@ -2419,9 +2447,6 @@ class FdfParser: FfsFileObj.NameGuid = self.__Token - FfsFileObj.CurrentLineNum = self.CurrentLineNumber - FfsFileObj.CurrentLineContent = self.__CurrentLine() - self.__GetFilePart( FfsFileObj, MacroDict.copy()) if ForCapsule: @@ -2511,6 +2536,8 @@ class FdfParser: self.__UndoToken() self.__GetSectionData( FfsFileObj, MacroDict) else: + FfsFileObj.CurrentLineNum = self.CurrentLineNumber + FfsFileObj.CurrentLineContent = self.__CurrentLine() FfsFileObj.FileName = self.__Token if FfsFileObj.FileName.replace('$(WORKSPACE)', '').find('$') == -1: # diff --git a/BaseTools/Source/Python/GenFds/Ffs.py b/BaseTools/Source/Python/GenFds/Ffs.py index d9f1cdaff0..c8c5a6e861 100644 --- a/BaseTools/Source/Python/GenFds/Ffs.py +++ b/BaseTools/Source/Python/GenFds/Ffs.py @@ -64,6 +64,7 @@ class Ffs(FDClassObject): 'COMPAT16' : '.com16', 'RAW' : '.raw', 'FREEFORM_SUBTYPE_GUID': '.guid', + 'SUBTYPE_GUID' : '.guid', 'FV_IMAGE' : 'fv.sec', 'COMPRESS' : '.com', 'GUIDED' : '.guided', diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index 8a742d95be..fb86a152b6 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -314,7 +314,7 @@ def myOptionParser(): Parser.add_option("-r", "--rom_image", dest="uiFdName", help="Build the image using the [FD] section named by FdUiName.") Parser.add_option("-i", "--FvImage", dest="uiFvName", help="Build the FV image using the [FV] section named by UiFvName") Parser.add_option("-C", "--CapsuleImage", dest="uiCapName", help="Build the Capsule image using the [Capsule] section named by UiCapName") - Parser.add_option("-b", "--buildtarget", type="choice", choices=['DEBUG','RELEASE', 'NOOPT'], dest="BuildTarget", help="Build TARGET is one of list: DEBUG, RELEASE, NOOPT.", + Parser.add_option("-b", "--buildtarget", type="string", dest="BuildTarget", help="Set the build TARGET, overrides target.txt TARGET setting.", action="callback", callback=SingleCheckCallback) Parser.add_option("-t", "--tagname", type="string", dest="ToolChain", help="Using the tools: TOOL_CHAIN_TAG name to build the platform.", action="callback", callback=SingleCheckCallback) @@ -516,10 +516,13 @@ class GenFds : for ModuleFile in PlatformDataBase.Modules: Module = BuildDb.BuildObject[ModuleFile, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] GuidXRefFile.write("%s %s\n" % (Module.Guid, Module.BaseName)) - SaveFileOnChange(GuidXRefFileName, GuidXRefFile.getvalue(), False) + if GuidXRefFile.getvalue(): + SaveFileOnChange(GuidXRefFileName, GuidXRefFile.getvalue(), False) + GenFdsGlobalVariable.InfLogger("\nGUID cross reference file can be found at %s" % GuidXRefFileName) + elif os.path.exists(GuidXRefFileName): + os.remove(GuidXRefFileName) GuidXRefFile.close() - GenFdsGlobalVariable.InfLogger("\nGUID cross reference file can be found at %s" % GuidXRefFileName) - + ##Define GenFd as static function GenFd = staticmethod(GenFd) GetFvBlockSize = staticmethod(GetFvBlockSize) diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index ea6b191bc1..b457937628 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -1,7 +1,7 @@ ## @file # Global variables for GenFds # -# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2012, 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 @@ -581,7 +581,7 @@ class GenFdsGlobalVariable: sys.stdout.write('\n') try: - PopenObject = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr= subprocess.PIPE) + PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr= subprocess.PIPE, shell=True) except Exception, X: EdkLogger.error("GenFds", COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0])) (out, error) = PopenObject.communicate() -- cgit v1.2.3