Sync BaseTools Trunk (version r2387) to EDKII main trunk.
Signed-off-by: lgao4 Reviewed-by: gikidy git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12602 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -180,16 +180,16 @@ class WorkspaceAutoGen(AutoGen):
|
||||
Fvs = []
|
||||
if Caps is None:
|
||||
Caps = []
|
||||
self.MetaFile = ActivePlatform.MetaFile
|
||||
self.BuildDatabase = MetaFileDb
|
||||
self.MetaFile = ActivePlatform
|
||||
self.WorkspaceDir = WorkspaceDir
|
||||
self.Platform = ActivePlatform
|
||||
self.Platform = self.BuildDatabase[self.MetaFile, 'COMMON', Target, Toolchain]
|
||||
self.BuildTarget = Target
|
||||
self.ToolChain = Toolchain
|
||||
self.ArchList = ArchList
|
||||
self.SkuId = SkuId
|
||||
self.UniFlag = UniFlag
|
||||
|
||||
self.BuildDatabase = MetaFileDb
|
||||
self.TargetTxt = BuildConfig
|
||||
self.ToolDef = ToolDefinition
|
||||
self.FdfFile = FlashDefinitionFile
|
||||
@@ -201,30 +201,74 @@ class WorkspaceAutoGen(AutoGen):
|
||||
# there's many relative directory operations, so ...
|
||||
os.chdir(self.WorkspaceDir)
|
||||
|
||||
#
|
||||
# Merge Arch
|
||||
#
|
||||
if not self.ArchList:
|
||||
ArchList = set(self.Platform.SupArchList)
|
||||
else:
|
||||
ArchList = set(self.ArchList) & set(self.Platform.SupArchList)
|
||||
if not ArchList:
|
||||
EdkLogger.error("build", PARAMETER_INVALID,
|
||||
ExtraData = "Invalid ARCH specified. [Valid ARCH: %s]" % (" ".join(self.Platform.SupArchList)))
|
||||
elif self.ArchList and len(ArchList) != len(self.ArchList):
|
||||
SkippedArchList = set(self.ArchList).symmetric_difference(set(self.Platform.SupArchList))
|
||||
EdkLogger.verbose("\nArch [%s] is ignored because the platform supports [%s] only!"
|
||||
% (" ".join(SkippedArchList), " ".join(self.Platform.SupArchList)))
|
||||
self.ArchList = tuple(ArchList)
|
||||
|
||||
# Validate build target
|
||||
if self.BuildTarget not in self.Platform.BuildTargets:
|
||||
EdkLogger.error("build", PARAMETER_INVALID,
|
||||
ExtraData="Build target [%s] is not supported by the platform. [Valid target: %s]"
|
||||
% (self.BuildTarget, " ".join(self.Platform.BuildTargets)))
|
||||
|
||||
# Validate SKU ID
|
||||
if not self.SkuId:
|
||||
self.SkuId = 'DEFAULT'
|
||||
|
||||
if self.SkuId not in self.Platform.SkuIds:
|
||||
EdkLogger.error("build", PARAMETER_INVALID,
|
||||
ExtraData="SKU-ID [%s] is not supported by the platform. [Valid SKU-ID: %s]"
|
||||
% (self.SkuId, " ".join(self.Platform.SkuIds.keys())))
|
||||
|
||||
# parse FDF file to get PCDs in it, if any
|
||||
if self.FdfFile != None and self.FdfFile != '':
|
||||
#
|
||||
# Make global macros available when parsing FDF file
|
||||
#
|
||||
InputMacroDict.update(self.BuildDatabase.WorkspaceDb._GlobalMacros)
|
||||
if not self.FdfFile:
|
||||
self.FdfFile = self.Platform.FlashDefinition
|
||||
EdkLogger.verbose("\nFLASH_DEFINITION = %s" % self.FdfFile)
|
||||
|
||||
if self.FdfFile:
|
||||
#
|
||||
# Mark now build in AutoGen Phase
|
||||
#
|
||||
GlobalData.gAutoGenPhase = True
|
||||
GlobalData.gAutoGenPhase = True
|
||||
Fdf = FdfParser(self.FdfFile.Path)
|
||||
Fdf.ParseFile()
|
||||
GlobalData.gAutoGenPhase = False
|
||||
GlobalData.gAutoGenPhase = False
|
||||
PcdSet = Fdf.Profile.PcdDict
|
||||
ModuleList = Fdf.Profile.InfList
|
||||
self.FdfProfile = Fdf.Profile
|
||||
for fvname in self.FvTargetList:
|
||||
if fvname.upper() not in self.FdfProfile.FvDict:
|
||||
EdkLogger.error("build", OPTION_VALUE_INVALID,
|
||||
"No such an FV in FDF file: %s" % fvname)
|
||||
else:
|
||||
PcdSet = {}
|
||||
ModuleList = []
|
||||
self.FdfProfile = None
|
||||
if self.FdTargetList:
|
||||
EdkLogger.info("No flash definition file found. FD [%s] will be ignored." % " ".join(self.FdTargetList))
|
||||
self.FdTargetList = []
|
||||
if self.FvTargetList:
|
||||
EdkLogger.info("No flash definition file found. FV [%s] will be ignored." % " ".join(self.FvTargetList))
|
||||
self.FvTargetList = []
|
||||
if self.CapTargetList:
|
||||
EdkLogger.info("No flash definition file found. Capsule [%s] will be ignored." % " ".join(self.CapTargetList))
|
||||
self.CapTargetList = []
|
||||
|
||||
# apply SKU and inject PCDs from Flash Definition file
|
||||
for Arch in self.ArchList:
|
||||
Platform = self.BuildDatabase[self.MetaFile, Arch]
|
||||
Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]
|
||||
Platform.SkuName = self.SkuId
|
||||
for Name, Guid in PcdSet:
|
||||
Platform.AddPcd(Name, Guid, PcdSet[Name, Guid])
|
||||
@@ -971,7 +1015,7 @@ class PlatformAutoGen(AutoGen):
|
||||
## Return the platform build data object
|
||||
def _GetPlatform(self):
|
||||
if self._Platform == None:
|
||||
self._Platform = self.BuildDatabase[self.MetaFile, self.Arch]
|
||||
self._Platform = self.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarget, self.ToolChain]
|
||||
return self._Platform
|
||||
|
||||
## Return platform name
|
||||
@@ -1309,7 +1353,7 @@ class PlatformAutoGen(AutoGen):
|
||||
File=self.MetaFile,
|
||||
ExtraData="in [%s] [%s]\n\tconsumed by module [%s]" % (str(M), self.Arch, str(Module)))
|
||||
|
||||
LibraryModule = self.BuildDatabase[LibraryPath, self.Arch]
|
||||
LibraryModule = self.BuildDatabase[LibraryPath, self.Arch, self.BuildTarget, self.ToolChain]
|
||||
# for those forced library instance (NULL library), add a fake library class
|
||||
if LibraryClassName.startswith("NULL"):
|
||||
LibraryModule.LibraryClass.append(LibraryClassObject(LibraryClassName, [ModuleType]))
|
||||
@@ -1907,6 +1951,7 @@ class ModuleAutoGen(AutoGen):
|
||||
self._Macro["ARCH" ] = self.Arch
|
||||
self._Macro["TOOLCHAIN" ] = self.ToolChain
|
||||
self._Macro["TOOLCHAIN_TAG" ] = self.ToolChain
|
||||
self._Macro["TOOL_CHAIN_TAG" ] = self.ToolChain
|
||||
self._Macro["TARGET" ] = self.BuildTarget
|
||||
|
||||
self._Macro["BUILD_DIR" ] = self.PlatformInfo.BuildDir
|
||||
@@ -1920,7 +1965,7 @@ class ModuleAutoGen(AutoGen):
|
||||
## Return the module build data object
|
||||
def _GetModule(self):
|
||||
if self._Module == None:
|
||||
self._Module = self.Workspace.BuildDatabase[self.MetaFile, self.Arch]
|
||||
self._Module = self.Workspace.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarget, self.ToolChain]
|
||||
return self._Module
|
||||
|
||||
## Return the module name
|
||||
@@ -2279,7 +2324,7 @@ class ModuleAutoGen(AutoGen):
|
||||
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
|
||||
continue
|
||||
RuleObject = self.BuildRules[TAB_DEFAULT_BINARY_FILE]
|
||||
elif FileType in self.BuildRules:
|
||||
RuleObject = self.BuildRules[FileType]
|
||||
@@ -2672,7 +2717,7 @@ class ModuleAutoGen(AutoGen):
|
||||
DpxFile = gAutoGenDepexFileName % {"module_name" : self.Name}
|
||||
|
||||
if len(Dpx.PostfixNotation) <> 0:
|
||||
self.DepexGenerated = True
|
||||
self.DepexGenerated = True
|
||||
|
||||
if Dpx.Generate(path.join(self.OutputDir, DpxFile)):
|
||||
AutoGenList.append(str(DpxFile))
|
||||
|
@@ -137,7 +137,7 @@ class FileBuildRule:
|
||||
self.MacroList = []
|
||||
self.CommandList = []
|
||||
for CmdLine in Command:
|
||||
self.MacroList.extend(gMacroPattern.findall(CmdLine))
|
||||
self.MacroList.extend(gMacroRefPattern.findall(CmdLine))
|
||||
# replace path separator with native one
|
||||
self.CommandList.append(CmdLine)
|
||||
|
||||
|
@@ -956,6 +956,14 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
Value = Pcd.DefaultValue
|
||||
Unicode = False
|
||||
ValueNumber = 0
|
||||
|
||||
if Pcd.DatumType == 'BOOLEAN':
|
||||
BoolValue = Value.upper()
|
||||
if BoolValue == 'TRUE':
|
||||
Value = 1
|
||||
elif BoolValue == 'FALSE':
|
||||
Value = 0
|
||||
|
||||
if Pcd.DatumType in ['UINT64', 'UINT32', 'UINT16', 'UINT8']:
|
||||
try:
|
||||
if Value.upper().startswith('0X'):
|
||||
|
@@ -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 and len(self._AutoGenObject.SourceFileList) <> 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))
|
||||
|
||||
@@ -1253,7 +1253,7 @@ ${END}\t@cd $(BUILD_DIR)
|
||||
#
|
||||
fds: init
|
||||
\t-@cd $(FV_DIR)
|
||||
${BEGIN}\tGenFds -f ${fdf_file} -o $(BUILD_DIR) -t $(TOOLCHAIN) -b $(TARGET) -p ${active_platform} -a ${build_architecture_list}${END}${BEGIN}${extra_options}${END}${BEGIN} -r ${fd}${END}${BEGIN} -i ${fv}${END}${BEGIN} -C ${cap}${END}${BEGIN} -D${macro}${END}
|
||||
${BEGIN}\tGenFds -f ${fdf_file} -o $(BUILD_DIR) -t $(TOOLCHAIN) -b $(TARGET) -p ${active_platform} -a ${build_architecture_list} ${extra_options}${END}${BEGIN} -r ${fd} ${END}${BEGIN} -i ${fv} ${END}${BEGIN} -C ${cap} ${END}${BEGIN} -D ${macro} ${END}
|
||||
|
||||
#
|
||||
# run command for emulator platform only
|
||||
@@ -1320,6 +1320,11 @@ ${END}\t@cd $(BUILD_DIR)\n
|
||||
MacroList.append('"%s=%s"' % (MacroName, GlobalData.gGlobalDefines[MacroName]))
|
||||
else:
|
||||
MacroList.append('"%s"' % MacroName)
|
||||
for MacroName in GlobalData.gCommandLineDefines:
|
||||
if GlobalData.gCommandLineDefines[MacroName] != "":
|
||||
MacroList.append('"%s=%s"' % (MacroName, GlobalData.gCommandLineDefines[MacroName]))
|
||||
else:
|
||||
MacroList.append('"%s"' % MacroName)
|
||||
else:
|
||||
FdfFileList = []
|
||||
|
||||
@@ -1335,9 +1340,6 @@ ${END}\t@cd $(BUILD_DIR)\n
|
||||
|
||||
if GlobalData.gCaseInsensitive:
|
||||
ExtraOption += " -c"
|
||||
ExtraOptionList = []
|
||||
if ExtraOption:
|
||||
ExtraOptionList.append(ExtraOption)
|
||||
|
||||
MakefileName = self._FILE_NAME_[self._FileType]
|
||||
SubBuildCommandList = []
|
||||
@@ -1369,7 +1371,7 @@ ${END}\t@cd $(BUILD_DIR)\n
|
||||
"fd" : PlatformInfo.FdTargetList,
|
||||
"fv" : PlatformInfo.FvTargetList,
|
||||
"cap" : PlatformInfo.CapTargetList,
|
||||
"extra_options" : ExtraOptionList,
|
||||
"extra_options" : ExtraOption,
|
||||
"macro" : MacroList,
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1,3 @@
|
||||
#This file is for build version number auto generation
|
||||
#
|
||||
gBUILD_VERSION = "Build 2361"
|
||||
gBUILD_VERSION = "Build 2386"
|
||||
|
@@ -360,6 +360,7 @@ TAB_DSC_DEFINES_ISO_LANGUAGES = 'ISO_LANGUAGES'
|
||||
TAB_DSC_DEFINES_DEFINE = 'DEFINE'
|
||||
TAB_DSC_DEFINES_VPD_TOOL_GUID = 'VPD_TOOL_GUID'
|
||||
TAB_FIX_LOAD_TOP_MEMORY_ADDRESS = 'FIX_LOAD_TOP_MEMORY_ADDRESS'
|
||||
TAB_DSC_DEFINES_EDKGLOBAL = 'EDK_GLOBAL'
|
||||
|
||||
#
|
||||
# TargetTxt Definitions
|
||||
|
555
BaseTools/Source/Python/Common/Expression.py
Normal file
555
BaseTools/Source/Python/Common/Expression.py
Normal file
@@ -0,0 +1,555 @@
|
||||
## @file
|
||||
# This file is used to parse and evaluate expression in directive or PCD value.
|
||||
#
|
||||
# Copyright (c) 2011, 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
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
## Import Modules
|
||||
#
|
||||
from Common.GlobalData import *
|
||||
from CommonDataClass.Exceptions import BadExpression
|
||||
from CommonDataClass.Exceptions import SymbolNotFound
|
||||
from CommonDataClass.Exceptions import WrnExpression
|
||||
from Misc import GuidStringToGuidStructureString
|
||||
|
||||
ERR_STRING_EXPR = 'This operator cannot be used in string expression: [%s].'
|
||||
ERR_SNYTAX = 'Syntax error, the rest of expression cannot be evaluated: [%s].'
|
||||
ERR_MATCH = 'No matching right parenthesis.'
|
||||
ERR_STRING_TOKEN = 'Bad string token: [%s].'
|
||||
ERR_MACRO_TOKEN = 'Bad macro token: [%s].'
|
||||
ERR_EMPTY_TOKEN = 'Empty token is not allowed.'
|
||||
ERR_PCD_RESOLVE = 'PCD token cannot be resolved: [%s].'
|
||||
ERR_VALID_TOKEN = 'No more valid token found from rest of string: [%s].'
|
||||
ERR_EXPR_TYPE = 'Different types found in expression.'
|
||||
ERR_OPERATOR_UNSUPPORT = 'Unsupported operator: [%s]'
|
||||
ERR_REL_NOT_IN = 'Expect "IN" after "not" operator.'
|
||||
WRN_BOOL_EXPR = 'Operand of boolean type cannot be used in arithmetic expression.'
|
||||
WRN_EQCMP_STR_OTHERS = '== Comparison between Operand of string type and Boolean/Number Type always return False.'
|
||||
WRN_NECMP_STR_OTHERS = '!= Comparison between Operand of string type and Boolean/Number Type always return True.'
|
||||
ERR_RELCMP_STR_OTHERS = 'Operator taking Operand of string type and Boolean/Number Type is not allowed: [%s].'
|
||||
ERR_STRING_CMP = 'Unicode string and general string cannot be compared: [%s %s %s]'
|
||||
ERR_ARRAY_TOKEN = 'Bad C array or C format GUID token: [%s].'
|
||||
ERR_ARRAY_ELE = 'This must be HEX value for NList or Array: [%s].'
|
||||
|
||||
## SplitString
|
||||
# Split string to list according double quote
|
||||
# For example: abc"de\"f"ghi"jkl"mn will be: ['abc', '"de\"f"', 'ghi', '"jkl"', 'mn']
|
||||
#
|
||||
def SplitString(String):
|
||||
# There might be escaped quote: "abc\"def\\\"ghi"
|
||||
Str = String.replace('\\\\', '//').replace('\\\"', '\\\'')
|
||||
RetList = []
|
||||
InQuote = False
|
||||
Item = ''
|
||||
for i, ch in enumerate(Str):
|
||||
if ch == '"':
|
||||
InQuote = not InQuote
|
||||
if not InQuote:
|
||||
Item += String[i]
|
||||
RetList.append(Item)
|
||||
Item = ''
|
||||
continue
|
||||
if Item:
|
||||
RetList.append(Item)
|
||||
Item = ''
|
||||
Item += String[i]
|
||||
if InQuote:
|
||||
raise BadExpression(ERR_STRING_TOKEN % Item)
|
||||
if Item:
|
||||
RetList.append(Item)
|
||||
return RetList
|
||||
|
||||
## ReplaceExprMacro
|
||||
#
|
||||
def ReplaceExprMacro(String, Macros, ExceptionList = None):
|
||||
StrList = SplitString(String)
|
||||
for i, String in enumerate(StrList):
|
||||
InQuote = False
|
||||
if String.startswith('"'):
|
||||
InQuote = True
|
||||
MacroStartPos = String.find('$(')
|
||||
if MacroStartPos < 0:
|
||||
continue
|
||||
RetStr = ''
|
||||
while MacroStartPos >= 0:
|
||||
RetStr = String[0:MacroStartPos]
|
||||
MacroEndPos = String.find(')', MacroStartPos)
|
||||
if MacroEndPos < 0:
|
||||
raise BadExpression(ERR_MACRO_TOKEN % String[MacroStartPos:])
|
||||
Macro = String[MacroStartPos+2:MacroEndPos]
|
||||
if Macro not in Macros:
|
||||
# From C reference manual:
|
||||
# If an undefined macro name appears in the constant-expression of
|
||||
# !if or !elif, it is replaced by the integer constant 0.
|
||||
RetStr += '0'
|
||||
elif not InQuote and ExceptionList and Macro in ExceptionList:
|
||||
# Make sure the macro in exception list is encapsulated by double quote
|
||||
# For example: DEFINE ARCH = IA32 X64
|
||||
# $(ARCH) is replaced with "IA32 X64"
|
||||
RetStr += '"' + Macros[Macro] + '"'
|
||||
else:
|
||||
if Macros[Macro].strip() != "":
|
||||
RetStr += Macros[Macro]
|
||||
else:
|
||||
RetStr += '""'
|
||||
RetStr += String[MacroEndPos+1:]
|
||||
String = RetStr
|
||||
MacroStartPos = String.find('$(')
|
||||
StrList[i] = RetStr
|
||||
return ''.join(StrList)
|
||||
|
||||
class ValueExpression(object):
|
||||
# Logical operator mapping
|
||||
LogicalOperators = {
|
||||
'&&' : 'and', '||' : 'or',
|
||||
'!' : 'not', 'AND': 'and',
|
||||
'OR' : 'or' , 'NOT': 'not',
|
||||
'XOR': '^' , 'xor': '^',
|
||||
'EQ' : '==' , 'NE' : '!=',
|
||||
'GT' : '>' , 'LT' : '<',
|
||||
'GE' : '>=' , 'LE' : '<=',
|
||||
'IN' : 'in'
|
||||
}
|
||||
|
||||
NonLetterOpLst = ['+', '-', '&', '|', '^', '!', '=', '>', '<']
|
||||
|
||||
PcdPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]*$')
|
||||
HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')
|
||||
RegGuidPattern = re.compile(r'[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}')
|
||||
|
||||
SymbolPattern = re.compile("("
|
||||
"\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|"
|
||||
"&&|\|\||!(?!=)|"
|
||||
"(?<=\W)AND(?=\W)|(?<=\W)OR(?=\W)|(?<=\W)NOT(?=\W)|(?<=\W)XOR(?=\W)|"
|
||||
"(?<=\W)EQ(?=\W)|(?<=\W)NE(?=\W)|(?<=\W)GT(?=\W)|(?<=\W)LT(?=\W)|(?<=\W)GE(?=\W)|(?<=\W)LE(?=\W)"
|
||||
")")
|
||||
|
||||
@staticmethod
|
||||
def Eval(Operator, Oprand1, Oprand2 = None):
|
||||
WrnExp = None
|
||||
|
||||
if Operator not in ["==", "!=", ">=", "<=", ">", "<", "in", "not in"] and \
|
||||
(type(Oprand1) == type('') or type(Oprand2) == type('')):
|
||||
raise BadExpression(ERR_STRING_EXPR % Operator)
|
||||
|
||||
TypeDict = {
|
||||
type(0) : 0,
|
||||
type(0L) : 0,
|
||||
type('') : 1,
|
||||
type(True) : 2
|
||||
}
|
||||
|
||||
EvalStr = ''
|
||||
if Operator in ["!", "NOT", "not"]:
|
||||
if type(Oprand1) == type(''):
|
||||
raise BadExpression(ERR_STRING_EXPR % Operator)
|
||||
EvalStr = 'not Oprand1'
|
||||
else:
|
||||
if Operator in ["+", "-"] and (type(True) in [type(Oprand1), type(Oprand2)]):
|
||||
# Boolean in '+'/'-' will be evaluated but raise warning
|
||||
WrnExp = WrnExpression(WRN_BOOL_EXPR)
|
||||
elif type('') in [type(Oprand1), type(Oprand2)] and type(Oprand1)!= type(Oprand2):
|
||||
# == between string and number/boolean will always return False, != return True
|
||||
if Operator == "==":
|
||||
WrnExp = WrnExpression(WRN_EQCMP_STR_OTHERS)
|
||||
WrnExp.result = False
|
||||
raise WrnExp
|
||||
elif Operator == "!=":
|
||||
WrnExp = WrnExpression(WRN_NECMP_STR_OTHERS)
|
||||
WrnExp.result = True
|
||||
raise WrnExp
|
||||
else:
|
||||
raise BadExpression(ERR_RELCMP_STR_OTHERS % Operator)
|
||||
elif TypeDict[type(Oprand1)] != TypeDict[type(Oprand2)]:
|
||||
if Operator in ["==", "!=", ">=", "<=", ">", "<"] and set((TypeDict[type(Oprand1)], TypeDict[type(Oprand2)])) == set((TypeDict[type(True)], TypeDict[type(0)])):
|
||||
# comparison between number and boolean is allowed
|
||||
pass
|
||||
elif Operator in ['&', '|', '^', "&&", "||"] and set((TypeDict[type(Oprand1)], TypeDict[type(Oprand2)])) == set((TypeDict[type(True)], TypeDict[type(0)])):
|
||||
# bitwise and logical operation between number and boolean is allowed
|
||||
pass
|
||||
else:
|
||||
raise BadExpression(ERR_EXPR_TYPE)
|
||||
if type(Oprand1) == type('') and type(Oprand2) == type(''):
|
||||
if (Oprand1.startswith('L"') and not Oprand2.startswith('L"')) or \
|
||||
(not Oprand1.startswith('L"') and Oprand2.startswith('L"')):
|
||||
raise BadExpression(ERR_STRING_CMP % (Oprand1, Operator, Oprand2))
|
||||
if 'in' in Operator and type(Oprand2) == type(''):
|
||||
Oprand2 = Oprand2.split()
|
||||
EvalStr = 'Oprand1 ' + Operator + ' Oprand2'
|
||||
|
||||
# Local symbols used by built in eval function
|
||||
Dict = {
|
||||
'Oprand1' : Oprand1,
|
||||
'Oprand2' : Oprand2
|
||||
}
|
||||
try:
|
||||
Val = eval(EvalStr, {}, Dict)
|
||||
except Exception, Excpt:
|
||||
raise BadExpression(str(Excpt))
|
||||
|
||||
if Operator in ['and', 'or']:
|
||||
if Val:
|
||||
Val = True
|
||||
else:
|
||||
Val = False
|
||||
|
||||
if WrnExp:
|
||||
WrnExp.result = Val
|
||||
raise WrnExp
|
||||
return Val
|
||||
|
||||
def __init__(self, Expression, SymbolTable={}):
|
||||
self._NoProcess = False
|
||||
if type(Expression) != type(''):
|
||||
self._Expr = Expression
|
||||
self._NoProcess = True
|
||||
return
|
||||
|
||||
self._Expr = ReplaceExprMacro(Expression.strip(),
|
||||
SymbolTable,
|
||||
['TARGET', 'TOOL_CHAIN_TAG', 'ARCH'])
|
||||
|
||||
if not self._Expr.strip():
|
||||
self._NoProcess = True
|
||||
return
|
||||
|
||||
#
|
||||
# The symbol table including PCD and macro mapping
|
||||
#
|
||||
self._Symb = SymbolTable
|
||||
self._Symb.update(self.LogicalOperators)
|
||||
self._Idx = 0
|
||||
self._Len = len(self._Expr)
|
||||
self._Token = ''
|
||||
|
||||
# Literal token without any conversion
|
||||
self._LiteralToken = ''
|
||||
|
||||
# Public entry for this class
|
||||
def __call__(self):
|
||||
if self._NoProcess:
|
||||
return self._Expr
|
||||
|
||||
Val = self._OrExpr()
|
||||
if type(Val) == type('') and Val == 'L""':
|
||||
Val = ''
|
||||
|
||||
# The expression has been parsed, but the end of expression is not reached
|
||||
# It means the rest does not comply EBNF of <Expression>
|
||||
if self._Idx != self._Len:
|
||||
raise BadExpression(ERR_SNYTAX % self._Expr[self._Idx:])
|
||||
|
||||
return Val
|
||||
|
||||
# Template function to parse binary operators which have same precedence
|
||||
# Expr [Operator Expr]*
|
||||
def _ExprFuncTemplate(self, EvalFunc, OpLst):
|
||||
Val = EvalFunc()
|
||||
while self._IsOperator(OpLst):
|
||||
Op = self._Token
|
||||
Val = self.Eval(Op, Val, EvalFunc())
|
||||
return Val
|
||||
|
||||
# A [|| B]*
|
||||
def _OrExpr(self):
|
||||
return self._ExprFuncTemplate(self._AndExpr, ["OR", "or", "||"])
|
||||
|
||||
# A [&& B]*
|
||||
def _AndExpr(self):
|
||||
return self._ExprFuncTemplate(self._BitOr, ["AND", "and", "&&"])
|
||||
|
||||
# A [ | B]*
|
||||
def _BitOr(self):
|
||||
return self._ExprFuncTemplate(self._BitXor, ["|"])
|
||||
|
||||
# A [ ^ B]*
|
||||
def _BitXor(self):
|
||||
return self._ExprFuncTemplate(self._BitAnd, ["XOR", "xor", "^"])
|
||||
|
||||
# A [ & B]*
|
||||
def _BitAnd(self):
|
||||
return self._ExprFuncTemplate(self._EqExpr, ["&"])
|
||||
|
||||
# A [ == B]*
|
||||
def _EqExpr(self):
|
||||
Val = self._RelExpr()
|
||||
while self._IsOperator(["==", "!=", "EQ", "NE", "IN", "in", "!", "NOT", "not"]):
|
||||
Op = self._Token
|
||||
if Op in ["!", "NOT", "not"]:
|
||||
if not self._IsOperator(["IN", "in"]):
|
||||
raise BadExpression(ERR_REL_NOT_IN)
|
||||
Op += ' ' + self._Token
|
||||
Val = self.Eval(Op, Val, self._RelExpr())
|
||||
return Val
|
||||
|
||||
# A [ > B]*
|
||||
def _RelExpr(self):
|
||||
return self._ExprFuncTemplate(self._AddExpr, ["<=", ">=", "<", ">", "LE", "GE", "LT", "GT"])
|
||||
|
||||
# A [ + B]*
|
||||
def _AddExpr(self):
|
||||
return self._ExprFuncTemplate(self._UnaryExpr, ["+", "-"])
|
||||
|
||||
# [!]*A
|
||||
def _UnaryExpr(self):
|
||||
if self._IsOperator(["!", "NOT", "not"]):
|
||||
Val = self._UnaryExpr()
|
||||
return self.Eval('not', Val)
|
||||
return self._IdenExpr()
|
||||
|
||||
# Parse identifier or encapsulated expression
|
||||
def _IdenExpr(self):
|
||||
Tk = self._GetToken()
|
||||
if Tk == '(':
|
||||
Val = self._OrExpr()
|
||||
try:
|
||||
# _GetToken may also raise BadExpression
|
||||
if self._GetToken() != ')':
|
||||
raise BadExpression(ERR_MATCH)
|
||||
except BadExpression:
|
||||
raise BadExpression(ERR_MATCH)
|
||||
return Val
|
||||
return Tk
|
||||
|
||||
# Skip whitespace or tab
|
||||
def __SkipWS(self):
|
||||
for Char in self._Expr[self._Idx:]:
|
||||
if Char not in ' \t':
|
||||
break
|
||||
self._Idx += 1
|
||||
|
||||
# Try to convert string to number
|
||||
def __IsNumberToken(self):
|
||||
Radix = 10
|
||||
if self._Token.lower()[0:2] == '0x' and len(self._Token) > 2:
|
||||
Radix = 16
|
||||
try:
|
||||
self._Token = int(self._Token, Radix)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
except TypeError:
|
||||
return False
|
||||
|
||||
# Parse array: {...}
|
||||
def __GetArray(self):
|
||||
Token = '{'
|
||||
self._Idx += 1
|
||||
self.__GetNList(True)
|
||||
Token += self._LiteralToken
|
||||
if self._Idx >= self._Len or self._Expr[self._Idx] != '}':
|
||||
raise BadExpression(ERR_ARRAY_TOKEN % Token)
|
||||
Token += '}'
|
||||
|
||||
# All whitespace and tabs in array are already stripped.
|
||||
IsArray = IsGuid = False
|
||||
if len(Token.split(',')) == 11 and len(Token.split(',{')) == 2 \
|
||||
and len(Token.split('},')) == 1:
|
||||
HexLen = [11,6,6,5,4,4,4,4,4,4,6]
|
||||
HexList= Token.split(',')
|
||||
if HexList[3].startswith('{') and \
|
||||
not [Index for Index, Hex in enumerate(HexList) if len(Hex) > HexLen[Index]]:
|
||||
IsGuid = True
|
||||
if Token.lstrip('{').rstrip('}').find('{') == -1:
|
||||
if not [Hex for Hex in Token.lstrip('{').rstrip('}').split(',') if len(Hex) > 4]:
|
||||
IsArray = True
|
||||
if not IsArray and not IsGuid:
|
||||
raise BadExpression(ERR_ARRAY_TOKEN % Token)
|
||||
self._Idx += 1
|
||||
self._Token = self._LiteralToken = Token
|
||||
return self._Token
|
||||
|
||||
# Parse string, the format must be: "..."
|
||||
def __GetString(self):
|
||||
Idx = self._Idx
|
||||
|
||||
# Skip left quote
|
||||
self._Idx += 1
|
||||
|
||||
# Replace escape \\\", \"
|
||||
Expr = self._Expr[self._Idx:].replace('\\\\', '//').replace('\\\"', '\\\'')
|
||||
for Ch in Expr:
|
||||
self._Idx += 1
|
||||
if Ch == '"':
|
||||
break
|
||||
self._Token = self._LiteralToken = self._Expr[Idx:self._Idx]
|
||||
if not self._Token.endswith('"'):
|
||||
raise BadExpression(ERR_STRING_TOKEN % self._Token)
|
||||
self._Token = self._Token[1:-1]
|
||||
return self._Token
|
||||
|
||||
# Get token that is comprised by alphanumeric, underscore or dot(used by PCD)
|
||||
# @param IsAlphaOp: Indicate if parsing general token or script operator(EQ, NE...)
|
||||
def __GetIdToken(self, IsAlphaOp = False):
|
||||
IdToken = ''
|
||||
for Ch in self._Expr[self._Idx:]:
|
||||
if not self.__IsIdChar(Ch):
|
||||
break
|
||||
self._Idx += 1
|
||||
IdToken += Ch
|
||||
|
||||
self._Token = self._LiteralToken = IdToken
|
||||
if not IsAlphaOp:
|
||||
self.__ResolveToken()
|
||||
return self._Token
|
||||
|
||||
# Try to resolve token
|
||||
def __ResolveToken(self):
|
||||
if not self._Token:
|
||||
raise BadExpression(ERR_EMPTY_TOKEN)
|
||||
|
||||
# PCD token
|
||||
if self.PcdPattern.match(self._Token):
|
||||
if self._Token not in self._Symb:
|
||||
raise SymbolNotFound(ERR_PCD_RESOLVE % self._Token)
|
||||
self._Token = ValueExpression(self._Symb[self._Token], self._Symb)()
|
||||
if type(self._Token) != type(''):
|
||||
self._LiteralToken = hex(self._Token)
|
||||
return
|
||||
|
||||
if self._Token.startswith('"'):
|
||||
self._Token = self._Token[1:-1]
|
||||
elif self._Token in ["FALSE", "false", "False"]:
|
||||
self._Token = False
|
||||
elif self._Token in ["TRUE", "true", "True"]:
|
||||
self._Token = True
|
||||
else:
|
||||
self.__IsNumberToken()
|
||||
|
||||
def __GetNList(self, InArray=False):
|
||||
self._GetSingleToken()
|
||||
if not self.__IsHexLiteral():
|
||||
if InArray:
|
||||
raise BadExpression(ERR_ARRAY_ELE % self._Token)
|
||||
return self._Token
|
||||
|
||||
self.__SkipWS()
|
||||
Expr = self._Expr[self._Idx:]
|
||||
if not Expr.startswith(','):
|
||||
return self._Token
|
||||
|
||||
NList = self._LiteralToken
|
||||
while Expr.startswith(','):
|
||||
NList += ','
|
||||
self._Idx += 1
|
||||
self.__SkipWS()
|
||||
self._GetSingleToken()
|
||||
if not self.__IsHexLiteral():
|
||||
raise BadExpression(ERR_ARRAY_ELE % self._Token)
|
||||
NList += self._LiteralToken
|
||||
self.__SkipWS()
|
||||
Expr = self._Expr[self._Idx:]
|
||||
self._Token = self._LiteralToken = NList
|
||||
return self._Token
|
||||
|
||||
def __IsHexLiteral(self):
|
||||
if self._LiteralToken.startswith('{') and \
|
||||
self._LiteralToken.endswith('}'):
|
||||
return True
|
||||
|
||||
if self.HexPattern.match(self._LiteralToken):
|
||||
Token = self._LiteralToken[2:]
|
||||
Token = Token.lstrip('0')
|
||||
if not Token:
|
||||
self._LiteralToken = '0x0'
|
||||
else:
|
||||
self._LiteralToken = '0x' + Token
|
||||
return True
|
||||
return False
|
||||
|
||||
def _GetToken(self):
|
||||
return self.__GetNList()
|
||||
|
||||
@staticmethod
|
||||
def __IsIdChar(Ch):
|
||||
return Ch in '._/:' or Ch.isalnum()
|
||||
|
||||
# Parse operand
|
||||
def _GetSingleToken(self):
|
||||
self.__SkipWS()
|
||||
Expr = self._Expr[self._Idx:]
|
||||
if Expr.startswith('L"'):
|
||||
# Skip L
|
||||
self._Idx += 1
|
||||
UStr = self.__GetString()
|
||||
self._Token = 'L"' + UStr + '"'
|
||||
return self._Token
|
||||
|
||||
self._Token = ''
|
||||
if Expr:
|
||||
Ch = Expr[0]
|
||||
Match = self.RegGuidPattern.match(Expr)
|
||||
if Match and not Expr[Match.end():Match.end()+1].isalnum() \
|
||||
and Expr[Match.end():Match.end()+1] != '_':
|
||||
self._Idx += Match.end()
|
||||
self._Token = ValueExpression(GuidStringToGuidStructureString(Expr[0:Match.end()]))()
|
||||
return self._Token
|
||||
elif self.__IsIdChar(Ch):
|
||||
return self.__GetIdToken()
|
||||
elif Ch == '"':
|
||||
return self.__GetString()
|
||||
elif Ch == '{':
|
||||
return self.__GetArray()
|
||||
elif Ch == '(' or Ch == ')':
|
||||
self._Idx += 1
|
||||
self._Token = Ch
|
||||
return self._Token
|
||||
|
||||
raise BadExpression(ERR_VALID_TOKEN % Expr)
|
||||
|
||||
# Parse operator
|
||||
def _GetOperator(self):
|
||||
self.__SkipWS()
|
||||
LegalOpLst = ['&&', '||', '!=', '==', '>=', '<='] + self.NonLetterOpLst
|
||||
|
||||
self._Token = ''
|
||||
Expr = self._Expr[self._Idx:]
|
||||
|
||||
# Reach end of expression
|
||||
if not Expr:
|
||||
return ''
|
||||
|
||||
# Script operator: LT, GT, LE, GE, EQ, NE, and, or, xor, not
|
||||
if Expr[0].isalpha():
|
||||
return self.__GetIdToken(True)
|
||||
|
||||
# Start to get regular operator: +, -, <, > ...
|
||||
if Expr[0] not in self.NonLetterOpLst:
|
||||
return ''
|
||||
|
||||
OpToken = ''
|
||||
for Ch in Expr:
|
||||
if Ch in self.NonLetterOpLst:
|
||||
if '!' == Ch and OpToken in ['!=', '!']:
|
||||
break
|
||||
self._Idx += 1
|
||||
OpToken += Ch
|
||||
else:
|
||||
break
|
||||
|
||||
if OpToken not in LegalOpLst:
|
||||
raise BadExpression(ERR_OPERATOR_UNSUPPORT % OpToken)
|
||||
self._Token = OpToken
|
||||
return OpToken
|
||||
|
||||
# Check if current token matches the operators given from OpList
|
||||
def _IsOperator(self, OpList):
|
||||
Idx = self._Idx
|
||||
self._GetOperator()
|
||||
if self._Token in OpList:
|
||||
if self._Token in self.LogicalOperators:
|
||||
self._Token = self.LogicalOperators[self._Token]
|
||||
return True
|
||||
self._Idx = Idx
|
||||
return False
|
||||
|
||||
if __name__ == '__main__':
|
||||
pass
|
||||
|
||||
|
@@ -22,9 +22,11 @@ gEcpSource = "EdkCompatibilityPkg"
|
||||
|
||||
gOptions = None
|
||||
gCaseInsensitive = False
|
||||
gGlobalDefines = {}
|
||||
gAllFiles = None
|
||||
|
||||
gGlobalDefines = {}
|
||||
gPlatformDefines = {}
|
||||
gCommandLineDefines = {}
|
||||
gEdkGlobal = {}
|
||||
gOverrideDir = {}
|
||||
|
||||
@@ -33,8 +35,13 @@ gProcessingFile = ''
|
||||
gBuildingModule = ''
|
||||
|
||||
## Regular expression for matching macro used in DSC/DEC/INF file inclusion
|
||||
gMacroPattern = re.compile("\$\(([_A-Z][_A-Z0-9]*)\)", re.UNICODE)
|
||||
gMacroRefPattern = re.compile("\$\(([A-Z][_A-Z0-9]*)\)", re.UNICODE)
|
||||
gMacroDefPattern = re.compile("^(DEFINE|EDK_GLOBAL)[ \t]+")
|
||||
gMacroNamePattern = re.compile("^[A-Z][A-Z0-9_]*$")
|
||||
# C-style wide string pattern
|
||||
gWideStringPattern = re.compile('(\W|\A)L"')
|
||||
#
|
||||
# A global variable for whether current build in AutoGen phase or not.
|
||||
#
|
||||
gAutoGenPhase = False
|
||||
|
||||
|
@@ -156,7 +156,7 @@ def GuidStructureStringToGuidValueName(GuidValue):
|
||||
guidValueString = GuidValue.lower().replace("{", "").replace("}", "").replace(" ", "")
|
||||
guidValueList = guidValueString.split(",")
|
||||
if len(guidValueList) != 11:
|
||||
EdkLogger.error(None, None, "Invalid GUID value string %s" % GuidValue)
|
||||
EdkLogger.error(None, FORMAT_INVALID, "Invalid GUID value string [%s]" % GuidValue)
|
||||
return "%08x_%04x_%04x_%02x%02x_%02x%02x%02x%02x%02x%02x" % (
|
||||
int(guidValueList[0], 16),
|
||||
int(guidValueList[1], 16),
|
||||
@@ -1431,6 +1431,9 @@ class PathClass(object):
|
||||
self._Key = self.Path.upper() # + self.ToolChainFamily + self.TagName + self.ToolCode + self.Target
|
||||
return self._Key
|
||||
|
||||
def _GetTimeStamp(self):
|
||||
return os.stat(self.Path)[8]
|
||||
|
||||
def Validate(self, Type='', CaseSensitive=True):
|
||||
if GlobalData.gCaseInsensitive:
|
||||
CaseSensitive = False
|
||||
@@ -1465,6 +1468,7 @@ class PathClass(object):
|
||||
return ErrorCode, ErrorInfo
|
||||
|
||||
Key = property(_GetFileKey)
|
||||
TimeStamp = property(_GetTimeStamp)
|
||||
|
||||
## Parse PE image to get the required PE informaion.
|
||||
#
|
||||
@@ -1482,7 +1486,7 @@ class PeImageClass():
|
||||
self.SectionHeaderList = []
|
||||
self.ErrorInfo = ''
|
||||
try:
|
||||
PeObject = open(PeFile, 'rb')
|
||||
PeObject = open(PeFile, 'rb')
|
||||
except:
|
||||
self.ErrorInfo = self.FileName + ' can not be found\n'
|
||||
return
|
||||
|
@@ -22,6 +22,7 @@ import EdkLogger as EdkLogger
|
||||
|
||||
import GlobalData
|
||||
from BuildToolError import *
|
||||
from CommonDataClass.Exceptions import *
|
||||
|
||||
gHexVerPatt = re.compile('0x[a-f0-9]{4}[a-f0-9]{4}$',re.IGNORECASE)
|
||||
gHumanReadableVerPatt = re.compile(r'([1-9][0-9]*|0)\.[0-9]{1,2}$')
|
||||
@@ -39,7 +40,52 @@ gHumanReadableVerPatt = re.compile(r'([1-9][0-9]*|0)\.[0-9]{1,2}$')
|
||||
# @retval list() A list for splitted string
|
||||
#
|
||||
def GetSplitValueList(String, SplitTag = DataType.TAB_VALUE_SPLIT, MaxSplit = -1):
|
||||
return map(lambda l: l.strip(), String.split(SplitTag, MaxSplit))
|
||||
ValueList = []
|
||||
Last = 0
|
||||
Escaped = False
|
||||
InString = False
|
||||
for Index in range(0, len(String)):
|
||||
Char = String[Index]
|
||||
|
||||
if not Escaped:
|
||||
# Found a splitter not in a string, split it
|
||||
if not InString and Char == SplitTag:
|
||||
ValueList.append(String[Last:Index].strip())
|
||||
Last = Index+1
|
||||
if MaxSplit > 0 and len(ValueList) >= MaxSplit:
|
||||
break
|
||||
|
||||
if Char == '\\' and InString:
|
||||
Escaped = True
|
||||
elif Char == '"':
|
||||
if not InString:
|
||||
InString = True
|
||||
else:
|
||||
InString = False
|
||||
else:
|
||||
Escaped = False
|
||||
|
||||
if Last < len(String):
|
||||
ValueList.append(String[Last:].strip())
|
||||
elif Last == len(String):
|
||||
ValueList.append('')
|
||||
|
||||
return ValueList
|
||||
|
||||
## GetSplitList
|
||||
#
|
||||
# Get a value list from a string with multiple values splited with SplitString
|
||||
# The default SplitTag is DataType.TAB_VALUE_SPLIT
|
||||
# 'AAA|BBB|CCC' -> ['AAA', 'BBB', 'CCC']
|
||||
#
|
||||
# @param String: The input string to be splitted
|
||||
# @param SplitStr: The split key, default is DataType.TAB_VALUE_SPLIT
|
||||
# @param MaxSplit: The max number of split values, default is -1
|
||||
#
|
||||
# @retval list() A list for splitted string
|
||||
#
|
||||
def GetSplitList(String, SplitStr = DataType.TAB_VALUE_SPLIT, MaxSplit = -1):
|
||||
return map(lambda l: l.strip(), String.split(SplitStr, MaxSplit))
|
||||
|
||||
## MergeArches
|
||||
#
|
||||
@@ -210,16 +256,18 @@ def ReplaceMacros(StringList, MacroDefinitions={}, SelfReplacement = False):
|
||||
#
|
||||
# @retval string The string whose macros are replaced
|
||||
#
|
||||
def ReplaceMacro(String, MacroDefinitions={}, SelfReplacement = False):
|
||||
def ReplaceMacro(String, MacroDefinitions={}, SelfReplacement=False, RaiseError=False):
|
||||
LastString = String
|
||||
while MacroDefinitions:
|
||||
MacroUsed = GlobalData.gMacroPattern.findall(String)
|
||||
while String and MacroDefinitions:
|
||||
MacroUsed = GlobalData.gMacroRefPattern.findall(String)
|
||||
# no macro found in String, stop replacing
|
||||
if len(MacroUsed) == 0:
|
||||
break
|
||||
|
||||
for Macro in MacroUsed:
|
||||
if Macro not in MacroDefinitions:
|
||||
if RaiseError:
|
||||
raise SymbolNotFound("%s not defined" % Macro)
|
||||
if SelfReplacement:
|
||||
String = String.replace("$(%s)" % Macro, '')
|
||||
continue
|
||||
|
@@ -89,11 +89,13 @@ MODEL_META_DATA_COMPONENT = 5009
|
||||
MODEL_META_DATA_USER_EXTENSION = 5010
|
||||
MODEL_META_DATA_PACKAGE = 5011
|
||||
MODEL_META_DATA_NMAKE = 5012
|
||||
MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSEIF = 50013
|
||||
MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSEIF = 5013
|
||||
MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF = 5014
|
||||
MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH = 5015
|
||||
MODEL_META_DATA_COMMENT = 5016
|
||||
MODEL_META_DATA_GLOBAL_DEFINE = 5017
|
||||
MODEL_META_DATA_SECTION_HEADER = 5100
|
||||
MODEL_META_DATA_SUBSECTION_HEADER = 5200
|
||||
|
||||
MODEL_EXTERNAL_DEPENDENCY = 10000
|
||||
|
||||
|
29
BaseTools/Source/Python/CommonDataClass/Exceptions.py
Normal file
29
BaseTools/Source/Python/CommonDataClass/Exceptions.py
Normal file
@@ -0,0 +1,29 @@
|
||||
## @file
|
||||
# This file is used to define common Exceptions class used in python tools
|
||||
#
|
||||
# Copyright (c) 2011, 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
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
## Exceptions used in Expression
|
||||
class EvaluationException(Exception):
|
||||
pass
|
||||
|
||||
class BadExpression(EvaluationException):
|
||||
pass
|
||||
|
||||
class WrnExpression(Exception):
|
||||
pass
|
||||
|
||||
## Exceptions used in macro replacements
|
||||
class MacroException(Exception):
|
||||
pass
|
||||
|
||||
class SymbolNotFound(MacroException):
|
||||
pass
|
||||
|
@@ -79,11 +79,11 @@ class AprioriSection (AprioriSectionClassObject):
|
||||
InfFileName = GenFdsGlobalVariable.MacroExtend(InfFileName, Dict, Arch)
|
||||
|
||||
if Arch != None:
|
||||
Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(InfFileName, GenFdsGlobalVariable.WorkSpaceDir), Arch]
|
||||
Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(InfFileName, GenFdsGlobalVariable.WorkSpaceDir), Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
|
||||
Guid = Inf.Guid
|
||||
|
||||
else:
|
||||
Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(InfFileName, GenFdsGlobalVariable.WorkSpaceDir), 'COMMON']
|
||||
Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(InfFileName, GenFdsGlobalVariable.WorkSpaceDir), 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
|
||||
Guid = Inf.Guid
|
||||
|
||||
self.BinFileList = Inf.Module.Binaries
|
||||
|
@@ -39,7 +39,10 @@ class DepexSection (DepexSectionClassObject):
|
||||
|
||||
def __FindGuidValue(self, CName):
|
||||
for Arch in GenFdsGlobalVariable.ArchList:
|
||||
for PkgDb in GenFdsGlobalVariable.WorkSpace.PackageList:
|
||||
for PkgDb in GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform,
|
||||
Arch,
|
||||
GenFdsGlobalVariable.TargetName,
|
||||
GenFdsGlobalVariable.ToolChainTag):
|
||||
if CName in PkgDb.Ppis:
|
||||
return PkgDb.Ppis[CName]
|
||||
if CName in PkgDb.Protocols:
|
||||
|
@@ -71,11 +71,11 @@ class FD(FDClassObject):
|
||||
|
||||
for RegionObj in self.RegionList :
|
||||
if RegionObj.RegionType == 'CAPSULE':
|
||||
continue
|
||||
continue
|
||||
if RegionObj.Offset + RegionObj.Size <= PreviousRegionStart:
|
||||
pass
|
||||
pass
|
||||
elif RegionObj.Offset <= PreviousRegionStart or (RegionObj.Offset >=PreviousRegionStart and RegionObj.Offset < PreviousRegionStart + PreviousRegionSize):
|
||||
pass
|
||||
pass
|
||||
elif RegionObj.Offset > PreviousRegionStart + PreviousRegionSize:
|
||||
GenFdsGlobalVariable.InfLogger('Padding region starting from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionSize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize)))
|
||||
PadRegion = Region.Region()
|
||||
@@ -88,7 +88,7 @@ class FD(FDClassObject):
|
||||
# Call each region's AddToBuffer function
|
||||
#
|
||||
if PreviousRegionSize > self.Size:
|
||||
pass
|
||||
pass
|
||||
GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')
|
||||
RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
|
||||
|
||||
|
@@ -15,6 +15,8 @@
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import re
|
||||
|
||||
import Fd
|
||||
import Region
|
||||
import Fv
|
||||
@@ -45,6 +47,8 @@ from Common.BuildToolError import *
|
||||
from Common import EdkLogger
|
||||
from Common.Misc import PathClass
|
||||
from Common.String import NormPath
|
||||
import Common.GlobalData as GlobalData
|
||||
from Common.Expression import *
|
||||
from Common import GlobalData
|
||||
|
||||
import re
|
||||
@@ -68,6 +72,9 @@ T_CHAR_BACKSLASH, T_CHAR_DOUBLE_QUOTE, T_CHAR_SINGLE_QUOTE, T_CHAR_STAR, T_CHAR_
|
||||
|
||||
SEPERATOR_TUPLE = ('=', '|', ',', '{', '}')
|
||||
|
||||
RegionSizePattern = re.compile("\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size>(?:0x|0X)?[a-fA-F0-9]+)\s*")
|
||||
RegionSizeGuidPattern = re.compile("\s*(?P<base>\w+\.\w+)\s*\|\s*(?P<size>\w+\.\w+)\s*")
|
||||
|
||||
IncludeFileList = []
|
||||
# Macro passed from command line, which has greatest priority and can NOT be overridden by those in FDF
|
||||
InputMacroDict = {}
|
||||
@@ -211,6 +218,10 @@ class FdfParser:
|
||||
if GenFdsGlobalVariable.WorkSpaceDir == '':
|
||||
GenFdsGlobalVariable.WorkSpaceDir = os.getenv("WORKSPACE")
|
||||
|
||||
InputMacroDict.update(GlobalData.gPlatformDefines)
|
||||
InputMacroDict.update(GlobalData.gGlobalDefines)
|
||||
InputMacroDict.update(GlobalData.gCommandLineDefines)
|
||||
|
||||
## __IsWhiteSpace() method
|
||||
#
|
||||
# Whether char at current FileBufferPos is whitespace
|
||||
@@ -317,10 +328,10 @@ class FdfParser:
|
||||
#
|
||||
def __GetOneChar(self):
|
||||
if self.CurrentOffsetWithinLine == len(self.Profile.FileLinesList[self.CurrentLineNumber - 1]) - 1:
|
||||
self.CurrentLineNumber += 1
|
||||
self.CurrentOffsetWithinLine = 0
|
||||
self.CurrentLineNumber += 1
|
||||
self.CurrentOffsetWithinLine = 0
|
||||
else:
|
||||
self.CurrentOffsetWithinLine += 1
|
||||
self.CurrentOffsetWithinLine += 1
|
||||
|
||||
## __CurrentChar() method
|
||||
#
|
||||
@@ -564,7 +575,7 @@ class FdfParser:
|
||||
self.Profile.FileLinesList[IncludeLine - 1] = ''.join(TempList)
|
||||
|
||||
self.Rewind()
|
||||
|
||||
|
||||
def __GetIfListCurrentItemStat(self, IfList):
|
||||
if len(IfList) == 0:
|
||||
return True
|
||||
@@ -574,8 +585,7 @@ class FdfParser:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
## PreprocessConditionalStatement() method
|
||||
#
|
||||
# Preprocess conditional statement.
|
||||
@@ -586,9 +596,10 @@ class FdfParser:
|
||||
def PreprocessConditionalStatement(self):
|
||||
# IfList is a stack of if branches with elements of list [Pos, CondSatisfied, BranchDetermined]
|
||||
IfList = []
|
||||
RegionLayoutLine = 0
|
||||
while self.__GetNextToken():
|
||||
if self.__Token == 'DEFINE':
|
||||
if self.__GetIfListCurrentItemStat(IfList):
|
||||
if self.__GetIfListCurrentItemStat(IfList):
|
||||
DefineLine = self.CurrentLineNumber - 1
|
||||
DefineOffset = self.CurrentOffsetWithinLine - len('DEFINE')
|
||||
if not self.__GetNextToken():
|
||||
@@ -609,60 +620,48 @@ class FdfParser:
|
||||
MacProfile.MacroName = Macro
|
||||
MacProfile.MacroValue = Value
|
||||
AllMacroList.append(MacProfile)
|
||||
InputMacroDict[MacProfile.MacroName] = MacProfile.MacroValue
|
||||
self.__WipeOffArea.append(((DefineLine, DefineOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
|
||||
elif self.__Token == 'SET':
|
||||
PcdPair = self.__GetNextPcdName()
|
||||
PcdName = "%s.%s" % (PcdPair[1], PcdPair[0])
|
||||
if not self.__IsToken( "="):
|
||||
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
if not self.__GetNextToken():
|
||||
raise Warning("expected value", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
Value = self.__Token
|
||||
if Value.startswith("{"):
|
||||
# deal with value with {}
|
||||
if not self.__SkipToToken( "}"):
|
||||
raise Warning("expected '}'", self.FileName, self.CurrentLineNumber)
|
||||
Value += self.__SkippedChars
|
||||
|
||||
InputMacroDict[PcdName] = Value
|
||||
elif self.__Token in ('!ifdef', '!ifndef', '!if'):
|
||||
IfStartPos = (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - len(self.__Token))
|
||||
IfList.append([IfStartPos, None, None])
|
||||
|
||||
CondLabel = self.__Token
|
||||
Expression = self.__GetExpression()
|
||||
|
||||
MacroName, NotFlag = self.__GetMacroName()
|
||||
NotDefineFlag = False
|
||||
if CondLabel == '!ifndef':
|
||||
NotDefineFlag = True
|
||||
if CondLabel == '!ifdef' or CondLabel == '!ifndef':
|
||||
if NotFlag:
|
||||
raise Warning("'NOT' operation not allowed for Macro name", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
if CondLabel == '!if':
|
||||
|
||||
if not self.__GetNextOp():
|
||||
raise Warning("expected !endif", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
if self.__Token in ('!=', '==', '>', '<', '>=', '<='):
|
||||
Op = self.__Token
|
||||
if not self.__GetNextToken():
|
||||
raise Warning("expected value", self.FileName, self.CurrentLineNumber)
|
||||
if self.__GetStringData():
|
||||
pass
|
||||
MacroValue = self.__Token
|
||||
ConditionSatisfied = self.__EvaluateConditional(MacroName, IfList[-1][0][0] + 1, Op, MacroValue)
|
||||
if NotFlag:
|
||||
ConditionSatisfied = not ConditionSatisfied
|
||||
BranchDetermined = ConditionSatisfied
|
||||
else:
|
||||
self.CurrentOffsetWithinLine -= len(self.__Token)
|
||||
ConditionSatisfied = self.__EvaluateConditional(MacroName, IfList[-1][0][0] + 1, None, 'Bool')
|
||||
if NotFlag:
|
||||
ConditionSatisfied = not ConditionSatisfied
|
||||
BranchDetermined = ConditionSatisfied
|
||||
IfList[-1] = [IfList[-1][0], ConditionSatisfied, BranchDetermined]
|
||||
if ConditionSatisfied:
|
||||
self.__WipeOffArea.append((IfList[-1][0], (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
|
||||
|
||||
ConditionSatisfied = self.__EvaluateConditional(Expression, IfList[-1][0][0] + 1, 'eval')
|
||||
else:
|
||||
ConditionSatisfied = self.__EvaluateConditional(MacroName, IfList[-1][0][0] + 1)
|
||||
if NotDefineFlag:
|
||||
ConditionSatisfied = self.__EvaluateConditional(Expression, IfList[-1][0][0] + 1, 'in')
|
||||
if CondLabel == '!ifndef':
|
||||
ConditionSatisfied = not ConditionSatisfied
|
||||
BranchDetermined = ConditionSatisfied
|
||||
IfList[-1] = [IfList[-1][0], ConditionSatisfied, BranchDetermined]
|
||||
if ConditionSatisfied:
|
||||
self.__WipeOffArea.append((IfStartPos, (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
|
||||
|
||||
BranchDetermined = ConditionSatisfied
|
||||
IfList[-1] = [IfList[-1][0], ConditionSatisfied, BranchDetermined]
|
||||
if ConditionSatisfied:
|
||||
self.__WipeOffArea.append((IfList[-1][0], (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
|
||||
elif self.__Token in ('!elseif', '!else'):
|
||||
ElseStartPos = (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - len(self.__Token))
|
||||
if len(IfList) <= 0:
|
||||
raise Warning("Missing !if statement", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
if IfList[-1][1]:
|
||||
IfList[-1] = [ElseStartPos, False, True]
|
||||
self.__WipeOffArea.append((ElseStartPos, (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
|
||||
@@ -670,27 +669,8 @@ class FdfParser:
|
||||
self.__WipeOffArea.append((IfList[-1][0], ElseStartPos))
|
||||
IfList[-1] = [ElseStartPos, True, IfList[-1][2]]
|
||||
if self.__Token == '!elseif':
|
||||
MacroName, NotFlag = self.__GetMacroName()
|
||||
if not self.__GetNextOp():
|
||||
raise Warning("expected !endif", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
if self.__Token in ('!=', '==', '>', '<', '>=', '<='):
|
||||
Op = self.__Token
|
||||
if not self.__GetNextToken():
|
||||
raise Warning("expected value", self.FileName, self.CurrentLineNumber)
|
||||
if self.__GetStringData():
|
||||
pass
|
||||
MacroValue = self.__Token
|
||||
ConditionSatisfied = self.__EvaluateConditional(MacroName, IfList[-1][0][0] + 1, Op, MacroValue)
|
||||
if NotFlag:
|
||||
ConditionSatisfied = not ConditionSatisfied
|
||||
|
||||
else:
|
||||
self.CurrentOffsetWithinLine -= len(self.__Token)
|
||||
ConditionSatisfied = self.__EvaluateConditional(MacroName, IfList[-1][0][0] + 1, None, 'Bool')
|
||||
if NotFlag:
|
||||
ConditionSatisfied = not ConditionSatisfied
|
||||
|
||||
Expression = self.__GetExpression()
|
||||
ConditionSatisfied = self.__EvaluateConditional(Expression, IfList[-1][0][0] + 1, 'eval')
|
||||
IfList[-1] = [IfList[-1][0], ConditionSatisfied, IfList[-1][2]]
|
||||
|
||||
if IfList[-1][1]:
|
||||
@@ -699,8 +679,6 @@ class FdfParser:
|
||||
else:
|
||||
IfList[-1][2] = True
|
||||
self.__WipeOffArea.append((IfList[-1][0], (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
|
||||
|
||||
|
||||
elif self.__Token == '!endif':
|
||||
if IfList[-1][1]:
|
||||
self.__WipeOffArea.append(((self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - len('!endif')), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
|
||||
@@ -708,106 +686,48 @@ class FdfParser:
|
||||
self.__WipeOffArea.append((IfList[-1][0], (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
|
||||
|
||||
IfList.pop()
|
||||
elif not IfList: # Don't use PCDs inside conditional directive
|
||||
if self.CurrentLineNumber <= RegionLayoutLine:
|
||||
# Don't try the same line twice
|
||||
continue
|
||||
RegionSize = RegionSizePattern.match(self.Profile.FileLinesList[self.CurrentLineNumber - 1])
|
||||
if not RegionSize:
|
||||
RegionLayoutLine = self.CurrentLineNumber
|
||||
continue
|
||||
RegionSizeGuid = RegionSizeGuidPattern.match(self.Profile.FileLinesList[self.CurrentLineNumber])
|
||||
if not RegionSizeGuid:
|
||||
RegionLayoutLine = self.CurrentLineNumber + 1
|
||||
continue
|
||||
InputMacroDict[RegionSizeGuid.group('base')] = RegionSize.group('base')
|
||||
InputMacroDict[RegionSizeGuid.group('size')] = RegionSize.group('size')
|
||||
RegionLayoutLine = self.CurrentLineNumber + 1
|
||||
|
||||
|
||||
if len(IfList) > 0:
|
||||
if IfList:
|
||||
raise Warning("Missing !endif", self.FileName, self.CurrentLineNumber)
|
||||
self.Rewind()
|
||||
|
||||
def __EvaluateConditional(self, Name, Line, Op = None, Value = None):
|
||||
|
||||
def __EvaluateConditional(self, Expression, Line, Op = None, Value = None):
|
||||
FileLineTuple = GetRealFileLine(self.FileName, Line)
|
||||
if Name in InputMacroDict:
|
||||
MacroValue = InputMacroDict[Name]
|
||||
if Op == None:
|
||||
if Value == 'Bool' and MacroValue == None or MacroValue.upper() == 'FALSE':
|
||||
return False
|
||||
return True
|
||||
elif Op == '!=':
|
||||
if Value != MacroValue:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
elif Op == '==':
|
||||
if Value == MacroValue:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
if (self.__IsHex(Value) or Value.isdigit()) and (self.__IsHex(MacroValue) or (MacroValue != None and MacroValue.isdigit())):
|
||||
InputVal = long(Value, 0)
|
||||
MacroVal = long(MacroValue, 0)
|
||||
if Op == '>':
|
||||
if MacroVal > InputVal:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
elif Op == '>=':
|
||||
if MacroVal >= InputVal:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
elif Op == '<':
|
||||
if MacroVal < InputVal:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
elif Op == '<=':
|
||||
if MacroVal <= InputVal:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
raise Warning("Value %s is not a number", self.FileName, Line)
|
||||
|
||||
for Profile in AllMacroList:
|
||||
if Profile.MacroName == Name and Profile.DefinedAtLine <= FileLineTuple[1]:
|
||||
if Op == None:
|
||||
if Value == 'Bool' and Profile.MacroValue == None or Profile.MacroValue.upper() == 'FALSE':
|
||||
return False
|
||||
return True
|
||||
elif Op == '!=':
|
||||
if Value != Profile.MacroValue:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
elif Op == '==':
|
||||
if Value == Profile.MacroValue:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
if (self.__IsHex(Value) or Value.isdigit()) and (self.__IsHex(Profile.MacroValue) or (Profile.MacroValue != None and Profile.MacroValue.isdigit())):
|
||||
InputVal = long(Value, 0)
|
||||
MacroVal = long(Profile.MacroValue, 0)
|
||||
if Op == '>':
|
||||
if MacroVal > InputVal:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
elif Op == '>=':
|
||||
if MacroVal >= InputVal:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
elif Op == '<':
|
||||
if MacroVal < InputVal:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
elif Op == '<=':
|
||||
if MacroVal <= InputVal:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
raise Warning("Value %s is not a number", self.FileName, Line)
|
||||
|
||||
return False
|
||||
if Op == 'eval':
|
||||
try:
|
||||
return ValueExpression(Expression, InputMacroDict)()
|
||||
except SymbolNotFound:
|
||||
return False
|
||||
except WrnExpression, Excpt:
|
||||
#
|
||||
# Catch expression evaluation warning here. We need to report
|
||||
# the precise number of line and return the evaluation result
|
||||
#
|
||||
EdkLogger.warn('Parser', "Suspicious expression: %s" % str(Excpt),
|
||||
File=self.FileName, ExtraData=self.__CurrentLine(),
|
||||
Line=Line)
|
||||
return Excpt.result
|
||||
except Exception, Excpt:
|
||||
raise Warning("Invalid expression", *FileLineTuple)
|
||||
else:
|
||||
if Expression.startswith('$(') and Expression[-1] == ')':
|
||||
Expression = Expression[2:-1]
|
||||
return Expression in InputMacroDict
|
||||
|
||||
## __IsToken() method
|
||||
#
|
||||
@@ -866,6 +786,16 @@ class FdfParser:
|
||||
return True
|
||||
return False
|
||||
|
||||
def __GetExpression(self):
|
||||
Line = self.Profile.FileLinesList[self.CurrentLineNumber - 1]
|
||||
Index = len(Line) - 1
|
||||
while Line[Index] in ['\r', '\n']:
|
||||
Index -= 1
|
||||
ExpressionString = self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine:Index+1]
|
||||
self.CurrentOffsetWithinLine += len(ExpressionString)
|
||||
ExpressionString = ExpressionString.strip()
|
||||
return ExpressionString
|
||||
|
||||
## __GetNextWord() method
|
||||
#
|
||||
# Get next C name from file lines
|
||||
@@ -1208,7 +1138,7 @@ class FdfParser:
|
||||
for Pos in self.__WipeOffArea:
|
||||
self.__ReplaceFragment(Pos[0], Pos[1])
|
||||
self.Profile.FileLinesList = ["".join(list) for list in self.Profile.FileLinesList]
|
||||
|
||||
|
||||
while self.__GetDefines():
|
||||
pass
|
||||
|
||||
@@ -2014,8 +1944,8 @@ class FdfParser:
|
||||
if not IsValidBaseAddrValue.match(self.__Token.upper()):
|
||||
raise Warning("Unknown FV base address value '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
|
||||
Obj.FvBaseAddress = self.__Token
|
||||
return True
|
||||
|
||||
return True
|
||||
|
||||
## __GetFvForceRebase() method
|
||||
#
|
||||
# Get FvForceRebase for FV
|
||||
@@ -2047,7 +1977,8 @@ class FdfParser:
|
||||
Obj.FvForceRebase = None
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
## __GetFvAttributes() method
|
||||
#
|
||||
# Get attributes for FV
|
||||
@@ -2475,6 +2406,7 @@ class FdfParser:
|
||||
if ErrorCode != 0:
|
||||
EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
|
||||
|
||||
|
||||
if not self.__IsToken( "}"):
|
||||
raise Warning("expected '}'", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
|
@@ -71,7 +71,7 @@ class FileStatement (FileStatementClassObject) :
|
||||
|
||||
OutputDir = os.path.join(GenFdsGlobalVariable.FfsDir, self.NameGuid)
|
||||
if not os.path.exists(OutputDir):
|
||||
os.makedirs(OutputDir)
|
||||
os.makedirs(OutputDir)
|
||||
|
||||
Dict.update(self.DefineVarDict)
|
||||
SectionAlignments = None
|
||||
@@ -98,7 +98,7 @@ class FileStatement (FileStatementClassObject) :
|
||||
SectionFiles = []
|
||||
Index = 0
|
||||
SectionAlignments = []
|
||||
for section in self.SectionList:
|
||||
for section in self.SectionList :
|
||||
Index = Index + 1
|
||||
SecIndex = '%d' %Index
|
||||
# process the inside FvImage from FvSection or GuidSection
|
||||
|
@@ -163,7 +163,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
|
||||
if self.CurrentArch != None:
|
||||
|
||||
Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, self.CurrentArch]
|
||||
Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
|
||||
#
|
||||
# Set Ffs BaseName, MdouleGuid, ModuleType, Version, OutputPath
|
||||
#
|
||||
@@ -181,7 +181,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
self.ShadowFromInfFile = Inf.Shadow
|
||||
|
||||
else:
|
||||
Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, 'COMMON']
|
||||
Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
|
||||
self.BaseName = Inf.BaseName
|
||||
self.ModuleGuid = Inf.Guid
|
||||
self.ModuleType = Inf.ModuleType
|
||||
@@ -363,27 +363,27 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
|
||||
InfFileKey = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName))
|
||||
DscArchList = []
|
||||
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'IA32']
|
||||
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'IA32', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
|
||||
if PlatformDataBase != None:
|
||||
if InfFileKey in PlatformDataBase.Modules:
|
||||
DscArchList.append ('IA32')
|
||||
|
||||
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'X64']
|
||||
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'X64', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
|
||||
if PlatformDataBase != None:
|
||||
if InfFileKey in PlatformDataBase.Modules:
|
||||
DscArchList.append ('X64')
|
||||
|
||||
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'IPF']
|
||||
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'IPF', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
|
||||
if PlatformDataBase != None:
|
||||
if InfFileKey in (PlatformDataBase.Modules):
|
||||
DscArchList.append ('IPF')
|
||||
|
||||
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'ARM']
|
||||
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'ARM', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
|
||||
if PlatformDataBase != None:
|
||||
if InfFileKey in (PlatformDataBase.Modules):
|
||||
DscArchList.append ('ARM')
|
||||
|
||||
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'EBC']
|
||||
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'EBC', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
|
||||
if PlatformDataBase != None:
|
||||
if InfFileKey in (PlatformDataBase.Modules):
|
||||
DscArchList.append ('EBC')
|
||||
|
@@ -48,7 +48,7 @@ class FV (FvClassObject):
|
||||
self.CapsuleName = None
|
||||
self.FvBaseAddress = None
|
||||
self.FvForceRebase = None
|
||||
|
||||
|
||||
## AddToBuffer()
|
||||
#
|
||||
# Generate Fv and add it to the Buffer
|
||||
@@ -83,13 +83,13 @@ class FV (FvClassObject):
|
||||
elif RegionData.upper() + 'fv' in GenFds.ImageBinDict.keys():
|
||||
continue
|
||||
elif self.UiFvName.upper() == RegionData.upper():
|
||||
GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper()))
|
||||
GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper()))
|
||||
|
||||
GenFdsGlobalVariable.InfLogger( "\nGenerating %s FV" %self.UiFvName)
|
||||
|
||||
if self.FvBaseAddress != None:
|
||||
BaseAddress = self.FvBaseAddress
|
||||
|
||||
BaseAddress = self.FvBaseAddress
|
||||
|
||||
self.__InitializeInf__(BaseAddress, BlockSize, BlockNum, ErasePloarity, VtfDict)
|
||||
#
|
||||
# First Process the Apriori section
|
||||
|
@@ -161,20 +161,22 @@ def main():
|
||||
if len(List) == 2:
|
||||
if List[0].strip() == "EFI_SOURCE":
|
||||
GlobalData.gEfiSource = List[1].strip()
|
||||
GlobalData.gGlobalDefines["EFI_SOURCE"] = GlobalData.gEfiSource
|
||||
continue
|
||||
elif List[0].strip() == "EDK_SOURCE":
|
||||
GlobalData.gEdkSource = List[1].strip()
|
||||
GlobalData.gGlobalDefines["EDK_SOURCE"] = GlobalData.gEdkSource
|
||||
continue
|
||||
elif List[0].strip() in ["WORKSPACE", "TARGET", "TOOLCHAIN"]:
|
||||
GlobalData.gGlobalDefines[List[0].strip()] = List[1].strip()
|
||||
else:
|
||||
GlobalData.gEdkGlobal[List[0].strip()] = List[1].strip()
|
||||
FdfParser.InputMacroDict[List[0].strip()] = List[1].strip()
|
||||
GlobalData.gCommandLineDefines[List[0].strip()] = List[1].strip()
|
||||
else:
|
||||
FdfParser.InputMacroDict[List[0].strip()] = ""
|
||||
GlobalData.gCommandLineDefines[List[0].strip()] = "TRUE"
|
||||
os.environ["WORKSPACE"] = Workspace
|
||||
|
||||
"""call Workspace build create database"""
|
||||
os.environ["WORKSPACE"] = Workspace
|
||||
FdfParser.InputMacroDict["WORKSPACE"] = Workspace
|
||||
BuildWorkSpace = WorkspaceDatabase(':memory:', FdfParser.InputMacroDict)
|
||||
BuildWorkSpace = WorkspaceDatabase(None)
|
||||
BuildWorkSpace.InitDatabase()
|
||||
|
||||
#
|
||||
@@ -187,15 +189,15 @@ def main():
|
||||
ArchList = Options.archList.split(',')
|
||||
else:
|
||||
# EdkLogger.error("GenFds", OPTION_MISSING, "Missing build ARCH")
|
||||
ArchList = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON'].SupArchList
|
||||
ArchList = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON', Options.BuildTarget, Options.ToolChain].SupArchList
|
||||
|
||||
TargetArchList = set(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON'].SupArchList) & set(ArchList)
|
||||
TargetArchList = set(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON', Options.BuildTarget, Options.ToolChain].SupArchList) & set(ArchList)
|
||||
if len(TargetArchList) == 0:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON'].SupArchList)))
|
||||
|
||||
for Arch in ArchList:
|
||||
GenFdsGlobalVariable.OutputDirFromDscDict[Arch] = NormPath(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch].OutputDirectory)
|
||||
GenFdsGlobalVariable.PlatformName = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch].PlatformName
|
||||
GenFdsGlobalVariable.OutputDirFromDscDict[Arch] = NormPath(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, Options.BuildTarget, Options.ToolChain].OutputDirectory)
|
||||
GenFdsGlobalVariable.PlatformName = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, Options.BuildTarget, Options.ToolChain].PlatformName
|
||||
|
||||
if (Options.outputDir):
|
||||
OutputDirFromCommandLine = GenFdsGlobalVariable.ReplaceWorkspaceMacro(Options.outputDir)
|
||||
@@ -276,7 +278,8 @@ def main():
|
||||
ExtraData="Please send email to edk2-buildtools-devel@lists.sourceforge.net for help, attaching following call stack trace!\n",
|
||||
RaiseError=False
|
||||
)
|
||||
EdkLogger.quiet(traceback.format_exc())
|
||||
if Options.debug != None:
|
||||
EdkLogger.quiet(traceback.format_exc())
|
||||
ReturnCode = CODE_ERROR
|
||||
return ReturnCode
|
||||
|
||||
@@ -482,7 +485,7 @@ class GenFds :
|
||||
# @retval None
|
||||
#
|
||||
def PreprocessImage(BuildDb, DscFile):
|
||||
PcdDict = BuildDb.BuildObject[DscFile, 'COMMON'].Pcds
|
||||
PcdDict = BuildDb.BuildObject[DscFile, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Pcds
|
||||
PcdValue = ''
|
||||
for Key in PcdDict:
|
||||
PcdObj = PcdDict[Key]
|
||||
@@ -501,20 +504,20 @@ class GenFds :
|
||||
if Int64PcdValue > 0:
|
||||
TopAddress = Int64PcdValue
|
||||
|
||||
ModuleDict = BuildDb.BuildObject[DscFile, 'COMMON'].Modules
|
||||
ModuleDict = BuildDb.BuildObject[DscFile, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules
|
||||
for Key in ModuleDict:
|
||||
ModuleObj = BuildDb.BuildObject[Key, 'COMMON']
|
||||
ModuleObj = BuildDb.BuildObject[Key, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
|
||||
print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType
|
||||
|
||||
def GenerateGuidXRefFile(BuildDb, ArchList):
|
||||
GuidXRefFileName = os.path.join(GenFdsGlobalVariable.FvDir, "Guid.xref")
|
||||
GuidXRefFile = StringIO.StringIO('')
|
||||
for Arch in ArchList:
|
||||
PlatformDataBase = BuildDb.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch]
|
||||
PlatformDataBase = BuildDb.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
|
||||
for ModuleFile in PlatformDataBase.Modules:
|
||||
Module = BuildDb.BuildObject[ModuleFile, Arch]
|
||||
Module = BuildDb.BuildObject[ModuleFile, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
|
||||
GuidXRefFile.write("%s %s\n" % (Module.Guid, Module.BaseName))
|
||||
SaveFileOnChange(GuidXRefFileName, GuidXRefFile.getvalue(), False)
|
||||
SaveFileOnChange(GuidXRefFileName, GuidXRefFile.getvalue(), False)
|
||||
GuidXRefFile.close()
|
||||
GenFdsGlobalVariable.InfLogger("\nGUID cross reference file can be found at %s" % GuidXRefFileName)
|
||||
|
||||
|
@@ -117,7 +117,7 @@ class GenFdsGlobalVariable:
|
||||
if not BuildRuleDatabase:
|
||||
return {}
|
||||
|
||||
PathClassObj = PathClass(str(Inf.MetaFile).lstrip(GenFdsGlobalVariable.WorkSpaceDir),
|
||||
PathClassObj = PathClass(Inf.MetaFile.File,
|
||||
GenFdsGlobalVariable.WorkSpaceDir)
|
||||
Macro = {}
|
||||
Macro["WORKSPACE" ] = GenFdsGlobalVariable.WorkSpaceDir
|
||||
@@ -135,6 +135,7 @@ class GenFdsGlobalVariable:
|
||||
Macro["ARCH" ] = Arch
|
||||
Macro["TOOLCHAIN" ] = GenFdsGlobalVariable.ToolChainTag
|
||||
Macro["TOOLCHAIN_TAG" ] = GenFdsGlobalVariable.ToolChainTag
|
||||
Macro["TOOL_CHAIN_TAG" ] = GenFdsGlobalVariable.ToolChainTag
|
||||
Macro["TARGET" ] = GenFdsGlobalVariable.TargetName
|
||||
|
||||
Macro["BUILD_DIR" ] = GenFdsGlobalVariable.OutputDirDict[Arch]
|
||||
@@ -280,8 +281,8 @@ class GenFdsGlobalVariable:
|
||||
FvAddressFile.writelines("[options]" + T_CHAR_LF)
|
||||
BsAddress = '0'
|
||||
for Arch in ArchList:
|
||||
if GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch].BsBaseAddress:
|
||||
BsAddress = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch].BsBaseAddress
|
||||
if GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].BsBaseAddress:
|
||||
BsAddress = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].BsBaseAddress
|
||||
break
|
||||
|
||||
FvAddressFile.writelines("EFI_BOOT_DRIVER_BASE_ADDRESS = " + \
|
||||
@@ -290,8 +291,8 @@ class GenFdsGlobalVariable:
|
||||
|
||||
RtAddress = '0'
|
||||
for Arch in ArchList:
|
||||
if GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch].RtBaseAddress:
|
||||
RtAddress = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch].RtBaseAddress
|
||||
if GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].RtBaseAddress:
|
||||
RtAddress = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].RtBaseAddress
|
||||
|
||||
FvAddressFile.writelines("EFI_RUNTIME_DRIVER_BASE_ADDRESS = " + \
|
||||
RtAddress + \
|
||||
@@ -345,10 +346,6 @@ class GenFdsGlobalVariable:
|
||||
@staticmethod
|
||||
def GenerateSection(Output, Input, Type=None, CompressionType=None, Guid=None,
|
||||
GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None):
|
||||
if not GenFdsGlobalVariable.NeedsUpdate(Output, Input):
|
||||
return
|
||||
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||
|
||||
Cmd = ["GenSec"]
|
||||
if Type not in [None, '']:
|
||||
Cmd += ["-s", Type]
|
||||
@@ -388,6 +385,13 @@ class GenFdsGlobalVariable:
|
||||
else:
|
||||
Cmd += ["-o", Output]
|
||||
Cmd += Input
|
||||
|
||||
CommandFile = Output + '.txt'
|
||||
SaveFileOnChange(CommandFile, ' '.join(Cmd), False)
|
||||
if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):
|
||||
return
|
||||
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||
|
||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section")
|
||||
|
||||
@staticmethod
|
||||
@@ -402,10 +406,6 @@ class GenFdsGlobalVariable:
|
||||
@staticmethod
|
||||
def GenerateFfs(Output, Input, Type, Guid, Fixed=False, CheckSum=False, Align=None,
|
||||
SectionAlign=None):
|
||||
if not GenFdsGlobalVariable.NeedsUpdate(Output, Input):
|
||||
return
|
||||
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||
|
||||
Cmd = ["GenFfs", "-t", Type, "-g", Guid]
|
||||
if Fixed == True:
|
||||
Cmd += ["-x"]
|
||||
@@ -419,6 +419,13 @@ class GenFdsGlobalVariable:
|
||||
Cmd += ("-i", Input[I])
|
||||
if SectionAlign not in [None, '', []] and SectionAlign[I] not in [None, '']:
|
||||
Cmd += ("-n", SectionAlign[I])
|
||||
|
||||
CommandFile = Output + '.txt'
|
||||
SaveFileOnChange(CommandFile, ' '.join(Cmd), False)
|
||||
if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):
|
||||
return
|
||||
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||
|
||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FFS")
|
||||
|
||||
@staticmethod
|
||||
@@ -436,7 +443,7 @@ class GenFdsGlobalVariable:
|
||||
Cmd +=["-F", "FALSE"]
|
||||
elif ForceRebase == True:
|
||||
Cmd +=["-F", "TRUE"]
|
||||
|
||||
|
||||
if Capsule:
|
||||
Cmd += ["-c"]
|
||||
if Dump:
|
||||
@@ -653,25 +660,9 @@ class GenFdsGlobalVariable:
|
||||
TokenCName = PcdPair[1]
|
||||
|
||||
PcdValue = ''
|
||||
for Platform in GenFdsGlobalVariable.WorkSpace.PlatformList:
|
||||
#
|
||||
# Only process platform which match current build option.
|
||||
#
|
||||
if Platform.MetaFile == GenFdsGlobalVariable.ActivePlatform:
|
||||
PcdDict = Platform.Pcds
|
||||
for Key in PcdDict:
|
||||
PcdObj = PcdDict[Key]
|
||||
if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace):
|
||||
if PcdObj.Type != 'FixedAtBuild':
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern)
|
||||
if PcdObj.DatumType != 'VOID*':
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern)
|
||||
|
||||
PcdValue = PcdObj.DefaultValue
|
||||
return PcdValue
|
||||
|
||||
for Package in GenFdsGlobalVariable.WorkSpace.PackageList:
|
||||
PcdDict = Package.Pcds
|
||||
for Arch in GenFdsGlobalVariable.ArchList:
|
||||
Platform = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
|
||||
PcdDict = Platform.Pcds
|
||||
for Key in PcdDict:
|
||||
PcdObj = PcdDict[Key]
|
||||
if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace):
|
||||
@@ -682,6 +673,22 @@ class GenFdsGlobalVariable:
|
||||
|
||||
PcdValue = PcdObj.DefaultValue
|
||||
return PcdValue
|
||||
|
||||
for Package in GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform,
|
||||
Arch,
|
||||
GenFdsGlobalVariable.TargetName,
|
||||
GenFdsGlobalVariable.ToolChainTag):
|
||||
PcdDict = Package.Pcds
|
||||
for Key in PcdDict:
|
||||
PcdObj = PcdDict[Key]
|
||||
if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace):
|
||||
if PcdObj.Type != 'FixedAtBuild':
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern)
|
||||
if PcdObj.DatumType != 'VOID*':
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern)
|
||||
|
||||
PcdValue = PcdObj.DefaultValue
|
||||
return PcdValue
|
||||
|
||||
return PcdValue
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# section base class
|
||||
#
|
||||
# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2007-2011, 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
|
||||
|
@@ -23,7 +23,6 @@ from optparse import make_option
|
||||
from Common.BuildToolError import *
|
||||
import Common.EdkLogger as EdkLogger
|
||||
from Common.BuildVersion import gBUILD_VERSION
|
||||
|
||||
import array
|
||||
|
||||
# Version and Copyright
|
||||
|
@@ -17,6 +17,7 @@ PaserValidate
|
||||
|
||||
import os.path
|
||||
import re
|
||||
import platform
|
||||
|
||||
from Library.DataType import MODULE_LIST
|
||||
from Library.DataType import COMPONENT_TYPE_LIST
|
||||
@@ -281,9 +282,14 @@ def IsValidPath(Path, Root):
|
||||
# @param Path: path to be checked
|
||||
#
|
||||
def IsValidInstallPath(Path):
|
||||
if os.path.isabs(Path):
|
||||
return False
|
||||
|
||||
if platform.platform().find("Windows") >= 0:
|
||||
if os.path.isabs(Path):
|
||||
return False
|
||||
else:
|
||||
if Path[1:2] == ':' or Path.find('\\') >=0:
|
||||
return False
|
||||
if os.path.isabs(Path):
|
||||
return False
|
||||
if Path.startswith('.'):
|
||||
return False
|
||||
|
||||
|
@@ -140,6 +140,10 @@ class Table(object):
|
||||
|
||||
def SetEndFlag(self):
|
||||
self.Exec("insert into %s values(%s)" % (self.Table, self._DUMMY_))
|
||||
#
|
||||
# Need to execution commit for table data changed.
|
||||
#
|
||||
self.Cur.connection.commit()
|
||||
|
||||
def IsIntegral(self):
|
||||
Result = self.Exec("select min(ID) from %s" % (self.Table))
|
||||
@@ -147,6 +151,9 @@ class Table(object):
|
||||
return False
|
||||
return True
|
||||
|
||||
def GetAll(self):
|
||||
return self.Exec("select * from %s where ID > 0 order by ID" % (self.Table))
|
||||
|
||||
## TableFile
|
||||
#
|
||||
# This class defined a table used for file
|
||||
@@ -198,19 +205,15 @@ class TableFile(Table):
|
||||
#
|
||||
# @retval FileID: The ID after record is inserted
|
||||
#
|
||||
def InsertFile(self, FileFullPath, Model):
|
||||
(Filepath, Name) = os.path.split(FileFullPath)
|
||||
(Root, Ext) = os.path.splitext(FileFullPath)
|
||||
TimeStamp = os.stat(FileFullPath)[8]
|
||||
File = FileClass(-1, Name, Ext, Filepath, FileFullPath, Model, '', [], [], [])
|
||||
def InsertFile(self, File, Model):
|
||||
return self.Insert(
|
||||
Name,
|
||||
Ext,
|
||||
Filepath,
|
||||
FileFullPath,
|
||||
Model,
|
||||
TimeStamp
|
||||
)
|
||||
File.Name,
|
||||
File.Ext,
|
||||
File.Dir,
|
||||
File.Path,
|
||||
Model,
|
||||
File.TimeStamp
|
||||
)
|
||||
|
||||
## Get ID of a given file
|
||||
#
|
||||
@@ -218,8 +221,8 @@ class TableFile(Table):
|
||||
#
|
||||
# @retval ID ID value of given file in the table
|
||||
#
|
||||
def GetFileId(self, FilePath):
|
||||
QueryScript = "select ID from %s where FullPath = '%s'" % (self.Table, FilePath)
|
||||
def GetFileId(self, File):
|
||||
QueryScript = "select ID from %s where FullPath = '%s'" % (self.Table, str(File))
|
||||
RecordList = self.Exec(QueryScript)
|
||||
if len(RecordList) == 0:
|
||||
return None
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -14,13 +14,58 @@
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import uuid
|
||||
|
||||
import Common.EdkLogger as EdkLogger
|
||||
from MetaDataTable import Table
|
||||
|
||||
from MetaDataTable import Table, TableFile
|
||||
from MetaDataTable import ConvertToSqlString
|
||||
from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, MODEL_FILE_INF, \
|
||||
MODEL_FILE_OTHERS
|
||||
|
||||
class MetaFileTable(Table):
|
||||
# TRICK: use file ID as the part before '.'
|
||||
_ID_STEP_ = 0.00000001
|
||||
_ID_MAX_ = 0.99999999
|
||||
|
||||
## Constructor
|
||||
def __init__(self, Cursor, MetaFile, FileType, Temporary):
|
||||
self.MetaFile = MetaFile
|
||||
|
||||
self._FileIndexTable = TableFile(Cursor)
|
||||
self._FileIndexTable.Create(False)
|
||||
|
||||
FileId = self._FileIndexTable.GetFileId(MetaFile)
|
||||
if not FileId:
|
||||
FileId = self._FileIndexTable.InsertFile(MetaFile, FileType)
|
||||
|
||||
if Temporary:
|
||||
TableName = "_%s_%s_%s" % (FileType, FileId, uuid.uuid4().hex)
|
||||
else:
|
||||
TableName = "_%s_%s" % (FileType, FileId)
|
||||
|
||||
#Table.__init__(self, Cursor, TableName, FileId, False)
|
||||
Table.__init__(self, Cursor, TableName, FileId, Temporary)
|
||||
self.Create(not self.IsIntegrity())
|
||||
|
||||
def IsIntegrity(self):
|
||||
try:
|
||||
Result = self.Cur.execute("select ID from %s where ID<0" % (self.Table)).fetchall()
|
||||
if not Result:
|
||||
return False
|
||||
|
||||
TimeStamp = self.MetaFile.TimeStamp
|
||||
if TimeStamp != self._FileIndexTable.GetFileTimeStamp(self.IdBase):
|
||||
# update the timestamp in database
|
||||
self._FileIndexTable.SetFileTimeStamp(self.IdBase, TimeStamp)
|
||||
return False
|
||||
except Exception, Exc:
|
||||
EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc))
|
||||
return False
|
||||
return True
|
||||
|
||||
## Python class representation of table storing module data
|
||||
class ModuleTable(Table):
|
||||
# TRICK: use file ID as the part before '.'
|
||||
class ModuleTable(MetaFileTable):
|
||||
_ID_STEP_ = 0.00000001
|
||||
_ID_MAX_ = 0.99999999
|
||||
_COLUMN_ = '''
|
||||
@@ -42,8 +87,8 @@ class ModuleTable(Table):
|
||||
_DUMMY_ = "-1, -1, '====', '====', '====', '====', '====', -1, -1, -1, -1, -1, -1"
|
||||
|
||||
## Constructor
|
||||
def __init__(self, Cursor, Name='Inf', IdBase=0, Temporary=False):
|
||||
Table.__init__(self, Cursor, Name, IdBase, Temporary)
|
||||
def __init__(self, Cursor, MetaFile, Temporary):
|
||||
MetaFileTable.__init__(self, Cursor, MetaFile, MODEL_FILE_INF, Temporary)
|
||||
|
||||
## Insert a record into table Inf
|
||||
#
|
||||
@@ -100,9 +145,7 @@ class ModuleTable(Table):
|
||||
return self.Exec(SqlCommand)
|
||||
|
||||
## Python class representation of table storing package data
|
||||
class PackageTable(Table):
|
||||
_ID_STEP_ = 0.00000001
|
||||
_ID_MAX_ = 0.99999999
|
||||
class PackageTable(MetaFileTable):
|
||||
_COLUMN_ = '''
|
||||
ID REAL PRIMARY KEY,
|
||||
Model INTEGER NOT NULL,
|
||||
@@ -122,8 +165,8 @@ class PackageTable(Table):
|
||||
_DUMMY_ = "-1, -1, '====', '====', '====', '====', '====', -1, -1, -1, -1, -1, -1"
|
||||
|
||||
## Constructor
|
||||
def __init__(self, Cursor, Name='Dec', IdBase=0, Temporary=False):
|
||||
Table.__init__(self, Cursor, Name, IdBase, Temporary)
|
||||
def __init__(self, Cursor, MetaFile, Temporary):
|
||||
MetaFileTable.__init__(self, Cursor, MetaFile, MODEL_FILE_DEC, Temporary)
|
||||
|
||||
## Insert table
|
||||
#
|
||||
@@ -179,9 +222,7 @@ class PackageTable(Table):
|
||||
return self.Exec(SqlCommand)
|
||||
|
||||
## Python class representation of table storing platform data
|
||||
class PlatformTable(Table):
|
||||
_ID_STEP_ = 0.00000001
|
||||
_ID_MAX_ = 0.99999999
|
||||
class PlatformTable(MetaFileTable):
|
||||
_COLUMN_ = '''
|
||||
ID REAL PRIMARY KEY,
|
||||
Model INTEGER NOT NULL,
|
||||
@@ -202,8 +243,8 @@ class PlatformTable(Table):
|
||||
_DUMMY_ = "-1, -1, '====', '====', '====', '====', '====', -1, -1, -1, -1, -1, -1, -1"
|
||||
|
||||
## Constructor
|
||||
def __init__(self, Cursor, Name='Dsc', IdBase=0, Temporary=False):
|
||||
Table.__init__(self, Cursor, Name, IdBase, Temporary)
|
||||
def __init__(self, Cursor, MetaFile, Temporary):
|
||||
MetaFileTable.__init__(self, Cursor, MetaFile, MODEL_FILE_DSC, Temporary)
|
||||
|
||||
## Insert table
|
||||
#
|
||||
@@ -254,7 +295,7 @@ class PlatformTable(Table):
|
||||
# @retval: A recordSet of all found records
|
||||
#
|
||||
def Query(self, Model, Scope1=None, Scope2=None, BelongsToItem=None, FromItem=None):
|
||||
ConditionString = "Model=%s AND Enabled>=0" % Model
|
||||
ConditionString = "Model=%s AND Enabled>0" % Model
|
||||
ValueString = "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine"
|
||||
|
||||
if Scope1 != None and Scope1 != 'COMMON':
|
||||
@@ -273,3 +314,36 @@ class PlatformTable(Table):
|
||||
SqlCommand = "SELECT %s FROM %s WHERE %s" % (ValueString, self.Table, ConditionString)
|
||||
return self.Exec(SqlCommand)
|
||||
|
||||
## Factory class to produce different storage for different type of meta-file
|
||||
class MetaFileStorage(object):
|
||||
_FILE_TABLE_ = {
|
||||
MODEL_FILE_INF : ModuleTable,
|
||||
MODEL_FILE_DEC : PackageTable,
|
||||
MODEL_FILE_DSC : PlatformTable,
|
||||
MODEL_FILE_OTHERS : MetaFileTable,
|
||||
}
|
||||
|
||||
_FILE_TYPE_ = {
|
||||
".inf" : MODEL_FILE_INF,
|
||||
".dec" : MODEL_FILE_DEC,
|
||||
".dsc" : MODEL_FILE_DSC,
|
||||
}
|
||||
|
||||
## Constructor
|
||||
def __new__(Class, Cursor, MetaFile, FileType=None, Temporary=False):
|
||||
# no type given, try to find one
|
||||
if not FileType:
|
||||
if MetaFile.Type in self._FILE_TYPE_:
|
||||
FileType = Class._FILE_TYPE_[MetaFile.Type]
|
||||
else:
|
||||
FileType = MODEL_FILE_OTHERS
|
||||
|
||||
# don't pass the type around if it's well known
|
||||
if FileType == MODEL_FILE_OTHERS:
|
||||
Args = (Cursor, MetaFile, FileType, Temporary)
|
||||
else:
|
||||
Args = (Cursor, MetaFile, Temporary)
|
||||
|
||||
# create the storage object and return it to caller
|
||||
return Class._FILE_TABLE_[FileType](*Args)
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
# This module contains the functionality to generate build report after
|
||||
# build all target completes successfully.
|
||||
#
|
||||
# Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2010, 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
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -184,16 +184,17 @@ class DepexParser(object):
|
||||
#
|
||||
def __init__(self, Wa):
|
||||
self._GuidDb = {}
|
||||
for Package in Wa.BuildDatabase.WorkspaceDb.PackageList:
|
||||
for Protocol in Package.Protocols:
|
||||
GuidValue = GuidStructureStringToGuidString(Package.Protocols[Protocol])
|
||||
self._GuidDb[GuidValue.upper()] = Protocol
|
||||
for Ppi in Package.Ppis:
|
||||
GuidValue = GuidStructureStringToGuidString(Package.Ppis[Ppi])
|
||||
self._GuidDb[GuidValue.upper()] = Ppi
|
||||
for Guid in Package.Guids:
|
||||
GuidValue = GuidStructureStringToGuidString(Package.Guids[Guid])
|
||||
self._GuidDb[GuidValue.upper()] = Guid
|
||||
for Pa in Wa.AutoGenObjectList:
|
||||
for Package in Pa.PackageList:
|
||||
for Protocol in Package.Protocols:
|
||||
GuidValue = GuidStructureStringToGuidString(Package.Protocols[Protocol])
|
||||
self._GuidDb[GuidValue.upper()] = Protocol
|
||||
for Ppi in Package.Ppis:
|
||||
GuidValue = GuidStructureStringToGuidString(Package.Ppis[Ppi])
|
||||
self._GuidDb[GuidValue.upper()] = Ppi
|
||||
for Guid in Package.Guids:
|
||||
GuidValue = GuidStructureStringToGuidString(Package.Guids[Guid])
|
||||
self._GuidDb[GuidValue.upper()] = Guid
|
||||
|
||||
##
|
||||
# Parse the binary dependency expression files.
|
||||
@@ -486,7 +487,7 @@ class ModuleReport(object):
|
||||
#
|
||||
if ModuleType == "DXE_SMM_DRIVER":
|
||||
PiSpec = M.Module.Specification.get("PI_SPECIFICATION_VERSION", "0x00010000")
|
||||
if int(PiSpec, 16) >= 0x0001000A:
|
||||
if int(PiSpec, 0) >= 0x0001000A:
|
||||
ModuleType = "SMM_DRIVER"
|
||||
self.DriverType = gDriverTypeMap.get(ModuleType, "0x2 (FREE_FORM)")
|
||||
self.UefiSpecVersion = M.Module.Specification.get("UEFI_SPECIFICATION_VERSION", "")
|
||||
@@ -641,10 +642,11 @@ class PcdReport(object):
|
||||
# Collect PCD DEC default value.
|
||||
#
|
||||
self.DecPcdDefault = {}
|
||||
for Package in Wa.BuildDatabase.WorkspaceDb.PackageList:
|
||||
for (TokenCName, TokenSpaceGuidCName, DecType) in Package.Pcds:
|
||||
DecDefaultValue = Package.Pcds[TokenCName, TokenSpaceGuidCName, DecType].DefaultValue
|
||||
self.DecPcdDefault.setdefault((TokenCName, TokenSpaceGuidCName, DecType), DecDefaultValue)
|
||||
for Pa in Wa.AutoGenObjectList:
|
||||
for Package in Pa.PackageList:
|
||||
for (TokenCName, TokenSpaceGuidCName, DecType) in Package.Pcds:
|
||||
DecDefaultValue = Package.Pcds[TokenCName, TokenSpaceGuidCName, DecType].DefaultValue
|
||||
self.DecPcdDefault.setdefault((TokenCName, TokenSpaceGuidCName, DecType), DecDefaultValue)
|
||||
#
|
||||
# Collect PCDs defined in DSC common section
|
||||
#
|
||||
@@ -1174,14 +1176,14 @@ class FdRegionReport(object):
|
||||
self._DiscoverNestedFvList(FvName, Wa)
|
||||
|
||||
PlatformPcds = {}
|
||||
|
||||
#
|
||||
# Collect PCDs declared in DEC files.
|
||||
#
|
||||
for Package in Wa.BuildDatabase.WorkspaceDb.PackageList:
|
||||
for (TokenCName, TokenSpaceGuidCName, DecType) in Package.Pcds:
|
||||
DecDefaultValue = Package.Pcds[TokenCName, TokenSpaceGuidCName, DecType].DefaultValue
|
||||
PlatformPcds[(TokenCName, TokenSpaceGuidCName)] = DecDefaultValue
|
||||
#
|
||||
for Pa in Wa.AutoGenObjectList:
|
||||
for Package in Pa.PackageList:
|
||||
for (TokenCName, TokenSpaceGuidCName, DecType) in Package.Pcds:
|
||||
DecDefaultValue = Package.Pcds[TokenCName, TokenSpaceGuidCName, DecType].DefaultValue
|
||||
PlatformPcds[(TokenCName, TokenSpaceGuidCName)] = DecDefaultValue
|
||||
#
|
||||
# Collect PCDs defined in DSC common section
|
||||
#
|
||||
|
@@ -172,6 +172,12 @@ def CheckEnvVariable():
|
||||
GlobalData.gEdkSource = EdkSourceDir
|
||||
GlobalData.gEcpSource = EcpSourceDir
|
||||
|
||||
GlobalData.gGlobalDefines["WORKSPACE"] = WorkspaceDir
|
||||
GlobalData.gGlobalDefines["EFI_SOURCE"] = EfiSourceDir
|
||||
GlobalData.gGlobalDefines["EDK_SOURCE"] = EdkSourceDir
|
||||
GlobalData.gGlobalDefines["ECP_SOURCE"] = EcpSourceDir
|
||||
GlobalData.gGlobalDefines["EDK_TOOLS_PATH"] = os.environ["EDK_TOOLS_PATH"]
|
||||
|
||||
## Get normalized file path
|
||||
#
|
||||
# Convert the path to be local format, and remove the WORKSPACE path at the
|
||||
@@ -301,10 +307,14 @@ class BuildUnit:
|
||||
self.WorkingDir = WorkingDir
|
||||
self.Target = Target
|
||||
self.BuildCommand = BuildCommand
|
||||
if BuildCommand == None or len(BuildCommand) == 0:
|
||||
EdkLogger.error("build", OPTION_MISSING, "No build command found for",
|
||||
if not BuildCommand:
|
||||
EdkLogger.error("build", OPTION_MISSING,
|
||||
"No build command found for this module. "
|
||||
"Please check your setting of %s_%s_%s_MAKE_PATH in Conf/tools_def.txt file." %
|
||||
(Obj.BuildTarget, Obj.ToolChain, Obj.Arch),
|
||||
ExtraData=str(Obj))
|
||||
|
||||
|
||||
## str() method
|
||||
#
|
||||
# It just returns the string representation of self.BuildObject
|
||||
@@ -690,93 +700,59 @@ class Build():
|
||||
#
|
||||
# @param Target The build command target, one of gSupportedTarget
|
||||
# @param WorkspaceDir The directory of workspace
|
||||
# @param Platform The DSC file of active platform
|
||||
# @param Module The INF file of active module, if any
|
||||
# @param Arch The Arch list of platform or module
|
||||
# @param ToolChain The name list of toolchain
|
||||
# @param BuildTarget The "DEBUG" or "RELEASE" build
|
||||
# @param FlashDefinition The FDF file of active platform
|
||||
# @param FdList=[] The FD names to be individually built
|
||||
# @param FvList=[] The FV names to be individually built
|
||||
# @param MakefileType The type of makefile (for MSFT make or GNU make)
|
||||
# @param SilentMode Indicate multi-thread build mode
|
||||
# @param ThreadNumber The maximum number of thread if in multi-thread build mode
|
||||
# @param SkipAutoGen Skip AutoGen step
|
||||
# @param Reparse Re-parse all meta files
|
||||
# @param SkuId SKU id from command line
|
||||
# @param BuildOptions Build options passed from command line
|
||||
#
|
||||
def __init__(self, Target, WorkspaceDir, Platform, Module, Arch, ToolChain,
|
||||
BuildTarget, FlashDefinition, FdList=[], FvList=[], CapList=[],
|
||||
MakefileType="nmake", SilentMode=False, ThreadNumber=2,
|
||||
SkipAutoGen=False, Reparse=False, SkuId=None,
|
||||
ReportFile=None, ReportType=None, UniFlag=None):
|
||||
|
||||
self.WorkspaceDir = WorkspaceDir
|
||||
def __init__(self, Target, WorkspaceDir, BuildOptions):
|
||||
self.WorkspaceDir = WorkspaceDir
|
||||
self.Target = Target
|
||||
self.PlatformFile = Platform
|
||||
self.ModuleFile = Module
|
||||
self.ArchList = Arch
|
||||
self.ToolChainList = ToolChain
|
||||
self.BuildTargetList= BuildTarget
|
||||
self.Fdf = FlashDefinition
|
||||
self.FdList = FdList
|
||||
self.FvList = FvList
|
||||
self.CapList = CapList
|
||||
self.MakefileType = MakefileType
|
||||
self.SilentMode = SilentMode
|
||||
self.ThreadNumber = ThreadNumber
|
||||
self.SkipAutoGen = SkipAutoGen
|
||||
self.Reparse = Reparse
|
||||
self.SkuId = SkuId
|
||||
self.PlatformFile = BuildOptions.PlatformFile
|
||||
self.ModuleFile = BuildOptions.ModuleFile
|
||||
self.ArchList = BuildOptions.TargetArch
|
||||
self.ToolChainList = BuildOptions.ToolChain
|
||||
self.BuildTargetList= BuildOptions.BuildTarget
|
||||
self.Fdf = BuildOptions.FdfFile
|
||||
self.FdList = BuildOptions.RomImage
|
||||
self.FvList = BuildOptions.FvImage
|
||||
self.CapList = BuildOptions.CapName
|
||||
self.SilentMode = BuildOptions.SilentMode
|
||||
self.ThreadNumber = BuildOptions.ThreadNumber
|
||||
self.SkipAutoGen = BuildOptions.SkipAutoGen
|
||||
self.Reparse = BuildOptions.Reparse
|
||||
self.SkuId = BuildOptions.SkuId
|
||||
self.SpawnMode = True
|
||||
self.BuildReport = BuildReport(ReportFile, ReportType)
|
||||
self.BuildReport = BuildReport(BuildOptions.ReportFile, BuildOptions.ReportType)
|
||||
self.TargetTxt = TargetTxtClassObject()
|
||||
self.ToolDef = ToolDefClassObject()
|
||||
self.Db = WorkspaceDatabase(None, GlobalData.gGlobalDefines, self.Reparse)
|
||||
#self.Db = WorkspaceDatabase(None, {}, self.Reparse)
|
||||
if BuildOptions.DisableCache:
|
||||
self.Db = WorkspaceDatabase(":memory:")
|
||||
else:
|
||||
self.Db = WorkspaceDatabase(None, self.Reparse)
|
||||
self.BuildDatabase = self.Db.BuildObject
|
||||
self.Platform = None
|
||||
self.LoadFixAddress = 0
|
||||
self.UniFlag = UniFlag
|
||||
self.UniFlag = BuildOptions.Flag
|
||||
|
||||
# print dot character during doing some time-consuming work
|
||||
self.Progress = Utils.Progressor()
|
||||
|
||||
# parse target.txt, tools_def.txt, and platform file
|
||||
#self.RestoreBuildData()
|
||||
self.LoadConfiguration()
|
||||
|
||||
#
|
||||
# @attention Treat $(TARGET)/$(TOOL_CHAIN_TAG) in meta data files as special macro when it has only one build target/toolchain.
|
||||
# This is not a complete support for $(TARGET)/$(TOOL_CHAIN_TAG) macro as it can only support one build target/toolchain in ONE
|
||||
# invocation of build command. However, it should cover the frequent usage model that $(TARGET)/$(TOOL_CHAIN_TAG) macro
|
||||
# is used in DSC/FDF files to specify different libraries & PCD setting for debug/release build.
|
||||
#
|
||||
if len(self.BuildTargetList) == 1:
|
||||
self.Db._GlobalMacros.setdefault("TARGET", self.BuildTargetList[0])
|
||||
if len(self.ToolChainList) == 1:
|
||||
self.Db._GlobalMacros.setdefault("TOOL_CHAIN_TAG", self.ToolChainList[0])
|
||||
|
||||
self.InitBuild()
|
||||
|
||||
# print current build environment and configuration
|
||||
EdkLogger.quiet("%-24s = %s" % ("WORKSPACE", os.environ["WORKSPACE"]))
|
||||
EdkLogger.quiet("%-24s = %s" % ("ECP_SOURCE", os.environ["ECP_SOURCE"]))
|
||||
EdkLogger.quiet("%-24s = %s" % ("EDK_SOURCE", os.environ["EDK_SOURCE"]))
|
||||
EdkLogger.quiet("%-24s = %s" % ("EFI_SOURCE", os.environ["EFI_SOURCE"]))
|
||||
EdkLogger.quiet("%-24s = %s" % ("EDK_TOOLS_PATH", os.environ["EDK_TOOLS_PATH"]))
|
||||
EdkLogger.quiet("%-16s = %s" % ("WORKSPACE", os.environ["WORKSPACE"]))
|
||||
EdkLogger.quiet("%-16s = %s" % ("ECP_SOURCE", os.environ["ECP_SOURCE"]))
|
||||
EdkLogger.quiet("%-16s = %s" % ("EDK_SOURCE", os.environ["EDK_SOURCE"]))
|
||||
EdkLogger.quiet("%-16s = %s" % ("EFI_SOURCE", os.environ["EFI_SOURCE"]))
|
||||
EdkLogger.quiet("%-16s = %s" % ("EDK_TOOLS_PATH", os.environ["EDK_TOOLS_PATH"]))
|
||||
|
||||
EdkLogger.info('\n%-24s = %s' % ("TARGET_ARCH", ' '.join(self.ArchList)))
|
||||
EdkLogger.info('%-24s = %s' % ("TARGET", ' '.join(self.BuildTargetList)))
|
||||
EdkLogger.info('%-24s = %s' % ("TOOL_CHAIN_TAG", ' '.join(self.ToolChainList)))
|
||||
EdkLogger.info("")
|
||||
if self.ArchList:
|
||||
EdkLogger.info('%-16s = %s' % ("Architecture(s)", ' '.join(self.ArchList)))
|
||||
EdkLogger.info('%-16s = %s' % ("Build target", ' '.join(self.BuildTargetList)))
|
||||
EdkLogger.info('%-16s = %s' % ("Toolchain", ' '.join(self.ToolChainList)))
|
||||
|
||||
EdkLogger.info('\n%-24s = %s' % ("Active Platform", self.PlatformFile))
|
||||
|
||||
if self.Fdf != None and self.Fdf != "":
|
||||
EdkLogger.info('%-24s = %s' % ("Flash Image Definition", self.Fdf))
|
||||
|
||||
if self.ModuleFile != None and self.ModuleFile != "":
|
||||
EdkLogger.info('%-24s = %s' % ("Active Module", self.ModuleFile))
|
||||
#EdkLogger.info('\n%-24s = %s' % ("Active Platform", self.PlatformFile))
|
||||
if self.ModuleFile:
|
||||
EdkLogger.info('%-16s = %s' % ("Active Module", self.ModuleFile))
|
||||
|
||||
os.chdir(self.WorkspaceDir)
|
||||
self.Progress.Start("\nProcessing meta-data")
|
||||
@@ -805,15 +781,16 @@ class Build():
|
||||
EdkLogger.error("build", FILE_NOT_FOUND, ExtraData=BuildConfigurationFile)
|
||||
|
||||
# if no ARCH given in command line, get it from target.txt
|
||||
if self.ArchList == None or len(self.ArchList) == 0:
|
||||
if not self.ArchList:
|
||||
self.ArchList = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET_ARCH]
|
||||
self.ArchList = tuple(self.ArchList)
|
||||
|
||||
# if no build target given in command line, get it from target.txt
|
||||
if self.BuildTargetList == None or len(self.BuildTargetList) == 0:
|
||||
if not self.BuildTargetList:
|
||||
self.BuildTargetList = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET]
|
||||
|
||||
# if no tool chain given in command line, get it from target.txt
|
||||
if self.ToolChainList == None or len(self.ToolChainList) == 0:
|
||||
if not self.ToolChainList:
|
||||
self.ToolChainList = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG]
|
||||
if self.ToolChainList == None or len(self.ToolChainList) == 0:
|
||||
EdkLogger.error("build", RESOURCE_NOT_AVAILABLE, ExtraData="No toolchain given. Don't know how to build.\n")
|
||||
@@ -859,9 +836,6 @@ class Build():
|
||||
ExtraData="No active platform specified in target.txt or command line! Nothing can be built.\n")
|
||||
|
||||
self.PlatformFile = PathClass(NormFile(PlatformFile, self.WorkspaceDir), self.WorkspaceDir)
|
||||
ErrorCode, ErrorInfo = self.PlatformFile.Validate(".dsc", False)
|
||||
if ErrorCode != 0:
|
||||
EdkLogger.error("build", ErrorCode, ExtraData=ErrorInfo)
|
||||
|
||||
## Initialize build configuration
|
||||
#
|
||||
@@ -869,90 +843,17 @@ class Build():
|
||||
# command line and target.txt, then get the final build configurations.
|
||||
#
|
||||
def InitBuild(self):
|
||||
ErrorCode, ErrorInfo = self.PlatformFile.Validate(".dsc")
|
||||
# parse target.txt, tools_def.txt, and platform file
|
||||
self.LoadConfiguration()
|
||||
|
||||
# Allow case-insensitive for those from command line or configuration file
|
||||
ErrorCode, ErrorInfo = self.PlatformFile.Validate(".dsc", False)
|
||||
if ErrorCode != 0:
|
||||
EdkLogger.error("build", ErrorCode, ExtraData=ErrorInfo)
|
||||
|
||||
# create metafile database
|
||||
self.Db.InitDatabase()
|
||||
|
||||
# we need information in platform description file to determine how to build
|
||||
self.Platform = self.BuildDatabase[self.PlatformFile, 'COMMON']
|
||||
if not self.Fdf:
|
||||
self.Fdf = self.Platform.FlashDefinition
|
||||
|
||||
LoadFixAddressString = None
|
||||
if TAB_FIX_LOAD_TOP_MEMORY_ADDRESS in GlobalData.gGlobalDefines:
|
||||
LoadFixAddressString = GlobalData.gGlobalDefines[TAB_FIX_LOAD_TOP_MEMORY_ADDRESS]
|
||||
else:
|
||||
LoadFixAddressString = self.Platform.LoadFixAddress
|
||||
|
||||
if LoadFixAddressString != None and LoadFixAddressString != '':
|
||||
try:
|
||||
if LoadFixAddressString.upper().startswith('0X'):
|
||||
self.LoadFixAddress = int (LoadFixAddressString, 16)
|
||||
else:
|
||||
self.LoadFixAddress = int (LoadFixAddressString)
|
||||
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))
|
||||
if self.LoadFixAddress != 0xFFFFFFFFFFFFFFFF and self.LoadFixAddress % 0x1000 != 0:
|
||||
EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_MEMORY_ADDRESS is set to the invalid unaligned 4K value %s" % (LoadFixAddressString))
|
||||
|
||||
if self.SkuId == None or self.SkuId == '':
|
||||
self.SkuId = self.Platform.SkuName
|
||||
|
||||
# check FD/FV build target
|
||||
if self.Fdf == None or self.Fdf == "":
|
||||
if self.FdList != []:
|
||||
EdkLogger.info("No flash definition file found. FD [%s] will be ignored." % " ".join(self.FdList))
|
||||
self.FdList = []
|
||||
if self.FvList != []:
|
||||
EdkLogger.info("No flash definition file found. FV [%s] will be ignored." % " ".join(self.FvList))
|
||||
self.FvList = []
|
||||
else:
|
||||
#
|
||||
# Mark now build in AutoGen Phase
|
||||
#
|
||||
GlobalData.gAutoGenPhase = True
|
||||
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():
|
||||
EdkLogger.error("build", OPTION_VALUE_INVALID,
|
||||
"No such an FV in FDF file: %s" % fvname)
|
||||
GlobalData.gAutoGenPhase = False
|
||||
|
||||
#
|
||||
# Merge Arch
|
||||
#
|
||||
if self.ArchList == None or len(self.ArchList) == 0:
|
||||
ArchList = set(self.Platform.SupArchList)
|
||||
else:
|
||||
ArchList = set(self.ArchList) & set(self.Platform.SupArchList)
|
||||
if len(ArchList) == 0:
|
||||
EdkLogger.error("build", PARAMETER_INVALID,
|
||||
ExtraData = "Active platform supports [%s] only, but [%s] is given."
|
||||
% (" ".join(self.Platform.SupArchList), " ".join(self.ArchList)))
|
||||
elif len(ArchList) != len(self.ArchList):
|
||||
SkippedArchList = set(self.ArchList).symmetric_difference(set(self.Platform.SupArchList))
|
||||
EdkLogger.verbose("\nArch [%s] is ignored because active platform supports [%s] but [%s] is specified !"
|
||||
% (" ".join(SkippedArchList), " ".join(self.Platform.SupArchList), " ".join(self.ArchList)))
|
||||
self.ArchList = tuple(ArchList)
|
||||
|
||||
# Merge build target
|
||||
if self.BuildTargetList == None or len(self.BuildTargetList) == 0:
|
||||
BuildTargetList = self.Platform.BuildTargets
|
||||
else:
|
||||
BuildTargetList = list(set(self.BuildTargetList) & set(self.Platform.BuildTargets))
|
||||
if BuildTargetList == []:
|
||||
EdkLogger.error("build", PARAMETER_INVALID, "Active platform only supports [%s], but [%s] is given"
|
||||
% (" ".join(self.Platform.BuildTargets), " ".join(self.BuildTargetList)))
|
||||
self.BuildTargetList = BuildTargetList
|
||||
|
||||
## Build a module or platform
|
||||
#
|
||||
# Create autogen code and makefile for a module or platform, and the launch
|
||||
@@ -1000,7 +901,11 @@ class Build():
|
||||
|
||||
BuildCommand = AutoGenObject.BuildCommand
|
||||
if BuildCommand == None or len(BuildCommand) == 0:
|
||||
EdkLogger.error("build", OPTION_MISSING, ExtraData="No MAKE command found for [%s, %s, %s]" % Key)
|
||||
EdkLogger.error("build", OPTION_MISSING,
|
||||
"No build command found for this module. "
|
||||
"Please check your setting of %s_%s_%s_MAKE_PATH in Conf/tools_def.txt file." %
|
||||
(AutoGenObject.BuildTarget, AutoGenObject.ToolChain, AutoGenObject.Arch),
|
||||
ExtraData=str(AutoGenObject))
|
||||
|
||||
BuildCommand = BuildCommand + [Target]
|
||||
LaunchCommand(BuildCommand, AutoGenObject.MakeFileDir)
|
||||
@@ -1011,7 +916,7 @@ class Build():
|
||||
#
|
||||
# First should close DB.
|
||||
#
|
||||
self.Db.Close()
|
||||
self.Db.Close()
|
||||
RemoveDirectory(gBuildCacheDir, True)
|
||||
except WindowsError, X:
|
||||
EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=str(X))
|
||||
@@ -1121,7 +1026,7 @@ class Build():
|
||||
## Collect MAP information of all FVs
|
||||
#
|
||||
def _CollectFvMapBuffer (self, MapBuffer, Wa, ModuleList):
|
||||
if self.Fdf != '':
|
||||
if self.Fdf:
|
||||
# First get the XIP base address for FV map file.
|
||||
GuidPattern = re.compile("[-a-fA-F0-9]+")
|
||||
GuidName = re.compile("\(GUID=[-a-fA-F0-9]+")
|
||||
@@ -1318,10 +1223,13 @@ class Build():
|
||||
#
|
||||
def _BuildPlatform(self):
|
||||
for BuildTarget in self.BuildTargetList:
|
||||
GlobalData.gGlobalDefines['TARGET'] = BuildTarget
|
||||
for ToolChain in self.ToolChainList:
|
||||
GlobalData.gGlobalDefines['TOOLCHAIN'] = ToolChain
|
||||
GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = ToolChain
|
||||
Wa = WorkspaceAutoGen(
|
||||
self.WorkspaceDir,
|
||||
self.Platform,
|
||||
self.PlatformFile,
|
||||
BuildTarget,
|
||||
ToolChain,
|
||||
self.ArchList,
|
||||
@@ -1335,18 +1243,21 @@ class Build():
|
||||
self.SkuId,
|
||||
self.UniFlag
|
||||
)
|
||||
self.Fdf = Wa.FdfFile
|
||||
self.LoadFixAddress = Wa.Platform.LoadFixAddress
|
||||
self.BuildReport.AddPlatformReport(Wa)
|
||||
self.Progress.Stop("done!")
|
||||
self._Build(self.Target, Wa)
|
||||
|
||||
# Create MAP file when Load Fix Address is enabled.
|
||||
if self.Target in ["", "all", "fds"]:
|
||||
for Arch in self.ArchList:
|
||||
for Arch in Wa.ArchList:
|
||||
GlobalData.gGlobalDefines['ARCH'] = Arch
|
||||
#
|
||||
# Check whether the set fix address is above 4G for 32bit image.
|
||||
#
|
||||
if (Arch == 'IA32' or Arch == 'ARM') and self.LoadFixAddress != 0xFFFFFFFFFFFFFFFF and self.LoadFixAddress >= 0x100000000:
|
||||
EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_MEMORY_ADDRESS can't be set to larger than or equal to 4G for the platorm with IA32 or ARM arch modules")
|
||||
EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_MEMORY_ADDRESS can't be set to larger than or equal to 4G for the platform with IA32 or ARM arch modules")
|
||||
#
|
||||
# Get Module List
|
||||
#
|
||||
@@ -1364,12 +1275,12 @@ class Build():
|
||||
# Rebase module to the preferred memory address before GenFds
|
||||
#
|
||||
self._CollectModuleMapBuffer(MapBuffer, ModuleList)
|
||||
if self.Fdf != '':
|
||||
if self.Fdf:
|
||||
#
|
||||
# create FDS again for the updated EFI image
|
||||
#
|
||||
self._Build("fds", Wa)
|
||||
if self.Fdf != '':
|
||||
if self.Fdf:
|
||||
#
|
||||
# Create MAP file for all platform FVs after GenFds.
|
||||
#
|
||||
@@ -1383,14 +1294,17 @@ class Build():
|
||||
#
|
||||
def _BuildModule(self):
|
||||
for BuildTarget in self.BuildTargetList:
|
||||
GlobalData.gGlobalDefines['TARGET'] = BuildTarget
|
||||
for ToolChain in self.ToolChainList:
|
||||
GlobalData.gGlobalDefines['TOOLCHAIN'] = ToolChain
|
||||
GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = ToolChain
|
||||
#
|
||||
# module build needs platform build information, so get platform
|
||||
# AutoGen first
|
||||
#
|
||||
Wa = WorkspaceAutoGen(
|
||||
self.WorkspaceDir,
|
||||
self.Platform,
|
||||
self.PlatformFile,
|
||||
BuildTarget,
|
||||
ToolChain,
|
||||
self.ArchList,
|
||||
@@ -1404,10 +1318,13 @@ class Build():
|
||||
self.SkuId,
|
||||
self.UniFlag
|
||||
)
|
||||
self.Fdf = Wa.FdfFile
|
||||
self.LoadFixAddress = Wa.Platform.LoadFixAddress
|
||||
Wa.CreateMakeFile(False)
|
||||
self.Progress.Stop("done!")
|
||||
MaList = []
|
||||
for Arch in self.ArchList:
|
||||
for Arch in Wa.ArchList:
|
||||
GlobalData.gGlobalDefines['ARCH'] = Arch
|
||||
Ma = ModuleAutoGen(Wa, self.ModuleFile, BuildTarget, ToolChain, Arch, self.PlatformFile)
|
||||
if Ma == None: continue
|
||||
MaList.append(Ma)
|
||||
@@ -1421,12 +1338,12 @@ class Build():
|
||||
"Module for [%s] is not a component of active platform."\
|
||||
" Please make sure that the ARCH and inf file path are"\
|
||||
" given in the same as in [%s]" %\
|
||||
(', '.join(self.ArchList), self.Platform),
|
||||
(', '.join(Wa.ArchList), self.PlatformFile),
|
||||
ExtraData=self.ModuleFile
|
||||
)
|
||||
# Create MAP file when Load Fix Address is enabled.
|
||||
if self.Target == "fds" and self.Fdf != '':
|
||||
for Arch in self.ArchList:
|
||||
if self.Target == "fds" and self.Fdf:
|
||||
for Arch in Wa.ArchList:
|
||||
#
|
||||
# Check whether the set fix address is above 4G for 32bit image.
|
||||
#
|
||||
@@ -1466,10 +1383,13 @@ class Build():
|
||||
#
|
||||
def _MultiThreadBuildPlatform(self):
|
||||
for BuildTarget in self.BuildTargetList:
|
||||
GlobalData.gGlobalDefines['TARGET'] = BuildTarget
|
||||
for ToolChain in self.ToolChainList:
|
||||
GlobalData.gGlobalDefines['TOOLCHAIN'] = ToolChain
|
||||
GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = ToolChain
|
||||
Wa = WorkspaceAutoGen(
|
||||
self.WorkspaceDir,
|
||||
self.Platform,
|
||||
self.PlatformFile,
|
||||
BuildTarget,
|
||||
ToolChain,
|
||||
self.ArchList,
|
||||
@@ -1483,13 +1403,16 @@ class Build():
|
||||
self.SkuId,
|
||||
self.UniFlag
|
||||
)
|
||||
self.Fdf = Wa.FdfFile
|
||||
self.LoadFixAddress = Wa.Platform.LoadFixAddress
|
||||
self.BuildReport.AddPlatformReport(Wa)
|
||||
Wa.CreateMakeFile(False)
|
||||
|
||||
# multi-thread exit flag
|
||||
ExitFlag = threading.Event()
|
||||
ExitFlag.clear()
|
||||
for Arch in self.ArchList:
|
||||
for Arch in Wa.ArchList:
|
||||
GlobalData.gGlobalDefines['ARCH'] = Arch
|
||||
Pa = PlatformAutoGen(Wa, self.PlatformFile, BuildTarget, ToolChain, Arch)
|
||||
if Pa == None:
|
||||
continue
|
||||
@@ -1546,7 +1469,7 @@ class Build():
|
||||
|
||||
# Create MAP file when Load Fix Address is enabled.
|
||||
if self.Target in ["", "all", "fds"]:
|
||||
for Arch in self.ArchList:
|
||||
for Arch in Wa.ArchList:
|
||||
#
|
||||
# Check whether the set fix address is above 4G for 32bit image.
|
||||
#
|
||||
@@ -1569,7 +1492,7 @@ class Build():
|
||||
if self.LoadFixAddress != 0:
|
||||
self._CollectModuleMapBuffer(MapBuffer, ModuleList)
|
||||
|
||||
if self.Fdf != '':
|
||||
if self.Fdf:
|
||||
#
|
||||
# Generate FD image if there's a FDF file found
|
||||
#
|
||||
@@ -1586,20 +1509,32 @@ class Build():
|
||||
## Generate GuidedSectionTools.txt in the FV directories.
|
||||
#
|
||||
def CreateGuidedSectionToolsFile(self):
|
||||
for Arch in self.ArchList:
|
||||
for BuildTarget in self.BuildTargetList:
|
||||
for ToolChain in self.ToolChainList:
|
||||
FvDir = os.path.join(
|
||||
self.WorkspaceDir,
|
||||
self.Platform.OutputDirectory,
|
||||
'_'.join((BuildTarget, ToolChain)),
|
||||
'FV'
|
||||
)
|
||||
if not os.path.exists(FvDir):
|
||||
continue
|
||||
for BuildTarget in self.BuildTargetList:
|
||||
for ToolChain in self.ToolChainList:
|
||||
Wa = WorkspaceAutoGen(
|
||||
self.WorkspaceDir,
|
||||
self.PlatformFile,
|
||||
BuildTarget,
|
||||
ToolChain,
|
||||
self.ArchList,
|
||||
self.BuildDatabase,
|
||||
self.TargetTxt,
|
||||
self.ToolDef,
|
||||
self.Fdf,
|
||||
self.FdList,
|
||||
self.FvList,
|
||||
self.CapList,
|
||||
self.SkuId,
|
||||
self.UniFlag
|
||||
)
|
||||
FvDir = Wa.FvDir
|
||||
if not os.path.exists(FvDir):
|
||||
continue
|
||||
|
||||
for Arch in self.ArchList:
|
||||
# Build up the list of supported architectures for this build
|
||||
prefix = '%s_%s_%s_' % (BuildTarget, ToolChain, Arch)
|
||||
|
||||
|
||||
# Look through the tool definitions for GUIDed tools
|
||||
guidAttribs = []
|
||||
for (attrib, value) in self.ToolDef.ToolsDefTxtDictionary.iteritems():
|
||||
@@ -1614,7 +1549,7 @@ class Build():
|
||||
path = self.ToolDef.ToolsDefTxtDictionary[path]
|
||||
path = self.GetFullPathOfTool(path)
|
||||
guidAttribs.append((guid, toolName, path))
|
||||
|
||||
|
||||
# Write out GuidedSecTools.txt
|
||||
toolsFile = os.path.join(FvDir, 'GuidedSectionTools.txt')
|
||||
toolsFile = open(toolsFile, 'wt')
|
||||
@@ -1642,7 +1577,7 @@ class Build():
|
||||
## Launch the module or platform build
|
||||
#
|
||||
def Launch(self):
|
||||
if self.ModuleFile == None or self.ModuleFile == "":
|
||||
if not self.ModuleFile:
|
||||
if not self.SpawnMode or self.Target not in ["", "all"]:
|
||||
self.SpawnMode = False
|
||||
self._BuildPlatform()
|
||||
@@ -1687,8 +1622,13 @@ def ParseDefines(DefineList=[]):
|
||||
if DefineList != None:
|
||||
for Define in DefineList:
|
||||
DefineTokenList = Define.split("=", 1)
|
||||
if not GlobalData.gMacroNamePattern.match(DefineTokenList[0]):
|
||||
EdkLogger.error('build', FORMAT_INVALID,
|
||||
"The macro name must be in the pattern [A-Z][A-Z0-9_]*",
|
||||
ExtraData=DefineTokenList[0])
|
||||
|
||||
if len(DefineTokenList) == 1:
|
||||
DefineDict[DefineTokenList[0]] = ""
|
||||
DefineDict[DefineTokenList[0]] = "TRUE"
|
||||
else:
|
||||
DefineDict[DefineTokenList[0]] = DefineTokenList[1].strip()
|
||||
return DefineDict
|
||||
@@ -1737,10 +1677,7 @@ def MyOptionParser():
|
||||
Parser.add_option("-u", "--skip-autogen", action="store_true", dest="SkipAutoGen", help="Skip AutoGen step.")
|
||||
Parser.add_option("-e", "--re-parse", action="store_true", dest="Reparse", help="Re-parse all meta-data files.")
|
||||
|
||||
Parser.add_option("-c", "--case-insensitive", action="store_true", dest="CaseInsensitive", help="Don't check case of file name.")
|
||||
|
||||
# Parser.add_option("-D", "--define", action="append", dest="Defines", metavar="NAME[=[VALUE]]",
|
||||
# help="Define global macro which can be used in DSC/DEC/INF files.")
|
||||
Parser.add_option("-c", "--case-insensitive", action="store_true", dest="CaseInsensitive", default=False, help="Don't check case of file name.")
|
||||
|
||||
Parser.add_option("-w", "--warning-as-error", action="store_true", dest="WarningAsError", help="Treat warning in tools as error.")
|
||||
Parser.add_option("-j", "--log", action="store", dest="LogFile", help="Put log in specified file as well as on console.")
|
||||
@@ -1762,6 +1699,7 @@ def MyOptionParser():
|
||||
help="Specify the specific option to parse EDK UNI file. Must be one of: [-c, -s]. -c is for EDK framework UNI file, and -s is for EDK UEFI UNI file. "\
|
||||
"This option can also be specified by setting *_*_*_BUILD_FLAGS in [BuildOptions] section of platform DSC. If they are both specified, this value "\
|
||||
"will override the setting in [BuildOptions] section of platform DSC.")
|
||||
Parser.add_option("-N", "--no-cache", action="store_true", dest="DisableCache", default=False, help="Disable build cache mechanism")
|
||||
|
||||
(Opt, Args)=Parser.parse_args()
|
||||
return (Opt, Args)
|
||||
@@ -1826,11 +1764,12 @@ def Main():
|
||||
EdkLogger.error("build", OPTION_NOT_SUPPORTED, "Not supported target [%s]." % Target,
|
||||
ExtraData="Please select one of: %s" %(' '.join(gSupportedTarget)))
|
||||
|
||||
GlobalData.gGlobalDefines = ParseDefines(Option.Macros)
|
||||
#
|
||||
# Check environment variable: EDK_TOOLS_PATH, WORKSPACE, PATH
|
||||
#
|
||||
CheckEnvVariable()
|
||||
GlobalData.gCommandLineDefines.update(ParseDefines(Option.Macros))
|
||||
|
||||
Workspace = os.getenv("WORKSPACE")
|
||||
#
|
||||
# Get files real name in workspace dir
|
||||
@@ -1861,9 +1800,6 @@ def Main():
|
||||
if os.path.normcase (os.path.normpath(Option.PlatformFile)).find (Workspace) == 0:
|
||||
Option.PlatformFile = NormFile(os.path.normpath(Option.PlatformFile), Workspace)
|
||||
Option.PlatformFile = PathClass(Option.PlatformFile, Workspace)
|
||||
ErrorCode, ErrorInfo = Option.PlatformFile.Validate(".dsc", False)
|
||||
if ErrorCode != 0:
|
||||
EdkLogger.error("build", ErrorCode, ExtraData=ErrorInfo)
|
||||
|
||||
if Option.FdfFile != None:
|
||||
if os.path.isabs (Option.FdfFile):
|
||||
@@ -1877,12 +1813,7 @@ def Main():
|
||||
if Option.Flag != None and Option.Flag not in ['-c', '-s']:
|
||||
EdkLogger.error("build", OPTION_VALUE_INVALID, "UNI flag must be one of -c or -s")
|
||||
|
||||
MyBuild = Build(Target, Workspace, Option.PlatformFile, Option.ModuleFile,
|
||||
Option.TargetArch, Option.ToolChain, Option.BuildTarget,
|
||||
Option.FdfFile, Option.RomImage, Option.FvImage, Option.CapName,
|
||||
None, Option.SilentMode, Option.ThreadNumber,
|
||||
Option.SkipAutoGen, Option.Reparse, Option.SkuId,
|
||||
Option.ReportFile, Option.ReportType, Option.Flag)
|
||||
MyBuild = Build(Target, Workspace, Option)
|
||||
MyBuild.Launch()
|
||||
#MyBuild.DumpBuildData()
|
||||
except FatalError, X:
|
||||
@@ -1925,7 +1856,8 @@ def Main():
|
||||
ExtraData="\n(Please send email to edk2-buildtools-devel@lists.sourceforge.net for help, attaching following call stack trace!)\n",
|
||||
RaiseError=False
|
||||
)
|
||||
EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc())
|
||||
if Option != None and Option.debug != None:
|
||||
EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc())
|
||||
ReturnCode = CODE_ERROR
|
||||
finally:
|
||||
Utils.Progressor.Abort()
|
||||
|
Reference in New Issue
Block a user