## @file\r
# Global variables for GenFds\r
#\r
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
#\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
import Common.DataType as DataType\r
from Common.Misc import PathClass\r
from Common.LongFilePathSupport import OpenLongFilePath as open\r
+from Common.MultipleWorkspace import MultipleWorkspace as mws\r
\r
## Global variables\r
#\r
BuildRuleFamily = "MSFT"\r
ToolChainFamily = "MSFT"\r
__BuildRuleDatabase = None\r
+ GuidToolDefinition = {}\r
\r
#\r
# The list whose element are flags to indicate if large FFS or SECTION files exist in FV.\r
# @param ArchList The Arch list of platform\r
#\r
def SetDir (OutputDir, FdfParser, WorkSpace, ArchList):\r
- GenFdsGlobalVariable.VerboseLogger( "GenFdsGlobalVariable.OutputDir :%s" %OutputDir)\r
+ GenFdsGlobalVariable.VerboseLogger("GenFdsGlobalVariable.OutputDir :%s" % OutputDir)\r
# GenFdsGlobalVariable.OutputDirDict = OutputDir\r
GenFdsGlobalVariable.FdfParser = FdfParser\r
GenFdsGlobalVariable.WorkSpace = WorkSpace\r
GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir, 'Ffs')\r
if not os.path.exists(GenFdsGlobalVariable.FfsDir) :\r
os.makedirs(GenFdsGlobalVariable.FfsDir)\r
- if ArchList != None:\r
- GenFdsGlobalVariable.ArchList = ArchList\r
\r
T_CHAR_LF = '\n'\r
#\r
# Create FV Address inf file\r
#\r
GenFdsGlobalVariable.FvAddressFileName = os.path.join(GenFdsGlobalVariable.FfsDir, 'FvAddress.inf')\r
- FvAddressFile = open (GenFdsGlobalVariable.FvAddressFileName, 'w')\r
+ FvAddressFile = open(GenFdsGlobalVariable.FvAddressFileName, 'w')\r
#\r
# Add [Options]\r
#\r
break\r
\r
FvAddressFile.writelines("EFI_BOOT_DRIVER_BASE_ADDRESS = " + \\r
- BsAddress + \\r
+ BsAddress + \\r
T_CHAR_LF)\r
\r
RtAddress = '0'\r
RtAddress = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].RtBaseAddress\r
\r
FvAddressFile.writelines("EFI_RUNTIME_DRIVER_BASE_ADDRESS = " + \\r
- RtAddress + \\r
+ RtAddress + \\r
T_CHAR_LF)\r
\r
FvAddressFile.close()\r
# @param String String that may contain macro\r
#\r
def ReplaceWorkspaceMacro(String):\r
+ String = mws.handleWsMacro(String)\r
Str = String.replace('$(WORKSPACE)', GenFdsGlobalVariable.WorkSpaceDir)\r
if os.path.exists(Str):\r
if not os.path.isabs(Str):\r
Str = os.path.abspath(Str)\r
else:\r
- Str = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, String)\r
+ Str = mws.join(GenFdsGlobalVariable.WorkSpaceDir, String)\r
return os.path.normpath(Str)\r
\r
## Check if the input files are newer than output files\r
CommandFile = Output + '.txt'\r
if Ui not in [None, '']:\r
#Cmd += ["-n", '"' + Ui + '"']\r
- SectionData = array.array('B', [0,0,0,0])\r
+ SectionData = array.array('B', [0, 0, 0, 0])\r
SectionData.fromstring(Ui.encode("utf_16_le"))\r
SectionData.append(0)\r
SectionData.append(0)\r
Len = len(SectionData)\r
GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15)\r
- SaveFileOnChange(Output, SectionData.tostring())\r
+ SaveFileOnChange(Output, SectionData.tostring())\r
elif Ver not in [None, '']:\r
Cmd += ["-n", Ver]\r
if BuildNumber:\r
def GetAlignment (AlignString):\r
if AlignString == None:\r
return 0\r
- if AlignString in ("1K", "2K", "4K", "8K", "16K", "32K", "64K"):\r
+ if AlignString in ("1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "256K", "512K"):\r
return int (AlignString.rstrip('K')) * 1024\r
+ elif AlignString in ("1M", "2M", "4M", "8M", "16M"):\r
+ return int (AlignString.rstrip('M')) * 1024 * 1024\r
else:\r
return int (AlignString)\r
\r
def GenerateFfs(Output, Input, Type, Guid, Fixed=False, CheckSum=False, Align=None,\r
SectionAlign=None):\r
Cmd = ["GenFfs", "-t", Type, "-g", Guid]\r
+ mFfsValidAlign = ["0", "8", "16", "128", "512", "1K", "4K", "32K", "64K", "128K", "256K", "512K", "1M", "2M", "4M", "8M", "16M"]\r
if Fixed == True:\r
Cmd += ["-x"]\r
if CheckSum:\r
Cmd += ["-s"]\r
if Align not in [None, '']:\r
+ if Align not in mFfsValidAlign:\r
+ Align = GenFdsGlobalVariable.GetAlignment (Align)\r
+ for index in range(0, len(mFfsValidAlign) - 1):\r
+ if ((Align > GenFdsGlobalVariable.GetAlignment(mFfsValidAlign[index])) and (Align <= GenFdsGlobalVariable.GetAlignment(mFfsValidAlign[index + 1]))):\r
+ break\r
+ Align = mFfsValidAlign[index + 1]\r
Cmd += ["-a", Align]\r
\r
Cmd += ["-o", Output]\r
Cmd = ["GenFv"]\r
if BaseAddress not in [None, '']:\r
Cmd += ["-r", BaseAddress]\r
- \r
+\r
if ForceRebase == False:\r
- Cmd +=["-F", "FALSE"]\r
+ Cmd += ["-F", "FALSE"]\r
elif ForceRebase == True:\r
- Cmd +=["-F", "TRUE"]\r
- \r
+ Cmd += ["-F", "TRUE"]\r
+\r
if Capsule:\r
Cmd += ["-c"]\r
if Dump:\r
if VendorId != None:\r
Cmd += ["-f", VendorId]\r
\r
- Cmd += ["-o", Output] \r
+ Cmd += ["-o", Output]\r
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate option rom")\r
\r
@staticmethod\r
sys.stdout.write('\n')\r
\r
try:\r
- PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr= subprocess.PIPE, shell=True)\r
+ PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
except Exception, X:\r
EdkLogger.error("GenFds", COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0]))\r
(out, error) = PopenObject.communicate()\r
returnValue[0] = PopenObject.returncode\r
return\r
if PopenObject.returncode != 0 or GenFdsGlobalVariable.VerboseMode or GenFdsGlobalVariable.DebugLevel != -1:\r
- GenFdsGlobalVariable.InfLogger ("Return Value = %d" %PopenObject.returncode)\r
+ GenFdsGlobalVariable.InfLogger ("Return Value = %d" % PopenObject.returncode)\r
GenFdsGlobalVariable.InfLogger (out)\r
GenFdsGlobalVariable.InfLogger (error)\r
if PopenObject.returncode != 0:\r
def InfLogger (msg):\r
EdkLogger.info(msg)\r
\r
- def ErrorLogger (msg, File = None, Line = None, ExtraData = None):\r
+ def ErrorLogger (msg, File=None, Line=None, ExtraData=None):\r
EdkLogger.error('GenFds', GENFDS_ERROR, msg, File, Line, ExtraData)\r
\r
def DebugLogger (Level, msg):\r
# @param Str String that may contain macro\r
# @param MacroDict Dictionary that contains macro value pair\r
#\r
- def MacroExtend (Str, MacroDict = {}, Arch = 'COMMON'):\r
+ def MacroExtend (Str, MacroDict={}, Arch='COMMON'):\r
if Str == None :\r
return None\r
\r
\r
PcdValue = PcdObj.DefaultValue\r
return PcdValue\r
- \r
- for Package in GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform, \r
- Arch, \r
- GenFdsGlobalVariable.TargetName, \r
+\r
+ for Package in GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform,\r
+ Arch,\r
+ GenFdsGlobalVariable.TargetName,\r
GenFdsGlobalVariable.ToolChainTag):\r
PcdDict = Package.Pcds\r
for Key in PcdDict:\r