from Common.DataType import *\r
from Common.Misc import *\r
from types import *\r
-\r
+from Common.Expression import *\r
from CommonDataClass.CommonClass import SkuInfoClass\r
from Common.TargetTxtClassObject import *\r
from Common.ToolDefClassObject import *\r
from Common.VariableAttributes import VariableAttributes\r
import Common.GlobalData as GlobalData\r
import subprocess\r
+from Common.Misc import SaveFileOnChange\r
from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject\r
+from collections import OrderedDict\r
\r
#\r
# Treat CHAR16 as a synonym for UINT16. CHAR16 support is required for VFR C structs\r
'''\r
\r
PcdGccMakefile = '''\r
-ARCH ?= IA32\r
MAKEROOT ?= $(EDK_TOOLS_PATH)/Source/C\r
LIBS = -lCommon\r
'''\r
\r
+## Regular expression for finding header file inclusions\r
+from AutoGen.GenMake import gIncludePattern\r
+\r
+## Find dependencies for one source file\r
+#\r
+# By searching recursively "#include" directive in file, find out all the\r
+# files needed by given source file. The dependecies will be only searched\r
+# in given search path list.\r
+#\r
+# @param SearchPathList The list of search path\r
+#\r
+# @retval list The list of files the given source file depends on\r
+#\r
+def GetDependencyList(FileStack,SearchPathList):\r
+ DepDb = dict()\r
+ DependencySet = set(FileStack)\r
+ while len(FileStack) > 0:\r
+ F = FileStack.pop()\r
+ FullPathDependList = []\r
+ CurrentFileDependencyList = []\r
+ if F in DepDb:\r
+ CurrentFileDependencyList = DepDb[F]\r
+ else:\r
+ try:\r
+ Fd = open(F, 'r')\r
+ FileContent = Fd.read()\r
+ except BaseException, X:\r
+ EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F + "\n\t" + str(X))\r
+ finally:\r
+ if "Fd" in dir(locals()):\r
+ Fd.close()\r
+\r
+ if len(FileContent) == 0:\r
+ continue\r
+\r
+ if FileContent[0] == 0xff or FileContent[0] == 0xfe:\r
+ FileContent = unicode(FileContent, "utf-16")\r
+ IncludedFileList = gIncludePattern.findall(FileContent)\r
+\r
+ for Inc in IncludedFileList:\r
+ Inc = Inc.strip()\r
+ Inc = os.path.normpath(Inc)\r
+ CurrentFileDependencyList.append(Inc)\r
+ DepDb[F] = CurrentFileDependencyList\r
+\r
+ CurrentFilePath = os.path.dirname(F)\r
+ PathList = [CurrentFilePath] + SearchPathList\r
+ for Inc in CurrentFileDependencyList:\r
+ for SearchPath in PathList:\r
+ FilePath = os.path.join(SearchPath, Inc)\r
+ if not os.path.exists(FilePath):\r
+ continue\r
+ if FilePath not in DependencySet:\r
+ FileStack.append(FilePath)\r
+ FullPathDependList.append(FilePath)\r
+ break\r
+ DependencySet.update(FullPathDependList)\r
+ DependencyList = list(DependencySet) # remove duplicate ones\r
+\r
+ return DependencyList\r
+\r
class DscBuildData(PlatformBuildClassObject):\r
# dict used to convert PCD type in database to string used by build tool\r
_PCD_TYPE_STRING_ = {\r
self._ToolChainFamily = None\r
self._Clear()\r
self._HandleOverridePath()\r
- if os.getenv("WORKSPACE"):\r
- self.OutputPath = os.path.join(os.getenv("WORKSPACE"), 'Build', PcdValueInitName)\r
- else:\r
- self.OutputPath = os.path.dirname(self.DscFile)\r
+ self.WorkspaceDir = os.getenv("WORKSPACE") if os.getenv("WORKSPACE") else ""\r
self.DefaultStores = None\r
self.SkuIdMgr = SkuClass(self.SkuName, self.SkuIds)\r
- arraystr = self.SkuIdMgr.DumpSkuIdArrary()\r
+ @property\r
+ def OutputPath(self):\r
+ if os.getenv("WORKSPACE"):\r
+ return os.path.join(os.getenv("WORKSPACE"), self.OutputDirectory, self._Target + "_" + self._Toolchain,PcdValueInitName)\r
+ else:\r
+ return os.path.dirname(self.DscFile)\r
\r
## XXX[key] = value\r
def __setitem__(self, key, value):\r
\r
## Get current effective macros\r
def _GetMacros(self):\r
- if self.__Macros == None:\r
+ if self.__Macros is None:\r
self.__Macros = {}\r
self.__Macros.update(GlobalData.gPlatformDefines)\r
self.__Macros.update(GlobalData.gGlobalDefines)\r
elif Name == TAB_DSC_DEFINES_BUILD_TARGETS:\r
self._BuildTargets = GetSplitValueList(Record[2])\r
elif Name == TAB_DSC_DEFINES_SKUID_IDENTIFIER:\r
- if self._SkuName == None:\r
+ if self._SkuName is None:\r
self._SkuName = Record[2]\r
if GlobalData.gSKUID_CMD:\r
self._SkuName = GlobalData.gSKUID_CMD\r
\r
## Retrieve platform name\r
def _GetPlatformName(self):\r
- if self._PlatformName == None:\r
- if self._Header == None:\r
+ if self._PlatformName is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._PlatformName == None:\r
+ if self._PlatformName is None:\r
EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No PLATFORM_NAME", File=self.MetaFile)\r
return self._PlatformName\r
\r
## Retrieve file guid\r
def _GetFileGuid(self):\r
- if self._Guid == None:\r
- if self._Header == None:\r
+ if self._Guid is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._Guid == None:\r
+ if self._Guid is None:\r
EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No PLATFORM_GUID", File=self.MetaFile)\r
return self._Guid\r
\r
## Retrieve platform version\r
def _GetVersion(self):\r
- if self._Version == None:\r
- if self._Header == None:\r
+ if self._Version is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._Version == None:\r
+ if self._Version is None:\r
EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No PLATFORM_VERSION", File=self.MetaFile)\r
return self._Version\r
\r
## Retrieve platform description file version\r
def _GetDscSpec(self):\r
- if self._DscSpecification == None:\r
- if self._Header == None:\r
+ if self._DscSpecification is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._DscSpecification == None:\r
+ if self._DscSpecification is None:\r
EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No DSC_SPECIFICATION", File=self.MetaFile)\r
return self._DscSpecification\r
\r
## Retrieve OUTPUT_DIRECTORY\r
def _GetOutpuDir(self):\r
- if self._OutputDirectory == None:\r
- if self._Header == None:\r
+ if self._OutputDirectory is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._OutputDirectory == None:\r
+ if self._OutputDirectory is None:\r
self._OutputDirectory = os.path.join("Build", self._PlatformName)\r
return self._OutputDirectory\r
\r
## Retrieve SUPPORTED_ARCHITECTURES\r
def _GetSupArch(self):\r
- if self._SupArchList == None:\r
- if self._Header == None:\r
+ if self._SupArchList is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._SupArchList == None:\r
+ if self._SupArchList is None:\r
EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No SUPPORTED_ARCHITECTURES", File=self.MetaFile)\r
return self._SupArchList\r
\r
## Retrieve BUILD_TARGETS\r
def _GetBuildTarget(self):\r
- if self._BuildTargets == None:\r
- if self._Header == None:\r
+ if self._BuildTargets is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._BuildTargets == None:\r
+ if self._BuildTargets is None:\r
EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No BUILD_TARGETS", File=self.MetaFile)\r
return self._BuildTargets\r
\r
def _GetPcdInfoFlag(self):\r
- if self._PcdInfoFlag == None or self._PcdInfoFlag.upper() == 'FALSE':\r
+ if self._PcdInfoFlag is None or self._PcdInfoFlag.upper() == 'FALSE':\r
return False\r
elif self._PcdInfoFlag.upper() == 'TRUE':\r
return True\r
else:\r
return False\r
def _GetVarCheckFlag(self):\r
- if self._VarCheckFlag == None or self._VarCheckFlag.upper() == 'FALSE':\r
+ if self._VarCheckFlag is None or self._VarCheckFlag.upper() == 'FALSE':\r
return False\r
elif self._VarCheckFlag.upper() == 'TRUE':\r
return True\r
\r
# # Retrieve SKUID_IDENTIFIER\r
def _GetSkuName(self):\r
- if self._SkuName == None:\r
- if self._Header == None:\r
+ if self._SkuName is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._SkuName == None:\r
+ if self._SkuName is None:\r
self._SkuName = 'DEFAULT'\r
return self._SkuName\r
\r
## Override SKUID_IDENTIFIER\r
def _SetSkuName(self, Value):\r
self._SkuName = Value\r
- self._Pcds = None\r
\r
def _GetFdfFile(self):\r
- if self._FlashDefinition == None:\r
- if self._Header == None:\r
+ if self._FlashDefinition is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._FlashDefinition == None:\r
+ if self._FlashDefinition is None:\r
self._FlashDefinition = ''\r
return self._FlashDefinition\r
\r
def _GetPrebuild(self):\r
- if self._Prebuild == None:\r
- if self._Header == None:\r
+ if self._Prebuild is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._Prebuild == None:\r
+ if self._Prebuild is None:\r
self._Prebuild = ''\r
return self._Prebuild\r
\r
def _GetPostbuild(self):\r
- if self._Postbuild == None:\r
- if self._Header == None:\r
+ if self._Postbuild is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._Postbuild == None:\r
+ if self._Postbuild is None:\r
self._Postbuild = ''\r
return self._Postbuild\r
\r
## Retrieve FLASH_DEFINITION\r
def _GetBuildNumber(self):\r
- if self._BuildNumber == None:\r
- if self._Header == None:\r
+ if self._BuildNumber is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._BuildNumber == None:\r
+ if self._BuildNumber is None:\r
self._BuildNumber = ''\r
return self._BuildNumber\r
\r
## Retrieve MAKEFILE_NAME\r
def _GetMakefileName(self):\r
- if self._MakefileName == None:\r
- if self._Header == None:\r
+ if self._MakefileName is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._MakefileName == None:\r
+ if self._MakefileName is None:\r
self._MakefileName = ''\r
return self._MakefileName\r
\r
## Retrieve BsBaseAddress\r
def _GetBsBaseAddress(self):\r
- if self._BsBaseAddress == None:\r
- if self._Header == None:\r
+ if self._BsBaseAddress is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._BsBaseAddress == None:\r
+ if self._BsBaseAddress is None:\r
self._BsBaseAddress = ''\r
return self._BsBaseAddress\r
\r
## Retrieve RtBaseAddress\r
def _GetRtBaseAddress(self):\r
- if self._RtBaseAddress == None:\r
- if self._Header == None:\r
+ if self._RtBaseAddress is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._RtBaseAddress == None:\r
+ if self._RtBaseAddress is None:\r
self._RtBaseAddress = ''\r
return self._RtBaseAddress\r
\r
## Retrieve the top address for the load fix address\r
def _GetLoadFixAddress(self):\r
- if self._LoadFixAddress == None:\r
- if self._Header == None:\r
+ if self._LoadFixAddress is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
\r
- if self._LoadFixAddress == None:\r
+ if self._LoadFixAddress is None:\r
self._LoadFixAddress = self._Macros.get(TAB_FIX_LOAD_TOP_MEMORY_ADDRESS, '0')\r
\r
try:\r
\r
## Retrieve RFCLanguage filter\r
def _GetRFCLanguages(self):\r
- if self._RFCLanguages == None:\r
- if self._Header == None:\r
+ if self._RFCLanguages is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._RFCLanguages == None:\r
+ if self._RFCLanguages is None:\r
self._RFCLanguages = []\r
return self._RFCLanguages\r
\r
## Retrieve ISOLanguage filter\r
def _GetISOLanguages(self):\r
- if self._ISOLanguages == None:\r
- if self._Header == None:\r
+ if self._ISOLanguages is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._ISOLanguages == None:\r
+ if self._ISOLanguages is None:\r
self._ISOLanguages = []\r
return self._ISOLanguages\r
## Retrieve the GUID string for VPD tool\r
def _GetVpdToolGuid(self):\r
- if self._VpdToolGuid == None:\r
- if self._Header == None:\r
+ if self._VpdToolGuid is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._VpdToolGuid == None:\r
+ if self._VpdToolGuid is None:\r
self._VpdToolGuid = ''\r
return self._VpdToolGuid\r
\r
## Retrieve [SkuIds] section information\r
def _GetSkuIds(self):\r
- if self._SkuIds == None:\r
- self._SkuIds = sdict()\r
+ if self._SkuIds is None:\r
+ self._SkuIds = OrderedDict()\r
RecordList = self._RawData[MODEL_EFI_SKU_ID, self._Arch]\r
for Record in RecordList:\r
if Record[0] in [None, '']:\r
File=self.MetaFile, Line=Record[-1])\r
Pattern = re.compile('^[1-9]\d*|0$')\r
HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')\r
- if Pattern.match(Record[0]) == None and HexPattern.match(Record[0]) == None:\r
+ if Pattern.match(Record[0]) is None and HexPattern.match(Record[0]) is None:\r
EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID number is invalid. It only support Integer and HexNumber",\r
File=self.MetaFile, Line=Record[-1])\r
if not IsValidWord(Record[1]):\r
def ToInt(self,intstr):\r
return int(intstr,16) if intstr.upper().startswith("0X") else int(intstr)\r
def _GetDefaultStores(self):\r
- if self.DefaultStores == None:\r
- self.DefaultStores = sdict()\r
+ if self.DefaultStores is None:\r
+ self.DefaultStores = OrderedDict()\r
RecordList = self._RawData[MODEL_EFI_DEFAULT_STORES, self._Arch]\r
for Record in RecordList:\r
if Record[0] in [None, '']:\r
File=self.MetaFile, Line=Record[-1])\r
Pattern = re.compile('^[1-9]\d*|0$')\r
HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')\r
- if Pattern.match(Record[0]) == None and HexPattern.match(Record[0]) == None:\r
+ if Pattern.match(Record[0]) is None and HexPattern.match(Record[0]) is None:\r
EdkLogger.error('build', FORMAT_INVALID, "The format of the DefaultStores ID number is invalid. It only support Integer and HexNumber",\r
File=self.MetaFile, Line=Record[-1])\r
if not IsValidWord(Record[1]):\r
\r
## Retrieve [Components] section information\r
def _GetModules(self):\r
- if self._Modules != None:\r
+ if self._Modules is not None:\r
return self._Modules\r
\r
- self._Modules = sdict()\r
+ self._Modules = OrderedDict()\r
RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch]\r
Macros = self._Macros\r
Macros["EDK_SOURCE"] = GlobalData.gEcpSource\r
for TokenSpaceGuid, PcdCName, Setting, Dummy1, Dummy2, Dummy3, Dummy4,Dummy5 in RecordList:\r
TokenList = GetSplitValueList(Setting)\r
DefaultValue = TokenList[0]\r
- if len(TokenList) > 1:\r
- MaxDatumSize = TokenList[1]\r
+ # the format is PcdName| Value | VOID* | MaxDatumSize\r
+ if len(TokenList) > 2:\r
+ MaxDatumSize = TokenList[2]\r
else:\r
MaxDatumSize = ''\r
TypeString = self._PCD_TYPE_STRING_[Type]\r
\r
## Retrieve all possible library instances used in this platform\r
def _GetLibraryInstances(self):\r
- if self._LibraryInstances == None:\r
+ if self._LibraryInstances is None:\r
self._GetLibraryClasses()\r
return self._LibraryInstances\r
\r
## Retrieve [LibraryClasses] information\r
def _GetLibraryClasses(self):\r
- if self._LibraryClasses == None:\r
+ if self._LibraryClasses is None:\r
self._LibraryInstances = []\r
#\r
# tdict is a special dict kind of type, used for selecting correct\r
# try all possible module types\r
for ModuleType in SUP_MODULE_LIST:\r
LibraryInstance = LibraryClassDict[self._Arch, ModuleType, LibraryClass]\r
- if LibraryInstance == None:\r
+ if LibraryInstance is None:\r
continue\r
self._LibraryClasses[LibraryClass, ModuleType] = LibraryInstance\r
\r
return self._LibraryClasses\r
\r
def _ValidatePcd(self, PcdCName, TokenSpaceGuid, Setting, PcdType, LineNo):\r
- if self._DecPcds == None:\r
+ if self._DecPcds is None:\r
\r
FdfInfList = []\r
if GlobalData.gFdfParser:\r
PkgSet.update(ModuleData.Packages)\r
\r
self._DecPcds, self._GuidDict = GetDeclaredPcd(self, self._Bdb, self._Arch, self._Target, self._Toolchain,PkgSet)\r
-\r
+ self._GuidDict.update(GlobalData.gPlatformPcds)\r
\r
if (PcdCName, TokenSpaceGuid) not in self._DecPcds:\r
EdkLogger.error('build', PARSER_ERROR,\r
ExtraData="%s.%s" % (TokenSpaceGuid, PcdCName))\r
if PcdType in (MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX_DEFAULT):\r
if self._DecPcds[PcdCName, TokenSpaceGuid].DatumType.strip() != ValueList[1].strip():\r
- EdkLogger.error('build', FORMAT_INVALID, ErrStr , File=self.MetaFile, Line=LineNo,\r
+ EdkLogger.error('build', FORMAT_INVALID, "Pcd datumtype used in DSC file is not the same as its declaration in DEC file." , File=self.MetaFile, Line=LineNo,\r
ExtraData="%s.%s|%s" % (TokenSpaceGuid, PcdCName, Setting))\r
if (TokenSpaceGuid + '.' + PcdCName) in GlobalData.gPlatformPcds:\r
if GlobalData.gPlatformPcds[TokenSpaceGuid + '.' + PcdCName] != ValueList[Index]:\r
for pcd in HiiPcd:\r
for skuid in pcd.SkuInfoList:\r
skuobj = pcd.SkuInfoList.get(skuid)\r
- if "STANDARD" not in skuobj.DefaultStoreDict:\r
+ if TAB_DEFAULT_STORES_DEFAULT not in skuobj.DefaultStoreDict:\r
PcdDefaultStoreSet = set([defaultstorename for defaultstorename in skuobj.DefaultStoreDict])\r
mindefaultstorename = DefaultStoreMgr.GetMin(PcdDefaultStoreSet)\r
- skuobj.DefaultStoreDict['STANDARD'] = copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename])\r
+ skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename])\r
return Pcds\r
\r
+ def RecoverCommandLinePcd(self):\r
+ def UpdateCommandLineValue(pcd):\r
+ if pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],\r
+ self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:\r
+ pcd.PcdValueFromComm = pcd.DefaultValue\r
+ elif pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:\r
+ pcd.PcdValueFromComm = pcd.SkuInfoList.get("DEFAULT").HiiDefaultValue\r
+ else:\r
+ pcd.PcdValueFromComm = pcd.SkuInfoList.get("DEFAULT").DefaultValue\r
+ for pcd in self._Pcds:\r
+ if isinstance(self._Pcds[pcd],StructurePcd) and (self._Pcds[pcd].PcdValueFromComm or self._Pcds[pcd].PcdFieldValueFromComm):\r
+ UpdateCommandLineValue(self._Pcds[pcd])\r
+\r
+ def __ParsePcdFromCommandLine(self):\r
+ if GlobalData.BuildOptionPcd:\r
+ for i, pcd in enumerate(GlobalData.BuildOptionPcd):\r
+ if type(pcd) is tuple:\r
+ continue\r
+ (pcdname, pcdvalue) = pcd.split('=')\r
+ if not pcdvalue:\r
+ EdkLogger.error('build', AUTOGEN_ERROR, "No Value specified for the PCD %s." % (pcdname))\r
+ if '.' in pcdname:\r
+ (Name1, Name2) = pcdname.split('.',1)\r
+ if "." in Name2:\r
+ (Name3, FieldName) = Name2.split(".",1)\r
+ if ((Name3,Name1)) in self.DecPcds:\r
+ HasTokenSpace = True\r
+ TokenCName = Name3\r
+ TokenSpaceGuidCName = Name1\r
+ else:\r
+ FieldName = Name2\r
+ TokenCName = Name1\r
+ TokenSpaceGuidCName = ''\r
+ HasTokenSpace = False\r
+ else:\r
+ if ((Name2,Name1)) in self.DecPcds:\r
+ HasTokenSpace = True\r
+ TokenCName = Name2\r
+ TokenSpaceGuidCName = Name1\r
+ FieldName =""\r
+ else:\r
+ FieldName = Name2\r
+ TokenCName = Name1\r
+ TokenSpaceGuidCName = ''\r
+ HasTokenSpace = False\r
+ else:\r
+ FieldName = ""\r
+ TokenCName = pcdname\r
+ TokenSpaceGuidCName = ''\r
+ HasTokenSpace = False\r
+ TokenSpaceGuidCNameList = []\r
+ FoundFlag = False\r
+ PcdDatumType = ''\r
+ DisplayName = TokenCName\r
+ if FieldName:\r
+ DisplayName = TokenCName + '.' + FieldName\r
+ if not HasTokenSpace:\r
+ for key in self.DecPcds:\r
+ PcdItem = self.DecPcds[key]\r
+ if TokenCName == PcdItem.TokenCName:\r
+ if not PcdItem.TokenSpaceGuidCName in TokenSpaceGuidCNameList:\r
+ if len (TokenSpaceGuidCNameList) < 1:\r
+ TokenSpaceGuidCNameList.append(PcdItem.TokenSpaceGuidCName)\r
+ TokenSpaceGuidCName = PcdItem.TokenSpaceGuidCName\r
+ PcdDatumType = PcdItem.DatumType\r
+ FoundFlag = True\r
+ else:\r
+ EdkLogger.error(\r
+ 'build',\r
+ AUTOGEN_ERROR,\r
+ "The Pcd %s is found under multiple different TokenSpaceGuid: %s and %s." % (DisplayName, PcdItem.TokenSpaceGuidCName, TokenSpaceGuidCNameList[0])\r
+ )\r
+ else:\r
+ if (TokenCName, TokenSpaceGuidCName) in self.DecPcds:\r
+ PcdDatumType = self.DecPcds[(TokenCName, TokenSpaceGuidCName)].DatumType\r
+ FoundFlag = True\r
+ if not FoundFlag:\r
+ if HasTokenSpace:\r
+ EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s.%s is not found in the DEC file." % (TokenSpaceGuidCName, DisplayName))\r
+ else:\r
+ EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s is not found in the DEC file." % (DisplayName))\r
+ pcdvalue = pcdvalue.replace("\\\\\\'", '\\\\\\"').replace('\\\'', '\'').replace('\\\\\\"', "\\'")\r
+ if FieldName:\r
+ pcdvalue = self.HandleFlexiblePcd(TokenSpaceGuidCName, TokenCName, pcdvalue, PcdDatumType, self._GuidDict, FieldName)\r
+ else:\r
+ pcdvalue = self.HandleFlexiblePcd(TokenSpaceGuidCName, TokenCName, pcdvalue, PcdDatumType, self._GuidDict)\r
+ IsValid, Cause = CheckPcdDatum(PcdDatumType, pcdvalue)\r
+ if not IsValid:\r
+ EdkLogger.error("build", FORMAT_INVALID, Cause, ExtraData="%s.%s" % (TokenSpaceGuidCName, TokenCName))\r
+ GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, FieldName, pcdvalue,("build command options",1))\r
+\r
+ for BuildData in self._Bdb._CACHE_.values():\r
+ if BuildData.MetaFile.Ext == '.dec' or BuildData.MetaFile.Ext == '.dsc':\r
+ continue\r
+ for key in BuildData.Pcds:\r
+ PcdItem = BuildData.Pcds[key]\r
+ if (TokenSpaceGuidCName, TokenCName) == (PcdItem.TokenSpaceGuidCName, PcdItem.TokenCName) and FieldName =="":\r
+ PcdItem.DefaultValue = pcdvalue\r
+\r
+ def HandleFlexiblePcd(self, TokenSpaceGuidCName, TokenCName, PcdValue, PcdDatumType, GuidDict, FieldName=''):\r
+ if FieldName:\r
+ IsArray = False\r
+ TokenCName += '.' + FieldName\r
+ if PcdValue.startswith('H'):\r
+ if FieldName and IsFieldValueAnArray(PcdValue[1:]):\r
+ PcdDatumType = 'VOID*'\r
+ IsArray = True\r
+ if FieldName and not IsArray:\r
+ return PcdValue\r
+ try:\r
+ PcdValue = ValueExpressionEx(PcdValue[1:], PcdDatumType, GuidDict)(True)\r
+ except BadExpression, Value: \r
+ EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
+ (TokenSpaceGuidCName, TokenCName, PcdValue, Value))\r
+ elif PcdValue.startswith("L'") or PcdValue.startswith("'"):\r
+ if FieldName and IsFieldValueAnArray(PcdValue):\r
+ PcdDatumType = 'VOID*'\r
+ IsArray = True\r
+ if FieldName and not IsArray:\r
+ return PcdValue\r
+ try:\r
+ PcdValue = ValueExpressionEx(PcdValue, PcdDatumType, GuidDict)(True)\r
+ except BadExpression, Value:\r
+ EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
+ (TokenSpaceGuidCName, TokenCName, PcdValue, Value))\r
+ elif PcdValue.startswith('L'):\r
+ PcdValue = 'L"' + PcdValue[1:] + '"'\r
+ if FieldName and IsFieldValueAnArray(PcdValue):\r
+ PcdDatumType = 'VOID*'\r
+ IsArray = True\r
+ if FieldName and not IsArray:\r
+ return PcdValue\r
+ try:\r
+ PcdValue = ValueExpressionEx(PcdValue, PcdDatumType, GuidDict)(True)\r
+ except BadExpression, Value:\r
+ EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
+ (TokenSpaceGuidCName, TokenCName, PcdValue, Value))\r
+ else:\r
+ if PcdValue.upper() == 'FALSE':\r
+ PcdValue = str(0)\r
+ if PcdValue.upper() == 'TRUE':\r
+ PcdValue = str(1)\r
+ if not FieldName:\r
+ if PcdDatumType not in ['UINT8','UINT16','UINT32','UINT64','BOOLEAN']:\r
+ PcdValue = '"' + PcdValue + '"'\r
+ else:\r
+ IsArray = False\r
+ Base = 10\r
+ if PcdValue.upper().startswith('0X'):\r
+ Base = 16\r
+ try:\r
+ Num = int(PcdValue, Base)\r
+ except:\r
+ PcdValue = '"' + PcdValue + '"'\r
+ if IsFieldValueAnArray(PcdValue):\r
+ PcdDatumType = 'VOID*'\r
+ IsArray = True\r
+ if not IsArray:\r
+ return PcdValue\r
+ try:\r
+ PcdValue = ValueExpressionEx(PcdValue, PcdDatumType, GuidDict)(True)\r
+ except BadExpression, Value:\r
+ EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
+ (TokenSpaceGuidCName, TokenCName, PcdValue, Value))\r
+ return PcdValue\r
+\r
## Retrieve all PCD settings in platform\r
def _GetPcds(self):\r
- if self._Pcds == None:\r
- self._Pcds = sdict()\r
+ if self._Pcds is None:\r
+ self._Pcds = OrderedDict()\r
+ self.__ParsePcdFromCommandLine()\r
self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))\r
self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))\r
self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG))\r
self._Pcds.update(self._GetDynamicVpdPcd(MODEL_PCD_DYNAMIC_EX_VPD))\r
\r
self._Pcds = self.CompletePcdValues(self._Pcds)\r
+ self._Pcds = self.OverrideByFdfCommOverAll(self._Pcds)\r
self._Pcds = self.UpdateStructuredPcds(MODEL_PCD_TYPE_LIST, self._Pcds)\r
self._Pcds = self.CompleteHiiPcdsDefaultStores(self._Pcds)\r
self._Pcds = self._FilterPcdBySkuUsage(self._Pcds)\r
+\r
+ self.RecoverCommandLinePcd()\r
return self._Pcds\r
\r
def _dumpPcdInfo(self,Pcds):\r
print "PcdCName: %s, SkuName: %s, Value: %s" % (".".join((pcdobj.TokenSpaceGuidCName, pcdobj.TokenCName)), skuid,str(pcdobj.SkuInfoList[skuid].DefaultValue))\r
## Retrieve [BuildOptions]\r
def _GetBuildOptions(self):\r
- if self._BuildOptions == None:\r
- self._BuildOptions = sdict()\r
+ if self._BuildOptions is None:\r
+ self._BuildOptions = OrderedDict()\r
#\r
# Retrieve build option for EDKII and EDK style module\r
#\r
return self._BuildOptions\r
\r
def GetBuildOptionsByModuleType(self, Edk, ModuleType):\r
- if self._ModuleTypeOptions == None:\r
- self._ModuleTypeOptions = sdict()\r
+ if self._ModuleTypeOptions is None:\r
+ self._ModuleTypeOptions = OrderedDict()\r
if (Edk, ModuleType) not in self._ModuleTypeOptions:\r
- options = sdict()\r
+ options = OrderedDict()\r
self._ModuleTypeOptions[Edk, ModuleType] = options\r
DriverType = '%s.%s' % (Edk, ModuleType)\r
CommonDriverType = '%s.%s' % ('COMMON', ModuleType)\r
structure_pcd_data[(item[0],item[1])].append(item)\r
\r
return structure_pcd_data\r
+ def OverrideByFdfComm(self,StruPcds):\r
+ StructurePcdInCom = OrderedDict()\r
+ for item in GlobalData.BuildOptionPcd:\r
+ if len(item) == 5 and (item[1],item[0]) in StruPcds:\r
+ StructurePcdInCom[(item[0],item[1],item[2] )] = (item[3],item[4])\r
+ GlobalPcds = set([(item[0],item[1]) for item in StructurePcdInCom.keys()])\r
+ for Pcd in StruPcds.values():\r
+ if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) not in GlobalPcds:\r
+ continue\r
+ FieldValues = OrderedDict()\r
+ for item in StructurePcdInCom:\r
+ if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) == (item[0],item[1]) and item[2]:\r
+ FieldValues[item[2]] = StructurePcdInCom[item]\r
+ for field in FieldValues:\r
+ if field not in Pcd.PcdFieldValueFromComm:\r
+ Pcd.PcdFieldValueFromComm[field] = ["","",""]\r
+ Pcd.PcdFieldValueFromComm[field][0] = FieldValues[field][0]\r
+ Pcd.PcdFieldValueFromComm[field][1] = FieldValues[field][1][0]\r
+ Pcd.PcdFieldValueFromComm[field][2] = FieldValues[field][1][1]\r
+ return StruPcds\r
+ def OverrideByFdfCommOverAll(self,AllPcds):\r
+ def CheckStructureInComm(commpcds):\r
+ if not commpcds:\r
+ return False\r
+ if len(commpcds[0]) == 5:\r
+ return True\r
+ return False\r
\r
+ if CheckStructureInComm(GlobalData.BuildOptionPcd):\r
+ StructurePcdInCom = {(item[0],item[1],item[2] ):(item[3],item[4]) for item in GlobalData.BuildOptionPcd } if GlobalData.BuildOptionPcd else {}\r
+ NoFiledValues = {(item[0],item[1]):StructurePcdInCom[item] for item in StructurePcdInCom if not item[2]}\r
+ else:\r
+ NoFiledValues = {(item[0],item[1]):[item[2]] for item in GlobalData.BuildOptionPcd}\r
+ for Guid,Name in NoFiledValues:\r
+ if (Name,Guid) in AllPcds:\r
+ Pcd = AllPcds.get((Name,Guid))\r
+ if isinstance(self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCName), None),StructurePcd):\r
+ self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCName)).PcdValueFromComm = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]\r
+ else:\r
+ Pcd.PcdValueFromComm = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]\r
+ Pcd.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]\r
+ for sku in Pcd.SkuInfoList:\r
+ SkuInfo = Pcd.SkuInfoList[sku]\r
+ if SkuInfo.DefaultValue:\r
+ SkuInfo.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]\r
+ else:\r
+ SkuInfo.HiiDefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]\r
+ for defaultstore in SkuInfo.DefaultStoreDict:\r
+ SkuInfo.DefaultStoreDict[defaultstore] = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]\r
+ if Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII]]:\r
+ if Pcd.DatumType == "VOID*":\r
+ if not Pcd.MaxDatumSize:\r
+ Pcd.MaxDatumSize = '0'\r
+ CurrentSize = int(Pcd.MaxDatumSize,16) if Pcd.MaxDatumSize.upper().startswith("0X") else int(Pcd.MaxDatumSize)\r
+ OptionSize = len((StringToArray(Pcd.PcdValueFromComm)).split(","))\r
+ MaxSize = max(CurrentSize, OptionSize)\r
+ Pcd.MaxDatumSize = str(MaxSize)\r
+ else:\r
+ PcdInDec = self.DecPcds.get((Name,Guid))\r
+ if PcdInDec:\r
+ PcdInDec.PcdValueFromComm = NoFiledValues[(Guid,Name)][0]\r
+ if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],\r
+ self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE],\r
+ self._PCD_TYPE_STRING_[MODEL_PCD_FEATURE_FLAG]]:\r
+ self.Pcds[Name, Guid] = copy.deepcopy(PcdInDec)\r
+ self.Pcds[Name, Guid].DefaultValue = NoFiledValues[( Guid,Name)][0]\r
+ return AllPcds\r
def UpdateStructuredPcds(self, TypeList, AllPcds):\r
\r
DynamicPcdType = [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_DEFAULT],\r
continue\r
\r
if SkuName in SkuIds and "." in TokenSpaceGuid:\r
- S_PcdSet.append(( TokenSpaceGuid.split(".")[0],TokenSpaceGuid.split(".")[1], PcdCName,SkuName, default_store,Dummy5, AnalyzePcdExpression(Setting)[0]))\r
+ S_PcdSet.append([ TokenSpaceGuid.split(".")[0],TokenSpaceGuid.split(".")[1], PcdCName,SkuName, default_store,Dummy5, AnalyzePcdExpression(Setting)[0]])\r
\r
# handle pcd value override\r
StrPcdSet = self.GetStructurePcdInfo(S_PcdSet)\r
- S_pcd_set = {}\r
+ S_pcd_set = OrderedDict()\r
for str_pcd in StrPcdSet:\r
str_pcd_obj = Pcds.get((str_pcd[1], str_pcd[0]), None)\r
str_pcd_dec = self._DecPcds.get((str_pcd[1], str_pcd[0]), None)\r
+ if not isinstance (str_pcd_dec, StructurePcd):\r
+ EdkLogger.error('build', PARSER_ERROR,\r
+ "Pcd (%s.%s) is not declared as Structure PCD in DEC files. Arch: ['%s']" % (str_pcd[0], str_pcd[1], self._Arch),\r
+ File=self.MetaFile,Line = StrPcdSet[str_pcd][0][5])\r
if str_pcd_dec:\r
str_pcd_obj_str = StructurePcd()\r
str_pcd_obj_str.copy(str_pcd_dec)\r
if str_pcd_obj:\r
str_pcd_obj_str.copy(str_pcd_obj)\r
- if str_pcd_obj.DefaultValue:\r
- str_pcd_obj_str.DefaultFromDSC = str_pcd_obj.DefaultValue\r
+ if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:\r
+ str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}\r
+ else:\r
+ str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}\r
for str_pcd_data in StrPcdSet[str_pcd]:\r
if str_pcd_data[3] in SkuIds:\r
- str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File,LineNo=str_pcd_data[5])\r
+ str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],TAB_DEFAULT_STORES_DEFAULT if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:],LineNo=str_pcd_data[5])\r
S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str\r
else:\r
EdkLogger.error('build', PARSER_ERROR,\r
str_pcd_obj = Pcds.get(Pcd, None)\r
if str_pcd_obj:\r
str_pcd_obj_str.copy(str_pcd_obj)\r
- if str_pcd_obj.DefaultValue:\r
- str_pcd_obj_str.DefaultFromDSC = str_pcd_obj.DefaultValue\r
+ if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:\r
+ str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}\r
+ else:\r
+ str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}\r
S_pcd_set[Pcd] = str_pcd_obj_str\r
if S_pcd_set:\r
GlobalData.gStructurePcd[self.Arch] = S_pcd_set\r
continue\r
nextskuid = self.SkuIdMgr.GetNextSkuId(skuid)\r
NoDefault = False\r
- while nextskuid not in stru_pcd.SkuOverrideValues:\r
- if nextskuid == "DEFAULT":\r
- NoDefault = True\r
- break\r
- nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid)\r
- stru_pcd.SkuOverrideValues[skuid] = copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid]) if not NoDefault else copy.deepcopy({defaultstorename: stru_pcd.DefaultValues for defaultstorename in DefaultStores} if DefaultStores else {'STANDARD':stru_pcd.DefaultValues})\r
+ if skuid not in stru_pcd.SkuOverrideValues:\r
+ while nextskuid not in stru_pcd.SkuOverrideValues:\r
+ if nextskuid == "DEFAULT":\r
+ NoDefault = True\r
+ break\r
+ nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid)\r
+ stru_pcd.SkuOverrideValues[skuid] = copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid]) if not NoDefault else copy.deepcopy({defaultstorename: stru_pcd.DefaultValues for defaultstorename in DefaultStores} if DefaultStores else {TAB_DEFAULT_STORES_DEFAULT:stru_pcd.DefaultValues})\r
+ if not NoDefault:\r
+ stru_pcd.ValueChain[(skuid,'')]= (nextskuid,'')\r
if stru_pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:\r
for skuid in SkuIds:\r
nextskuid = skuid\r
for defaultstoreid in DefaultStores:\r
if defaultstoreid not in stru_pcd.SkuOverrideValues[skuid]:\r
stru_pcd.SkuOverrideValues[skuid][defaultstoreid] = copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid][mindefaultstorename])\r
-\r
+ stru_pcd.ValueChain[(skuid,defaultstoreid)]= (nextskuid,mindefaultstorename)\r
+ S_pcd_set = self.OverrideByFdfComm(S_pcd_set)\r
Str_Pcd_Values = self.GenerateByteArrayValue(S_pcd_set)\r
if Str_Pcd_Values:\r
for (skuname,StoreName,PcdGuid,PcdName,PcdValue) in Str_Pcd_Values:\r
# @retval a dict object contains settings of given PCD type\r
#\r
def _GetPcd(self, Type):\r
- Pcds = sdict()\r
+ Pcds = OrderedDict()\r
#\r
# tdict is a special dict kind of type, used for selecting correct\r
# PCD settings for certain ARCH\r
PcdSet = set()\r
# Find out all possible PCD candidates for self._Arch\r
RecordList = self._RawData[Type, self._Arch]\r
- PcdValueDict = sdict()\r
+ PcdValueDict = OrderedDict()\r
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList:\r
SkuName = SkuName.upper()\r
SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName\r
File=self.MetaFile, Line=Dummy5)\r
if SkuName in (self.SkuIdMgr.SystemSkuId, 'DEFAULT', 'COMMON'):\r
if "." not in TokenSpaceGuid:\r
- PcdSet.add((PcdCName, TokenSpaceGuid, SkuName, Dummy4))\r
+ PcdSet.add((PcdCName, TokenSpaceGuid, SkuName, Dummy5))\r
PcdDict[Arch, PcdCName, TokenSpaceGuid, SkuName] = Setting\r
\r
for PcdCName, TokenSpaceGuid, SkuName, Dummy4 in PcdSet:\r
Setting = PcdDict[self._Arch, PcdCName, TokenSpaceGuid, SkuName]\r
- if Setting == None:\r
+ if Setting is None:\r
continue\r
PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)\r
if (PcdCName, TokenSpaceGuid) in PcdValueDict:\r
\r
return str(max([pcd_size for pcd_size in [get_length(item) for item in sku_values]]))\r
\r
- def IsFieldValueAnArray (self, Value):\r
- Value = Value.strip()\r
- if Value.startswith('GUID') and Value.endswith(')'):\r
- return True\r
- if Value.startswith('L"') and Value.endswith('"') and len(list(Value[2:-1])) > 1:\r
- return True\r
- if Value[0] == '"' and Value[-1] == '"' and len(list(Value[1:-1])) > 1:\r
- return True\r
- if Value[0] == '{' and Value[-1] == '}':\r
- return True\r
- if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2:-1])) > 1:\r
- print 'foo = ', list(Value[2:-1])\r
- return True\r
- if Value[0] == "'" and Value[-1] == "'" and len(list(Value[1:-1])) > 1:\r
- print 'bar = ', list(Value[1:-1])\r
- return True\r
- return False\r
-\r
def ExecuteCommand (self, Command):\r
try:\r
Process = subprocess.Popen(Command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
except:\r
- print 'ERROR: Can not execute command:', Command\r
- sys.exit(1)\r
+ EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute command: %s' % Command)\r
Result = Process.communicate()\r
- if Process.returncode <> 0:\r
- print 'ERROR: Can not collect output from command:', Command\r
- return Result[0], Result[1]\r
+ return Process.returncode, Result[0], Result[1]\r
\r
def IntToCString(self, Value, ValueSize):\r
Result = '"'\r
Result = Result + '"'\r
return Result\r
\r
- def GenerateInitializeFunc(self, SkuName, DefaultStoreName, Pcd, InitByteValue, CApp):\r
- OverrideValues = {DefaultStoreName:""}\r
+ def GetPcdMaxSize(self,Pcd):\r
+ MaxSize = int(Pcd.MaxDatumSize,10) if Pcd.MaxDatumSize else 0\r
+ if Pcd.DatumType not in ['BOOLEAN','UINT8','UINT16','UINT32','UINT64']:\r
+ if Pcd.PcdValueFromComm:\r
+ if Pcd.PcdValueFromComm.startswith("{") and Pcd.PcdValueFromComm.endswith("}"):\r
+ MaxSize = max([len(Pcd.PcdValueFromComm.split(",")),MaxSize])\r
+ elif Pcd.PcdValueFromComm.startswith("\"") or Pcd.PcdValueFromComm.startswith("\'"):\r
+ MaxSize = max([len(Pcd.PcdValueFromComm)-2+1,MaxSize])\r
+ elif Pcd.PcdValueFromComm.startswith("L\""):\r
+ MaxSize = max([2*(len(Pcd.PcdValueFromComm)-3+1),MaxSize])\r
+ else:\r
+ MaxSize = max([len(Pcd.PcdValueFromComm),MaxSize])\r
+ elif Pcd.DatumType not in ['BOOLEAN','UINT8']:\r
+ MaxSize = 1\r
+ elif Pcd.DatumType == 'UINT16':\r
+ MaxSize = 2\r
+ elif Pcd.DatumType == 'UINT32':\r
+ MaxSize = 4\r
+ elif Pcd.DatumType == 'UINT64':\r
+ MaxSize = 8\r
+ return MaxSize\r
+ def GenerateSizeFunction(self,Pcd):\r
+ CApp = "// Default Value in Dec \n"\r
+ CApp = CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
+ for FieldList in [Pcd.DefaultValues]:\r
+ if not FieldList:\r
+ continue\r
+ for FieldName in FieldList:\r
+ FieldName = "." + FieldName\r
+ IsArray = IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])\r
+ if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')):\r
+ try:\r
+ Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True)\r
+ except BadExpression:\r
+ EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %\r
+ (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2]))\r
+ Value, ValueSize = ParseFieldValue(Value)\r
+ CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);\r
+ else:\r
+ NewFieldName = ''\r
+ FieldName_ori = FieldName.strip('.')\r
+ while '[' in FieldName:\r
+ NewFieldName = NewFieldName + FieldName.split('[', 1)[0] + '[0]'\r
+ ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])\r
+ FieldName = FieldName.split(']', 1)[1]\r
+ FieldName = NewFieldName + FieldName\r
+ while '[' in FieldName:\r
+ FieldName = FieldName.rsplit('[', 1)[0]\r
+ CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0])\r
+ for skuname in Pcd.SkuOverrideValues:\r
+ if skuname == "COMMON":\r
+ continue\r
+ for defaultstorenameitem in Pcd.SkuOverrideValues[skuname]:\r
+ CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (skuname, defaultstorenameitem)\r
+ for FieldList in [Pcd.SkuOverrideValues[skuname].get(defaultstorenameitem)]:\r
+ if not FieldList:\r
+ continue\r
+ for FieldName in FieldList:\r
+ FieldName = "." + FieldName\r
+ IsArray = IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])\r
+ if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')):\r
+ try:\r
+ Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True)\r
+ except BadExpression:\r
+ EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %\r
+ (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2]))\r
+ Value, ValueSize = ParseFieldValue(Value)\r
+ CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);\r
+ else:\r
+ NewFieldName = ''\r
+ FieldName_ori = FieldName.strip('.')\r
+ while '[' in FieldName:\r
+ NewFieldName = NewFieldName + FieldName.split('[', 1)[0] + '[0]'\r
+ ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])\r
+ FieldName = FieldName.split(']', 1)[1]\r
+ FieldName = NewFieldName + FieldName\r
+ while '[' in FieldName:\r
+ FieldName = FieldName.rsplit('[', 1)[0]\r
+ CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0])\r
+ if Pcd.PcdFieldValueFromComm:\r
+ CApp = CApp + "// From Command Line \n"\r
+ for FieldName in Pcd.PcdFieldValueFromComm:\r
+ FieldName = "." + FieldName\r
+ IsArray = IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0])\r
+ if IsArray and not (Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].startswith('{GUID') and Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].endswith('}')):\r
+ try:\r
+ Value = ValueExpressionEx(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True)\r
+ except BadExpression:\r
+ EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %\r
+ (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2]))\r
+ Value, ValueSize = ParseFieldValue(Value)\r
+ CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0]);\r
+ else:\r
+ NewFieldName = ''\r
+ FieldName_ori = FieldName.strip('.')\r
+ while '[' in FieldName:\r
+ NewFieldName = NewFieldName + FieldName.split('[', 1)[0] + '[0]'\r
+ ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])\r
+ FieldName = FieldName.split(']', 1)[1]\r
+ FieldName = NewFieldName + FieldName\r
+ while '[' in FieldName:\r
+ FieldName = FieldName.rsplit('[', 1)[0]\r
+ CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, Pcd.PcdFieldValueFromComm[FieldName_ori][1], Pcd.PcdFieldValueFromComm[FieldName_ori][2], Pcd.PcdFieldValueFromComm[FieldName_ori][0])\r
+ CApp = CApp + " *Size = (%d > *Size ? %d : *Size); // The Pcd maxsize is %d \n" % (self.GetPcdMaxSize(Pcd),self.GetPcdMaxSize(Pcd),self.GetPcdMaxSize(Pcd))\r
+ CApp = CApp + "}\n"\r
+ return CApp\r
+ def GenerateSizeStatments(self,Pcd):\r
+ CApp = ' Size = sizeof(%s);\n' % (Pcd.DatumType)\r
+ CApp = CApp + ' Cal_%s_%s_Size(&Size);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
+ return CApp\r
+ def GenerateDefaultValueAssignFunction(self,Pcd):\r
+ CApp = "// Default value in Dec \n"\r
+ CApp = CApp + "void Assign_%s_%s_Default_Value(%s *Pcd){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,Pcd.DatumType)\r
+ CApp = CApp + ' UINT32 FieldSize;\n'\r
+ CApp = CApp + ' CHAR8 *Value;\n'\r
+ DefaultValueFromDec = Pcd.DefaultValueFromDec\r
+ IsArray = IsFieldValueAnArray(Pcd.DefaultValueFromDec)\r
+ if IsArray:\r
+ try:\r
+ DefaultValueFromDec = ValueExpressionEx(Pcd.DefaultValueFromDec, "VOID*")(True)\r
+ except BadExpression:\r
+ EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DEC: %s" %\r
+ (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValueFromDec))\r
+ DefaultValueFromDec = StringToArray(DefaultValueFromDec)\r
+ Value, ValueSize = ParseFieldValue (DefaultValueFromDec)\r
+ if isinstance(Value, str):\r
+ CApp = CApp + ' Pcd = %s; // From DEC Default Value %s\n' % (Value, Pcd.DefaultValueFromDec)\r
+ elif IsArray:\r
+ #\r
+ # Use memcpy() to copy value into field\r
+ #\r
+ CApp = CApp + ' Value = %s; // From DEC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultValueFromDec)\r
+ CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)\r
+ for FieldList in [Pcd.DefaultValues]:\r
+ if not FieldList:\r
+ continue\r
+ for FieldName in FieldList:\r
+ IsArray = IsFieldValueAnArray(FieldList[FieldName][0])\r
+ if IsArray:\r
+ try:\r
+ FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True)\r
+ except BadExpression:\r
+ EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %\r
+ (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1],FieldList[FieldName][2]))\r
+\r
+ try:\r
+ Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])\r
+ except Exception:\r
+ EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName,FieldName)),FieldList[FieldName][1], FieldList[FieldName][2]))\r
+ if isinstance(Value, str):\r
+ CApp = CApp + ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
+ elif IsArray:\r
+ #\r
+ # Use memcpy() to copy value into field\r
+ #\r
+ CApp = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd.DatumType, FieldName)\r
+ CApp = CApp + ' Value = %s; // From %s Line %d Value %s\n' % (self.IntToCString(Value, ValueSize), FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
+ CApp = CApp + ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)\r
+ else:\r
+ if ValueSize > 4:\r
+ CApp = CApp + ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
+ else:\r
+ CApp = CApp + ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
+ CApp = CApp + "}\n"\r
+ return CApp\r
+ def GenerateDefaultValueAssignStatement(self,Pcd):\r
+ CApp = ' Assign_%s_%s_Default_Value(Pcd);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
+ return CApp\r
+ def GenerateInitValueFunction(self,Pcd,SkuName,DefaultStoreName):\r
+ CApp = "// Value in Dsc for Sku: %s, DefaultStore %s\n" % (SkuName,DefaultStoreName)\r
+ CApp = CApp + "void Assign_%s_%s_%s_%s_Value(%s *Pcd){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName,DefaultStoreName,Pcd.DatumType)\r
+ CApp = CApp + ' UINT32 FieldSize;\n'\r
+ CApp = CApp + ' CHAR8 *Value;\n'\r
+\r
+ CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % ('DEFAULT', TAB_DEFAULT_STORES_DEFAULT)\r
+ inherit_OverrideValues = Pcd.SkuOverrideValues[SkuName]\r
+ if (SkuName,DefaultStoreName) == ('DEFAULT',TAB_DEFAULT_STORES_DEFAULT):\r
+ pcddefaultvalue = Pcd.DefaultFromDSC.get('DEFAULT',{}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue\r
+ else:\r
+ if not Pcd.DscRawValue:\r
+ # handle the case that structure pcd is not appear in DSC\r
+ self.CopyDscRawValue(Pcd)\r
+ pcddefaultvalue = Pcd.DscRawValue.get(SkuName,{}).get(DefaultStoreName)\r
+ for FieldList in [pcddefaultvalue,inherit_OverrideValues.get(DefaultStoreName)]:\r
+ if not FieldList:\r
+ continue\r
+ if pcddefaultvalue and FieldList == pcddefaultvalue:\r
+ IsArray = IsFieldValueAnArray(FieldList)\r
+ if IsArray:\r
+ try:\r
+ FieldList = ValueExpressionEx(FieldList, "VOID*")(True)\r
+ except BadExpression:\r
+ EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DSC: %s" %\r
+ (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList))\r
+ Value, ValueSize = ParseFieldValue (FieldList)\r
+\r
+ if (SkuName,DefaultStoreName) == ('DEFAULT',TAB_DEFAULT_STORES_DEFAULT):\r
+ if isinstance(Value, str):\r
+ CApp = CApp + ' Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC.get('DEFAULT',{}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)\r
+ elif IsArray:\r
+ #\r
+ # Use memcpy() to copy value into field\r
+ #\r
+ CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC.get('DEFAULT',{}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)\r
+ CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)\r
+ else:\r
+ if isinstance(Value, str):\r
+ CApp = CApp + ' Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DscRawValue.get(SkuName,{}).get(DefaultStoreName))\r
+ elif IsArray:\r
+ #\r
+ # Use memcpy() to copy value into field\r
+ #\r
+ CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DscRawValue.get(SkuName,{}).get(DefaultStoreName))\r
+ CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)\r
+ continue\r
+ if (SkuName,DefaultStoreName) == ('DEFAULT',TAB_DEFAULT_STORES_DEFAULT) or (( (SkuName,'') not in Pcd.ValueChain) and ( (SkuName,DefaultStoreName) not in Pcd.ValueChain )):\r
+ for FieldName in FieldList:\r
+ IsArray = IsFieldValueAnArray(FieldList[FieldName][0])\r
+ if IsArray:\r
+ try:\r
+ FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True)\r
+ except BadExpression:\r
+ EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %\r
+ (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2]))\r
+ try:\r
+ Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])\r
+ except Exception:\r
+ EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName,FieldName)),FieldList[FieldName][1], FieldList[FieldName][2]))\r
+ if isinstance(Value, str):\r
+ CApp = CApp + ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
+ elif IsArray:\r
+ #\r
+ # Use memcpy() to copy value into field\r
+ #\r
+ CApp = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd.DatumType, FieldName)\r
+ CApp = CApp + ' Value = %s; // From %s Line %d Value %s\n' % (self.IntToCString(Value, ValueSize), FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
+ CApp = CApp + ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)\r
+ else:\r
+ if ValueSize > 4:\r
+ CApp = CApp + ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
+ else:\r
+ CApp = CApp + ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
+ CApp = CApp + "}\n"\r
+ return CApp\r
+ def GenerateInitValueStatement(self,Pcd,SkuName,DefaultStoreName):\r
+ CApp = ' Assign_%s_%s_%s_%s_Value(Pcd);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName,DefaultStoreName)\r
+ return CApp\r
+ def GenerateCommandLineValue(self,Pcd):\r
+ CApp = "// Value in CommandLine\n"\r
+ CApp = CApp + "void Assign_%s_%s_CommandLine_Value(%s *Pcd){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,Pcd.DatumType)\r
+ CApp = CApp + ' UINT32 FieldSize;\n'\r
+ CApp = CApp + ' CHAR8 *Value;\n'\r
+\r
+ pcddefaultvalue = Pcd.PcdValueFromComm\r
+ for FieldList in [pcddefaultvalue,Pcd.PcdFieldValueFromComm]:\r
+ if not FieldList:\r
+ continue\r
+ if pcddefaultvalue and FieldList == pcddefaultvalue:\r
+ IsArray = IsFieldValueAnArray(FieldList)\r
+ if IsArray:\r
+ try:\r
+ FieldList = ValueExpressionEx(FieldList, "VOID*")(True)\r
+ except BadExpression:\r
+ EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from Command: %s" %\r
+ (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList))\r
+ Value, ValueSize = ParseFieldValue (FieldList)\r
+\r
+ if isinstance(Value, str):\r
+ CApp = CApp + ' Pcd = %s; // From Command Line \n' % (Value)\r
+ elif IsArray:\r
+ #\r
+ # Use memcpy() to copy value into field\r
+ #\r
+ CApp = CApp + ' Value = %s; // From Command Line.\n' % (self.IntToCString(Value, ValueSize))\r
+ CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)\r
+ continue\r
+ for FieldName in FieldList:\r
+ IsArray = IsFieldValueAnArray(FieldList[FieldName][0])\r
+ if IsArray:\r
+ try:\r
+ FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True)\r
+ except BadExpression:\r
+ EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %\r
+ (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2]))\r
+ except:\r
+ print "error"\r
+ try:\r
+ Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])\r
+ except Exception:\r
+ EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName,FieldName)),FieldList[FieldName][1], FieldList[FieldName][2]))\r
+ if isinstance(Value, str):\r
+ CApp = CApp + ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
+ elif IsArray:\r
+ #\r
+ # Use memcpy() to copy value into field\r
+ #\r
+ CApp = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd.DatumType, FieldName)\r
+ CApp = CApp + ' Value = %s; // From %s Line %d Value %s\n' % (self.IntToCString(Value, ValueSize), FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
+ CApp = CApp + ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)\r
+ else:\r
+ if ValueSize > 4:\r
+ CApp = CApp + ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
+ else:\r
+ CApp = CApp + ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
+ CApp = CApp + "}\n"\r
+ return CApp\r
+ def GenerateCommandLineValueStatement(self,Pcd):\r
+ CApp = ' Assign_%s_%s_CommandLine_Value(Pcd);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
+ return CApp\r
+ def GenerateInitializeFunc(self, SkuName, DefaultStore, Pcd, InitByteValue, CApp):\r
+ OverrideValues = {DefaultStore:""}\r
if Pcd.SkuOverrideValues:\r
OverrideValues = Pcd.SkuOverrideValues[SkuName]\r
for DefaultStoreName in OverrideValues.keys():\r
CApp = CApp + '\n'\r
\r
if SkuName in Pcd.SkuInfoList:\r
- DefaultValue = Pcd.SkuInfoList[SkuName].DefaultStoreDict.get(DefaultStoreName,Pcd.SkuInfoList[SkuName].HiiDefaultValue) if Pcd.SkuInfoList[SkuName].HiiDefaultValue else Pcd.SkuInfoList[SkuName].DefaultValue\r
+ DefaultValue = Pcd.SkuInfoList[SkuName].DefaultStoreDict.get(DefaultStoreName,Pcd.SkuInfoList[SkuName].HiiDefaultValue if Pcd.SkuInfoList[SkuName].HiiDefaultValue else Pcd.SkuInfoList[SkuName].DefaultValue)\r
else:\r
DefaultValue = Pcd.DefaultValue\r
PcdDefaultValue = StringToArray(DefaultValue.strip())\r
# in a structure. The size formula for this case is:\r
# OFFSET_OF(FlexbleArrayField) + sizeof(FlexibleArray[0]) * (HighestIndex + 1)\r
#\r
- CApp = CApp + ' Size = sizeof(%s);\n' % (Pcd.DatumType)\r
- for FieldList in [Pcd.DefaultValues]:\r
- if not FieldList:\r
- continue\r
- for FieldName in FieldList:\r
- FieldName = "." + FieldName\r
- IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])\r
- if IsArray:\r
- Value, ValueSize = ParseFieldValue (FieldList[FieldName.strip(".")][0])\r
- CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0));\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."));\r
- else:\r
- NewFieldName = ''\r
- while '[' in FieldName:\r
- NewFieldName = NewFieldName + FieldName.split('[', 1)[0] + '[0]'\r
- ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])\r
- FieldName = FieldName.split(']', 1)[1]\r
- FieldName = NewFieldName + FieldName\r
- while '[' in FieldName:\r
- FieldName = FieldName.rsplit('[', 1)[0]\r
- CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d);\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1)\r
- for skuname in self.SkuIdMgr.GetSkuChain(SkuName):\r
- inherit_OverrideValues = Pcd.SkuOverrideValues[skuname]\r
- for FieldList in [inherit_OverrideValues.get(DefaultStoreName)]:\r
- if not FieldList:\r
- continue\r
- for FieldName in FieldList:\r
- FieldName = "." + FieldName\r
- IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])\r
- if IsArray:\r
- Value, ValueSize = ParseFieldValue (FieldList[FieldName.strip(".")][0])\r
- CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0));\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."));\r
- else:\r
- NewFieldName = ''\r
- while '[' in FieldName:\r
- NewFieldName = NewFieldName + FieldName.split('[', 1)[0] + '[0]'\r
- ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])\r
- FieldName = FieldName.split(']', 1)[1]\r
- FieldName = NewFieldName + FieldName\r
- while '[' in FieldName:\r
- FieldName = FieldName.rsplit('[', 1)[0]\r
- CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d);\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1)\r
- if skuname == SkuName:\r
- break\r
+ CApp = CApp + self.GenerateSizeStatments(Pcd)\r
\r
#\r
# Allocate and zero buffer for the PCD\r
#\r
# Assign field values in PCD\r
#\r
- for FieldList in [Pcd.DefaultValues]:\r
- if not FieldList:\r
- continue\r
- for FieldName in FieldList:\r
- IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0])\r
- try:\r
- Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])\r
- except Exception:\r
- print FieldList[FieldName][0]\r
- if isinstance(Value, str):\r
- CApp = CApp + ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
- elif IsArray:\r
- #\r
- # Use memcpy() to copy value into field\r
- #\r
- CApp = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd.DatumType, FieldName)\r
- CApp = CApp + ' Value = %s; // From %s Line %d Value %s\n' % (self.IntToCString(Value, ValueSize), FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
- CApp = CApp + ' memcpy (&Pcd->%s[0], Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)\r
- else:\r
- if ValueSize > 4:\r
- CApp = CApp + ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
- else:\r
- CApp = CApp + ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
- for skuname in self.SkuIdMgr.GetSkuChain(SkuName):\r
- inherit_OverrideValues = Pcd.SkuOverrideValues[skuname]\r
- for FieldList in [Pcd.DefaultFromDSC,inherit_OverrideValues.get(DefaultStoreName)]:\r
- if not FieldList:\r
- continue\r
- if Pcd.DefaultFromDSC and FieldList == Pcd.DefaultFromDSC:\r
- IsArray = self.IsFieldValueAnArray(FieldList)\r
- Value, ValueSize = ParseFieldValue (FieldList)\r
- if isinstance(Value, str):\r
- CApp = CApp + ' Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC)\r
- elif IsArray:\r
- #\r
- # Use memcpy() to copy value into field\r
- #\r
- CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC)\r
- CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)\r
- continue\r
-\r
- for FieldName in FieldList:\r
- IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0])\r
- try:\r
- Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])\r
- except Exception:\r
- print FieldList[FieldName][0]\r
- if isinstance(Value, str):\r
- CApp = CApp + ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
- elif IsArray:\r
- #\r
- # Use memcpy() to copy value into field\r
- #\r
- CApp = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd.DatumType, FieldName)\r
- CApp = CApp + ' Value = %s; // From %s Line %d Value %s\n' % (self.IntToCString(Value, ValueSize), FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
- CApp = CApp + ' memcpy (&Pcd->%s[0], Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)\r
- else:\r
- if ValueSize > 4:\r
- CApp = CApp + ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
- else:\r
- CApp = CApp + ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
- if skuname == SkuName:\r
- break\r
+ CApp = CApp + self.GenerateDefaultValueAssignStatement(Pcd)\r
+ if Pcd.Type not in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],\r
+ self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:\r
+ for skuname in self.SkuIdMgr.GetSkuChain(SkuName):\r
+ storeset = [DefaultStoreName] if DefaultStoreName == TAB_DEFAULT_STORES_DEFAULT else [TAB_DEFAULT_STORES_DEFAULT, DefaultStoreName]\r
+ for defaultstorenameitem in storeset:\r
+ CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (skuname, defaultstorenameitem)\r
+ CApp = CApp + self.GenerateInitValueStatement(Pcd,skuname,defaultstorenameitem)\r
+ if skuname == SkuName:\r
+ break\r
+ else:\r
+ CApp = CApp + "// SkuName: %s, DefaultStoreName: STANDARD \n" % self.SkuIdMgr.SystemSkuId\r
+ CApp = CApp + self.GenerateInitValueStatement(Pcd,self.SkuIdMgr.SystemSkuId,TAB_DEFAULT_STORES_DEFAULT)\r
+ CApp = CApp + self.GenerateCommandLineValueStatement(Pcd)\r
#\r
# Set new PCD value and size\r
#\r
CApp = PcdMainCHeader\r
\r
Includes = {}\r
+ IncludeFiles = set()\r
for PcdName in StructuredPcds:\r
Pcd = StructuredPcds[PcdName]\r
- IncludeFile = Pcd.StructuredPcdIncludeFile\r
- if IncludeFile not in Includes:\r
- Includes[IncludeFile] = True\r
- CApp = CApp + '#include <%s>\n' % (IncludeFile)\r
+ for IncludeFile in Pcd.StructuredPcdIncludeFile:\r
+ if IncludeFile not in Includes:\r
+ Includes[IncludeFile] = True\r
+ IncludeFiles.add(IncludeFile)\r
+ CApp = CApp + '#include <%s>\n' % (IncludeFile)\r
CApp = CApp + '\n'\r
-\r
for PcdName in StructuredPcds:\r
Pcd = StructuredPcds[PcdName]\r
- if not Pcd.SkuOverrideValues:\r
- InitByteValue, CApp = self.GenerateInitializeFunc(self.SkuIdMgr.SystemSkuId, 'STANDARD', Pcd, InitByteValue, CApp)\r
+ CApp = CApp + self.GenerateSizeFunction(Pcd)\r
+ CApp = CApp + self.GenerateDefaultValueAssignFunction(Pcd)\r
+ CApp = CApp + self.GenerateCommandLineValue(Pcd)\r
+ if not Pcd.SkuOverrideValues or Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],\r
+ self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:\r
+ CApp = CApp + self.GenerateInitValueFunction(Pcd,self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT)\r
+ else:\r
+ for SkuName in self.SkuIdMgr.SkuOverrideOrder():\r
+ if SkuName not in Pcd.SkuOverrideValues:\r
+ continue\r
+ for DefaultStoreName in Pcd.SkuOverrideValues[SkuName]:\r
+ CApp = CApp + self.GenerateInitValueFunction(Pcd,SkuName,DefaultStoreName)\r
+ if not Pcd.SkuOverrideValues or Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],\r
+ self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:\r
+ InitByteValue, CApp = self.GenerateInitializeFunc(self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT, Pcd, InitByteValue, CApp)\r
else:\r
for SkuName in self.SkuIdMgr.SkuOverrideOrder():\r
if SkuName not in Pcd.SkuOverrideValues:\r
CApp = CApp + ' )\n'\r
CApp = CApp + '{\n'\r
for Pcd in StructuredPcds.values():\r
- if not Pcd.SkuOverrideValues:\r
- CApp = CApp + ' Initialize_%s_%s_%s_%s();\n' % (self.SkuIdMgr.SystemSkuId, 'STANDARD', Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
+ if not Pcd.SkuOverrideValues or Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:\r
+ CApp = CApp + ' Initialize_%s_%s_%s_%s();\n' % (self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
else:\r
for SkuName in self.SkuIdMgr.SkuOverrideOrder():\r
if SkuName not in Pcd.SkuOverrideValues:\r
if not os.path.exists(self.OutputPath):\r
os.makedirs(self.OutputPath)\r
CAppBaseFileName = os.path.join(self.OutputPath, PcdValueInitName)\r
- File = open (CAppBaseFileName + '.c', 'w')\r
- File.write(CApp)\r
- File.close()\r
+ SaveFileOnChange(CAppBaseFileName + '.c', CApp, False)\r
\r
MakeApp = PcdMakefileHeader\r
if sys.platform == "win32":\r
- MakeApp = MakeApp + 'ARCH = IA32\nAPPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s\%s.obj\n' % (self.OutputPath, PcdValueInitName) + 'INC = '\r
+ MakeApp = MakeApp + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s\%s.obj\n' % (self.OutputPath, PcdValueInitName) + 'INC = '\r
else:\r
MakeApp = MakeApp + PcdGccMakefile\r
MakeApp = MakeApp + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s/%s.o\n' % (self.OutputPath, PcdValueInitName) + \\r
'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'INCLUDE +='\r
\r
+ IncSearchList = []\r
PlatformInc = {}\r
for Cache in self._Bdb._CACHE_.values():\r
if Cache.MetaFile.Ext.lower() != '.dec':\r
continue\r
if Cache.Includes:\r
if str(Cache.MetaFile.Path) not in PlatformInc:\r
- PlatformInc[str(Cache.MetaFile.Path)] = Cache.Includes\r
+ PlatformInc[str(Cache.MetaFile.Path)] = []\r
+ PlatformInc[str(Cache.MetaFile.Path)].append (os.path.dirname(Cache.MetaFile.Path))\r
+ PlatformInc[str(Cache.MetaFile.Path)].extend (Cache.CommonIncludes)\r
\r
PcdDependDEC = []\r
for Pcd in StructuredPcds.values():\r
if pkg in PlatformInc:\r
for inc in PlatformInc[pkg]:\r
MakeApp += '-I' + str(inc) + ' '\r
+ IncSearchList.append(inc)\r
MakeApp = MakeApp + '\n'\r
\r
CC_FLAGS = LinuxCFLAGS\r
\r
if sys.platform == "win32":\r
MakeApp = MakeApp + PcdMakefileEnd\r
+ MakeApp = MakeApp + '\n'\r
+ IncludeFileFullPaths = []\r
+ for includefile in IncludeFiles:\r
+ for includepath in IncSearchList:\r
+ includefullpath = os.path.join(str(includepath),includefile)\r
+ if os.path.exists(includefullpath):\r
+ IncludeFileFullPaths.append(os.path.normpath(includefullpath))\r
+ break\r
+ SearchPathList = []\r
+ SearchPathList.append(os.path.normpath(mws.join(GlobalData.gWorkspace, "BaseTools/Source/C/Include")))\r
+ SearchPathList.append(os.path.normpath(mws.join(GlobalData.gWorkspace, "BaseTools/Source/C/Common")))\r
+ SearchPathList.extend([str(item) for item in IncSearchList])\r
+ IncFileList = GetDependencyList(IncludeFileFullPaths,SearchPathList)\r
+ for include_file in IncFileList:\r
+ MakeApp += "$(OBJECTS) : %s\n" % include_file\r
MakeFileName = os.path.join(self.OutputPath, 'Makefile')\r
- File = open (MakeFileName, 'w')\r
- File.write(MakeApp)\r
- File.close()\r
+ MakeApp += "$(OBJECTS) : %s\n" % MakeFileName\r
+ SaveFileOnChange(MakeFileName, MakeApp, False)\r
\r
InputValueFile = os.path.join(self.OutputPath, 'Input.txt')\r
OutputValueFile = os.path.join(self.OutputPath, 'Output.txt')\r
- File = open (InputValueFile, 'w')\r
- File.write(InitByteValue)\r
- File.close()\r
+ SaveFileOnChange(InputValueFile, InitByteValue, False)\r
+\r
+ PcdValueInitExe = PcdValueInitName\r
+ if not sys.platform == "win32":\r
+ PcdValueInitExe = os.path.join(os.getenv("EDK_TOOLS_PATH"), 'Source', 'C', 'bin', PcdValueInitName)\r
+ else:\r
+ PcdValueInitExe = os.path.join(os.getenv("EDK_TOOLS_PATH"), 'Bin', 'Win32', PcdValueInitName) +".exe"\r
\r
Messages = ''\r
if sys.platform == "win32":\r
- StdOut, StdErr = self.ExecuteCommand ('nmake clean & nmake -f %s' % (MakeFileName))\r
+ MakeCommand = 'nmake -f %s' % (MakeFileName)\r
+ returncode, StdOut, StdErr = self.ExecuteCommand (MakeCommand)\r
Messages = StdOut\r
else:\r
- StdOut, StdErr = self.ExecuteCommand ('make clean & make -f %s' % (MakeFileName))\r
+ MakeCommand = 'make -f %s' % (MakeFileName)\r
+ returncode, StdOut, StdErr = self.ExecuteCommand (MakeCommand)\r
Messages = StdErr\r
Messages = Messages.split('\n')\r
- for Message in Messages:\r
- if " error" in Message:\r
- FileInfo = Message.strip().split('(')\r
- if len (FileInfo) > 1:\r
- FileName = FileInfo [0]\r
- FileLine = FileInfo [1].split (')')[0]\r
- else:\r
- FileInfo = Message.strip().split(':')\r
- FileName = FileInfo [0]\r
- FileLine = FileInfo [1]\r
-\r
- File = open (FileName, 'r')\r
- FileData = File.readlines()\r
- File.close()\r
- error_line = FileData[int (FileLine) - 1]\r
- if r"//" in error_line:\r
- c_line,dsc_line = error_line.split(r"//")\r
- else:\r
- dsc_line = error_line\r
-\r
- message_itmes = Message.split(":")\r
- Index = 0\r
- for item in message_itmes:\r
- if "PcdValueInit.c" in item:\r
- Index = message_itmes.index(item)\r
- message_itmes[Index] = dsc_line.strip()\r
- break\r
-\r
- EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, ":".join(message_itmes[Index:]))\r
+ MessageGroup = []\r
+ if returncode <>0:\r
+ CAppBaseFileName = os.path.join(self.OutputPath, PcdValueInitName)\r
+ File = open (CAppBaseFileName + '.c', 'r')\r
+ FileData = File.readlines()\r
+ File.close()\r
+ for Message in Messages:\r
+ if " error" in Message or "warning" in Message:\r
+ FileInfo = Message.strip().split('(')\r
+ if len (FileInfo) > 1:\r
+ FileName = FileInfo [0]\r
+ FileLine = FileInfo [1].split (')')[0]\r
+ else:\r
+ FileInfo = Message.strip().split(':')\r
+ FileName = FileInfo [0]\r
+ FileLine = FileInfo [1]\r
+ if FileLine.isdigit():\r
+ error_line = FileData[int (FileLine) - 1]\r
+ if r"//" in error_line:\r
+ c_line,dsc_line = error_line.split(r"//")\r
+ else:\r
+ dsc_line = error_line\r
+ message_itmes = Message.split(":")\r
+ Index = 0\r
+ if "PcdValueInit.c" not in Message:\r
+ if not MessageGroup:\r
+ MessageGroup.append(Message)\r
+ break\r
+ else:\r
+ for item in message_itmes:\r
+ if "PcdValueInit.c" in item:\r
+ Index = message_itmes.index(item)\r
+ message_itmes[Index] = dsc_line.strip()\r
+ break\r
+ MessageGroup.append(":".join(message_itmes[Index:]).strip())\r
+ continue\r
+ else:\r
+ MessageGroup.append(Message)\r
+ if MessageGroup:\r
+ EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "\n".join(MessageGroup) )\r
+ else:\r
+ EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute command: %s' % MakeCommand)\r
\r
- PcdValueInitExe = PcdValueInitName\r
- if not sys.platform == "win32":\r
- PcdValueInitExe = os.path.join(os.getenv("EDK_TOOLS_PATH"), 'Source', 'C', 'bin', PcdValueInitName)\r
+ if self.NeedUpdateOutput(OutputValueFile, PcdValueInitExe ,InputValueFile):\r
+ Command = PcdValueInitExe + ' -i %s -o %s' % (InputValueFile, OutputValueFile)\r
+ returncode, StdOut, StdErr = self.ExecuteCommand (Command)\r
+ if returncode <> 0:\r
+ EdkLogger.warn('Build', COMMAND_FAILURE, 'Can not collect output from command: %s' % Command)\r
\r
- StdOut, StdErr = self.ExecuteCommand (PcdValueInitExe + ' -i %s -o %s' % (InputValueFile, OutputValueFile))\r
File = open (OutputValueFile, 'r')\r
FileBuffer = File.readlines()\r
File.close()\r
StructurePcdSet.append((PcdInfo[0],PcdInfo[1], PcdInfo[2], PcdInfo[3], PcdValue[2].strip()))\r
return StructurePcdSet\r
\r
+ def NeedUpdateOutput(self,OutputFile, ValueCFile, StructureInput):\r
+ if not os.path.exists(OutputFile):\r
+ return True\r
+ if os.stat(OutputFile).st_mtime <= os.stat(ValueCFile).st_mtime:\r
+ return True\r
+ if os.stat(OutputFile).st_mtime <= os.stat(StructureInput).st_mtime:\r
+ return True\r
+ return False\r
+\r
## Retrieve dynamic PCD settings\r
#\r
# @param Type PCD type\r
def _GetDynamicPcd(self, Type):\r
\r
\r
- Pcds = sdict()\r
+ Pcds = OrderedDict()\r
#\r
# tdict is a special dict kind of type, used for selecting correct\r
# PCD settings for certain ARCH and SKU\r
EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName,\r
File=self.MetaFile, Line=Dummy5)\r
if "." not in TokenSpaceGuid:\r
- PcdList.append((PcdCName, TokenSpaceGuid, SkuName, Dummy4))\r
+ PcdList.append((PcdCName, TokenSpaceGuid, SkuName, Dummy5))\r
PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting\r
\r
# Remove redundant PCD candidates, per the ARCH and SKU\r
for PcdCName, TokenSpaceGuid, SkuName, Dummy4 in PcdList:\r
\r
Setting = PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceGuid]\r
- if Setting == None:\r
+ if Setting is None:\r
continue\r
\r
PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)\r
pcdDecObject = self._DecPcds[pcd.TokenCName, pcd.TokenSpaceGuidCName]\r
# Only fix the value while no value provided in DSC file.\r
for sku in pcd.SkuInfoList.values():\r
- if (sku.DefaultValue == "" or sku.DefaultValue==None):\r
+ if not sku.DefaultValue:\r
sku.DefaultValue = pcdDecObject.DefaultValue\r
if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():\r
valuefromDec = pcdDecObject.DefaultValue\r
return True\r
else:\r
return False\r
+ def CopyDscRawValue(self,Pcd):\r
+ if Pcd.DscRawValue is None:\r
+ Pcd.DscRawValue = dict()\r
+ if Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:\r
+ if self.SkuIdMgr.SystemSkuId not in Pcd.DscRawValue:\r
+ Pcd.DscRawValue[self.SkuIdMgr.SystemSkuId] = {}\r
+ Pcd.DscRawValue[self.SkuIdMgr.SystemSkuId][TAB_DEFAULT_STORES_DEFAULT] = Pcd.DefaultValue\r
+ for skuname in Pcd.SkuInfoList:\r
+ Pcd.DscRawValue[skuname] = {}\r
+ if Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:\r
+ for defaultstore in Pcd.SkuInfoList[skuname].DefaultStoreDict:\r
+ Pcd.DscRawValue[skuname][defaultstore] = Pcd.SkuInfoList[skuname].DefaultStoreDict[defaultstore]\r
+ else:\r
+ Pcd.DscRawValue[skuname][TAB_DEFAULT_STORES_DEFAULT] = Pcd.SkuInfoList[skuname].DefaultValue\r
def CompletePcdValues(self,PcdSet):\r
Pcds = {}\r
DefaultStoreObj = DefaultStore(self._GetDefaultStores())\r
DefaultStores = set([storename for pcdobj in PcdSet.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict.keys()])\r
for PcdCName, TokenSpaceGuid in PcdSet:\r
PcdObj = PcdSet[(PcdCName, TokenSpaceGuid)]\r
+ self.CopyDscRawValue(PcdObj)\r
if PcdObj.Type not in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_DEFAULT],\r
self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],\r
self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_VPD],\r
\r
VariableAttrs = {}\r
\r
- Pcds = sdict()\r
+ Pcds = OrderedDict()\r
#\r
# tdict is a special dict kind of type, used for selecting correct\r
# PCD settings for certain ARCH and SKU\r
SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName\r
DefaultStore = DefaultStore.upper()\r
if DefaultStore == "COMMON":\r
- DefaultStore = "STANDARD"\r
+ DefaultStore = TAB_DEFAULT_STORES_DEFAULT\r
if SkuName not in AvailableSkuIdSet:\r
EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName,\r
File=self.MetaFile, Line=Dummy5)\r
EdkLogger.error('build', PARAMETER_INVALID, 'DefaultStores %s is not defined in [DefaultStores] section' % DefaultStore,\r
File=self.MetaFile, Line=Dummy5)\r
if "." not in TokenSpaceGuid:\r
- PcdSet.add((PcdCName, TokenSpaceGuid, SkuName,DefaultStore, Dummy4))\r
+ PcdSet.add((PcdCName, TokenSpaceGuid, SkuName,DefaultStore, Dummy5))\r
PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid,DefaultStore] = Setting\r
\r
\r
for PcdCName, TokenSpaceGuid, SkuName,DefaultStore, Dummy4 in PcdSet:\r
\r
Setting = PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceGuid,DefaultStore]\r
- if Setting == None:\r
+ if Setting is None:\r
continue\r
VariableName, VariableGuid, VariableOffset, DefaultValue, VarAttribute = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)\r
\r
for pcd in Pcds.values():\r
SkuInfoObj = pcd.SkuInfoList.values()[0]\r
pcdDecObject = self._DecPcds[pcd.TokenCName, pcd.TokenSpaceGuidCName]\r
+ pcd.DatumType = pcdDecObject.DatumType\r
# Only fix the value while no value provided in DSC file.\r
for sku in pcd.SkuInfoList.values():\r
- if (sku.HiiDefaultValue == "" or sku.HiiDefaultValue == None):\r
+ if (sku.HiiDefaultValue == "" or sku.HiiDefaultValue is None):\r
sku.HiiDefaultValue = pcdDecObject.DefaultValue\r
+ for default_store in sku.DefaultStoreDict:\r
+ sku.DefaultStoreDict[default_store]=pcdDecObject.DefaultValue\r
+ pcd.DefaultValue = pcdDecObject.DefaultValue\r
if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():\r
valuefromDec = pcdDecObject.DefaultValue\r
SkuInfo = SkuInfoClass('DEFAULT', '0', SkuInfoObj.VariableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec,VariableAttribute=SkuInfoObj.VariableAttribute,DefaultStore={DefaultStore:valuefromDec})\r
MaxSize = int(pcd.MaxDatumSize, 0)\r
else:\r
MaxSize = 0\r
- if pcdDecObject.DatumType == 'VOID*':\r
+ if pcd.DatumType not in ['BOOLEAN','UINT8','UINT16','UINT32','UINT64']:\r
for (_, skuobj) in pcd.SkuInfoList.items():\r
datalen = 0\r
skuobj.HiiDefaultValue = StringToArray(skuobj.HiiDefaultValue)\r
def _GetDynamicVpdPcd(self, Type):\r
\r
\r
- Pcds = sdict()\r
+ Pcds = OrderedDict()\r
#\r
# tdict is a special dict kind of type, used for selecting correct\r
# PCD settings for certain ARCH and SKU\r
EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName,\r
File=self.MetaFile, Line=Dummy5)\r
if "." not in TokenSpaceGuid:\r
- PcdList.append((PcdCName, TokenSpaceGuid, SkuName, Dummy4))\r
+ PcdList.append((PcdCName, TokenSpaceGuid, SkuName, Dummy5))\r
PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting\r
\r
# Remove redundant PCD candidates, per the ARCH and SKU\r
for PcdCName, TokenSpaceGuid, SkuName, Dummy4 in PcdList:\r
Setting = PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceGuid]\r
- if Setting == None:\r
+ if Setting is None:\r
continue\r
#\r
# For the VOID* type, it can have optional data of MaxDatumSize and InitialValue\r
for pcd in Pcds.values():\r
SkuInfoObj = pcd.SkuInfoList.values()[0]\r
pcdDecObject = self._DecPcds[pcd.TokenCName, pcd.TokenSpaceGuidCName]\r
+ pcd.DatumType = pcdDecObject.DatumType\r
# Only fix the value while no value provided in DSC file.\r
for sku in pcd.SkuInfoList.values():\r
- if (sku.DefaultValue == "" or sku.DefaultValue==None):\r
+ if not sku.DefaultValue:\r
sku.DefaultValue = pcdDecObject.DefaultValue\r
if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():\r
valuefromDec = pcdDecObject.DefaultValue\r
self.Pcds[Name, Guid].DefaultValue = Value\r
@property\r
def DecPcds(self):\r
- if self._DecPcds == None:\r
+ if self._DecPcds is None:\r
FdfInfList = []\r
if GlobalData.gFdfParser:\r
FdfInfList = GlobalData.gFdfParser.Profile.InfList\r