#\r
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+# Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
#\r
-# Filename: build_rule.template\r
-#\r
\r
## Syntax\r
#\r
$(MAKE_FILE)\r
\r
<Command.MSFT, Command.INTEL>\r
- Trim --asl-file -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i ${src}\r
+ Trim --asl-file -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i -i $(INC_LIST) ${src}\r
"$(ASLPP)" $(ASLPP_FLAGS) $(INC) /I${s_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii\r
- "$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii\r
+ Trim --source-code -l -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii \r
+ "$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii\r
\r
<Command.GCC>\r
- Trim --asl-file -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i ${src}\r
+ Trim --asl-file -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i -i $(INC_LIST) ${src}\r
"$(ASLPP)" $(ASLPP_FLAGS) $(INC) -I${s_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii\r
"$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii\r
\r
<InputFile>\r
*.hpk\r
\r
- <OutputFile>\r
+ <OutputFile.MSFT, OutputFile.INTEL, OutputFile.GCC>\r
$(OUTPUT_DIR)(+)$(MODULE_NAME)hii.lib\r
\r
+ <OutputFile.XCODE, OutputFile.RVCT, OutputFile.ARMGCC>\r
+ $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc\r
+\r
<Command.MSFT, Command.INTEL>\r
"$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiipackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)\r
"$(RC)" /Fo${dst} $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc\r
<Command.GCC>\r
"$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiibinpackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)\r
"$(RC)" $(RC_FLAGS) $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc ${dst}\r
+ \r
+ <Command.XCODE, Command.RVCT, Command.ARMGCC> \r
+ GenFw -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiibinpackage $(HII_BINARY_PACKAGES)\r
+ \r
+ \r
#\r
-# Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2006 - 2010, 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
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
#\r
-# Filename: target.template\r
#\r
# ALL Paths are Relative to WORKSPACE\r
\r
DEFINE VS2003_DLL = C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\r
\r
DEFINE VS2005_BIN = C:\Program Files\Microsoft Visual Studio 8\Vc\bin\r
-DEFINE VS2005_DLL = C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\r
+DEFINE VS2005_DLL = C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;DEF(VS2005_BIN)\r
DEFINE VS2005_BINX64 = C:\Program Files\Microsoft Visual Studio 8\Vc\bin\x86_amd64\r
DEFINE VS2005_BIN64 = C:\Program Files\Microsoft Visual Studio 8\Vc\bin\x86_ia64\r
\r
DEFINE VS2005x86_BIN = C:\Program Files (x86)\Microsoft Visual Studio 8\Vc\bin\r
-DEFINE VS2005x86_DLL = C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\r
+DEFINE VS2005x86_DLL = C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE;DEF(VS2005x86_BIN)\r
DEFINE VS2005x86_BINX64 = DEF(VS2005x86_BIN)\x86_amd64\r
DEFINE VS2005x86_BIN64 = DEF(VS2005x86_BIN)\x86_ia64\r
\r
DEFINE VS2008_BIN = C:\Program Files\Microsoft Visual Studio 9.0\Vc\bin\r
-DEFINE VS2008_DLL = C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\r
+DEFINE VS2008_DLL = C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE;DEF(VS2008_BIN)\r
DEFINE VS2008_BINX64 = DEF(VS2008_BIN)\x86_amd64\r
DEFINE VS2008_BIN64 = DEF(VS2008_BIN)\x86_ia64\r
\r
DEFINE VS2008x86_BIN = C:\Program Files (x86)\Microsoft Visual Studio 9.0\Vc\bin\r
-DEFINE VS2008x86_DLL = C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\r
+DEFINE VS2008x86_DLL = C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE;DEF(VS2008x86_BIN)\r
DEFINE VS2008x86_BINX64 = DEF(VS2008x86_BIN)\x86_amd64\r
DEFINE VS2008x86_BIN64 = DEF(VS2008x86_BIN)\x86_ia64\r
\r
#DEFINE DEFAULT_WIN_ASL_FLAGS = DEF(MS_ASL_FLAGS)\r
#DEFINE DEFAULT_WIN_ASL_OUTFLAGS = DEF(MS_ASL_OUTFLAGS)\r
\r
-DEFINE MSFT_ASLPP_FLAGS = /nologo /EP /C\r
+DEFINE MSFT_ASLPP_FLAGS = /nologo /E /C /FIAutoGen.h\r
DEFINE MSFT_ASLCC_FLAGS = /GL- /Y- /TC /Dmain=ReferenceAcpiTable\r
DEFINE MSFT_ASLDLINK_FLAGS = /NODEFAULTLIB /ENTRY:ReferenceAcpiTable /SUBSYSTEM:CONSOLE\r
\r
-DEFINE ICC_WIN_ASLPP_FLAGS = /nologo /EP /C\r
+DEFINE ICC_WIN_ASLPP_FLAGS = /nologo /E /C /FIAutoGen.h\r
DEFINE ICC_WIN_ASLCC_FLAGS = /Y- /TC /WX- /Od /Dmain=ReferenceAcpiTable\r
DEFINE ICC_WIN_ASLDLINK_FLAGS = /NODEFAULTLIB /ENTRY:ReferenceAcpiTable /SUBSYSTEM:CONSOLE /NODEFAULTLIB:libmmt /NODEFAULTLIB:libirc\r
\r
#define EFI_IMAGE_REL_BASED_HIGHLOW 3\r
#define EFI_IMAGE_REL_BASED_HIGHADJ 4\r
#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR 5\r
+#define EFI_IMAGE_REL_BASED_ARM_MOV32A 5\r
+#define EFI_IMAGE_REL_BASED_ARM_MOV32T 7\r
#define EFI_IMAGE_REL_BASED_IA64_IMM64 9\r
#define EFI_IMAGE_REL_BASED_DIR64 10\r
\r
\r
# parse FDF file to get PCDs in it, if any\r
if self.FdfFile != None and self.FdfFile != '':\r
+ #\r
+ # Make global macros available when parsing FDF file\r
+ #\r
+ InputMacroDict.update(self.BuildDatabase.WorkspaceDb._GlobalMacros)\r
Fdf = FdfParser(self.FdfFile.Path)\r
Fdf.ParseFile()\r
PcdSet = Fdf.Profile.PcdDict\r
DecPcdEntry = eachDec.Pcds[DecPcd]\r
if (DecPcdEntry.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \\r
(DecPcdEntry.TokenCName == DscPcdEntry.TokenCName):\r
+ # Print warning message to let the developer make a determine.\r
+ EdkLogger.warn("build", "Unreferenced vpd pcd used!",\r
+ File=self.MetaFile, \\r
+ ExtraData = "PCD: %s.%s used in the DSC file %s is unreferenced." \\r
+ %(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, self.Platform.MetaFile.Path)) \r
+ \r
DscPcdEntry.DatumType = DecPcdEntry.DatumType\r
DscPcdEntry.DefaultValue = DecPcdEntry.DefaultValue\r
- Sku.DefaultValue = DecPcdEntry.DefaultValue \r
+ # Only fix the value while no value provided in DSC file.\r
+ if (Sku.DefaultValue == "" or Sku.DefaultValue==None):\r
+ DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]].DefaultValue = DecPcdEntry.DefaultValue\r
+ \r
\r
VpdFile.Add(DscPcdEntry, Sku.VpdOffset)\r
# if the offset of a VPD is *, then it need to be fixed up by third party tool.\r
except:\r
EdkLogger.error("build", FILE_WRITE_FAILURE, "Fail to create FV folder under %s" % self.BuildDir)\r
\r
- VpdFileName = self.Platform.VpdFileName \r
- if VpdFileName == None or VpdFileName == "" :\r
- VpdFilePath = os.path.join(FvPath, "%s.txt" % self.Platform.VpdToolGuid)\r
- else :\r
- VpdFilePath = os.path.join(FvPath, "%s.txt" % VpdFileName) \r
+ \r
+ VpdFilePath = os.path.join(FvPath, "%s.txt" % self.Platform.VpdToolGuid)\r
+\r
\r
if not os.path.exists(VpdFilePath) or os.path.getmtime(VpdFilePath) < DscTimeStamp:\r
VpdFile.Write(VpdFilePath)\r
break\r
# Call third party GUID BPDG tool.\r
if BPDGToolName != None:\r
- VpdInfoFile.CallExtenalBPDGTool(BPDGToolName, VpdFilePath, VpdFileName)\r
+ VpdInfoFile.CallExtenalBPDGTool(BPDGToolName, VpdFilePath)\r
else:\r
EdkLogger.error("Build", FILE_NOT_FOUND, "Fail to find third-party BPDG tool to process VPD PCDs. BPDG Guid tool need to be defined in tools_def.txt and VPD_TOOL_GUID need to be provided in DSC file.")\r
\r
# Process VPD map file generated by third party BPDG tool\r
if NeedProcessVpdMapFile:\r
- if VpdFileName == None or VpdFileName == "" :\r
- VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)\r
- else :\r
- VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % VpdFileName)\r
+ VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)\r
if os.path.exists(VpdMapFilePath):\r
VpdFile.Read(VpdMapFilePath)\r
\r
self._SourceFileList = []\r
for F in self.Module.Sources:\r
# match tool chain\r
- if F.TagName != "" and F.TagName != self.ToolChain:\r
+ if F.TagName not in ("", "*", self.ToolChain):\r
EdkLogger.debug(EdkLogger.DEBUG_9, "The toolchain [%s] for processing file [%s] is found, "\r
"but [%s] is needed" % (F.TagName, str(F), self.ToolChain))\r
continue\r
# match tool chain family\r
- if F.ToolChainFamily != "" and F.ToolChainFamily != self.ToolChainFamily:\r
+ if F.ToolChainFamily not in ("", "*", self.ToolChainFamily):\r
EdkLogger.debug(\r
EdkLogger.DEBUG_0,\r
"The file [%s] must be built by tools of [%s], " \\r
self._ApplyBuildRule(Lib.Target, TAB_UNKNOWN_FILE)\r
return self._LibraryAutoGenList\r
\r
- ## Return build command string\r
- #\r
- # @retval string Build command string\r
- #\r
- def _GetBuildCommand(self):\r
- return self.PlatformInfo.BuildCommand\r
-\r
-\r
Module = property(_GetModule)\r
Name = property(_GetBaseName)\r
Guid = property(_GetGuid)\r
import Common.GlobalData as GlobalData
## Regular expression for finding header file inclusions
-gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:[\"<]?[ \t]*)([\w.\\/() \t]+)(?:[ \t]*[\">]?)", re.MULTILINE|re.UNICODE|re.IGNORECASE)
+gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:\(?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)", re.MULTILINE|re.UNICODE|re.IGNORECASE)
## Regular expression for matching macro used in header file inclusion
gMacroPattern = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE)
Inc = os.path.normpath(Inc)
for SearchPath in [CurrentFilePath] + SearchPathList:
FilePath = os.path.join(SearchPath, Inc)
- if not os.path.exists(FilePath) or FilePath in CurrentFileDependencyList:
+ if not os.path.isfile(FilePath) or FilePath in CurrentFileDependencyList:
continue
FilePath = PathClass(FilePath)
CurrentFileDependencyList.append(FilePath)
# Add a string to list\r
#\r
def AddStringToList(self, Name, Language, Value, Token = None, Referenced = False, UseOtherLangDef = '', Index = -1):\r
+ for LangNameItem in self.LanguageDef:\r
+ if Language == LangNameItem[0]:\r
+ break\r
+ else:\r
+ EdkLogger.error('Unicode File Parser', FORMAT_NOT_SUPPORTED, "The language '%s' for %s is not defined in Unicode file %s." \\r
+ % (Language, Name, self.File))\r
+ \r
if Language not in self.OrderedStringList:\r
self.OrderedStringList[Language] = []\r
\r
import encodings.ascii\r
\r
from optparse import OptionParser\r
-from encodings import gbk\r
from Common import EdkLogger\r
from Common.BuildToolError import *\r
\r
\r
# Initialize log system\r
EdkLogger.Initialize() \r
- Options, Args = myOptionParser()\r
+ Options, Args = MyOptionParser()\r
\r
ReturnCode = 0\r
\r
- if Options.opt_slient:\r
- EdkLogger.SetLevel(EdkLogger.ERROR)\r
- elif Options.opt_verbose:\r
+ if Options.opt_verbose:\r
EdkLogger.SetLevel(EdkLogger.VERBOSE)\r
elif Options.opt_quiet:\r
EdkLogger.SetLevel(EdkLogger.QUIET)\r
else:\r
EdkLogger.SetLevel(EdkLogger.INFO)\r
\r
- if Options.vpd_filename == None:\r
+ if Options.bin_filename == None:\r
EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, "Please use the -o option to specify the file name for the VPD binary file") \r
if Options.filename == None:\r
EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, "Please use the -m option to specify the file name for the mapping file") \r
Force = True\r
\r
if (Args[0] != None) :\r
- startBPDG(Args[0], Options.filename, Options.vpd_filename, Force)\r
+ StartBpdg(Args[0], Options.filename, Options.bin_filename, Force)\r
else :\r
EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, "Please specify the file which contain the VPD pcd info.",\r
None) \r
\r
return ReturnCode\r
- \r
-def myOptionParser(): \r
+\r
+\r
+## Parse command line options\r
+#\r
+# Using standard Python module optparse to parse command line option of this tool.\r
+#\r
+# @retval options A optparse.Values object containing the parsed options\r
+# @retval args Target of BPDG command\r
+# \r
+def MyOptionParser(): \r
#\r
# Process command line firstly.\r
#\r
help=st.MSG_OPTION_DEBUG_LEVEL)\r
parser.add_option('-v', '--verbose', action='store_true', dest='opt_verbose',\r
help=st.MSG_OPTION_VERBOSE)\r
- parser.add_option('-s', '--silent', action='store_true', dest='opt_slient', default=False,\r
- help=st.MSG_OPTION_SILENT)\r
parser.add_option('-q', '--quiet', action='store_true', dest='opt_quiet', default=False,\r
help=st.MSG_OPTION_QUIET)\r
- parser.add_option('-o', '--vpd-filename', action='store', dest='vpd_filename',\r
+ parser.add_option('-o', '--vpd-filename', action='store', dest='bin_filename',\r
help=st.MSG_OPTION_VPD_FILENAME)\r
parser.add_option('-m', '--map-filename', action='store', dest='filename',\r
help=st.MSG_OPTION_MAP_FILENAME) \r
EdkLogger.info(parser.usage)\r
sys.exit(1)\r
return options, args\r
- \r
-def startBPDG(InputFileName, MapFileName, VpdFileName, Force):\r
+\r
+\r
+## Start BPDG and call the main functions \r
+#\r
+# This method mainly focus on call GenVPD class member functions to complete\r
+# BPDG's target. It will process VpdFile override, and provide the interface file\r
+# information.\r
+#\r
+# @Param InputFileName The filename include the vpd type pcd information\r
+# @param MapFileName The filename of map file that stores vpd type pcd information.\r
+# This file will be generated by the BPDG tool after fix the offset\r
+# and adjust the offset to make the pcd data aligned.\r
+# @param VpdFileName The filename of Vpd file that hold vpd pcd information.\r
+# @param Force Override the exist Vpdfile or not.\r
+#\r
+def StartBpdg(InputFileName, MapFileName, VpdFileName, Force):\r
if os.path.exists(VpdFileName) and not Force:\r
print "\nFile %s already exist, Overwrite(Yes/No)?[Y]: " % VpdFileName\r
choice = sys.stdin.readline()\r
8: 'Q'\r
}\r
\r
+## The VPD PCD data structure for store and process each VPD PCD entry.\r
+#\r
+# This class contain method to format and pack pcd's value. \r
+#\r
class PcdEntry:\r
def __init__(self, PcdCName, PcdOffset, PcdSize, PcdValue, Lineno=None, FileName=None, PcdUnpackValue=None, \r
PcdBinOffset=None, PcdBinSize=None):\r
"Invalid PCD format(Name: %s File: %s Line: %s), no PcdSize specified!" %(self.PcdCName, self.FileName, self.Lineno)) \r
\r
self._GenOffsetValue ()\r
+ \r
+ ## Analyze the string value to judge the PCD's datum type euqal to Boolean or not.\r
+ # \r
+ # @param ValueString PCD's value\r
+ # @param Size PCD's size\r
+ # \r
+ # @retval True PCD's datum type is Boolean\r
+ # @retval False PCD's datum type is not Boolean. \r
+ # \r
+ def _IsBoolean(self, ValueString, Size):\r
+ if (Size == "1"):\r
+ if ValueString.upper() in ["TRUE", "FALSE"]:\r
+ return True\r
+ elif ValueString in ["0", "1", "0x0", "0x1", "0x00", "0x01"]:\r
+ return True \r
\r
- def _IsBoolean(self, ValueString):\r
- if ValueString.upper() in ["TRUE", "FALSE"]:\r
- return True\r
return False\r
\r
+ ## Convert the PCD's value from string to integer.\r
+ # \r
+ # This function will try to convert the Offset value form string to integer\r
+ # for both hexadecimal and decimal.\r
+ # \r
def _GenOffsetValue(self):\r
if self.PcdOffset != "*" :\r
try:\r
except:\r
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
"Invalid offset value %s for PCD %s (File: %s Line: %s)" % (self.PcdOffset, self.PcdCName, self.FileName, self.Lineno)) \r
- \r
+ \r
+ ## Pack Boolean type VPD PCD's value form string to binary type.\r
+ # \r
+ # @param ValueString The boolean type string for pack.\r
+ # \r
+ # \r
def _PackBooleanValue(self, ValueString):\r
- if ValueString.upper() == "TRUE":\r
+ if ValueString.upper() == "TRUE" or ValueString in ["1", "0x1", "0x01"]:\r
try: \r
self.PcdValue = pack(_FORMAT_CHAR[1], 1)\r
except:\r
self.PcdValue = pack(_FORMAT_CHAR[1], 0)\r
except:\r
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
- "Invalid size or value for PCD %s to pack(File: %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno)) \r
- \r
+ "Invalid size or value for PCD %s to pack(File: %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno)) \r
+ \r
+ ## Pack Integer type VPD PCD's value form string to binary type.\r
+ # \r
+ # @param ValueString The Integer type string for pack.\r
+ # \r
+ # \r
def _PackIntValue(self, IntValue, Size):\r
if Size not in _FORMAT_CHAR.keys():\r
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
"Invalid size %d for PCD %s in integer datum size(File: %s Line: %s)." % (Size, self.PcdCName, self.FileName, self.Lineno)) \r
+ \r
+ if Size == 1: \r
+ if IntValue < 0:\r
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
+ "PCD can't be set to negative value %d for PCD %s in UINT8 datum type(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))\r
+ elif IntValue >= 0x100:\r
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
+ "Too large PCD value %d for datum type UINT8 for PCD %s(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno)) \r
+ elif Size == 2:\r
+ if IntValue < 0:\r
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
+ "PCD can't be set to negative value %d for PCD %s in UINT16 datum type(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))\r
+ elif IntValue >= 0x10000:\r
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
+ "Too large PCD value %d for datum type UINT16 for PCD %s(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno)) \r
+ elif Size == 4:\r
+ if IntValue < 0:\r
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
+ "PCD can't be set to negative value %d for PCD %s in UINT32 datum type(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))\r
+ elif IntValue >= 0x100000000:\r
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
+ "Too large PCD value %d for datum type UINT32 for PCD %s(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))\r
+ elif Size == 8:\r
+ if IntValue < 0:\r
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
+ "PCD can't be set to negative value %d for PCD %s in UINT32 datum type(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))\r
+ elif IntValue >= 0x10000000000000000:\r
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
+ "Too large PCD value %d for datum type UINT32 for PCD %s(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))\r
+ else:\r
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
+ "Invalid size %d for PCD %s in integer datum size(File: %s Line: %s)." % (Size, self.PcdCName, self.FileName, self.Lineno)) \r
+ \r
try:\r
self.PcdValue = pack(_FORMAT_CHAR[Size], IntValue)\r
except:\r
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
"Invalid size or value for PCD %s to pack(File: %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno)) \r
- \r
+\r
+ ## Pack VOID* type VPD PCD's value form string to binary type.\r
+ #\r
+ # The VOID* type of string divided into 3 sub-type:\r
+ # 1: L"String", Unicode type string.\r
+ # 2: "String", Ascii type string.\r
+ # 3: {bytearray}, only support byte-array.\r
+ #\r
+ # @param ValueString The Integer type string for pack.\r
+ # \r
def _PackPtrValue(self, ValueString, Size):\r
if ValueString.startswith('L"'):\r
self._PackUnicode(ValueString, Size)\r
else:\r
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
"Invalid VOID* type PCD %s value %s (File: %s Line: %s)" % (self.PcdCName, ValueString, self.FileName, self.Lineno)) \r
- \r
+ \r
+ ## Pack an Ascii PCD value.\r
+ # \r
+ # An Ascii string for a PCD should be in format as "".\r
+ # \r
def _PackString(self, ValueString, Size):\r
if (Size < 0):\r
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
self.PcdValue= pack('%ds' % Size, ValueString)\r
except:\r
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, \r
- "Invalid size or value for PCD %s to pack(File: %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno)) \r
- \r
+ "Invalid size or value for PCD %s to pack(File: %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno)) \r
+ \r
+ ## Pack a byte-array PCD value.\r
+ # \r
+ # A byte-array for a PCD should be in format as {0x01, 0x02, ...}.\r
+ # \r
def _PackByteArray(self, ValueString, Size):\r
if (Size < 0): \r
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid parameter Size %s of PCD %s!(File: %s Line: %s)" % (self.PcdBinSize, self.PcdCName, self.FileName, self.Lineno))\r
ReturnArray.append(0)\r
\r
self.PcdValue = ReturnArray.tolist() \r
- \r
-class GenVPD :\r
- \r
+\r
+\r
+\r
+## The class implementing the BPDG VPD PCD offset fix process\r
+#\r
+# The VPD PCD offset fix process includes:\r
+# 1. Parse the input guided.txt file and store it in the data structure;\r
+# 2. Format the input file data to remove unused lines;\r
+# 3. Fixed offset if needed;\r
+# 4. Generate output file, including guided.map and guided.bin file;\r
+# \r
+class GenVPD : \r
## Constructor of DscBuildData\r
#\r
# Initialize object of GenVPD\r
except:\r
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid PCD size value %s at file: %s line: %s" % (PCD.PcdSize, self.InputFileName, PCD.Lineno))\r
\r
- if PCD._IsBoolean(PCD.PcdValue):\r
+ if PCD._IsBoolean(PCD.PcdValue, PCD.PcdSize):\r
PCD._PackBooleanValue(PCD.PcdValue)\r
self.FileLinesList[count] = PCD\r
count += 1\r
Copyright (c) 2010 Intel Corporation All Rights Reserved.\r
\r
Required Flags:\r
- -o VPD_FILENAME, --vpd-filename=VPD_FILENAME\r
+ -o BIN_FILENAME, --vpd-filename=BIN_FILENAME\r
Specify the file name for the VPD binary file\r
-m FILENAME, --map-filename=FILENAME\r
Generate file name for consumption during the build that contains \r
MSG_OPTION_HELP = ("Show this help message and exit.")\r
MSG_OPTION_DEBUG_LEVEL = ("Print DEBUG statements, where DEBUG_LEVEL is 0-9.")\r
MSG_OPTION_VERBOSE = ("Print informational statements.")\r
-MSG_OPTION_SILENT = ("Only the exit code will be returned, all informational and error messages will not be displayed.")\r
MSG_OPTION_QUIET = ("Returns the exit code and will display only error messages.")\r
MSG_OPTION_VPD_FILENAME = ("Specify the file name for the VPD binary file.")\r
MSG_OPTION_MAP_FILENAME = ("Generate file name for consumption during the build that contains the mapping of Pcd name, offset, datum size and value derived from the input file and any automatic calculations.")\r
-MSG_OPTION_FORCE = ("Disable prompting the user for overwriting files as well as for missing input content.")\r
+MSG_OPTION_FORCE = ("Will force overwriting existing output files rather than returning an error message.")\r
\r
ERR_INVALID_DEBUG_LEVEL = ("Invalid level for debug message. Only "\r
"'DEBUG', 'INFO', 'WARNING', 'ERROR', "\r
## @file
# Standardized Error Hanlding infrastructures.
#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 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
RESOURCE_FULL : "Full",
RESOURCE_OVERFLOW : "Overflow",
RESOURCE_UNDERRUN : "Underrun",
- RESOURCE_UNKNOWN_ERROR : "Unkown error",
+ RESOURCE_UNKNOWN_ERROR : "Unknown error",
ATTRIBUTE_NOT_AVAILABLE : "Not available",
ATTRIBUTE_GET_FAILURE : "Failed to retrieve",
TAB_DSC_DEFINES_RT_BASE_ADDRESS = 'RtBaseAddress'\r
TAB_DSC_DEFINES_DEFINE = 'DEFINE'\r
TAB_DSC_DEFINES_VPD_TOOL_GUID = 'VPD_TOOL_GUID'\r
-TAB_DSC_DEFINES_VPD_FILENAME = 'VPD_FILENAME'\r
TAB_FIX_LOAD_TOP_MEMORY_ADDRESS = 'FIX_LOAD_TOP_MEMORY_ADDRESS'\r
\r
#\r
TAB_TAT_DEFINES_ACTIVE_PLATFORM = 'ACTIVE_PLATFORM'\r
TAB_TAT_DEFINES_ACTIVE_MODULE = 'ACTIVE_MODULE'\r
TAB_TAT_DEFINES_TOOL_CHAIN_CONF = 'TOOL_CHAIN_CONF'\r
-TAB_TAT_DEFINES_MULTIPLE_THREAD = 'MULTIPLE_THREAD'\r
TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER = 'MAX_CONCURRENT_THREAD_NUMBER'\r
TAB_TAT_DEFINES_TARGET = 'TARGET'\r
TAB_TAT_DEFINES_TOOL_CHAIN_TAG = 'TOOL_CHAIN_TAG'\r
# @retval 1 Open file failed\r
#\r
def ConvertTextFileToDictionary(FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):\r
- try:\r
- F = open(FileName,'r')\r
- Keys = []\r
- for Line in F:\r
- if Line.startswith(CommentCharacter):\r
- continue\r
- LineList = Line.split(KeySplitCharacter,1)\r
- if len(LineList) >= 2:\r
- Key = LineList[0].split()\r
- if len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] not in Keys:\r
- if ValueSplitFlag:\r
- Dictionary[Key[0]] = LineList[1].replace('\\','/').split(ValueSplitCharacter)\r
- else:\r
- Dictionary[Key[0]] = LineList[1].strip().replace('\\','/')\r
- Keys += [Key[0]]\r
- F.close()\r
- return 0\r
- except:\r
- EdkLogger.info('Open file failed')\r
- return 1\r
+ try:\r
+ F = open(FileName,'r')\r
+ Keys = []\r
+ for Line in F:\r
+ if Line.startswith(CommentCharacter):\r
+ continue\r
+ LineList = Line.split(KeySplitCharacter,1)\r
+ if len(LineList) >= 2:\r
+ Key = LineList[0].split()\r
+ if len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] not in Keys:\r
+ if ValueSplitFlag:\r
+ Dictionary[Key[0]] = LineList[1].replace('\\','/').split(ValueSplitCharacter)\r
+ else:\r
+ Dictionary[Key[0]] = LineList[1].strip().replace('\\','/')\r
+ Keys += [Key[0]]\r
+ F.close()\r
+ return 0\r
+ except:\r
+ EdkLogger.info('Open file failed')\r
+ return 1\r
\r
## Print the dictionary\r
#\r
# @param Dict: The dictionary to be printed\r
#\r
def printDict(Dict):\r
- if Dict != None:\r
- KeyList = Dict.keys()\r
- for Key in KeyList:\r
- if Dict[Key] != '':\r
- print Key + ' = ' + str(Dict[Key])\r
+ if Dict != None:\r
+ KeyList = Dict.keys()\r
+ for Key in KeyList:\r
+ if Dict[Key] != '':\r
+ print Key + ' = ' + str(Dict[Key])\r
\r
## Print the dictionary\r
#\r
# @param key: The key of the item to be printed\r
#\r
def printList(Key, List):\r
- if type(List) == type([]):\r
- if len(List) > 0:\r
- if key.find(TAB_SPLIT) != -1:\r
- print "\n" + Key\r
- for Item in List:\r
- print Item\r
+ if type(List) == type([]):\r
+ if len(List) > 0:\r
+ if Key.find(TAB_SPLIT) != -1:\r
+ print "\n" + Key\r
+ for Item in List:\r
+ print Item\r
from GlobalData import *\r
from BuildToolError import *\r
\r
+gHexVerPatt = re.compile('0x[a-f0-9]{4}[a-f0-9]{4}$',re.IGNORECASE)\r
+gHumanReadableVerPatt = re.compile(r'([1-9][0-9]*|0)\.[0-9]{1,2}$')\r
+\r
## GetSplitValueList\r
#\r
# Get a value list from a string with multiple values splited with SplitTag\r
String = CleanString(String)\r
return String[String.find(Key + ' ') + len(Key + ' ') : ]\r
\r
+## GetHexVerValue\r
+#\r
+# Get a Hex Version Value\r
+#\r
+# @param VerString: The version string to be parsed\r
+#\r
+#\r
+# @retval: If VerString is incorrectly formatted, return "None" which will break the build.\r
+# If VerString is correctly formatted, return a Hex value of the Version Number (0xmmmmnnnn)\r
+# where mmmm is the major number and nnnn is the adjusted minor number.\r
+#\r
+def GetHexVerValue(VerString):\r
+ VerString = CleanString(VerString)\r
+\r
+ if gHumanReadableVerPatt.match(VerString):\r
+ ValueList = VerString.split('.')\r
+ Major = ValueList[0]\r
+ Minor = ValueList[1]\r
+ if len(Minor) == 1:\r
+ Minor += '0'\r
+ DeciValue = (int(Major) << 16) + int(Minor);\r
+ return "0x%08x"%DeciValue\r
+ elif gHexVerPatt.match(VerString):\r
+ return VerString\r
+ else:\r
+ return None\r
+\r
+\r
## GetSingleValueOfKeyFromLines\r
#\r
# Parse multiple strings as below to get value of each definition line\r
## @file\r
# This file is used to define each component of Target.txt file\r
#\r
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM : '',\r
DataType.TAB_TAT_DEFINES_ACTIVE_MODULE : '',\r
DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF : '',\r
- DataType.TAB_TAT_DEFINES_MULTIPLE_THREAD : '',\r
DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER : '',\r
DataType.TAB_TAT_DEFINES_TARGET : [],\r
DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG : [],\r
elif Key in [DataType.TAB_TAT_DEFINES_TARGET, DataType.TAB_TAT_DEFINES_TARGET_ARCH, \\r
DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG]:\r
self.TargetTxtDictionary[Key] = Value.split()\r
- elif Key == DataType.TAB_TAT_DEFINES_MULTIPLE_THREAD:\r
- if Value not in ["Enable", "Disable"]:\r
- EdkLogger.error("build", FORMAT_INVALID, "Invalid setting of [%s]: %s." % (Key, Value),\r
- ExtraData="\tSetting must be one of [Enable, Disable]",\r
- File=FileName)\r
- self.TargetTxtDictionary[Key] = Value\r
elif Key == DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER:\r
try:\r
V = int(Value, 0)\r
from TargetTxtClassObject import *\r
\r
##\r
-# Static vailabes used for pattern\r
+# Static variables used for pattern\r
#\r
gMacroRefPattern = re.compile('(DEF\([^\(\)]+\))')\r
gEnvRefPattern = re.compile('(ENV\([^\(\)]+\))')\r
# @param ToolPath The string path name for BPDG tool\r
# @param VpdFileName The string path name for VPD information guid.txt\r
# \r
-def CallExtenalBPDGTool(ToolPath, VpdFilePath, VpdFileName):\r
+def CallExtenalBPDGTool(ToolPath, VpdFileName):\r
assert ToolPath != None, "Invalid parameter ToolPath"\r
- assert VpdFilePath != None and os.path.exists(VpdFilePath), "Invalid parameter VpdFileName"\r
+ assert VpdFileName != None and os.path.exists(VpdFileName), "Invalid parameter VpdFileName"\r
\r
- OutputDir = os.path.dirname(VpdFilePath)\r
- if (VpdFileName == None or VpdFileName == "") :\r
- FileName = os.path.basename(VpdFilePath)\r
- BaseName, ext = os.path.splitext(FileName)\r
- OutputMapFileName = os.path.join(OutputDir, "%s.map" % BaseName)\r
- OutputBinFileName = os.path.join(OutputDir, "%s.bin" % BaseName)\r
- else :\r
- OutputMapFileName = os.path.join(OutputDir, "%s.map" % VpdFileName)\r
- OutputBinFileName = os.path.join(OutputDir, "%s.bin" % VpdFileName)\r
+ OutputDir = os.path.dirname(VpdFileName)\r
+ FileName = os.path.basename(VpdFileName)\r
+ BaseName, ext = os.path.splitext(FileName)\r
+ OutputMapFileName = os.path.join(OutputDir, "%s.map" % BaseName)\r
+ OutputBinFileName = os.path.join(OutputDir, "%s.bin" % BaseName)\r
\r
try:\r
PopenObject = subprocess.Popen([ToolPath,\r
'-o', OutputBinFileName, \r
'-m', OutputMapFileName,\r
- '-s',\r
+ '-q',\r
'-f',\r
- '-v',\r
- VpdFilePath],\r
+ VpdFileName],\r
stdout=subprocess.PIPE, \r
stderr= subprocess.PIPE)\r
except Exception, X:\r
## @file\r
# This file is used to define common items of class object\r
#\r
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
self.HelpText = HelpText\r
self.HelpTextList = []\r
\r
-## CommonClass\r
+## CommonHeaderClass\r
#\r
# This class defined common items used in Module/Platform/Package files\r
# \r
# @retval Rtn Formatted String\r
#\r
def __str__(self):\r
- Rtn = Rtn = 'SkuId = ' + str(self.SkuId) + "," + \\r
+ Rtn = 'SkuId = ' + str(self.SkuId) + "," + \\r
'SkuIdName = ' + str(self.SkuIdName) + "," + \\r
'VariableName = ' + str(self.VariableName) + "," + \\r
'VariableGuid = ' + str(self.VariableGuid) + "," + \\r
# script.\r
#\r
if __name__ == '__main__':\r
- pass\r
D = DistributionPackageClass()\r
D.GetDistributionPackage(os.getenv('WORKSPACE'), ['MdePkg/MdePkg.dec', 'TianoModulePkg/TianoModulePkg.dec'], ['MdeModulePkg/Application/HelloWorld/HelloWorld.inf'])\r
Xml = DistributionPackageXml()\r
## @file\r
# This file is for installed package information database operations\r
#\r
-# Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
\r
## IpiDb\r
#\r
-# This class represents the installed package information databse\r
+# This class represents the installed package information database\r
# Add/Remove/Get installed distribution package information here.\r
# \r
# \r
return False\r
\r
\r
- ## Check whether a module depex satified by current workspace.\r
+ ## Check whether a module depex satisfied by current workspace.\r
#\r
# @param ModuleObj: \r
# @param DpObj:\r
\r
EdkLogger.verbose("Check package exists in workspace ... DONE!")\r
\r
- ## Check whether a package depex satified by current workspace.\r
+ ## Check whether a package depex satisfied by current workspace.\r
#\r
# @param ModuleObj: \r
# @param DpObj:\r
\r
EdkLogger.verbose("Check DP exists in workspace ... DONE!")\r
\r
- ## Check whether a DP depex satified by current workspace.\r
+ ## Check whether a DP depex satisfied by current workspace.\r
#\r
# @param ModuleObj: \r
# @param DpObj:\r
\r
return True\r
\r
- ## Check whether a DP depex satified by current workspace.\r
+ ## Check whether a DP depex satisfied by current workspace.\r
#\r
# @param ModuleObj: \r
# @param DpObj:\r
self.TargetTxtDictionary = {\r
TAB_TAT_DEFINES_ACTIVE_PLATFORM : None,\r
TAB_TAT_DEFINES_TOOL_CHAIN_CONF : None,\r
- TAB_TAT_DEFINES_MULTIPLE_THREAD : None,\r
TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER : None,\r
TAB_TAT_DEFINES_TARGET : None,\r
TAB_TAT_DEFINES_TOOL_CHAIN_TAG : None,\r
\r
def LoadTargetTxtFile(self, filename):\r
if os.path.exists(filename) and os.path.isfile(filename):\r
- return self.ConvertTextFileToDict(filename, '#', '=')\r
+ return self.ConvertTextFileToDict(filename, '#', '=')\r
else:\r
raise ParseError('LoadTargetTxtFile() : No Target.txt file exists.')\r
return 1\r
Key = LineList[0].strip()\r
if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary.keys():\r
if Key == TAB_TAT_DEFINES_ACTIVE_PLATFORM or Key == TAB_TAT_DEFINES_TOOL_CHAIN_CONF \\r
- or Key == TAB_TAT_DEFINES_MULTIPLE_THREAD or Key == TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER \\r
+ or Key == TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER \\r
or Key == TAB_TAT_DEFINES_ACTIVE_MODULE:\r
self.TargetTxtDictionary[Key] = LineList[1].replace('\\', '/').strip()\r
elif Key == TAB_TAT_DEFINES_TARGET or Key == TAB_TAT_DEFINES_TARGET_ARCH \\r
else:\r
EdkLogger.error("TagetTool", BuildToolError.FILE_NOT_FOUND, \r
"Tooldef file %s does not exist!" % self.Opt.TOOL_DEFINITION_FILE, RaiseError=False)\r
- elif Key == TAB_TAT_DEFINES_MULTIPLE_THREAD and self.Opt.NUM != None:\r
- if self.Opt.NUM >= 2:\r
- Line = "%-30s = %s\n" % (Key, 'Enable')\r
- else:\r
- Line = "%-30s = %s\n" % (Key, 'Disable')\r
+\r
+ elif self.Opt.NUM >= 2:\r
+ Line = "%-30s = %s\n" % (Key, 'Enable')\r
+ elif self.Opt.NUM <= 1:\r
+ Line = "%-30s = %s\n" % (Key, 'Disable') \r
elif Key == TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER and self.Opt.NUM != None:\r
Line = "%-30s = %s\n" % (Key, str(self.Opt.NUM))\r
- elif Key == TAB_TAT_DEFINES_MULTIPLE_THREAD and self.Opt.ENABLE_MULTI_THREAD != None:\r
- Line = "%-30s = %s\n" % (Key, self.Opt.ENABLE_MULTI_THREAD)\r
elif Key == TAB_TAT_DEFINES_TARGET and self.Opt.TARGET != None:\r
Line = "%-30s = %s\n" % (Key, ''.join(elem + ' ' for elem in self.Opt.TARGET))\r
elif Key == TAB_TAT_DEFINES_TARGET_ARCH and self.Opt.TARGET_ARCH != None:\r
help="Specify the build rule configure file, which replaces target.txt's BUILD_RULE_CONF definition. If not specified, the default value Conf/build_rule.txt will be set.")\r
parser.add_option("-m", "--multithreadnum", action="callback", type="int", dest="NUM", callback=RangeCheckCallback,\r
help="Specify the multi-thread number which replace target.txt's MAX_CONCURRENT_THREAD_NUMBER. If the value is less than 2, MULTIPLE_THREAD will be disabled. If the value is larger than 1, MULTIPLE_THREAD will be enabled.")\r
- parser.add_option("-e", "--enablemultithread", action="store", type="choice", choices=['Enable', 'Disable'], dest="ENABLE_MULTI_THREAD", \r
- help="Specify whether enable multi-thread! If Enable, multi-thread is enabled; If Disable, mutli-thread is disable")\r
(opt, args)=parser.parse_args()\r
return (opt, args)\r
\r
gHexNumberPattern = re.compile("0[xX]([0-9a-fA-F]+)")
## Regular expression for matching "Include ()" in asl file
gAslIncludePattern = re.compile("^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)", re.MULTILINE)
+## Regular expression for matching C style #include "XXX.asl" in asl file
+gAslCIncludePattern = re.compile(r'^(\s*)#include\s*[<"]\s*([-\\/\w.]+)\s*[>"]', re.MULTILINE)
+## Regular expression for matching constant with 'ULL' and 'UL', 'LL', 'L' postfix
+gLongNumberPattern = re.compile("(0[xX][0-9a-fA-F]+|[0-9]+)U?LL", re.MULTILINE)
## Patterns used to convert EDK conventions to EDK2 ECP conventions
gImportCodePatterns = [
[
# @param Target File to store the trimmed content
# @param Convert If True, convert standard HEX format to MASM format
#
-def TrimPreprocessedFile(Source, Target, Convert):
+def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong):
CreateDirectory(os.path.dirname(Target))
try:
f = open (Source, 'r')
% (LineIndexOfOriginalFile + 1))
# convert HEX number format if indicated
- if Convert:
+ if ConvertHex:
Line = gHexNumberPattern.sub(r"0\1h", Line)
+ if TrimLong:
+ Line = gLongNumberPattern.sub(r"\1", Line)
if LineNumber != None:
EdkLogger.verbose("Got line directive: line=%d" % LineNumber)
## Read the content ASL file, including ASL included, recursively
#
-# @param Source File to be read
-# @param Indent Spaces before the Include() statement
+# @param Source File to be read
+# @param Indent Spaces before the Include() statement
+# @param IncludePathList The list of external include file
#
-def DoInclude(Source, Indent=''):
+def DoInclude(Source, Indent='', IncludePathList=[]):
NewFileContent = []
- # avoid A "include" B and B "include" A
- if Source in gIncludedAslFile:
- EdkLogger.warn("Trim", "Circular include",
- ExtraData= "%s -> %s" % (" -> ".join(gIncludedAslFile), Source))
- return []
- gIncludedAslFile.append(Source)
try:
- F = open(Source,'r')
+ for IncludePath in IncludePathList:
+ IncludeFile = os.path.join(IncludePath, Source)
+ if os.path.isfile(IncludeFile):
+ F = open(IncludeFile, "r")
+ break
+ else:
+ EdkLogger.error("Trim", "Failed to find include file %s" % Source)
except:
EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=Source)
+
+ # avoid A "include" B and B "include" A
+ IncludeFile = os.path.abspath(os.path.normpath(IncludeFile))
+ if IncludeFile in gIncludedAslFile:
+ EdkLogger.warn("Trim", "Circular include",
+ ExtraData= "%s -> %s" % (" -> ".join(gIncludedAslFile), IncludeFile))
+ return []
+ gIncludedAslFile.append(IncludeFile)
+
for Line in F:
Result = gAslIncludePattern.findall(Line)
if len(Result) == 0:
- NewFileContent.append("%s%s" % (Indent, Line))
- continue
+ Result = gAslCIncludePattern.findall(Line)
+ if len(Result) == 0 or os.path.splitext(Result[0][1])[1].lower() not in [".asl", ".asi"]:
+ NewFileContent.append("%s%s" % (Indent, Line))
+ continue
CurrentIndent = Indent + Result[0][0]
IncludedFile = Result[0][1]
- NewFileContent.extend(DoInclude(IncludedFile, CurrentIndent))
+ NewFileContent.extend(DoInclude(IncludedFile, CurrentIndent, IncludePathList))
NewFileContent.append("\n")
gIncludedAslFile.pop()
#
# Replace ASL include statement with the content the included file
#
-# @param Source File to be trimmed
-# @param Target File to store the trimmed content
+# @param Source File to be trimmed
+# @param Target File to store the trimmed content
+# @param IncludePathFile The file to log the external include path
#
-def TrimAslFile(Source, Target):
+def TrimAslFile(Source, Target, IncludePathFile):
CreateDirectory(os.path.dirname(Target))
- Cwd = os.getcwd()
SourceDir = os.path.dirname(Source)
if SourceDir == '':
SourceDir = '.'
- os.chdir(SourceDir)
- Lines = DoInclude(Source)
- os.chdir(Cwd)
+
+ #
+ # Add source directory as the first search directory
+ #
+ IncludePathList = [SourceDir]
+
+ #
+ # If additional include path file is specified, append them all
+ # to the search directory list.
+ #
+ if IncludePathFile:
+ try:
+ LineNum = 0
+ for Line in open(IncludePathFile,'r'):
+ LineNum += 1
+ if Line.startswith("/I") or Line.startswith ("-I"):
+ IncludePathList.append(Line[2:].strip())
+ else:
+ EdkLogger.warn("Trim", "Invalid include line in include list file.", IncludePathFile, LineNum)
+ except:
+ EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=IncludePathFile)
+
+ Lines = DoInclude(Source, '', IncludePathList)
+
+ #
+ # Undef MIN and MAX to avoid collision in ASL source code
+ #
+ Lines.insert(0, "#undef MIN\n#undef MAX\n")
# save all lines trimmed
try:
make_option("-c", "--convert-hex", dest="ConvertHex", action="store_true",
help="Convert standard hex format (0xabcd) to MASM format (abcdh)"),
+ make_option("-l", "--trim-long", dest="TrimLong", action="store_true",
+ help="Remove postfix of long number"),
+ make_option("-i", "--include-path-file", dest="IncludePathFile",
+ help="The input file is include path list to search for ASL include file"),
make_option("-o", "--output", dest="OutputFile",
help="File to store the trimmed content"),
make_option("-v", "--verbose", dest="LogLevel", action="store_const", const=EdkLogger.VERBOSE,
]
# use clearer usage to override default usage message
- UsageString = "%prog [-s|-r|-a] [-c] [-v|-d <debug_level>|-q] [-o <output_file>] <input_file>"
+ UsageString = "%prog [-s|-r|-a] [-c] [-v|-d <debug_level>|-q] [-i <include_path_file>] [-o <output_file>] <input_file>"
Parser = OptionParser(description=__copyright__, version=__version__, option_list=OptionList, usage=UsageString)
Parser.set_defaults(FileType="Vfr")
elif CommandOptions.FileType == "Asl":
if CommandOptions.OutputFile == None:
CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii'
- TrimAslFile(InputFile, CommandOptions.OutputFile)
+ TrimAslFile(InputFile, CommandOptions.OutputFile, CommandOptions.IncludePathFile)
elif CommandOptions.FileType == "R8SourceCode":
TrimR8Sources(InputFile, CommandOptions.OutputFile)
else :
if CommandOptions.OutputFile == None:
CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii'
- TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, CommandOptions.ConvertHex)
+ TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, CommandOptions.ConvertHex, CommandOptions.TrimLong)
except FatalError, X:
import platform
import traceback
def _DefineParser(self):
TokenList = GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT, 1)
self._ValueList[0:len(TokenList)] = TokenList
- self._Macros[TokenList[0]] = ReplaceMacro(TokenList[1], self._Macros, False)
if self._ValueList[1] == '':
EdkLogger.error('Parser', FORMAT_INVALID, "No value specified",
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1)
-
+ self._Macros[TokenList[0]] = ReplaceMacro(TokenList[1], self._Macros, False)
+
## [nmake] section parser (R8.x style only)
def _NmakeParser(self):
TokenList = GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT, 1)
continue
# file private macros
elif Line.upper().startswith('DEFINE '):
+ if self._Enabled < 0:
+ # Do not parse the macro and add it to self._Macros dictionary if directives
+ # statement is evaluated to false.
+ continue
+
(Name, Value) = self._MacroParser()
# Make the defined macro in DSC [Defines] section also
# available for FDF file.
)
continue
elif Line.upper().startswith('EDK_GLOBAL '):
+ if self._Enabled < 0:
+ # Do not parse the macro and add it to self._Macros dictionary
+ # if previous directives statement is evaluated to false.
+ continue
+
(Name, Value) = self._MacroParser()
for Arch, ModuleType in self._Scope:
self._LastItem = self._Store(
if not self._SectionName in self._IncludeAllowedSection:
EdkLogger.error("Parser", FORMAT_INVALID, File=self.MetaFile, Line=self._LineIndex+1,
ExtraData="'!include' is not allowed under section [%s]" % self._SectionName)
- # the included file must be relative to the parsing file
- IncludedFile = os.path.join(self._FileDir, NormPath(self._ValueList[1], self._Macros))
+ # the included file must be relative to workspace
+ IncludedFile = os.path.join(os.environ["WORKSPACE"], NormPath(self._ValueList[1], self._Macros))
Parser = DscParser(IncludedFile, self._FileType, self._Table, self._Macros, From=self._LastItem)
# set the parser status with current status
Parser._SectionName = self._SectionName
self._BuildOptions = None\r
self._LoadFixAddress = None\r
self._VpdToolGuid = None\r
- self._VpdFileName = None\r
\r
## Get architecture\r
def _GetArch(self):\r
uuid.UUID(Record[1])\r
except:\r
EdkLogger.error("build", FORMAT_INVALID, "Invalid GUID format for VPD_TOOL_GUID", File=self.MetaFile)\r
- self._VpdToolGuid = Record[1] \r
- elif Name == TAB_DSC_DEFINES_VPD_FILENAME:\r
- self._VpdFileName = Record[1] \r
+ self._VpdToolGuid = Record[1] \r
# set _Header to non-None in order to avoid database re-querying\r
self._Header = 'DUMMY'\r
\r
if self._VpdToolGuid == None:\r
self._VpdToolGuid = ''\r
return self._VpdToolGuid\r
- \r
- ## Retrieve the VPD file Name, this is optional in DSC file\r
- def _GetVpdFileName(self):\r
- if self._VpdFileName == None:\r
- if self._Header == None:\r
- self._GetHeaderInfo()\r
- if self._VpdFileName == None:\r
- self._VpdFileName = ''\r
- return self._VpdFileName \r
- \r
+ \r
## Retrieve [SkuIds] section information\r
def _GetSkuIds(self):\r
if self._SkuIds == None:\r
BsBaseAddress = property(_GetBsBaseAddress)\r
RtBaseAddress = property(_GetRtBaseAddress)\r
LoadFixAddress = property(_GetLoadFixAddress)\r
- VpdToolGuid = property(_GetVpdToolGuid)\r
- VpdFileName = property(_GetVpdFileName) \r
+ VpdToolGuid = property(_GetVpdToolGuid) \r
SkuIds = property(_GetSkuIds)\r
Modules = property(_GetModules)\r
LibraryInstances = property(_GetLibraryInstances)\r
if Name in self:\r
self[Name] = Record[1]\r
# some special items in [Defines] section need special treatment\r
- elif Name in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION'):\r
- if self._Specification == None:\r
- self._Specification = sdict()\r
- self._Specification['UEFI_SPECIFICATION_VERSION'] = Record[1]\r
- elif Name == 'EDK_RELEASE_VERSION':\r
+ elif Name in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION', 'EDK_RELEASE_VERSION', 'PI_SPECIFICATION_VERSION'):\r
+ if Name in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION'):\r
+ Name = 'UEFI_SPECIFICATION_VERSION'\r
if self._Specification == None:\r
self._Specification = sdict()\r
- self._Specification[Name] = Record[1]\r
- elif Name == 'PI_SPECIFICATION_VERSION':\r
- if self._Specification == None:\r
- self._Specification = sdict()\r
- self._Specification[Name] = Record[1]\r
+ self._Specification[Name] = GetHexVerValue(Record[1])\r
+ if self._Specification[Name] == None:\r
+ EdkLogger.error("build", FORMAT_NOT_SUPPORTED,\r
+ "'%s' format is not supported for %s" % (Record[1], Name),\r
+ File=self.MetaFile, Line=Record[-1])\r
elif Name == 'LIBRARY_CLASS':\r
if self._LibraryClass == None:\r
self._LibraryClass = []\r
\r
## str() method\r
#\r
- # It just returns the string representaion of self.BuildObject\r
+ # It just returns the string representation of self.BuildObject\r
#\r
# @param self The object pointer\r
#\r
\r
## Build a module or platform\r
#\r
- # Create autogen code and makfile for a module or platform, and the launch\r
+ # Create autogen code and makefile for a module or platform, and the launch\r
# "make" command to build it\r
#\r
# @param Target The target of build command\r