X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FGenFds.py;h=672d1038702228931384bb03cf8eaf2105e8e3f2;hb=07fb9c264400d7ca2c14d3d8076102584038eb96;hp=c5ccda677b0cd83d18e14386512226fe53f8c5be;hpb=df0cee8d8ce6fefc7b38ac238479300bb3051298;p=mirror_edk2.git
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index c5ccda677b..672d103870 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -1,7 +1,7 @@
## @file
# generate flash image
#
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -34,15 +34,18 @@ import Common.DataType
import Common.GlobalData as GlobalData
from Common import EdkLogger
from Common.String import *
-from Common.Misc import DirCache,PathClass
+from Common.Misc import DirCache, PathClass
from Common.Misc import SaveFileOnChange
+from Common.Misc import ClearDuplicatedInf
from Common.Misc import GuidStructureStringToGuidString
+from Common.Misc import CheckPcdDatum
from Common.BuildVersion import gBUILD_VERSION
+from Common.MultipleWorkspace import MultipleWorkspace as mws
## Version and Copyright
versionNumber = "1.0" + ' ' + gBUILD_VERSION
__version__ = "%prog Version " + versionNumber
-__copyright__ = "Copyright (c) 2007 - 2014, Intel Corporation All rights reserved."
+__copyright__ = "Copyright (c) 2007 - 2016, Intel Corporation All rights reserved."
## Tool entrance method
#
@@ -91,8 +94,12 @@ def main():
if 'EDK_SOURCE' in os.environ.keys():
GenFdsGlobalVariable.EdkSourceDir = os.path.normcase(os.environ['EDK_SOURCE'])
if (Options.debug):
- GenFdsGlobalVariable.VerboseLogger( "Using Workspace:" + Workspace)
+ GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Workspace)
os.chdir(GenFdsGlobalVariable.WorkSpaceDir)
+
+ # set multiple workspace
+ PackagesPath = os.getenv("PACKAGES_PATH")
+ mws.setWs(GenFdsGlobalVariable.WorkSpaceDir, PackagesPath)
if (Options.filename):
FdfFilename = Options.filename
@@ -100,12 +107,10 @@ def main():
if FdfFilename[0:2] == '..':
FdfFilename = os.path.realpath(FdfFilename)
- if not os.path.isabs (FdfFilename):
- FdfFilename = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, FdfFilename)
+ if not os.path.isabs(FdfFilename):
+ FdfFilename = mws.join(GenFdsGlobalVariable.WorkSpaceDir, FdfFilename)
if not os.path.exists(FdfFilename):
EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=FdfFilename)
- if os.path.normcase (FdfFilename).find(Workspace) != 0:
- EdkLogger.error("GenFds", FILE_NOT_FOUND, "FdfFile doesn't exist in Workspace!")
GenFdsGlobalVariable.FdfFile = FdfFilename
GenFdsGlobalVariable.FdfFileTimeStamp = os.path.getmtime(FdfFilename)
@@ -130,34 +135,45 @@ def main():
ActivePlatform = os.path.realpath(ActivePlatform)
if not os.path.isabs (ActivePlatform):
- ActivePlatform = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ActivePlatform)
+ ActivePlatform = mws.join(GenFdsGlobalVariable.WorkSpaceDir, ActivePlatform)
if not os.path.exists(ActivePlatform) :
EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist!")
-
- if os.path.normcase (ActivePlatform).find(Workspace) != 0:
- EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist in Workspace!")
-
- ActivePlatform = ActivePlatform[len(Workspace):]
- if len(ActivePlatform) > 0 :
- if ActivePlatform[0] == '\\' or ActivePlatform[0] == '/':
- ActivePlatform = ActivePlatform[1:]
- else:
- EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist!")
else:
EdkLogger.error("GenFds", OPTION_MISSING, "Missing active platform")
- GenFdsGlobalVariable.ActivePlatform = PathClass(NormPath(ActivePlatform), Workspace)
-
- BuildConfigurationFile = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, "Conf/target.txt"))
+ GenFdsGlobalVariable.ActivePlatform = PathClass(NormPath(ActivePlatform))
+
+ if (Options.ConfDirectory):
+ # Get alternate Conf location, if it is absolute, then just use the absolute directory name
+ ConfDirectoryPath = os.path.normpath(Options.ConfDirectory)
+ if ConfDirectoryPath.startswith('"'):
+ ConfDirectoryPath = ConfDirectoryPath[1:]
+ if ConfDirectoryPath.endswith('"'):
+ ConfDirectoryPath = ConfDirectoryPath[:-1]
+ if not os.path.isabs(ConfDirectoryPath):
+ # Since alternate directory name is not absolute, the alternate directory is located within the WORKSPACE
+ # This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf
+ ConfDirectoryPath = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ConfDirectoryPath)
+ else:
+ # Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf
+ ConfDirectoryPath = mws.join(GenFdsGlobalVariable.WorkSpaceDir, 'Conf')
+ GenFdsGlobalVariable.ConfDir = ConfDirectoryPath
+ BuildConfigurationFile = os.path.normpath(os.path.join(ConfDirectoryPath, "target.txt"))
if os.path.isfile(BuildConfigurationFile) == True:
TargetTxtClassObject.TargetTxtClassObject(BuildConfigurationFile)
else:
EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=BuildConfigurationFile)
+ #Set global flag for build mode
+ GlobalData.gIgnoreSource = Options.IgnoreSources
+
if Options.Macros:
for Pair in Options.Macros:
- Pair = Pair.strip('"')
+ if Pair.startswith('"'):
+ Pair = Pair[1:]
+ if Pair.endswith('"'):
+ Pair = Pair[:-1]
List = Pair.split('=')
if len(List) == 2:
if List[0].strip() == "EFI_SOURCE":
@@ -177,7 +193,8 @@ def main():
os.environ["WORKSPACE"] = Workspace
"""call Workspace build create database"""
- BuildWorkSpace = WorkspaceDatabase(None)
+ GlobalData.gDatabasePath = os.path.normpath(os.path.join(ConfDirectoryPath, GlobalData.gDatabasePath))
+ BuildWorkSpace = WorkspaceDatabase(GlobalData.gDatabasePath)
BuildWorkSpace.InitDatabase()
#
@@ -250,6 +267,14 @@ def main():
EdkLogger.error("GenFds", OPTION_VALUE_INVALID,
"No such a Capsule in FDF file: %s" % Options.uiCapName)
+ GenFdsGlobalVariable.WorkSpace = BuildWorkSpace
+ if ArchList != None:
+ GenFdsGlobalVariable.ArchList = ArchList
+
+ if Options.OptionPcd:
+ GlobalData.BuildOptionPcd = Options.OptionPcd
+ CheckBuildOptionPcd()
+
"""Modify images from build output if the feature of loading driver at fixed address is on."""
if GenFdsGlobalVariable.FixedLoadAddress:
GenFds.PreprocessImage(BuildWorkSpace, GenFdsGlobalVariable.ActivePlatform)
@@ -263,7 +288,7 @@ def main():
GenFds.DisplayFvSpaceInfo(FdfParserObj)
except FdfParser.Warning, X:
- EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError = False)
+ EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError=False)
ReturnCode = FORMAT_INVALID
except FatalError, X:
if Options.debug != None:
@@ -276,11 +301,13 @@ def main():
"\nPython",
CODE_ERROR,
"Tools code failure",
- ExtraData="Please send email to edk2-buildtools-devel@lists.sourceforge.net for help, attaching following call stack trace!\n",
+ ExtraData="Please send email to edk2-devel@lists.01.org for help, attaching following call stack trace!\n",
RaiseError=False
)
EdkLogger.quiet(traceback.format_exc())
ReturnCode = CODE_ERROR
+ finally:
+ ClearDuplicatedInf()
return ReturnCode
gParamCheck = []
@@ -290,6 +317,79 @@ def SingleCheckCallback(option, opt_str, value, parser):
gParamCheck.append(option)
else:
parser.error("Option %s only allows one instance in command line!" % option)
+
+def CheckBuildOptionPcd():
+ for Arch in GenFdsGlobalVariable.ArchList:
+ PkgList = GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag)
+ for i, pcd in enumerate(GlobalData.BuildOptionPcd):
+ if type(pcd) is tuple:
+ continue
+ (pcdname, pcdvalue) = pcd.split('=')
+ if not pcdvalue:
+ EdkLogger.error('GenFds', OPTION_MISSING, "No Value specified for the PCD %s." % (pcdname))
+ if '.' in pcdname:
+ (TokenSpaceGuidCName, TokenCName) = pcdname.split('.')
+ HasTokenSpace = True
+ else:
+ TokenCName = pcdname
+ TokenSpaceGuidCName = ''
+ HasTokenSpace = False
+ TokenSpaceGuidCNameList = []
+ FoundFlag = False
+ PcdDatumType = ''
+ NewValue = ''
+ for package in PkgList:
+ for key in package.Pcds:
+ PcdItem = package.Pcds[key]
+ if HasTokenSpace:
+ if (PcdItem.TokenCName, PcdItem.TokenSpaceGuidCName) == (TokenCName, TokenSpaceGuidCName):
+ PcdDatumType = PcdItem.DatumType
+ NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)
+ FoundFlag = True
+ else:
+ if PcdItem.TokenCName == TokenCName:
+ if not PcdItem.TokenSpaceGuidCName in TokenSpaceGuidCNameList:
+ if len (TokenSpaceGuidCNameList) < 1:
+ TokenSpaceGuidCNameList.append(PcdItem.TokenSpaceGuidCName)
+ PcdDatumType = PcdItem.DatumType
+ TokenSpaceGuidCName = PcdItem.TokenSpaceGuidCName
+ NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)
+ FoundFlag = True
+ else:
+ EdkLogger.error(
+ 'GenFds',
+ PCD_VALIDATION_INFO_ERROR,
+ "The Pcd %s is found under multiple different TokenSpaceGuid: %s and %s." % (TokenCName, PcdItem.TokenSpaceGuidCName, TokenSpaceGuidCNameList[0])
+ )
+
+ GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, NewValue)
+
+def BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, Value):
+ if PcdDatumType == 'VOID*':
+ if Value.startswith('L'):
+ if not Value[1]:
+ EdkLogger.error('GenFds', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"')
+ Value = Value[0] + '"' + Value[1:] + '"'
+ elif Value.startswith('B'):
+ if not Value[1]:
+ EdkLogger.error('GenFds', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"')
+ Value = Value[1:]
+ else:
+ if not Value[0]:
+ EdkLogger.error('GenFds', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"')
+ Value = '"' + Value + '"'
+
+ IsValid, Cause = CheckPcdDatum(PcdDatumType, Value)
+ if not IsValid:
+ EdkLogger.error('build', FORMAT_INVALID, Cause, ExtraData="%s.%s" % (TokenSpaceGuidCName, TokenCName))
+ if PcdDatumType == 'BOOLEAN':
+ Value = Value.upper()
+ if Value == 'TRUE' or Value == '1':
+ Value = '1'
+ elif Value == 'FALSE' or Value == '0':
+ Value = '0'
+ return Value
+
## Parse command line options
#
@@ -300,7 +400,7 @@ def SingleCheckCallback(option, opt_str, value, parser):
#
def myOptionParser():
usage = "%prog [options] -f input_file -a arch_list -b build_target -p active_platform -t tool_chain_tag -D \"MacroName [= MacroValue]\""
- Parser = OptionParser(usage=usage,description=__copyright__,version="%prog " + str(versionNumber))
+ Parser = OptionParser(usage=usage, description=__copyright__, version="%prog " + str(versionNumber))
Parser.add_option("-f", "--file", dest="filename", type="string", help="Name of FDF file to convert", action="callback", callback=SingleCheckCallback)
Parser.add_option("-a", "--arch", dest="archList", help="comma separated list containing one or more of: IA32, X64, IPF, ARM, AARCH64 or EBC which should be built, overrides target.txt?s TARGET_ARCH")
Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")
@@ -321,6 +421,10 @@ def myOptionParser():
action="callback", callback=SingleCheckCallback)
Parser.add_option("-D", "--define", action="append", type="string", dest="Macros", help="Macro: \"Name [= Value]\".")
Parser.add_option("-s", "--specifyaddress", dest="FixedAddress", action="store_true", type=None, help="Specify driver load address.")
+ Parser.add_option("--conf", action="store", type="string", dest="ConfDirectory", help="Specify the customized Conf directory.")
+ Parser.add_option("--ignore-sources", action="store_true", dest="IgnoreSources", default=False, help="Focus to a binary build and ignore all source files")
+ Parser.add_option("--pcd", action="append", dest="OptionPcd", help="Set PCD value by command line. Format: \"PcdName=Value\" ")
+
(Options, args) = Parser.parse_args()
return Options
@@ -474,8 +578,8 @@ class GenFds :
if UsedSizeValue == TotalSizeValue:
Percentage = '100'
else:
- Percentage = str((UsedSizeValue+0.0)/TotalSizeValue)[0:4].lstrip('0.')
-
+ Percentage = str((UsedSizeValue + 0.0) / TotalSizeValue)[0:4].lstrip('0.')
+
GenFdsGlobalVariable.InfLogger(Name + ' ' + '[' + Percentage + '%Full] ' + str(TotalSizeValue) + ' total, ' + str(UsedSizeValue) + ' used, ' + str(FreeSizeValue) + ' free')
## PreprocessImage()