## @file
# Global variables for GenFds
#
# Copyright (c) 2007 - 2012, 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
#
# 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
#
import os
import sys
import subprocess
import struct
import array
from Common.BuildToolError import *
## Global variables
#
#
class GenFdsGlobalVariable:
OutputDirDict = {}
# will be FvDir + os.sep + 'Ffs'
FdfParser = None
WorkSpace = None
OutputDirFromDscDict = {}
RuleDict = {}
ArchList = None
VtfDict = {}
ActivePlatform = None
__BuildRuleDatabase = None
## LoadBuildRule
#
def __LoadBuildRule():
BuildConfigurationFile = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, "Conf/target.txt"))
# VBox - begin
# VBox - end
if BuildRuleFile in [None, '']:
if ToolDefinitionFile == '':
GenFdsGlobalVariable.BuildRuleFamily = ToolDefinition[DataType.TAB_TOD_DEFINES_BUILDRULEFAMILY][GenFdsGlobalVariable.ToolChainTag]
GenFdsGlobalVariable.ToolChainFamily = ToolDefinition[DataType.TAB_TOD_DEFINES_FAMILY][GenFdsGlobalVariable.ToolChainTag]
## GetBuildRules
# @param Inf: object of InfBuildData
# @param Arch: current arch
#
if not Arch:
Arch = 'COMMON'
return {}
if not BuildRuleDatabase:
return {}
Macro = {}
Arch,
)
BuildRules = {}
#first try getting build rule by BuildRuleFamily
if not RuleObject:
# build type is always module type, but ...
#second try getting build rule by ToolChainFamily
if not RuleObject:
if not RuleObject:
# build type is always module type, but ...
if not RuleObject:
continue
return BuildRules
## GetModuleCodaTargetList
#
# @param Inf: object of InfBuildData
# @param Arch: current arch
#
if not BuildRules:
return []
TargetList = set()
FileList = []
LastTarget = None
RuleChain = []
SourceList = [File]
Index = 0
# Skip all files that are not binary libraries
if not Inf.LibraryClass:
continue
elif FileType in BuildRules:
else:
# stop at no more rules
if LastTarget:
break
# stop at STATIC_LIBRARY for library
if LastTarget:
break
if not Target:
if LastTarget:
break
# Only do build for target with outputs
# to avoid cyclic rule
break
return list(TargetList)
## SetDir()
#
# @param OutputDir Output directory
# @param FdfParser FDF contents parser
# @param Workspace The directory of workspace
# @param ArchList The Arch list of platform
#
# GenFdsGlobalVariable.OutputDirDict = OutputDir
if ArchList != None:
T_CHAR_LF = '\n'
#
# Create FV Address inf file
#
#
# Add [Options]
#
BsAddress = '0'
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
BsAddress + \
RtAddress = '0'
if GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].RtBaseAddress:
RtAddress = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].RtBaseAddress
RtAddress + \
## ReplaceWorkspaceMacro()
#
# @param String String that may contain macro
#
else:
## Check if the input files are newer than output files
#
# @param Output Path of output file
# @param Input Path list of input files
#
# @retval True if Output doesn't exist, or any Input is newer
# @retval False if all Input is older than Output
#
return True
# always update "Output" if no "Input" given
return True
# if fdf file is changed after the 'Output" is generated, update the 'Output'
return True
for F in Input:
# always update "Output" if any "Input" doesn't exist
return True
# always update "Output" if any "Input" is newer than "Output"
return True
return False
Cmd = ["GenSec"]
if Type not in [None, '']:
if CompressionType not in [None, '']:
if Guid != None:
if GuidHdrLen not in [None, '']:
#Add each guided attribute
if InputAlign != None:
#Section Align is only for dummy section without section type
for SecAlign in InputAlign:
if Ui not in [None, '']:
#Cmd += ["-n", '"' + Ui + '"']
GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15)
elif Ver not in [None, '']:
#Cmd += ["-j", Ver]
GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x14)
else:
return
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
if AlignString == None:
return 0
else:
return int (AlignString)
SectionAlign=None):
Cmd += ["-x"]
if CheckSum:
Cmd += ["-s"]
if Align not in [None, '']:
return
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
def GenerateFirmwareVolume(Output, Input, BaseAddress=None, ForceRebase=None, Capsule=False, Dump=False,
return
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
Cmd = ["GenFv"]
if BaseAddress not in [None, '']:
if ForceRebase == False:
elif ForceRebase == True:
if Capsule:
Cmd += ["-c"]
if Dump:
Cmd += ["-p"]
if AddressFile not in [None, '']:
if MapFile not in [None, '']:
for I in Input:
Cmd += ["-i", I]
return
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
Cmd = ["GenVtf"]
for F in Input:
Cmd += ["-f", F]
return
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
Cmd = ["GenFw"]
Cmd += ["-t"]
if SubType not in [None, '']:
if TimeStamp not in [None, '']:
if Align not in [None, '']:
if Padding not in [None, '']:
if Zero:
Cmd += ["-z"]
if Strip:
Cmd += ["-l"]
if Replace:
Cmd += ["-r"]
if Join:
Cmd += ["-j"]
if Convert:
Cmd += ["-m"]
InputList = []
Cmd = ["EfiRom"]
if Compress:
Cmd += ["-ec"]
else:
Cmd += ["-e"]
Cmd += ["-b"]
for BinFile in BinaryInput:
# Check List
return
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, InputList))
if ClassCode != None:
if Revision != None:
if DeviceId != None:
if VendorId != None:
return
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
cmd += ('-v',)
else:
try:
PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr= subprocess.PIPE, shell=True)
except Exception, X:
while PopenObject.returncode == None :
#get command return value
return
if PopenObject.returncode != 0 or GenFdsGlobalVariable.VerboseMode or GenFdsGlobalVariable.DebugLevel != -1:
print "###", cmd
## ReplaceWorkspaceMacro()
#
# @param Str String that may contain macro
# @param MacroDict Dictionary that contains macro value pair
#
if Str == None :
return None
# '$(OUTPUT_DIRECTORY)': GenFdsGlobalVariable.OutputDirFromDsc,
}
else:
return Str
## GetPcdValue()
#
# @param PcdPattern pattern that labels a PCD.
#
if PcdPattern == None :
return None
PcdValue = ''
Platform = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
return PcdValue
Arch,
return PcdValue
return PcdValue