## @file\r
# Generate AutoGen.h, AutoGen.c and *.depex files\r
#\r
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2017, 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
import re\r
import os.path as path\r
import copy\r
+import uuid\r
\r
import GenC\r
import GenMake\r
import Common.VpdInfoFile as VpdInfoFile\r
from GenPcdDb import CreatePcdDatabaseCode\r
from Workspace.MetaFileCommentParser import UsageList\r
-\r
+from Common.MultipleWorkspace import MultipleWorkspace as mws\r
import InfSectionParser\r
+import datetime\r
+import hashlib\r
\r
## Regular expression for splitting Dependency Expression string into tokens\r
gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")\r
\r
\r
## Build rule configuration file\r
-gDefaultBuildRuleFile = 'Conf/build_rule.txt'\r
+gDefaultBuildRuleFile = 'build_rule.txt'\r
+\r
+## Tools definition configuration file\r
+gDefaultToolsDefFile = 'tools_def.txt'\r
\r
## Build rule default version\r
AutoGenReqBuildRuleVerNum = "0.1"\r
gAutoGenStringFileName = "%(module_name)sStrDefs.h"\r
gAutoGenStringFormFileName = "%(module_name)sStrDefs.hpk"\r
gAutoGenDepexFileName = "%(module_name)s.depex"\r
-\r
+gAutoGenImageDefFileName = "%(module_name)sImgDefs.h"\r
+gAutoGenIdfFileName = "%(module_name)sIdf.hpk"\r
gInfSpecVersion = "0x00010017"\r
\r
#\r
\r
${depexsection_item}\r
\r
+${userextension_tianocore_item}\r
+\r
${tail_comments}\r
\r
[BuildOptions.${module_arch}]\r
# @param SkuId SKU id from command line\r
#\r
def _Init(self, WorkspaceDir, ActivePlatform, Target, Toolchain, ArchList, MetaFileDb,\r
- BuildConfig, ToolDefinition, FlashDefinitionFile='', Fds=None, Fvs=None, Caps=None, SkuId='', UniFlag=None, \r
+ BuildConfig, ToolDefinition, FlashDefinitionFile='', Fds=None, Fvs=None, Caps=None, SkuId='', UniFlag=None,\r
Progress=None, BuildModule=None):\r
if Fds is None:\r
Fds = []\r
self.FvTargetList = Fvs\r
self.CapTargetList = Caps\r
self.AutoGenObjectList = []\r
+ self._BuildDir = None\r
+ self._FvDir = None\r
+ self._MakeFileDir = None\r
+ self._BuildCommand = None\r
\r
# there's many relative directory operations, so ...\r
os.chdir(self.WorkspaceDir)\r
\r
# Validate build target\r
if self.BuildTarget not in self.Platform.BuildTargets:\r
- EdkLogger.error("build", PARAMETER_INVALID, \r
+ EdkLogger.error("build", PARAMETER_INVALID,\r
ExtraData="Build target [%s] is not supported by the platform. [Valid target: %s]"\r
% (self.BuildTarget, " ".join(self.Platform.BuildTargets)))\r
\r
- # Validate SKU ID\r
- if not self.SkuId:\r
- self.SkuId = 'DEFAULT'\r
-\r
- if self.SkuId not in self.Platform.SkuIds:\r
- EdkLogger.error("build", PARAMETER_INVALID,\r
- ExtraData="SKU-ID [%s] is not supported by the platform. [Valid SKU-ID: %s]"\r
- % (self.SkuId, " ".join(self.Platform.SkuIds.keys())))\r
-\r
+ \r
# parse FDF file to get PCDs in it, if any\r
if not self.FdfFile:\r
self.FdfFile = self.Platform.FlashDefinition\r
- \r
+\r
EdkLogger.info("")\r
if self.ArchList:\r
EdkLogger.info('%-16s = %s' % ("Architecture(s)", ' '.join(self.ArchList)))\r
EdkLogger.info('%-16s = %s' % ("Build target", self.BuildTarget))\r
- EdkLogger.info('%-16s = %s' % ("Toolchain",self.ToolChain)) \r
- \r
+ EdkLogger.info('%-16s = %s' % ("Toolchain", self.ToolChain))\r
+\r
EdkLogger.info('\n%-24s = %s' % ("Active Platform", self.Platform))\r
if BuildModule:\r
EdkLogger.info('%-24s = %s' % ("Active Module", BuildModule))\r
- \r
+\r
if self.FdfFile:\r
EdkLogger.info('%-24s = %s' % ("Flash Image Definition", self.FdfFile))\r
\r
EdkLogger.verbose("\nFLASH_DEFINITION = %s" % self.FdfFile)\r
- \r
+\r
if Progress:\r
Progress.Start("\nProcessing meta-data")\r
- \r
+\r
if self.FdfFile:\r
#\r
# Mark now build in AutoGen Phase\r
#\r
- GlobalData.gAutoGenPhase = True \r
+ GlobalData.gAutoGenPhase = True\r
Fdf = FdfParser(self.FdfFile.Path)\r
Fdf.ParseFile()\r
GlobalData.gFdfParser = Fdf\r
GlobalData.gAutoGenPhase = False\r
PcdSet = Fdf.Profile.PcdDict\r
+ if Fdf.CurrentFdName and Fdf.CurrentFdName in Fdf.Profile.FdDict:\r
+ FdDict = Fdf.Profile.FdDict[Fdf.CurrentFdName]\r
+ for FdRegion in FdDict.RegionList:\r
+ if str(FdRegion.RegionType) is 'FILE' and self.Platform.VpdToolGuid in str(FdRegion.RegionDataList):\r
+ if int(FdRegion.Offset) % 8 != 0:\r
+ EdkLogger.error("build", FORMAT_INVALID, 'The VPD Base Address %s must be 8-byte aligned.' % (FdRegion.Offset))\r
ModuleList = Fdf.Profile.InfList\r
self.FdfProfile = Fdf.Profile\r
for fvname in self.FvTargetList:\r
if fvname.upper() not in self.FdfProfile.FvDict:\r
EdkLogger.error("build", OPTION_VALUE_INVALID,\r
"No such an FV in FDF file: %s" % fvname)\r
+\r
+ # In DSC file may use FILE_GUID to override the module, then in the Platform.Modules use FILE_GUIDmodule.inf as key,\r
+ # but the path (self.MetaFile.Path) is the real path\r
+ for key in self.FdfProfile.InfDict:\r
+ if key == 'ArchTBD':\r
+ Platform_cache = {}\r
+ MetaFile_cache = {}\r
+ for Arch in self.ArchList:\r
+ Platform_cache[Arch] = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]\r
+ MetaFile_cache[Arch] = []\r
+ for Pkey in Platform_cache[Arch].Modules.keys():\r
+ MetaFile_cache[Arch].append(Platform_cache[Arch].Modules[Pkey].MetaFile)\r
+ for Inf in self.FdfProfile.InfDict[key]:\r
+ ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch)\r
+ for Arch in self.ArchList:\r
+ if ModuleFile in MetaFile_cache[Arch]:\r
+ break\r
+ else:\r
+ ModuleData = self.BuildDatabase[ModuleFile, Arch, Target, Toolchain]\r
+ if not ModuleData.IsBinaryModule:\r
+ EdkLogger.error('build', PARSER_ERROR, "Module %s NOT found in DSC file; Is it really a binary module?" % ModuleFile)\r
+\r
+ else:\r
+ for Arch in self.ArchList:\r
+ if Arch == key:\r
+ Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]\r
+ MetaFileList = []\r
+ for Pkey in Platform.Modules.keys():\r
+ MetaFileList.append(Platform.Modules[Pkey].MetaFile)\r
+ for Inf in self.FdfProfile.InfDict[key]:\r
+ ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch)\r
+ if ModuleFile in MetaFileList:\r
+ continue\r
+ ModuleData = self.BuildDatabase[ModuleFile, Arch, Target, Toolchain]\r
+ if not ModuleData.IsBinaryModule:\r
+ EdkLogger.error('build', PARSER_ERROR, "Module %s NOT found in DSC file; Is it really a binary module?" % ModuleFile)\r
+\r
else:\r
PcdSet = {}\r
ModuleList = []\r
if self.CapTargetList:\r
EdkLogger.info("No flash definition file found. Capsule [%s] will be ignored." % " ".join(self.CapTargetList))\r
self.CapTargetList = []\r
- \r
+\r
# apply SKU and inject PCDs from Flash Definition file\r
for Arch in self.ArchList:\r
Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]\r
DecPcds = {}\r
DecPcdsKey = set()\r
PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)\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
+ (TokenSpaceGuidCName, TokenCName) = pcdname.split('.')\r
+ HasTokenSpace = True\r
+ else:\r
+ TokenCName = pcdname\r
+ TokenSpaceGuidCName = ''\r
+ HasTokenSpace = False\r
+ TokenSpaceGuidCNameList = []\r
+ FoundFlag = False\r
+ PcdDatumType = ''\r
+ NewValue = ''\r
+ for package in PGen.PackageList:\r
+ for key in package.Pcds:\r
+ PcdItem = package.Pcds[key]\r
+ if HasTokenSpace:\r
+ if (PcdItem.TokenCName, PcdItem.TokenSpaceGuidCName) == (TokenCName, TokenSpaceGuidCName):\r
+ PcdDatumType = PcdItem.DatumType\r
+ NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
+ FoundFlag = True\r
+ else:\r
+ if PcdItem.TokenCName == TokenCName:\r
+ if not PcdItem.TokenSpaceGuidCName in TokenSpaceGuidCNameList:\r
+ if len (TokenSpaceGuidCNameList) < 1:\r
+ TokenSpaceGuidCNameList.append(PcdItem.TokenSpaceGuidCName)\r
+ PcdDatumType = PcdItem.DatumType\r
+ TokenSpaceGuidCName = PcdItem.TokenSpaceGuidCName\r
+ NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\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." % (TokenCName, PcdItem.TokenSpaceGuidCName, TokenSpaceGuidCNameList[0])\r
+ )\r
+\r
+ GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, NewValue)\r
+\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, TokenCName))\r
+ else:\r
+ EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s is not found in the DEC file." % (TokenCName))\r
+\r
+ for BuildData in PGen.BuildDatabase._CACHE_.values():\r
+ if BuildData.Arch != Arch:\r
+ continue\r
+ if BuildData.MetaFile.Ext == '.dec':\r
+ continue\r
+ for key in BuildData.Pcds:\r
+ PcdItem = BuildData.Pcds[key]\r
+ if (TokenSpaceGuidCName, TokenCName) == (PcdItem.TokenSpaceGuidCName, PcdItem.TokenCName):\r
+ PcdItem.DefaultValue = NewValue\r
+\r
+ if (TokenCName, TokenSpaceGuidCName) in PcdSet:\r
+ PcdSet[(TokenCName, TokenSpaceGuidCName)] = NewValue\r
+\r
+ SourcePcdDict = {'DynamicEx':[], 'PatchableInModule':[],'Dynamic':[],'FixedAtBuild':[]}\r
+ BinaryPcdDict = {'DynamicEx':[], 'PatchableInModule':[]}\r
+ SourcePcdDict_Keys = SourcePcdDict.keys()\r
+ BinaryPcdDict_Keys = BinaryPcdDict.keys()\r
+\r
+ # generate the SourcePcdDict and BinaryPcdDict\r
+ for BuildData in PGen.BuildDatabase._CACHE_.values():\r
+ if BuildData.Arch != Arch:\r
+ continue\r
+ if BuildData.MetaFile.Ext == '.inf':\r
+ for key in BuildData.Pcds:\r
+ if BuildData.Pcds[key].Pending:\r
+ if key in Platform.Pcds:\r
+ PcdInPlatform = Platform.Pcds[key]\r
+ if PcdInPlatform.Type not in [None, '']:\r
+ BuildData.Pcds[key].Type = PcdInPlatform.Type\r
+\r
+ if BuildData.MetaFile in Platform.Modules:\r
+ PlatformModule = Platform.Modules[str(BuildData.MetaFile)]\r
+ if key in PlatformModule.Pcds:\r
+ PcdInPlatform = PlatformModule.Pcds[key]\r
+ if PcdInPlatform.Type not in [None, '']:\r
+ BuildData.Pcds[key].Type = PcdInPlatform.Type\r
+\r
+ if 'DynamicEx' in BuildData.Pcds[key].Type:\r
+ if BuildData.IsBinaryModule:\r
+ if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in BinaryPcdDict['DynamicEx']:\r
+ BinaryPcdDict['DynamicEx'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+ else:\r
+ if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in SourcePcdDict['DynamicEx']:\r
+ SourcePcdDict['DynamicEx'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+\r
+ elif 'PatchableInModule' in BuildData.Pcds[key].Type:\r
+ if BuildData.MetaFile.Ext == '.inf':\r
+ if BuildData.IsBinaryModule:\r
+ if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in BinaryPcdDict['PatchableInModule']:\r
+ BinaryPcdDict['PatchableInModule'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+ else:\r
+ if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in SourcePcdDict['PatchableInModule']:\r
+ SourcePcdDict['PatchableInModule'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+\r
+ elif 'Dynamic' in BuildData.Pcds[key].Type:\r
+ if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in SourcePcdDict['Dynamic']:\r
+ SourcePcdDict['Dynamic'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+ elif 'FixedAtBuild' in BuildData.Pcds[key].Type:\r
+ if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in SourcePcdDict['FixedAtBuild']:\r
+ SourcePcdDict['FixedAtBuild'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+ else:\r
+ pass\r
+ #\r
+ # A PCD can only use one type for all source modules\r
+ #\r
+ for i in SourcePcdDict_Keys:\r
+ for j in SourcePcdDict_Keys:\r
+ if i != j:\r
+ IntersectionList = list(set(SourcePcdDict[i]).intersection(set(SourcePcdDict[j])))\r
+ if len(IntersectionList) > 0:\r
+ EdkLogger.error(\r
+ 'build',\r
+ FORMAT_INVALID,\r
+ "Building modules from source INFs, following PCD use %s and %s access method. It must be corrected to use only one access method." % (i, j),\r
+ ExtraData="%s" % '\n\t'.join([str(P[1]+'.'+P[0]) for P in IntersectionList])\r
+ )\r
+ else:\r
+ pass\r
+\r
+ #\r
+ # intersection the BinaryPCD for Mixed PCD\r
+ #\r
+ for i in BinaryPcdDict_Keys:\r
+ for j in BinaryPcdDict_Keys:\r
+ if i != j:\r
+ IntersectionList = list(set(BinaryPcdDict[i]).intersection(set(BinaryPcdDict[j])))\r
+ for item in IntersectionList:\r
+ NewPcd1 = (item[0] + '_' + i, item[1])\r
+ NewPcd2 = (item[0] + '_' + j, item[1])\r
+ if item not in GlobalData.MixedPcd:\r
+ GlobalData.MixedPcd[item] = [NewPcd1, NewPcd2]\r
+ else:\r
+ if NewPcd1 not in GlobalData.MixedPcd[item]:\r
+ GlobalData.MixedPcd[item].append(NewPcd1)\r
+ if NewPcd2 not in GlobalData.MixedPcd[item]:\r
+ GlobalData.MixedPcd[item].append(NewPcd2)\r
+ else:\r
+ pass\r
+\r
+ #\r
+ # intersection the SourcePCD and BinaryPCD for Mixed PCD\r
+ #\r
+ for i in SourcePcdDict_Keys:\r
+ for j in BinaryPcdDict_Keys:\r
+ if i != j:\r
+ IntersectionList = list(set(SourcePcdDict[i]).intersection(set(BinaryPcdDict[j])))\r
+ for item in IntersectionList:\r
+ NewPcd1 = (item[0] + '_' + i, item[1])\r
+ NewPcd2 = (item[0] + '_' + j, item[1])\r
+ if item not in GlobalData.MixedPcd:\r
+ GlobalData.MixedPcd[item] = [NewPcd1, NewPcd2]\r
+ else:\r
+ if NewPcd1 not in GlobalData.MixedPcd[item]:\r
+ GlobalData.MixedPcd[item].append(NewPcd1)\r
+ if NewPcd2 not in GlobalData.MixedPcd[item]:\r
+ GlobalData.MixedPcd[item].append(NewPcd2)\r
+ else:\r
+ pass\r
+\r
+ for BuildData in PGen.BuildDatabase._CACHE_.values():\r
+ if BuildData.Arch != Arch:\r
+ continue\r
+ for key in BuildData.Pcds:\r
+ for SinglePcd in GlobalData.MixedPcd:\r
+ if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) == SinglePcd:\r
+ for item in GlobalData.MixedPcd[SinglePcd]:\r
+ Pcd_Type = item[0].split('_')[-1]\r
+ if (Pcd_Type == BuildData.Pcds[key].Type) or (Pcd_Type == TAB_PCDS_DYNAMIC_EX and BuildData.Pcds[key].Type in GenC.gDynamicExPcd) or \\r
+ (Pcd_Type == TAB_PCDS_DYNAMIC and BuildData.Pcds[key].Type in GenC.gDynamicPcd):\r
+ Value = BuildData.Pcds[key]\r
+ Value.TokenCName = BuildData.Pcds[key].TokenCName + '_' + Pcd_Type\r
+ if len(key) == 2:\r
+ newkey = (Value.TokenCName, key[1])\r
+ elif len(key) == 3:\r
+ newkey = (Value.TokenCName, key[1], key[2])\r
+ del BuildData.Pcds[key]\r
+ BuildData.Pcds[newkey] = Value\r
+ break\r
+ else:\r
+ pass\r
+ break\r
+ else:\r
+ pass\r
+\r
+ # handle the mixed pcd in FDF file\r
+ for key in PcdSet:\r
+ if key in GlobalData.MixedPcd:\r
+ Value = PcdSet[key]\r
+ del PcdSet[key]\r
+ for item in GlobalData.MixedPcd[key]:\r
+ PcdSet[item] = Value\r
+\r
#Collect package set information from INF of FDF\r
PkgSet = set()\r
for Inf in ModuleList:\r
Pa.CollectPlatformDynamicPcds()\r
Pa.CollectFixedAtBuildPcds()\r
self.AutoGenObjectList.append(Pa)\r
- \r
+\r
+ #\r
+ # Generate Package level hash value\r
+ #\r
+ GlobalData.gPackageHash[Arch] = {}\r
+ if GlobalData.gUseHashCache:\r
+ for Pkg in Pkgs:\r
+ self._GenPkgLevelHash(Pkg)\r
+\r
#\r
# Check PCDs token value conflict in each DEC file.\r
#\r
self._CheckAllPcdsTokenValueConflict()\r
- \r
+\r
#\r
# Check PCD type and definition between DSC and DEC\r
#\r
# if self.FdfFile:\r
# self._CheckDuplicateInFV(Fdf)\r
\r
- self._BuildDir = None\r
- self._FvDir = None\r
- self._MakeFileDir = None\r
- self._BuildCommand = None\r
+ #\r
+ # Create BuildOptions Macro & PCD metafile, also add the Active Platform and FDF file.\r
+ #\r
+ content = 'gCommandLineDefines: '\r
+ content += str(GlobalData.gCommandLineDefines)\r
+ content += os.linesep\r
+ content += 'BuildOptionPcd: '\r
+ content += str(GlobalData.BuildOptionPcd)\r
+ content += os.linesep\r
+ content += 'Active Platform: '\r
+ content += str(self.Platform)\r
+ content += os.linesep\r
+ if self.FdfFile:\r
+ content += 'Flash Image Definition: '\r
+ content += str(self.FdfFile)\r
+ content += os.linesep\r
+ if GlobalData.gBinCacheDest:\r
+ content += 'Cache of .efi location: '\r
+ content += str(GlobalData.gBinCacheDest)\r
+ SaveFileOnChange(os.path.join(self.BuildDir, 'BuildOptions'), content, False)\r
+\r
+ #\r
+ # Create PcdToken Number file for Dynamic/DynamicEx Pcd.\r
+ #\r
+ PcdTokenNumber = 'PcdTokenNumber: '\r
+ if Pa.PcdTokenNumber:\r
+ if Pa.DynamicPcdList:\r
+ for Pcd in Pa.DynamicPcdList:\r
+ PcdTokenNumber += os.linesep\r
+ PcdTokenNumber += str((Pcd.TokenCName, Pcd.TokenSpaceGuidCName))\r
+ PcdTokenNumber += ' : '\r
+ PcdTokenNumber += str(Pa.PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName])\r
+ SaveFileOnChange(os.path.join(self.BuildDir, 'PcdTokenNumber'), PcdTokenNumber, False)\r
+\r
+ #\r
+ # Get set of workspace metafiles\r
+ #\r
+ AllWorkSpaceMetaFiles = self._GetMetaFiles(Target, Toolchain, Arch)\r
\r
+ #\r
+ # Retrieve latest modified time of all metafiles\r
+ #\r
+ SrcTimeStamp = 0\r
+ for f in AllWorkSpaceMetaFiles:\r
+ if os.stat(f)[8] > SrcTimeStamp:\r
+ SrcTimeStamp = os.stat(f)[8]\r
+ self._SrcTimeStamp = SrcTimeStamp\r
+\r
+ if GlobalData.gUseHashCache:\r
+ m = hashlib.md5()\r
+ for files in AllWorkSpaceMetaFiles:\r
+ if files.endswith('.dec'):\r
+ continue\r
+ f = open(files, 'r')\r
+ Content = f.read()\r
+ f.close()\r
+ m.update(Content)\r
+ SaveFileOnChange(os.path.join(self.BuildDir, 'AutoGen.hash'), m.hexdigest(), True)\r
+ GlobalData.gPlatformHash = m.hexdigest()\r
+\r
+ #\r
+ # Write metafile list to build directory\r
+ #\r
+ AutoGenFilePath = os.path.join(self.BuildDir, 'AutoGen')\r
+ if os.path.exists (AutoGenFilePath):\r
+ os.remove(AutoGenFilePath)\r
+ if not os.path.exists(self.BuildDir):\r
+ os.makedirs(self.BuildDir)\r
+ with open(os.path.join(self.BuildDir, 'AutoGen'), 'w+') as file:\r
+ for f in AllWorkSpaceMetaFiles:\r
+ print >> file, f\r
return True\r
\r
+ def _GenPkgLevelHash(self, Pkg):\r
+ PkgDir = os.path.join(self.BuildDir, Pkg.Arch, Pkg.PackageName)\r
+ CreateDirectory(PkgDir)\r
+ HashFile = os.path.join(PkgDir, Pkg.PackageName + '.hash')\r
+ m = hashlib.md5()\r
+ # Get .dec file's hash value\r
+ f = open(Pkg.MetaFile.Path, 'r')\r
+ Content = f.read()\r
+ f.close()\r
+ m.update(Content)\r
+ # Get include files hash value\r
+ if Pkg.Includes:\r
+ for inc in Pkg.Includes:\r
+ for Root, Dirs, Files in os.walk(str(inc)):\r
+ for File in Files:\r
+ File_Path = os.path.join(Root, File)\r
+ f = open(File_Path, 'r')\r
+ Content = f.read()\r
+ f.close()\r
+ m.update(Content)\r
+ SaveFileOnChange(HashFile, m.hexdigest(), True)\r
+ if Pkg.PackageName not in GlobalData.gPackageHash[Pkg.Arch]:\r
+ GlobalData.gPackageHash[Pkg.Arch][Pkg.PackageName] = m.hexdigest()\r
+\r
+ def _GetMetaFiles(self, Target, Toolchain, Arch):\r
+ AllWorkSpaceMetaFiles = set()\r
+ #\r
+ # add fdf\r
+ #\r
+ if self.FdfFile:\r
+ AllWorkSpaceMetaFiles.add (self.FdfFile.Path)\r
+ if self.FdfFile:\r
+ FdfFiles = GlobalData.gFdfParser.GetAllIncludedFile()\r
+ for f in FdfFiles:\r
+ AllWorkSpaceMetaFiles.add (f.FileName)\r
+ #\r
+ # add dsc\r
+ #\r
+ AllWorkSpaceMetaFiles.add(self.MetaFile.Path)\r
+\r
+ #\r
+ # add build_rule.txt & tools_def.txt\r
+ #\r
+ AllWorkSpaceMetaFiles.add(os.path.join(GlobalData.gConfDirectory, gDefaultBuildRuleFile))\r
+ AllWorkSpaceMetaFiles.add(os.path.join(GlobalData.gConfDirectory, gDefaultToolsDefFile))\r
+\r
+ # add BuildOption metafile\r
+ #\r
+ AllWorkSpaceMetaFiles.add(os.path.join(self.BuildDir, 'BuildOptions'))\r
+\r
+ # add PcdToken Number file for Dynamic/DynamicEx Pcd\r
+ #\r
+ AllWorkSpaceMetaFiles.add(os.path.join(self.BuildDir, 'PcdTokenNumber'))\r
+\r
+ for Arch in self.ArchList:\r
+ Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]\r
+ PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)\r
+\r
+ #\r
+ # add dec\r
+ #\r
+ for Package in PGen.PackageList:\r
+ AllWorkSpaceMetaFiles.add(Package.MetaFile.Path)\r
+\r
+ #\r
+ # add included dsc\r
+ #\r
+ for filePath in Platform._RawData.IncludedFiles:\r
+ AllWorkSpaceMetaFiles.add(filePath.Path)\r
+\r
+ return AllWorkSpaceMetaFiles\r
+\r
## _CheckDuplicateInFV() method\r
#\r
# Check whether there is duplicate modules/files exist in FV section. \r
#\r
# Get INF file GUID\r
#\r
- InfFoundFlag = False \r
+ InfFoundFlag = False\r
for Pa in self.AutoGenObjectList:\r
if InfFoundFlag:\r
break\r
_GuidDict[Module.Guid.upper()] = FfsFile\r
break\r
else:\r
- EdkLogger.error("build", \r
+ EdkLogger.error("build",\r
FORMAT_INVALID,\r
- "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s"%(FfsFile.CurrentLineNum,\r
+ "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile.CurrentLineNum,\r
FfsFile.CurrentLineContent,\r
_GuidDict[Module.Guid.upper()].CurrentLineNum,\r
_GuidDict[Module.Guid.upper()].CurrentLineContent,\r
InfPath = NormPath(FfsFile.InfFileName)\r
if not os.path.exists(InfPath):\r
EdkLogger.error('build', GENFDS_ERROR, "Non-existant Module %s !" % (FfsFile.InfFileName))\r
- \r
+\r
PathClassObj = PathClass(FfsFile.InfFileName, self.WorkspaceDir)\r
#\r
# Here we just need to get FILE_GUID from INF file, use 'COMMON' as ARCH attribute. and use \r
if not InfObj.Guid.upper() in _GuidDict.keys():\r
_GuidDict[InfObj.Guid.upper()] = FfsFile\r
else:\r
- EdkLogger.error("build", \r
+ EdkLogger.error("build",\r
FORMAT_INVALID,\r
- "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s"%(FfsFile.CurrentLineNum,\r
+ "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile.CurrentLineNum,\r
FfsFile.CurrentLineContent,\r
_GuidDict[InfObj.Guid.upper()].CurrentLineNum,\r
_GuidDict[InfObj.Guid.upper()].CurrentLineContent,\r
InfObj.Guid.upper()),\r
ExtraData=self.FdfFile)\r
InfFoundFlag = False\r
- \r
+\r
if FfsFile.NameGuid != None:\r
_CheckPCDAsGuidPattern = re.compile("^PCD\(.+\..+\)$")\r
- \r
+\r
#\r
# If the NameGuid reference a PCD name. \r
# The style must match: PCD(xxxx.yyy)\r
# First convert from CFormatGuid to GUID string\r
#\r
_PcdGuidString = GuidStructureStringToGuidString(PcdItem.DefaultValue)\r
- \r
+\r
if not _PcdGuidString:\r
#\r
# Then try Byte array.\r
#\r
_PcdGuidString = GuidStructureByteArrayToGuidString(PcdItem.DefaultValue)\r
- \r
+\r
if not _PcdGuidString:\r
#\r
# Not Byte array or CFormat GUID, raise error.\r
#\r
EdkLogger.error("build",\r
FORMAT_INVALID,\r
- "The format of PCD value is incorrect. PCD: %s , Value: %s\n"%(_PcdName, PcdItem.DefaultValue),\r
+ "The format of PCD value is incorrect. PCD: %s , Value: %s\n" % (_PcdName, PcdItem.DefaultValue),\r
ExtraData=self.FdfFile)\r
- \r
- if not _PcdGuidString.upper() in _GuidDict.keys(): \r
+\r
+ if not _PcdGuidString.upper() in _GuidDict.keys():\r
_GuidDict[_PcdGuidString.upper()] = FfsFile\r
PcdFoundFlag = True\r
break\r
else:\r
- EdkLogger.error("build", \r
+ EdkLogger.error("build",\r
FORMAT_INVALID,\r
- "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s"%(FfsFile.CurrentLineNum,\r
+ "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile.CurrentLineNum,\r
FfsFile.CurrentLineContent,\r
_GuidDict[_PcdGuidString.upper()].CurrentLineNum,\r
_GuidDict[_PcdGuidString.upper()].CurrentLineContent,\r
FfsFile.NameGuid.upper()),\r
- ExtraData=self.FdfFile) \r
- \r
+ ExtraData=self.FdfFile)\r
+\r
if not FfsFile.NameGuid.upper() in _GuidDict.keys():\r
_GuidDict[FfsFile.NameGuid.upper()] = FfsFile\r
else:\r
#\r
# Two raw file GUID conflict.\r
#\r
- EdkLogger.error("build", \r
+ EdkLogger.error("build",\r
FORMAT_INVALID,\r
- "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s"%(FfsFile.CurrentLineNum,\r
+ "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile.CurrentLineNum,\r
FfsFile.CurrentLineContent,\r
_GuidDict[FfsFile.NameGuid.upper()].CurrentLineNum,\r
_GuidDict[FfsFile.NameGuid.upper()].CurrentLineContent,\r
FfsFile.NameGuid.upper()),\r
ExtraData=self.FdfFile)\r
- \r
+\r
\r
def _CheckPcdDefineAndType(self):\r
PcdTypeList = [\r
# Key of DSC's Pcds dictionary is PcdCName, TokenSpaceGuid\r
for Pcd in Pa.Platform.Pcds:\r
PcdType = Pa.Platform.Pcds[Pcd].Type\r
- \r
+\r
# If no PCD type, this PCD comes from FDF \r
if not PcdType:\r
continue\r
- \r
+\r
# Try to remove Hii and Vpd suffix\r
if PcdType.startswith("DynamicEx"):\r
PcdType = "DynamicEx"\r
elif PcdType.startswith("Dynamic"):\r
PcdType = "Dynamic"\r
- \r
+\r
for Package in Pa.PackageList:\r
# Key of DEC's Pcds dictionary is PcdCName, TokenSpaceGuid, PcdType\r
if (Pcd[0], Pcd[1], PcdType) in Package.Pcds:\r
\r
## Return the directory to store all intermediate and final files built\r
def _GetBuildDir(self):\r
- return self.AutoGenObjectList[0].BuildDir\r
+ if self._BuildDir == None:\r
+ return self.AutoGenObjectList[0].BuildDir\r
\r
## Return the build output directory platform specifies\r
def _GetOutputDir(self):\r
# BuildCommand should be all the same. So just get one from platform AutoGen\r
self._BuildCommand = self.AutoGenObjectList[0].BuildCommand\r
return self._BuildCommand\r
- \r
+\r
## Check the PCDs token value conflict in each DEC file.\r
#\r
# Will cause build break and raise error message while two PCDs conflict.\r
for Pa in self.AutoGenObjectList:\r
for Package in Pa.PackageList:\r
PcdList = Package.Pcds.values()\r
- PcdList.sort(lambda x, y: cmp(x.TokenValue, y.TokenValue)) \r
+ PcdList.sort(lambda x, y: cmp(int(x.TokenValue, 0), int(y.TokenValue, 0))) \r
Count = 0\r
while (Count < len(PcdList) - 1) :\r
Item = PcdList[Count]\r
#\r
# Make sure in the same token space the TokenValue should be unique\r
#\r
- if (Item.TokenValue == ItemNext.TokenValue):\r
+ if (int(Item.TokenValue, 0) == int(ItemNext.TokenValue, 0)):\r
SameTokenValuePcdList = []\r
SameTokenValuePcdList.append(Item)\r
SameTokenValuePcdList.append(ItemNext)\r
RemainPcdListLength = len(PcdList) - Count - 2\r
for ValueSameCount in range(RemainPcdListLength):\r
- if PcdList[len(PcdList) - RemainPcdListLength + ValueSameCount].TokenValue == Item.TokenValue:\r
+ if int(PcdList[len(PcdList) - RemainPcdListLength + ValueSameCount].TokenValue, 0) == int(Item.TokenValue, 0):\r
SameTokenValuePcdList.append(PcdList[len(PcdList) - RemainPcdListLength + ValueSameCount])\r
else:\r
break;\r
#\r
# Sort same token value PCD list with TokenGuid and TokenCName\r
#\r
- SameTokenValuePcdList.sort(lambda x, y: cmp("%s.%s"%(x.TokenSpaceGuidCName, x.TokenCName), "%s.%s"%(y.TokenSpaceGuidCName, y.TokenCName))) \r
- SameTokenValuePcdListCount = 0 \r
+ SameTokenValuePcdList.sort(lambda x, y: cmp("%s.%s" % (x.TokenSpaceGuidCName, x.TokenCName), "%s.%s" % (y.TokenSpaceGuidCName, y.TokenCName)))\r
+ SameTokenValuePcdListCount = 0\r
while (SameTokenValuePcdListCount < len(SameTokenValuePcdList) - 1):\r
- TemListItem = SameTokenValuePcdList[SameTokenValuePcdListCount]\r
- TemListItemNext = SameTokenValuePcdList[SameTokenValuePcdListCount + 1] \r
- \r
+ Flag = False\r
+ TemListItem = SameTokenValuePcdList[SameTokenValuePcdListCount]\r
+ TemListItemNext = SameTokenValuePcdList[SameTokenValuePcdListCount + 1]\r
+\r
if (TemListItem.TokenSpaceGuidCName == TemListItemNext.TokenSpaceGuidCName) and (TemListItem.TokenCName != TemListItemNext.TokenCName):\r
- EdkLogger.error(\r
- 'build',\r
- FORMAT_INVALID,\r
- "The TokenValue [%s] of PCD [%s.%s] is conflict with: [%s.%s] in %s"\\r
- % (TemListItem.TokenValue, TemListItem.TokenSpaceGuidCName, TemListItem.TokenCName, TemListItemNext.TokenSpaceGuidCName, TemListItemNext.TokenCName, Package),\r
- ExtraData=None\r
- )\r
+ for PcdItem in GlobalData.MixedPcd:\r
+ if (TemListItem.TokenCName, TemListItem.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem] or \\r
+ (TemListItemNext.TokenCName, TemListItemNext.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:\r
+ Flag = True\r
+ if not Flag:\r
+ EdkLogger.error(\r
+ 'build',\r
+ FORMAT_INVALID,\r
+ "The TokenValue [%s] of PCD [%s.%s] is conflict with: [%s.%s] in %s"\\r
+ % (TemListItem.TokenValue, TemListItem.TokenSpaceGuidCName, TemListItem.TokenCName, TemListItemNext.TokenSpaceGuidCName, TemListItemNext.TokenCName, Package),\r
+ ExtraData=None\r
+ )\r
SameTokenValuePcdListCount += 1\r
Count += SameTokenValuePcdListCount\r
Count += 1\r
- \r
+\r
PcdList = Package.Pcds.values()\r
- PcdList.sort(lambda x, y: cmp("%s.%s"%(x.TokenSpaceGuidCName, x.TokenCName), "%s.%s"%(y.TokenSpaceGuidCName, y.TokenCName)))\r
+ PcdList.sort(lambda x, y: cmp("%s.%s" % (x.TokenSpaceGuidCName, x.TokenCName), "%s.%s" % (y.TokenSpaceGuidCName, y.TokenCName)))\r
Count = 0\r
while (Count < len(PcdList) - 1) :\r
Item = PcdList[Count]\r
- ItemNext = PcdList[Count + 1] \r
+ ItemNext = PcdList[Count + 1]\r
#\r
# Check PCDs with same TokenSpaceGuidCName.TokenCName have same token value as well.\r
#\r
- if (Item.TokenSpaceGuidCName == ItemNext.TokenSpaceGuidCName) and (Item.TokenCName == ItemNext.TokenCName) and (Item.TokenValue != ItemNext.TokenValue):\r
+ if (Item.TokenSpaceGuidCName == ItemNext.TokenSpaceGuidCName) and (Item.TokenCName == ItemNext.TokenCName) and (int(Item.TokenValue, 0) != int(ItemNext.TokenValue, 0)):\r
EdkLogger.error(\r
'build',\r
FORMAT_INVALID,\r
# \r
_DynaPcdList_ = []\r
_NonDynaPcdList_ = []\r
+ _PlatformPcds = {}\r
\r
#\r
# The priority list while override build option \r
"0x01001" : 3, # ******_TOOLCHAIN_****_***********_ATTRIBUTE\r
"0x10001" : 2, # TARGET_*********_****_***********_ATTRIBUTE\r
"0x00001" : 1} # ******_*********_****_***********_ATTRIBUTE (Lowest)\r
- \r
+\r
## The real constructor of PlatformAutoGen\r
#\r
# This method is not supposed to be called by users of PlatformAutoGen. It's\r
## Generate Fds Command\r
def _GenFdsCommand(self):\r
return self.Workspace.GenFdsCommand\r
- \r
+\r
## Create makefile for the platform and mdoules in it\r
#\r
# @param CreateModuleMakeFile Flag indicating if the makefile for\r
# modules will be created as well\r
#\r
- def CreateMakeFile(self, CreateModuleMakeFile=False):\r
+ def CreateMakeFile(self, CreateModuleMakeFile=False, FfsCommand = {}):\r
if CreateModuleMakeFile:\r
for ModuleFile in self.Platform.Modules:\r
Ma = ModuleAutoGen(self.Workspace, ModuleFile, self.BuildTarget,\r
self.ToolChain, self.Arch, self.MetaFile)\r
- Ma.CreateMakeFile(True)\r
+ if (ModuleFile.File, self.Arch) in FfsCommand:\r
+ Ma.CreateMakeFile(True, FfsCommand[ModuleFile.File, self.Arch])\r
+ else:\r
+ Ma.CreateMakeFile(True)\r
#Ma.CreateAsBuiltInf()\r
\r
# no need to create makefile for the platform more than once\r
# This interface should be invoked explicitly when platform action is created.\r
#\r
def CollectPlatformDynamicPcds(self):\r
+ # Override the platform Pcd's value by build option\r
+ if GlobalData.BuildOptionPcd:\r
+ for key in self.Platform.Pcds:\r
+ PlatformPcd = self.Platform.Pcds[key]\r
+ for PcdItem in GlobalData.BuildOptionPcd:\r
+ if (PlatformPcd.TokenSpaceGuidCName, PlatformPcd.TokenCName) == (PcdItem[0], PcdItem[1]):\r
+ PlatformPcd.DefaultValue = PcdItem[2]\r
+ if PlatformPcd.SkuInfoList:\r
+ Sku = PlatformPcd.SkuInfoList[PlatformPcd.SkuInfoList.keys()[0]]\r
+ Sku.DefaultValue = PcdItem[2]\r
+ break\r
+\r
+ for key in self.Platform.Pcds:\r
+ for SinglePcd in GlobalData.MixedPcd:\r
+ if (self.Platform.Pcds[key].TokenCName, self.Platform.Pcds[key].TokenSpaceGuidCName) == SinglePcd:\r
+ for item in GlobalData.MixedPcd[SinglePcd]:\r
+ Pcd_Type = item[0].split('_')[-1]\r
+ if (Pcd_Type == self.Platform.Pcds[key].Type) or (Pcd_Type == TAB_PCDS_DYNAMIC_EX and self.Platform.Pcds[key].Type in GenC.gDynamicExPcd) or \\r
+ (Pcd_Type == TAB_PCDS_DYNAMIC and self.Platform.Pcds[key].Type in GenC.gDynamicPcd):\r
+ Value = self.Platform.Pcds[key]\r
+ Value.TokenCName = self.Platform.Pcds[key].TokenCName + '_' + Pcd_Type\r
+ if len(key) == 2:\r
+ newkey = (Value.TokenCName, key[1])\r
+ elif len(key) == 3:\r
+ newkey = (Value.TokenCName, key[1], key[2])\r
+ del self.Platform.Pcds[key]\r
+ self.Platform.Pcds[newkey] = Value\r
+ break\r
+ else:\r
+ pass\r
+ break\r
+ else:\r
+ pass\r
+\r
# for gathering error information\r
NoDatumTypePcdList = set()\r
PcdNotInDb = []\r
self._GuidValue = {}\r
FdfModuleList = []\r
for InfName in self._AsBuildInfList:\r
- InfName = os.path.join(self.WorkspaceDir, InfName)\r
+ InfName = mws.join(self.WorkspaceDir, InfName)\r
FdfModuleList.append(os.path.normpath(InfName))\r
for F in self.Platform.Modules.keys():\r
M = ModuleAutoGen(self.Workspace, F, self.BuildTarget, self.ToolChain, self.Arch, self.MetaFile)\r
#GuidValue.update(M.Guids)\r
\r
self.Platform.Modules[F].M = M\r
- \r
- for PcdFromModule in M.ModulePcdList+M.LibraryPcdList:\r
+\r
+ for PcdFromModule in M.ModulePcdList + M.LibraryPcdList:\r
# make sure that the "VOID*" kind of datum has MaxDatumSize set\r
if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:\r
NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F))\r
PcdFromModule.IsFromBinaryInf == False:\r
# Print warning message to let the developer make a determine.\r
if PcdFromModule not in PcdNotInDb:\r
- # EdkLogger.warn("build",\r
- # "A PCD listed in the DSC (%s.%s, %s) is used by a module not in the FDF. If the PCD is not used by any module listed in the FDF this PCD will be ignored. " \\r
- # % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, self.Platform.MetaFile.Path),\r
- # File=self.MetaFile, \\r
- # ExtraData=None)\r
PcdNotInDb.append(PcdFromModule)\r
continue\r
# If one of the Source built modules listed in the DSC is not listed in \r
% NoDatumTypePcdListString)\r
self._NonDynamicPcdList = self._NonDynaPcdList_\r
self._DynamicPcdList = self._DynaPcdList_\r
- # If PCD is listed in a PcdsDynamicHii, PcdsDynamicExHii, PcdsDynamicHii or PcdsDynamicExHii\r
- # section, and the PCD is not used by any module that is listed in the DSC file, the build \r
- # provide a warning message.\r
- #for PcdKey in self.Platform.Pcds.keys():\r
- # Pcd = self.Platform.Pcds[PcdKey]\r
- # if Pcd not in self._DynamicPcdList + PcdNotInDb and \\r
- # Pcd.Type in [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_HII, TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_PCDS_DYNAMIC_EX_HII]:\r
- # # Print warning message to let the developer make a determine.\r
- #EdkLogger.warn("build",\r
- # "A %s PCD listed in the DSC (%s.%s, %s) is not used by any module." \\r
- # % (Pcd.Type, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, self.Platform.MetaFile.Path),\r
- # File=self.MetaFile, \\r
- # ExtraData=None)\r
#\r
# Sort dynamic PCD list to:\r
# 1) If PCD's datum type is VOID* and value is unicode string which starts with L, the PCD item should \r
OtherPcdArray = []\r
VpdPcdDict = {}\r
VpdFile = VpdInfoFile.VpdInfoFile()\r
- NeedProcessVpdMapFile = False \r
- \r
+ NeedProcessVpdMapFile = False\r
+\r
+ for pcd in self.Platform.Pcds.keys():\r
+ if pcd not in self._PlatformPcds.keys():\r
+ self._PlatformPcds[pcd] = self.Platform.Pcds[pcd]\r
+\r
if (self.Workspace.ArchList[-1] == self.Arch): \r
for Pcd in self._DynamicPcdList:\r
# just pick the a value to determine whether is unicode string type\r
- Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]\r
+ Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]\r
Sku.VpdOffset = Sku.VpdOffset.strip()\r
- \r
+\r
PcdValue = Sku.DefaultValue\r
if Pcd.DatumType == 'VOID*' and PcdValue.startswith("L"):\r
# if found PCD which datum value is unicode string the insert to left size of UnicodeIndex\r
else:\r
OtherPcdArray.append(Pcd)\r
if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:\r
- VpdPcdDict[(Pcd.TokenCName, Pcd.TokenSpaceGuidCName)] = Pcd \r
- \r
- PlatformPcds = self.Platform.Pcds.keys()\r
- PlatformPcds.sort() \r
+ VpdPcdDict[(Pcd.TokenCName, Pcd.TokenSpaceGuidCName)] = Pcd\r
+\r
+ PlatformPcds = self._PlatformPcds.keys()\r
+ PlatformPcds.sort()\r
#\r
# Add VPD type PCD into VpdFile and determine whether the VPD PCD need to be fixed up.\r
#\r
for PcdKey in PlatformPcds:\r
- Pcd = self.Platform.Pcds[PcdKey]\r
+ Pcd = self._PlatformPcds[PcdKey]\r
if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD] and \\r
PcdKey in VpdPcdDict:\r
Pcd = VpdPcdDict[PcdKey]\r
for (SkuName,Sku) in Pcd.SkuInfoList.items():\r
Sku.VpdOffset = Sku.VpdOffset.strip()\r
+ PcdValue = Sku.DefaultValue\r
+ if PcdValue == "":\r
+ PcdValue = Pcd.DefaultValue\r
+ if Sku.VpdOffset != '*':\r
+ if PcdValue.startswith("{"):\r
+ Alignment = 8\r
+ elif PcdValue.startswith("L"):\r
+ Alignment = 2\r
+ else:\r
+ Alignment = 1\r
+ try:\r
+ VpdOffset = int(Sku.VpdOffset)\r
+ except:\r
+ try:\r
+ VpdOffset = int(Sku.VpdOffset, 16)\r
+ except:\r
+ EdkLogger.error("build", FORMAT_INVALID, "Invalid offset value %s for PCD %s.%s." % (Sku.VpdOffset, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))\r
+ if VpdOffset % Alignment != 0:\r
+ if PcdValue.startswith("{"):\r
+ EdkLogger.warn("build", "The offset value of PCD %s.%s is not 8-byte aligned!" %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName), File=self.MetaFile)\r
+ else:\r
+ EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Alignment))\r
VpdFile.Add(Pcd, Sku.VpdOffset)\r
# if the offset of a VPD is *, then it need to be fixed up by third party tool.\r
if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
if self.Platform.VpdToolGuid == None or self.Platform.VpdToolGuid == '':\r
EdkLogger.error("Build", FILE_NOT_FOUND, \\r
"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
- \r
+\r
+\r
#\r
# Fix the PCDs define in VPD PCD section that never referenced by module.\r
# An example is PCD for signature usage.\r
# \r
for DscPcd in PlatformPcds:\r
- DscPcdEntry = self.Platform.Pcds[DscPcd]\r
+ DscPcdEntry = self._PlatformPcds[DscPcd]\r
if DscPcdEntry.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:\r
if not (self.Platform.VpdToolGuid == None or self.Platform.VpdToolGuid == ''):\r
FoundFlag = False\r
if (VpdPcd.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \\r
(VpdPcd.TokenCName == DscPcdEntry.TokenCName):\r
FoundFlag = True\r
- \r
+\r
# Not found, it should be signature\r
if not FoundFlag :\r
# just pick the a value to determine whether is unicode string type\r
# Sku = DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]]\r
Sku.VpdOffset = Sku.VpdOffset.strip()\r
PcdValue = Sku.DefaultValue\r
+ if PcdValue == "":\r
+ PcdValue = DscPcdEntry.DefaultValue\r
+ if Sku.VpdOffset != '*':\r
+ if PcdValue.startswith("{"):\r
+ Alignment = 8\r
+ elif PcdValue.startswith("L"):\r
+ Alignment = 2\r
+ else:\r
+ Alignment = 1\r
+ try:\r
+ VpdOffset = int(Sku.VpdOffset)\r
+ except:\r
+ try:\r
+ VpdOffset = int(Sku.VpdOffset, 16)\r
+ except:\r
+ EdkLogger.error("build", FORMAT_INVALID, "Invalid offset value %s for PCD %s.%s." % (Sku.VpdOffset, DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName))\r
+ if VpdOffset % Alignment != 0:\r
+ if PcdValue.startswith("{"):\r
+ EdkLogger.warn("build", "The offset value of PCD %s.%s is not 8-byte aligned!" %(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName), File=self.MetaFile)\r
+ else:\r
+ EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, Alignment))\r
VpdFile.Add(DscPcdEntry, Sku.VpdOffset)\r
if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
NeedProcessVpdMapFile = True \r
VpdFile.GetCount() != 0:\r
EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, \r
"Fail to get FLASH_DEFINITION definition in DSC file %s which is required when DSC contains VPD PCD." % str(self.Platform.MetaFile))\r
- \r
+\r
if VpdFile.GetCount() != 0:\r
- DscTimeStamp = self.Platform.MetaFile.TimeStamp\r
FvPath = os.path.join(self.BuildDir, "FV")\r
if not os.path.exists(FvPath):\r
try:\r
os.makedirs(FvPath)\r
except:\r
EdkLogger.error("build", FILE_WRITE_FAILURE, "Fail to create FV folder under %s" % self.BuildDir)\r
- \r
- \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
- \r
+ if VpdFile.Write(VpdFilePath):\r
# retrieve BPDG tool's path from tool_def.txt according to VPD_TOOL_GUID defined in DSC file.\r
BPDGToolName = None\r
for ToolDef in self.ToolDefinition.values():\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
+\r
# Process VPD map file generated by third party BPDG tool\r
if NeedProcessVpdMapFile:\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
+\r
# Fixup "*" offset\r
for Pcd in self._DynamicPcdList:\r
# just pick the a value to determine whether is unicode string type\r
i += 1\r
else:\r
EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)\r
- \r
+\r
# Delete the DynamicPcdList At the last time enter into this function \r
- del self._DynamicPcdList[:] \r
+ del self._DynamicPcdList[:]\r
self._DynamicPcdList.extend(UnicodePcdArray)\r
self._DynamicPcdList.extend(HiiPcdArray)\r
self._DynamicPcdList.extend(OtherPcdArray)\r
def _GetFdfFile(self):\r
if self._FdfFile == None:\r
if self.Workspace.FdfFile != "":\r
- self._FdfFile= path.join(self.WorkspaceDir, self.Workspace.FdfFile)\r
+ self._FdfFile= mws.join(self.WorkspaceDir, self.Workspace.FdfFile)\r
else:\r
self._FdfFile = ''\r
return self._FdfFile\r
self.OutputDir,\r
self.BuildTarget + "_" + self.ToolChain,\r
)\r
+ GlobalData.gBuildDirectory = self._BuildDir\r
return self._BuildDir\r
\r
## Return directory of platform makefile\r
if self.BuildOption[Tool][Attr].startswith('='):\r
Value = self.BuildOption[Tool][Attr][1:]\r
else:\r
- Value += " " + self.BuildOption[Tool][Attr]\r
+ if Attr != 'PATH':\r
+ Value += " " + self.BuildOption[Tool][Attr]\r
+ else:\r
+ Value = self.BuildOption[Tool][Attr]\r
\r
if Attr == "PATH":\r
# Don't put MAKE definition in the file\r
else:\r
if self._BuildRule._FileVersion < AutoGenReqBuildRuleVerNum :\r
# If Build Rule's version is less than the version number required by the tools, halting the build.\r
- EdkLogger.error("build", AUTOGEN_ERROR, \r
+ EdkLogger.error("build", AUTOGEN_ERROR,\r
ExtraData="The version number [%s] of build_rule.txt is less than the version number required by the AutoGen.(the minimum required version number is [%s])"\\r
% (self._BuildRule._FileVersion, AutoGenReqBuildRuleVerNum))\r
- \r
+\r
return self._BuildRule\r
\r
## Summarize the packages used by modules in this platform\r
EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))\r
self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber\r
TokenNumber += 1\r
- \r
+\r
for Pcd in self.DynamicPcdList:\r
if Pcd.Phase == "PEI":\r
if Pcd.Type in ["DynamicEx", "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:\r
EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))\r
self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber\r
TokenNumber += 1\r
- \r
+\r
for Pcd in self.DynamicPcdList:\r
if Pcd.Phase == "DXE":\r
if Pcd.Type in ["Dynamic", "DynamicDefault", "DynamicVpd", "DynamicHii"]:\r
EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))\r
self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber\r
TokenNumber += 1\r
- \r
+\r
for Pcd in self.DynamicPcdList:\r
if Pcd.Phase == "DXE":\r
if Pcd.Type in ["DynamicEx", "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:\r
EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))\r
self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber\r
TokenNumber += 1\r
- \r
+\r
for Pcd in self.NonDynamicPcdList:\r
self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber\r
TokenNumber += 1\r
# @retval library_list List of library instances sorted\r
#\r
def ApplyLibraryInstance(self, Module):\r
+ # Cover the case that the binary INF file is list in the FDF file but not DSC file, return empty list directly\r
+ if str(Module) not in self.Platform.Modules:\r
+ return []\r
+\r
ModuleType = Module.ModuleType\r
\r
# for overridding library instances with module specific setting\r
# at this point, ToPcd.Type has the type found from dependent\r
# package\r
#\r
+ TokenCName = ToPcd.TokenCName\r
+ for PcdItem in GlobalData.MixedPcd:\r
+ if (ToPcd.TokenCName, ToPcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:\r
+ TokenCName = PcdItem[0]\r
+ break\r
if FromPcd != None:\r
+ if GlobalData.BuildOptionPcd:\r
+ for pcd in GlobalData.BuildOptionPcd:\r
+ if (FromPcd.TokenSpaceGuidCName, FromPcd.TokenCName) == (pcd[0], pcd[1]):\r
+ FromPcd.DefaultValue = pcd[2]\r
+ break\r
if ToPcd.Pending and FromPcd.Type not in [None, '']:\r
ToPcd.Type = FromPcd.Type\r
elif (ToPcd.Type not in [None, '']) and (FromPcd.Type not in [None, ''])\\r
and (ToPcd.Type != FromPcd.Type) and (ToPcd.Type in FromPcd.Type):\r
if ToPcd.Type.strip() == "DynamicEx":\r
- ToPcd.Type = FromPcd.Type \r
+ ToPcd.Type = FromPcd.Type\r
elif ToPcd.Type not in [None, ''] and FromPcd.Type not in [None, ''] \\r
and ToPcd.Type != FromPcd.Type:\r
EdkLogger.error("build", OPTION_CONFLICT, "Mismatched PCD type",\r
ExtraData="%s.%s is defined as [%s] in module %s, but as [%s] in platform."\\r
- % (ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName,\r
+ % (ToPcd.TokenSpaceGuidCName, TokenCName,\r
ToPcd.Type, Module, FromPcd.Type),\r
File=self.MetaFile)\r
\r
IsValid, Cause = CheckPcdDatum(ToPcd.DatumType, ToPcd.DefaultValue)\r
if not IsValid:\r
EdkLogger.error('build', FORMAT_INVALID, Cause, File=self.MetaFile,\r
- ExtraData="%s.%s" % (ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName))\r
+ ExtraData="%s.%s" % (ToPcd.TokenSpaceGuidCName, TokenCName))\r
+ ToPcd.validateranges = FromPcd.validateranges\r
+ ToPcd.validlists = FromPcd.validlists\r
+ ToPcd.expressions = FromPcd.expressions\r
\r
if ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]:\r
EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \\r
- % (ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName))\r
+ % (ToPcd.TokenSpaceGuidCName, TokenCName))\r
Value = ToPcd.DefaultValue\r
if Value in [None, '']:\r
ToPcd.MaxDatumSize = '1'\r
#\r
def ApplyPcdSetting(self, Module, Pcds):\r
# for each PCD in module\r
- for Name,Guid in Pcds:\r
- PcdInModule = Pcds[Name,Guid]\r
+ for Name, Guid in Pcds:\r
+ PcdInModule = Pcds[Name, Guid]\r
# find out the PCD setting in platform\r
- if (Name,Guid) in self.Platform.Pcds:\r
- PcdInPlatform = self.Platform.Pcds[Name,Guid]\r
+ if (Name, Guid) in self.Platform.Pcds:\r
+ PcdInPlatform = self.Platform.Pcds[Name, Guid]\r
else:\r
PcdInPlatform = None\r
# then override the settings if any\r
for SkuId in PcdInModule.SkuInfoList:\r
Sku = PcdInModule.SkuInfoList[SkuId]\r
if Sku.VariableGuid == '': continue\r
- Sku.VariableGuidValue = GuidValue(Sku.VariableGuid, self.PackageList)\r
+ Sku.VariableGuidValue = GuidValue(Sku.VariableGuid, self.PackageList, self.MetaFile.Path)\r
if Sku.VariableGuidValue == None:\r
PackageList = "\n\t".join([str(P) for P in self.PackageList])\r
EdkLogger.error(\r
if Module in self.Platform.Modules:\r
PlatformModule = self.Platform.Modules[str(Module)]\r
for Key in PlatformModule.Pcds:\r
+ Flag = False\r
if Key in Pcds:\r
- self._OverridePcd(Pcds[Key], PlatformModule.Pcds[Key], Module)\r
+ ToPcd = Pcds[Key]\r
+ Flag = True\r
+ elif Key in GlobalData.MixedPcd:\r
+ for PcdItem in GlobalData.MixedPcd[Key]:\r
+ if PcdItem in Pcds:\r
+ ToPcd = Pcds[PcdItem]\r
+ Flag = True\r
+ break\r
+ if Flag:\r
+ self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Module)\r
return Pcds.values()\r
\r
## Resolve library names to library modules\r
# @retval Value Priority value based on the priority list.\r
#\r
def CalculatePriorityValue(self, Key):\r
- Target, ToolChain, Arch, CommandType, Attr = Key.split('_') \r
- PriorityValue = 0x11111 \r
+ Target, ToolChain, Arch, CommandType, Attr = Key.split('_')\r
+ PriorityValue = 0x11111\r
if Target == "*":\r
PriorityValue &= 0x01111\r
if ToolChain == "*":\r
PriorityValue &= 0x11101\r
if Attr == "*":\r
PriorityValue &= 0x11110\r
- \r
- return self.PrioList["0x%0.5x"%PriorityValue]\r
- \r
+\r
+ return self.PrioList["0x%0.5x" % PriorityValue]\r
+\r
\r
## Expand * in build option key\r
#\r
BuildOptions = {}\r
FamilyMatch = False\r
FamilyIsNull = True\r
- \r
+\r
OverrideList = {}\r
#\r
# Construct a list contain the build options which need override.\r
# Key[0] -- tool family\r
# Key[1] -- TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE\r
#\r
- if Key[0] == self.BuildRuleFamily :\r
+ if (Key[0] == self.BuildRuleFamily and\r
+ (ModuleStyle == None or len(Key) < 3 or (len(Key) > 2 and Key[2] == ModuleStyle))):\r
Target, ToolChain, Arch, CommandType, Attr = Key[1].split('_')\r
if Target == self.BuildTarget or Target == "*":\r
if ToolChain == self.ToolChain or ToolChain == "*":\r
if Arch == self.Arch or Arch == "*":\r
if Options[Key].startswith("="):\r
- if OverrideList.get(Key[1]) != None: \r
+ if OverrideList.get(Key[1]) != None:\r
OverrideList.pop(Key[1])\r
OverrideList[Key[1]] = Options[Key]\r
\r
# Use the highest priority value. \r
#\r
if (len(OverrideList) >= 2):\r
- KeyList = OverrideList.keys()\r
+ KeyList = OverrideList.keys()\r
for Index in range(len(KeyList)):\r
- NowKey = KeyList[Index]\r
+ NowKey = KeyList[Index]\r
Target1, ToolChain1, Arch1, CommandType1, Attr1 = NowKey.split("_")\r
for Index1 in range(len(KeyList) - Index - 1):\r
NextKey = KeyList[Index1 + Index + 1]\r
if CommandType1 == CommandType2 or CommandType1 == "*" or CommandType2 == "*":\r
if Attr1 == Attr2 or Attr1 == "*" or Attr2 == "*":\r
if self.CalculatePriorityValue(NowKey) > self.CalculatePriorityValue(NextKey):\r
- if Options.get((self.BuildRuleFamily, NextKey)) != None: \r
+ if Options.get((self.BuildRuleFamily, NextKey)) != None:\r
Options.pop((self.BuildRuleFamily, NextKey))\r
else:\r
- if Options.get((self.BuildRuleFamily, NowKey)) != None: \r
+ if Options.get((self.BuildRuleFamily, NowKey)) != None:\r
Options.pop((self.BuildRuleFamily, NowKey))\r
\r
- \r
for Key in Options:\r
if ModuleStyle != None and len (Key) > 2:\r
# Check Module style is EDK or EDKII.\r
if Arch == "*" or Arch == self.Arch:\r
if Tool not in BuildOptions:\r
BuildOptions[Tool] = {}\r
- if Attr != "FLAGS" or Attr not in BuildOptions[Tool]:\r
+ if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or Options[Key].startswith('='):\r
BuildOptions[Tool][Attr] = Options[Key]\r
else:\r
- # append options for the same tool\r
- BuildOptions[Tool][Attr] += " " + Options[Key]\r
+ # append options for the same tool except PATH\r
+ if Attr != 'PATH':\r
+ BuildOptions[Tool][Attr] += " " + Options[Key]\r
+ else:\r
+ BuildOptions[Tool][Attr] = Options[Key]\r
# Build Option Family has been checked, which need't to be checked again for family.\r
if FamilyMatch or FamilyIsNull:\r
return BuildOptions\r
- \r
+\r
for Key in Options:\r
if ModuleStyle != None and len (Key) > 2:\r
# Check Module style is EDK or EDKII.\r
Family = Key[0]\r
Target, Tag, Arch, Tool, Attr = Key[1].split("_")\r
# if tool chain family doesn't match, skip it\r
- if Tool not in self.ToolDefinition or Family =="":\r
+ if Tool not in self.ToolDefinition or Family == "":\r
continue\r
# option has been added before\r
if Family != self.ToolDefinition[Tool][TAB_TOD_DEFINES_FAMILY]:\r
if Arch == "*" or Arch == self.Arch:\r
if Tool not in BuildOptions:\r
BuildOptions[Tool] = {}\r
- if Attr != "FLAGS" or Attr not in BuildOptions[Tool]:\r
+ if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or Options[Key].startswith('='):\r
BuildOptions[Tool][Attr] = Options[Key]\r
else:\r
- # append options for the same tool\r
- BuildOptions[Tool][Attr] += " " + Options[Key]\r
+ # append options for the same tool except PATH\r
+ if Attr != 'PATH':\r
+ BuildOptions[Tool][Attr] += " " + Options[Key]\r
+ else:\r
+ BuildOptions[Tool][Attr] = Options[Key]\r
return BuildOptions\r
\r
## Append build options in platform to a module\r
# Get the different options for the different style module\r
if Module.AutoGenVersion < 0x00010005:\r
PlatformOptions = self.EdkBuildOption\r
+ ModuleTypeOptions = self.Platform.GetBuildOptionsByModuleType(EDK_NAME, Module.ModuleType)\r
else:\r
PlatformOptions = self.EdkIIBuildOption\r
+ ModuleTypeOptions = self.Platform.GetBuildOptionsByModuleType(EDKII_NAME, Module.ModuleType)\r
+ ModuleTypeOptions = self._ExpandBuildOption(ModuleTypeOptions)\r
ModuleOptions = self._ExpandBuildOption(Module.BuildOptions)\r
if Module in self.Platform.Modules:\r
PlatformModule = self.Platform.Modules[str(Module)]\r
else:\r
PlatformModuleOptions = {}\r
\r
- AllTools = set(ModuleOptions.keys() + PlatformOptions.keys() + PlatformModuleOptions.keys() + self.ToolDefinition.keys())\r
+ BuildRuleOrder = None\r
+ for Options in [self.ToolDefinition, ModuleOptions, PlatformOptions, ModuleTypeOptions, PlatformModuleOptions]:\r
+ for Tool in Options:\r
+ for Attr in Options[Tool]:\r
+ if Attr == TAB_TOD_DEFINES_BUILDRULEORDER:\r
+ BuildRuleOrder = Options[Tool][Attr]\r
+\r
+ AllTools = set(ModuleOptions.keys() + PlatformOptions.keys() +\r
+ PlatformModuleOptions.keys() + ModuleTypeOptions.keys() +\r
+ self.ToolDefinition.keys())\r
BuildOptions = {}\r
for Tool in AllTools:\r
if Tool not in BuildOptions:\r
BuildOptions[Tool] = {}\r
\r
- for Options in [self.ToolDefinition, ModuleOptions, PlatformOptions, PlatformModuleOptions]:\r
+ for Options in [self.ToolDefinition, ModuleOptions, PlatformOptions, ModuleTypeOptions, PlatformModuleOptions]:\r
if Tool not in Options:\r
continue\r
for Attr in Options[Tool]:\r
Value = Options[Tool][Attr]\r
+ #\r
+ # Do not generate it in Makefile\r
+ #\r
+ if Attr == TAB_TOD_DEFINES_BUILDRULEORDER:\r
+ continue\r
if Attr not in BuildOptions[Tool]:\r
BuildOptions[Tool][Attr] = ""\r
# check if override is indicated\r
if Value.startswith('='):\r
- BuildOptions[Tool][Attr] = Value[1:]\r
+ ToolPath = Value[1:]\r
+ ToolPath = mws.handleWsMacro(ToolPath)\r
+ BuildOptions[Tool][Attr] = ToolPath\r
else:\r
- BuildOptions[Tool][Attr] += " " + Value\r
+ Value = mws.handleWsMacro(Value)\r
+ if Attr != 'PATH':\r
+ BuildOptions[Tool][Attr] += " " + Value\r
+ else:\r
+ BuildOptions[Tool][Attr] = Value\r
if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag != None:\r
#\r
# Override UNI flag only for EDK module.\r
if 'BUILD' not in BuildOptions:\r
BuildOptions['BUILD'] = {}\r
BuildOptions['BUILD']['FLAGS'] = self.Workspace.UniFlag\r
- return BuildOptions\r
+ return BuildOptions, BuildRuleOrder\r
\r
Platform = property(_GetPlatform)\r
Name = property(_GetName)\r
# to the [depex] section in module's inf file.\r
#\r
class ModuleAutoGen(AutoGen):\r
+ ## Cache the timestamps of metafiles of every module in a class variable\r
+ #\r
+ TimeDict = {}\r
+\r
## The real constructor of ModuleAutoGen\r
#\r
# This method is not supposed to be called by users of ModuleAutoGen. It's\r
return False\r
\r
self.SourceDir = self.MetaFile.SubDir\r
- if self.SourceDir.upper().find(self.WorkspaceDir.upper()) == 0:\r
- self.SourceDir = self.SourceDir[len(self.WorkspaceDir) + 1:]\r
+ self.SourceDir = mws.relpath(self.SourceDir, self.WorkspaceDir)\r
\r
self.SourceOverrideDir = None\r
# use overrided path defined in DSC file\r
self.DepexGenerated = False\r
\r
self.BuildDatabase = self.Workspace.BuildDatabase\r
+ self.BuildRuleOrder = None\r
+ self.BuildTime = 0\r
\r
self._Module = None\r
self._Name = None\r
\r
self._BuildDir = None\r
self._OutputDir = None\r
+ self._FfsOutputDir = None\r
self._DebugDir = None\r
self._MakeFileDir = None\r
\r
self._IncludePathList = None\r
+ self._IncludePathLength = 0\r
self._AutoGenFileList = None\r
self._UnicodeFileList = None\r
+ self._VfrFileList = None\r
+ self._IdfFileList = None\r
self._SourceFileList = None\r
self._ObjectFileList = None\r
self._BinaryFileList = None\r
self._FinalBuildTargetList = None\r
self._FileTypes = None\r
self._BuildRules = None\r
+\r
+ self._TimeStampPath = None\r
+\r
+ self.AutoGenDepSet = set()\r
+\r
\r
## The Modules referenced to this Library\r
# Only Library has this attribute\r
if self._FixedAtBuildPcds:\r
return self._FixedAtBuildPcds\r
for Pcd in self.ModulePcdList:\r
- if self.IsLibrary:\r
- if not (Pcd.Pending == False and Pcd.Type == "FixedAtBuild"):\r
- continue\r
- elif Pcd.Type != "FixedAtBuild":\r
+ if Pcd.Type != "FixedAtBuild":\r
continue\r
if Pcd not in self._FixedAtBuildPcds:\r
self._FixedAtBuildPcds.append(Pcd)\r
\r
return self._FixedAtBuildPcds \r
\r
+ def _GetUniqueBaseName(self):\r
+ BaseName = self.Name\r
+ for Module in self.PlatformInfo.ModuleAutoGenList:\r
+ if Module.MetaFile == self.MetaFile:\r
+ continue\r
+ if Module.Name == self.Name:\r
+ if uuid.UUID(Module.Guid) == uuid.UUID(self.Guid):\r
+ EdkLogger.error("build", FILE_DUPLICATED, 'Modules have same BaseName and FILE_GUID:\n'\r
+ ' %s\n %s' % (Module.MetaFile, self.MetaFile))\r
+ BaseName = '%s_%s' % (self.Name, self.Guid)\r
+ return BaseName\r
+\r
# Macros could be used in build_rule.txt (also Makefile)\r
def _GetMacros(self):\r
if self._Macro == None:\r
self._Macro = sdict()\r
self._Macro["WORKSPACE" ] = self.WorkspaceDir\r
self._Macro["MODULE_NAME" ] = self.Name\r
+ self._Macro["MODULE_NAME_GUID" ] = self._GetUniqueBaseName()\r
self._Macro["MODULE_GUID" ] = self.Guid\r
self._Macro["MODULE_VERSION" ] = self.Version\r
self._Macro["MODULE_TYPE" ] = self.ModuleType\r
self._Macro["MODULE_BUILD_DIR" ] = self.BuildDir\r
self._Macro["OUTPUT_DIR" ] = self.OutputDir\r
self._Macro["DEBUG_DIR" ] = self.DebugDir\r
+ self._Macro["DEST_DIR_OUTPUT" ] = self.OutputDir\r
+ self._Macro["DEST_DIR_DEBUG" ] = self.DebugDir\r
+ self._Macro["PLATFORM_NAME" ] = self.PlatformInfo.Name\r
+ self._Macro["PLATFORM_GUID" ] = self.PlatformInfo.Guid\r
+ self._Macro["PLATFORM_VERSION" ] = self.PlatformInfo.Version\r
+ self._Macro["PLATFORM_RELATIVE_DIR" ] = self.PlatformInfo.SourceDir\r
+ self._Macro["PLATFORM_DIR" ] = mws.join(self.WorkspaceDir, self.PlatformInfo.SourceDir)\r
+ self._Macro["PLATFORM_OUTPUT_DIR" ] = self.PlatformInfo.OutputDir\r
+ self._Macro["FFS_OUTPUT_DIR" ] = self.FfsOutputDir\r
return self._Macro\r
\r
## Return the module build data object\r
CreateDirectory(self._OutputDir)\r
return self._OutputDir\r
\r
+ ## Return the directory to store ffs file\r
+ def _GetFfsOutputDir(self):\r
+ if self._FfsOutputDir == None:\r
+ if GlobalData.gFdfParser != None:\r
+ self._FfsOutputDir = path.join(self.PlatformInfo.BuildDir, "FV", "Ffs", self.Guid + self.Name)\r
+ else:\r
+ self._FfsOutputDir = ''\r
+ return self._FfsOutputDir\r
+\r
## Return the directory to store auto-gened source files of the mdoule\r
def _GetDebugDir(self):\r
if self._DebugDir == None:\r
for DepexExpresion in DepexExpresionList:\r
for key in DepexExpresion.keys():\r
Arch, ModuleType = key\r
+ DepexExpr = [x for x in DepexExpresion[key] if not str(x).startswith('#')]\r
# the type of build module is USER_DEFINED.\r
# All different DEPEX section tags would be copied into the As Built INF file\r
# and there would be separate DEPEX section tags\r
if self.ModuleType.upper() == SUP_MODULE_USER_DEFINED:\r
if (Arch.upper() == self.Arch.upper()) and (ModuleType.upper() != TAB_ARCH_COMMON):\r
- DepexList.append({(Arch, ModuleType): DepexExpresion[key][:]})\r
+ DepexList.append({(Arch, ModuleType): DepexExpr})\r
else:\r
if Arch.upper() == TAB_ARCH_COMMON or \\r
(Arch.upper() == self.Arch.upper() and \\r
ModuleType.upper() in [TAB_ARCH_COMMON, self.ModuleType.upper()]):\r
- DepexList.append({(Arch, ModuleType): DepexExpresion[key][:]})\r
+ DepexList.append({(Arch, ModuleType): DepexExpr})\r
\r
#the type of build module is USER_DEFINED.\r
if self.ModuleType.upper() == SUP_MODULE_USER_DEFINED:\r
self._DepexExpressionList[ModuleType] = DepexExpressionList\r
return self._DepexExpressionList\r
\r
+ # Get the tiano core user extension, it is contain dependent library.\r
+ # @retval: a list contain tiano core userextension.\r
+ #\r
+ def _GetTianoCoreUserExtensionList(self):\r
+ TianoCoreUserExtentionList = []\r
+ for M in [self.Module] + self.DependentLibraryList:\r
+ Filename = M.MetaFile.Path\r
+ InfObj = InfSectionParser.InfSectionParser(Filename)\r
+ TianoCoreUserExtenList = InfObj.GetUserExtensionTianoCore()\r
+ for TianoCoreUserExtent in TianoCoreUserExtenList:\r
+ for Section in TianoCoreUserExtent.keys():\r
+ ItemList = Section.split(TAB_SPLIT)\r
+ Arch = self.Arch\r
+ if len(ItemList) == 4:\r
+ Arch = ItemList[3]\r
+ if Arch.upper() == TAB_ARCH_COMMON or Arch.upper() == self.Arch.upper():\r
+ TianoCoreList = []\r
+ TianoCoreList.extend([TAB_SECTION_START + Section + TAB_SECTION_END])\r
+ TianoCoreList.extend(TianoCoreUserExtent[Section][:])\r
+ TianoCoreList.append('\n')\r
+ TianoCoreUserExtentionList.append(TianoCoreList)\r
+\r
+ return TianoCoreUserExtentionList\r
+\r
## Return the list of specification version required for the module\r
#\r
# @retval list The list of specification defined in module file\r
#\r
def _GetModuleBuildOption(self):\r
if self._BuildOption == None:\r
- self._BuildOption = self.PlatformInfo.ApplyBuildOption(self.Module)\r
+ self._BuildOption, self.BuildRuleOrder = self.PlatformInfo.ApplyBuildOption(self.Module)\r
+ if self.BuildRuleOrder:\r
+ self.BuildRuleOrder = ['.%s' % Ext for Ext in self.BuildRuleOrder.split()]\r
return self._BuildOption\r
\r
## Get include path list from tool option for the module build\r
# is the former use /I , the Latter used -I to specify include directories\r
#\r
if self.PlatformInfo.ToolChainFamily in ('MSFT'):\r
- gBuildOptIncludePattern = re.compile(r"(?:.*?)/I[ \t]*([^ ]*)", re.MULTILINE|re.DOTALL)\r
+ gBuildOptIncludePattern = re.compile(r"(?:.*?)/I[ \t]*([^ ]*)", re.MULTILINE | re.DOTALL)\r
elif self.PlatformInfo.ToolChainFamily in ('INTEL', 'GCC', 'RVCT'):\r
- gBuildOptIncludePattern = re.compile(r"(?:.*?)-I[ \t]*([^ ]*)", re.MULTILINE|re.DOTALL)\r
+ gBuildOptIncludePattern = re.compile(r"(?:.*?)-I[ \t]*([^ ]*)", re.MULTILINE | re.DOTALL)\r
else:\r
#\r
# New ToolChainFamily, don't known whether there is option to specify include directories\r
if self.AutoGenVersion >= 0x00010005 and len(IncPathList) > 0:\r
for Path in IncPathList:\r
if (Path not in self.IncludePathList) and (CommonPath([Path, self.MetaFile.Dir]) != self.MetaFile.Dir):\r
- ErrMsg = "The include directory for the EDK II module in this line is invalid %s specified in %s FLAGS '%s'" % (Path, Tool, FlagOption) \r
- EdkLogger.error("build", \r
+ ErrMsg = "The include directory for the EDK II module in this line is invalid %s specified in %s FLAGS '%s'" % (Path, Tool, FlagOption)\r
+ EdkLogger.error("build",\r
PARAMETER_INVALID,\r
- ExtraData = ErrMsg, \r
- File = str(self.MetaFile))\r
+ ExtraData=ErrMsg,\r
+ File=str(self.MetaFile))\r
\r
\r
BuildOptionIncPathList += IncPathList\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 not in ("", "*", self.ToolChainFamily):\r
+ # match tool chain family or build rule family\r
+ if F.ToolChainFamily not in ("", "*", self.ToolChainFamily, self.BuildRuleFamily):\r
EdkLogger.debug(\r
EdkLogger.DEBUG_0,\r
"The file [%s] must be built by tools of [%s], " \\r
- "but current toolchain family is [%s]" \\r
- % (str(F), F.ToolChainFamily, self.ToolChainFamily))\r
+ "but current toolchain family is [%s], buildrule family is [%s]" \\r
+ % (str(F), F.ToolChainFamily, self.ToolChainFamily, self.BuildRuleFamily))\r
continue\r
\r
# add the file path into search path list for file including\r
if F.Dir not in self.IncludePathList and self.AutoGenVersion >= 0x00010005:\r
self.IncludePathList.insert(0, F.Dir)\r
self._SourceFileList.append(F)\r
+\r
+ self._MatchBuildRuleOrder(self._SourceFileList)\r
+\r
+ for F in self._SourceFileList:\r
self._ApplyBuildRule(F, TAB_UNKNOWN_FILE)\r
return self._SourceFileList\r
\r
+ def _MatchBuildRuleOrder(self, FileList):\r
+ Order_Dict = {}\r
+ self._GetModuleBuildOption()\r
+ for SingleFile in FileList:\r
+ if self.BuildRuleOrder and SingleFile.Ext in self.BuildRuleOrder and SingleFile.Ext in self.BuildRules:\r
+ key = SingleFile.Path.split(SingleFile.Ext)[0]\r
+ if key in Order_Dict:\r
+ Order_Dict[key].append(SingleFile.Ext)\r
+ else:\r
+ Order_Dict[key] = [SingleFile.Ext]\r
+\r
+ RemoveList = []\r
+ for F in Order_Dict:\r
+ if len(Order_Dict[F]) > 1:\r
+ Order_Dict[F].sort(key=lambda i: self.BuildRuleOrder.index(i))\r
+ for Ext in Order_Dict[F][1:]:\r
+ RemoveList.append(F + Ext)\r
+ \r
+ for item in RemoveList:\r
+ FileList.remove(item)\r
+\r
+ return FileList\r
+\r
## Return the list of unicode files\r
def _GetUnicodeFileList(self):\r
if self._UnicodeFileList == None:\r
self._UnicodeFileList = []\r
return self._UnicodeFileList\r
\r
+ ## Return the list of vfr files\r
+ def _GetVfrFileList(self):\r
+ if self._VfrFileList == None:\r
+ if TAB_VFR_FILE in self.FileTypes:\r
+ self._VfrFileList = self.FileTypes[TAB_VFR_FILE]\r
+ else:\r
+ self._VfrFileList = []\r
+ return self._VfrFileList\r
+\r
+ ## Return the list of Image Definition files\r
+ def _GetIdfFileList(self):\r
+ if self._IdfFileList == None:\r
+ if TAB_IMAGE_FILE in self.FileTypes:\r
+ self._IdfFileList = self.FileTypes[TAB_IMAGE_FILE]\r
+ else:\r
+ self._IdfFileList = []\r
+ return self._IdfFileList\r
+\r
## Return a list of files which can be built from binary\r
#\r
# "Build" binary files are just to copy them to build directory.\r
RuleChain = []\r
SourceList = [File]\r
Index = 0\r
+ #\r
+ # Make sure to get build rule order value\r
+ #\r
+ self._GetModuleBuildOption()\r
+\r
while Index < len(SourceList):\r
Source = SourceList[Index]\r
Index = Index + 1\r
if File.IsBinary and File == Source and self._BinaryFileList != None and File in self._BinaryFileList:\r
# Skip all files that are not binary libraries\r
if not self.IsLibrary:\r
- continue \r
+ continue\r
RuleObject = self.BuildRules[TAB_DEFAULT_BINARY_FILE]\r
elif FileType in self.BuildRules:\r
RuleObject = self.BuildRules[FileType]\r
self._FinalBuildTargetList.add(LastTarget)\r
break\r
\r
- Target = RuleObject.Apply(Source)\r
+ Target = RuleObject.Apply(Source, self.BuildRuleOrder)\r
if not Target:\r
if LastTarget:\r
self._FinalBuildTargetList.add(LastTarget)\r
#\r
def _GetAutoGenFileList(self):\r
UniStringAutoGenC = True\r
+ IdfStringAutoGenC = True\r
UniStringBinBuffer = StringIO()\r
+ IdfGenBinBuffer = StringIO()\r
if self.BuildType == 'UEFI_HII':\r
UniStringAutoGenC = False\r
+ IdfStringAutoGenC = False\r
if self._AutoGenFileList == None:\r
self._AutoGenFileList = {}\r
AutoGenC = TemplateString()\r
AutoGenH = TemplateString()\r
StringH = TemplateString()\r
- GenC.CreateCode(self, AutoGenC, AutoGenH, StringH, UniStringAutoGenC, UniStringBinBuffer)\r
+ StringIdf = TemplateString()\r
+ GenC.CreateCode(self, AutoGenC, AutoGenH, StringH, UniStringAutoGenC, UniStringBinBuffer, StringIdf, IdfStringAutoGenC, IdfGenBinBuffer)\r
#\r
# AutoGen.c is generated if there are library classes in inf, or there are object files\r
#\r
self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r
if UniStringBinBuffer != None:\r
UniStringBinBuffer.close()\r
+ if str(StringIdf) != "":\r
+ AutoFile = PathClass(gAutoGenImageDefFileName % {"module_name":self.Name}, self.DebugDir)\r
+ self._AutoGenFileList[AutoFile] = str(StringIdf)\r
+ self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r
+ if IdfGenBinBuffer != None and IdfGenBinBuffer.getvalue() != "":\r
+ AutoFile = PathClass(gAutoGenIdfFileName % {"module_name":self.Name}, self.OutputDir)\r
+ self._AutoGenFileList[AutoFile] = IdfGenBinBuffer.getvalue()\r
+ AutoFile.IsBinary = True\r
+ self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r
+ if IdfGenBinBuffer != None:\r
+ IdfGenBinBuffer.close()\r
return self._AutoGenFileList\r
\r
## Return the list of library modules explicitly or implicityly used by this module\r
#\r
def _GetGuidList(self):\r
if self._GuidList == None:\r
- self._GuidList = self.Module.Guids\r
+ self._GuidList = sdict()\r
+ self._GuidList.update(self.Module.Guids)\r
for Library in self.DependentLibraryList:\r
self._GuidList.update(Library.Guids)\r
self.UpdateComments(self._GuidComments, Library.GuidComments)\r
#\r
def _GetProtocolList(self):\r
if self._ProtocolList == None:\r
- self._ProtocolList = self.Module.Protocols\r
+ self._ProtocolList = sdict()\r
+ self._ProtocolList.update(self.Module.Protocols)\r
for Library in self.DependentLibraryList:\r
self._ProtocolList.update(Library.Protocols)\r
self.UpdateComments(self._ProtocolComments, Library.ProtocolComments)\r
#\r
def _GetPpiList(self):\r
if self._PpiList == None:\r
- self._PpiList = self.Module.Ppis\r
+ self._PpiList = sdict()\r
+ self._PpiList.update(self.Module.Ppis)\r
for Library in self.DependentLibraryList:\r
self._PpiList.update(Library.Ppis)\r
self.UpdateComments(self._PpiComments, Library.PpiComments)\r
self._IncludePathList.append(self.DebugDir)\r
\r
for Package in self.Module.Packages:\r
- PackageDir = path.join(self.WorkspaceDir, Package.MetaFile.Dir)\r
+ PackageDir = mws.join(self.WorkspaceDir, Package.MetaFile.Dir)\r
if PackageDir not in self._IncludePathList:\r
self._IncludePathList.append(PackageDir)\r
- for Inc in Package.Includes:\r
+ IncludesList = Package.Includes\r
+ if Package._PrivateIncludes:\r
+ if not self.MetaFile.Path.startswith(PackageDir):\r
+ IncludesList = list(set(Package.Includes).difference(set(Package._PrivateIncludes)))\r
+ for Inc in IncludesList:\r
if Inc not in self._IncludePathList:\r
self._IncludePathList.append(str(Inc))\r
return self._IncludePathList\r
\r
+ def _GetIncludePathLength(self):\r
+ self._IncludePathLength = 0\r
+ if self._IncludePathList:\r
+ for inc in self._IncludePathList:\r
+ self._IncludePathLength += len(' ' + inc)\r
+ return self._IncludePathLength\r
+\r
## Get HII EX PCDs which maybe used by VFR\r
#\r
# efivarstore used by VFR may relate with HII EX PCDs\r
for SkuName in Pcd.SkuInfoList:\r
SkuInfo = Pcd.SkuInfoList[SkuName]\r
Name = ConvertStringToByteArray(SkuInfo.VariableName)\r
- Value = GuidValue(SkuInfo.VariableGuid, self.PlatformInfo.PackageList)\r
+ Value = GuidValue(SkuInfo.VariableGuid, self.PlatformInfo.PackageList, self.MetaFile.Path)\r
if not Value:\r
continue\r
Guid = GuidStructureStringToGuidString(Value)\r
\r
return HiiExPcds\r
\r
+ def _GenOffsetBin(self):\r
+ VfrUniBaseName = {}\r
+ for SourceFile in self.Module.Sources:\r
+ if SourceFile.Type.upper() == ".VFR" :\r
+ #\r
+ # search the .map file to find the offset of vfr binary in the PE32+/TE file. \r
+ #\r
+ VfrUniBaseName[SourceFile.BaseName] = (SourceFile.BaseName + "Bin")\r
+ if SourceFile.Type.upper() == ".UNI" :\r
+ #\r
+ # search the .map file to find the offset of Uni strings binary in the PE32+/TE file. \r
+ #\r
+ VfrUniBaseName["UniOffsetName"] = (self.Name + "Strings")\r
+\r
+ if len(VfrUniBaseName) == 0:\r
+ return None\r
+ MapFileName = os.path.join(self.OutputDir, self.Name + ".map")\r
+ EfiFileName = os.path.join(self.OutputDir, self.Name + ".efi")\r
+ VfrUniOffsetList = GetVariableOffset(MapFileName, EfiFileName, VfrUniBaseName.values())\r
+ if not VfrUniOffsetList:\r
+ return None\r
+\r
+ OutputName = '%sOffset.bin' % self.Name\r
+ UniVfrOffsetFileName = os.path.join( self.OutputDir, OutputName)\r
+\r
+ try:\r
+ fInputfile = open(UniVfrOffsetFileName, "wb+", 0)\r
+ except:\r
+ EdkLogger.error("build", FILE_OPEN_FAILURE, "File open failed for %s" % UniVfrOffsetFileName,None)\r
+\r
+ # Use a instance of StringIO to cache data\r
+ fStringIO = StringIO('') \r
+\r
+ for Item in VfrUniOffsetList:\r
+ if (Item[0].find("Strings") != -1):\r
+ #\r
+ # UNI offset in image.\r
+ # GUID + Offset\r
+ # { 0x8913c5e0, 0x33f6, 0x4d86, { 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66 } }\r
+ #\r
+ UniGuid = [0xe0, 0xc5, 0x13, 0x89, 0xf6, 0x33, 0x86, 0x4d, 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66]\r
+ UniGuid = [chr(ItemGuid) for ItemGuid in UniGuid]\r
+ fStringIO.write(''.join(UniGuid)) \r
+ UniValue = pack ('Q', int (Item[1], 16))\r
+ fStringIO.write (UniValue)\r
+ else:\r
+ #\r
+ # VFR binary offset in image.\r
+ # GUID + Offset\r
+ # { 0xd0bc7cb4, 0x6a47, 0x495f, { 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2 } };\r
+ #\r
+ VfrGuid = [0xb4, 0x7c, 0xbc, 0xd0, 0x47, 0x6a, 0x5f, 0x49, 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2]\r
+ VfrGuid = [chr(ItemGuid) for ItemGuid in VfrGuid]\r
+ fStringIO.write(''.join(VfrGuid)) \r
+ type (Item[1]) \r
+ VfrValue = pack ('Q', int (Item[1], 16))\r
+ fStringIO.write (VfrValue)\r
+ #\r
+ # write data into file.\r
+ #\r
+ try : \r
+ fInputfile.write (fStringIO.getvalue())\r
+ except:\r
+ EdkLogger.error("build", FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the "\r
+ "file been locked or using by other applications." %UniVfrOffsetFileName,None)\r
+\r
+ fStringIO.close ()\r
+ fInputfile.close ()\r
+ return OutputName\r
+\r
## Create AsBuilt INF file the module\r
#\r
def CreateAsBuiltInf(self):\r
# Find all DynamicEx and PatchableInModule PCDs used by this module and dependent libraries\r
# Also find all packages that the DynamicEx PCDs depend on\r
Pcds = []\r
- PatchablePcds = {}\r
- Packages = [] \r
+ PatchablePcds = []\r
+ Packages = []\r
PcdCheckList = []\r
PcdTokenSpaceList = []\r
for Pcd in self.ModulePcdList + self.LibraryPcdList:\r
if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:\r
- PatchablePcds[Pcd.TokenCName] = Pcd\r
+ PatchablePcds += [Pcd]\r
PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'PatchableInModule'))\r
elif Pcd.Type in GenC.gDynamicExPcd:\r
if Pcd not in Pcds:\r
'module_uefi_hii_resource_section' : [MDefs['UEFI_HII_RESOURCE_SECTION']] if 'UEFI_HII_RESOURCE_SECTION' in MDefs else [],\r
'module_uni_file' : [MDefs['MODULE_UNI_FILE']] if 'MODULE_UNI_FILE' in MDefs else [],\r
'module_arch' : self.Arch,\r
- 'package_item' : ['%s' % (Package.MetaFile.File.replace('\\','/')) for Package in Packages],\r
+ 'package_item' : ['%s' % (Package.MetaFile.File.replace('\\', '/')) for Package in Packages],\r
'binary_item' : [],\r
'patchablepcd_item' : [],\r
'pcd_item' : [],\r
'libraryclasses_item' : []\r
}\r
\r
+ if 'MODULE_UNI_FILE' in MDefs:\r
+ UNIFile = os.path.join(self.MetaFile.Dir, MDefs['MODULE_UNI_FILE'])\r
+ if os.path.isfile(UNIFile):\r
+ shutil.copy2(UNIFile, self.OutputDir)\r
+\r
if self.AutoGenVersion > int(gInfSpecVersion, 0):\r
AsBuiltInfDict['module_inf_version'] = '0x%08x' % self.AutoGenVersion\r
else:\r
AsBuiltInfDict['pcd_is_driver_string'] += [DriverType]\r
\r
if 'UEFI_SPECIFICATION_VERSION' in self.Specification:\r
- AsBuiltInfDict['module_uefi_specification_version'] += [self.Specification['UEFI_SPECIFICATION_VERSION']]\r
+ AsBuiltInfDict['module_uefi_specification_version'] += [self.Specification['UEFI_SPECIFICATION_VERSION']]\r
if 'PI_SPECIFICATION_VERSION' in self.Specification:\r
- AsBuiltInfDict['module_pi_specification_version'] += [self.Specification['PI_SPECIFICATION_VERSION']]\r
-\r
- OutputDir = self.OutputDir.replace('\\','/').strip('/')\r
- if self.ModuleType in ['BASE', 'USER_DEFINED']:\r
- for Item in self.CodaTargetList:\r
- File = Item.Target.Path.replace('\\','/').strip('/').replace(OutputDir,'').strip('/')\r
- if Item.Target.Ext.lower() == '.aml': \r
- AsBuiltInfDict['binary_item'] += ['ASL|' + File]\r
- elif Item.Target.Ext.lower() == '.acpi': \r
- AsBuiltInfDict['binary_item'] += ['ACPI|' + File]\r
- else:\r
- AsBuiltInfDict['binary_item'] += ['BIN|' + File]\r
- else:\r
- for Item in self.CodaTargetList:\r
- File = Item.Target.Path.replace('\\','/').strip('/').replace(OutputDir,'').strip('/')\r
- if Item.Target.Ext.lower() == '.efi': \r
- AsBuiltInfDict['binary_item'] += ['PE32|' + self.Name + '.efi']\r
+ AsBuiltInfDict['module_pi_specification_version'] += [self.Specification['PI_SPECIFICATION_VERSION']]\r
+\r
+ OutputDir = self.OutputDir.replace('\\', '/').strip('/')\r
+ self.OutputFile = []\r
+ for Item in self.CodaTargetList:\r
+ File = Item.Target.Path.replace('\\', '/').strip('/').replace(OutputDir, '').strip('/')\r
+ if File not in self.OutputFile:\r
+ self.OutputFile.append(File)\r
+ if Item.Target.Ext.lower() == '.aml':\r
+ AsBuiltInfDict['binary_item'] += ['ASL|' + File]\r
+ elif Item.Target.Ext.lower() == '.acpi':\r
+ AsBuiltInfDict['binary_item'] += ['ACPI|' + File]\r
+ elif Item.Target.Ext.lower() == '.efi':\r
+ AsBuiltInfDict['binary_item'] += ['PE32|' + self.Name + '.efi']\r
else:\r
- AsBuiltInfDict['binary_item'] += ['BIN|' + File]\r
- if self.DepexGenerated:\r
+ AsBuiltInfDict['binary_item'] += ['BIN|' + File]\r
+ if self.DepexGenerated:\r
+ if self.Name + '.depex' not in self.OutputFile:\r
+ self.OutputFile.append(self.Name + '.depex')\r
if self.ModuleType in ['PEIM']:\r
- AsBuiltInfDict['binary_item'] += ['PEI_DEPEX|' + self.Name + '.depex']\r
- if self.ModuleType in ['DXE_DRIVER','DXE_RUNTIME_DRIVER','DXE_SAL_DRIVER','UEFI_DRIVER']:\r
- AsBuiltInfDict['binary_item'] += ['DXE_DEPEX|' + self.Name + '.depex']\r
+ AsBuiltInfDict['binary_item'] += ['PEI_DEPEX|' + self.Name + '.depex']\r
+ if self.ModuleType in ['DXE_DRIVER', 'DXE_RUNTIME_DRIVER', 'DXE_SAL_DRIVER', 'UEFI_DRIVER']:\r
+ AsBuiltInfDict['binary_item'] += ['DXE_DEPEX|' + self.Name + '.depex']\r
if self.ModuleType in ['DXE_SMM_DRIVER']:\r
- AsBuiltInfDict['binary_item'] += ['SMM_DEPEX|' + self.Name + '.depex']\r
+ AsBuiltInfDict['binary_item'] += ['SMM_DEPEX|' + self.Name + '.depex']\r
+\r
+ Bin = self._GenOffsetBin()\r
+ if Bin:\r
+ AsBuiltInfDict['binary_item'] += ['BIN|%s' % Bin]\r
+ if Bin not in self.OutputFile:\r
+ self.OutputFile.append(Bin)\r
\r
for Root, Dirs, Files in os.walk(OutputDir):\r
for File in Files:\r
if File.lower().endswith('.pdb'):\r
AsBuiltInfDict['binary_item'] += ['DISPOSABLE|' + File]\r
+ if File not in self.OutputFile:\r
+ self.OutputFile.append(File)\r
HeaderComments = self.Module.HeaderComments\r
StartPos = 0\r
for Index in range(len(HeaderComments)):\r
os.path.join(self.OutputDir, self.Name + '.efi')\r
)\r
if PatchList:\r
- for PatchPcd in PatchList:\r
- if PatchPcd[0] not in PatchablePcds:\r
+ for Pcd in PatchablePcds:\r
+ TokenCName = Pcd.TokenCName\r
+ for PcdItem in GlobalData.MixedPcd:\r
+ if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:\r
+ TokenCName = PcdItem[0]\r
+ break\r
+ for PatchPcd in PatchList:\r
+ if TokenCName == PatchPcd[0]:\r
+ break\r
+ else:\r
continue\r
- Pcd = PatchablePcds[PatchPcd[0]]\r
PcdValue = ''\r
+ if Pcd.DatumType == 'BOOLEAN':\r
+ BoolValue = Pcd.DefaultValue.upper()\r
+ if BoolValue == 'TRUE':\r
+ Pcd.DefaultValue = '1'\r
+ elif BoolValue == 'FALSE':\r
+ Pcd.DefaultValue = '0'\r
+\r
if Pcd.DatumType != 'VOID*':\r
HexFormat = '0x%02x'\r
if Pcd.DatumType == 'UINT16':\r
else:\r
if Pcd.MaxDatumSize == None or Pcd.MaxDatumSize == '':\r
EdkLogger.error("build", AUTOGEN_ERROR,\r
- "Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
+ "Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd.TokenSpaceGuidCName, TokenCName)\r
)\r
ArraySize = int(Pcd.MaxDatumSize, 0)\r
PcdValue = Pcd.DefaultValue\r
ArraySize = ArraySize / 2\r
if ArraySize < (len(PcdValue) + 1):\r
EdkLogger.error("build", AUTOGEN_ERROR,\r
- "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
+ "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName)\r
)\r
if ArraySize > len(PcdValue) + 1:\r
NewValue = NewValue + Padding * (ArraySize - len(PcdValue) - 1)\r
PcdValue += '}'\r
else:\r
EdkLogger.error("build", AUTOGEN_ERROR,\r
- "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
+ "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName)\r
)\r
PcdItem = '%s.%s|%s|0x%X' % \\r
- (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, PcdValue, PatchPcd[1])\r
+ (Pcd.TokenSpaceGuidCName, TokenCName, PcdValue, PatchPcd[1])\r
PcdComments = ''\r
if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdComments:\r
PcdComments = '\n '.join(self._PcdComments[Pcd.TokenSpaceGuidCName, Pcd.TokenCName])\r
PcdCommentList = []\r
HiiInfo = ''\r
SkuId = ''\r
+ TokenCName = Pcd.TokenCName\r
+ for PcdItem in GlobalData.MixedPcd:\r
+ if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:\r
+ TokenCName = PcdItem[0]\r
+ break\r
if Pcd.Type == TAB_PCDS_DYNAMIC_EX_HII:\r
for SkuName in Pcd.SkuInfoList:\r
SkuInfo = Pcd.SkuInfoList[SkuName]\r
else:\r
PcdCommentList.append('## UNDEFINED ' + HiiInfo)\r
PcdComments = '\n '.join(PcdCommentList)\r
- PcdEntry = Pcd.TokenSpaceGuidCName + '.' + Pcd.TokenCName\r
+ PcdEntry = Pcd.TokenSpaceGuidCName + '.' + TokenCName\r
if PcdComments:\r
PcdEntry = PcdComments + '\n ' + PcdEntry\r
AsBuiltInfDict['pcd_item'] += [PcdEntry]\r
for Item in self.BuildOption:\r
- if 'FLAGS' in self.BuildOption[Item]:\r
- AsBuiltInfDict['flags_item'] += ['%s:%s_%s_%s_%s_FLAGS = %s' % (self.ToolChainFamily, self.BuildTarget, self.ToolChain, self.Arch, Item, self.BuildOption[Item]['FLAGS'].strip())]\r
+ if 'FLAGS' in self.BuildOption[Item]:\r
+ AsBuiltInfDict['flags_item'] += ['%s:%s_%s_%s_%s_FLAGS = %s' % (self.ToolChainFamily, self.BuildTarget, self.ToolChain, self.Arch, Item, self.BuildOption[Item]['FLAGS'].strip())]\r
\r
# Generated LibraryClasses section in comments.\r
for Library in self.LibraryAutoGenList:\r
AsBuiltInfDict['libraryclasses_item'] += [Library.MetaFile.File.replace('\\', '/')]\r
\r
+ # Generated UserExtensions TianoCore section.\r
+ # All tianocore user extensions are copied.\r
+ UserExtStr = ''\r
+ for TianoCore in self._GetTianoCoreUserExtensionList():\r
+ UserExtStr += '\n'.join(TianoCore)\r
+ ExtensionFile = os.path.join(self.MetaFile.Dir, TianoCore[1])\r
+ if os.path.isfile(ExtensionFile):\r
+ shutil.copy2(ExtensionFile, self.OutputDir)\r
+ AsBuiltInfDict['userextension_tianocore_item'] = UserExtStr\r
+\r
# Generated depex expression section in comments.\r
AsBuiltInfDict['depexsection_item'] = ''\r
DepexExpresion = self._GetDepexExpresionString()\r
SaveFileOnChange(os.path.join(self.OutputDir, self.Name + '.inf'), str(AsBuiltInf), False)\r
\r
self.IsAsBuiltInfCreated = True\r
- \r
+ if GlobalData.gBinCacheDest:\r
+ self.CopyModuleToCache()\r
+\r
+ def CopyModuleToCache(self):\r
+ FileDir = path.join(GlobalData.gBinCacheDest, self.Arch, self.SourceDir, self.MetaFile.BaseName)\r
+ CreateDirectory (FileDir)\r
+ HashFile = path.join(self.BuildDir, self.Name + '.hash')\r
+ ModuleFile = path.join(self.OutputDir, self.Name + '.inf')\r
+ if os.path.exists(HashFile):\r
+ shutil.copy2(HashFile, FileDir)\r
+ if os.path.exists(ModuleFile):\r
+ shutil.copy2(ModuleFile, FileDir)\r
+ if self.OutputFile:\r
+ for File in self.OutputFile:\r
+ if not os.path.isabs(File):\r
+ File = os.path.join(self.OutputDir, File)\r
+ if os.path.exists(File):\r
+ shutil.copy2(File, FileDir)\r
+\r
+ def AttemptModuleCacheCopy(self):\r
+ if self.IsBinaryModule:\r
+ return False\r
+ FileDir = path.join(GlobalData.gBinCacheSource, self.Arch, self.SourceDir, self.MetaFile.BaseName)\r
+ HashFile = path.join(FileDir, self.Name + '.hash')\r
+ if os.path.exists(HashFile):\r
+ f = open(HashFile, 'r')\r
+ CacheHash = f.read()\r
+ f.close()\r
+ if GlobalData.gModuleHash[self.Arch][self.Name]:\r
+ if CacheHash == GlobalData.gModuleHash[self.Arch][self.Name]:\r
+ for root, dir, files in os.walk(FileDir):\r
+ for f in files:\r
+ if self.Name + '.hash' in f:\r
+ shutil.copy2(HashFile, self.BuildDir)\r
+ else:\r
+ File = path.join(root, f)\r
+ shutil.copy2(File, self.OutputDir)\r
+ if self.Name == "PcdPeim" or self.Name == "PcdDxe":\r
+ CreatePcdDatabaseCode(self, TemplateString(), TemplateString())\r
+ return True\r
+ return False\r
+\r
## Create makefile for the module and its dependent libraries\r
#\r
# @param CreateLibraryMakeFile Flag indicating if or not the makefiles of\r
# dependent libraries will be created\r
#\r
- def CreateMakeFile(self, CreateLibraryMakeFile=True):\r
+ def CreateMakeFile(self, CreateLibraryMakeFile=True, GenFfsList = []):\r
# Ignore generating makefile when it is a binary module\r
if self.IsBinaryModule:\r
return\r
\r
if self.IsMakeFileCreated:\r
return\r
-\r
+ self.GenFfsList = GenFfsList\r
if not self.IsLibrary and CreateLibraryMakeFile:\r
for LibraryAutoGen in self.LibraryAutoGenList:\r
LibraryAutoGen.CreateMakeFile()\r
\r
+ if self.CanSkip():\r
+ return\r
+\r
if len(self.CustomMakefile) == 0:\r
Makefile = GenMake.ModuleMakefile(self)\r
else:\r
EdkLogger.debug(EdkLogger.DEBUG_9, "Skipped the generation of makefile for module %s [%s]" %\r
(self.Name, self.Arch))\r
\r
+ self.CreateTimeStamp(Makefile)\r
self.IsMakeFileCreated = True\r
\r
def CopyBinaryFiles(self):\r
CreatePcdDatabaseCode(self, TemplateString(), TemplateString())\r
return\r
if self.IsBinaryModule:\r
- self.CopyBinaryFiles()\r
+ if self.IsLibrary:\r
+ self.CopyBinaryFiles()\r
return\r
\r
if not self.IsLibrary and CreateLibraryCodeFile:\r
for LibraryAutoGen in self.LibraryAutoGenList:\r
LibraryAutoGen.CreateCodeFile()\r
\r
+ if self.CanSkip():\r
+ return\r
+\r
AutoGenList = []\r
IgoredAutoGenList = []\r
\r
self._ApplyBuildRule(Lib.Target, TAB_UNKNOWN_FILE)\r
return self._LibraryAutoGenList\r
\r
+ def GenModuleHash(self):\r
+ if self.Arch not in GlobalData.gModuleHash:\r
+ GlobalData.gModuleHash[self.Arch] = {}\r
+ m = hashlib.md5()\r
+ # Add Platform level hash\r
+ m.update(GlobalData.gPlatformHash)\r
+ # Add Package level hash\r
+ if self.DependentPackageList:\r
+ for Pkg in self.DependentPackageList:\r
+ if Pkg.PackageName in GlobalData.gPackageHash[self.Arch]:\r
+ m.update(GlobalData.gPackageHash[self.Arch][Pkg.PackageName])\r
+\r
+ # Add Library hash\r
+ if self.LibraryAutoGenList:\r
+ for Lib in self.LibraryAutoGenList:\r
+ if Lib.Name not in GlobalData.gModuleHash[self.Arch]:\r
+ Lib.GenModuleHash()\r
+ m.update(GlobalData.gModuleHash[self.Arch][Lib.Name])\r
+\r
+ # Add Module self\r
+ f = open(str(self.MetaFile), 'r')\r
+ Content = f.read()\r
+ f.close()\r
+ m.update(Content)\r
+ # Add Module's source files\r
+ if self.SourceFileList:\r
+ for File in self.SourceFileList:\r
+ f = open(str(File), 'r')\r
+ Content = f.read()\r
+ f.close()\r
+ m.update(Content)\r
+\r
+ ModuleHashFile = path.join(self.BuildDir, self.Name + ".hash")\r
+ if self.Name not in GlobalData.gModuleHash[self.Arch]:\r
+ GlobalData.gModuleHash[self.Arch][self.Name] = m.hexdigest()\r
+ if GlobalData.gBinCacheSource:\r
+ CacheValid = self.AttemptModuleCacheCopy()\r
+ if CacheValid:\r
+ return False\r
+ return SaveFileOnChange(ModuleHashFile, m.hexdigest(), True)\r
+\r
+ ## Decide whether we can skip the ModuleAutoGen process\r
+ def CanSkipbyHash(self):\r
+ if GlobalData.gUseHashCache:\r
+ return not self.GenModuleHash()\r
+\r
+ ## Decide whether we can skip the ModuleAutoGen process\r
+ # If any source file is newer than the module than we cannot skip\r
+ #\r
+ def CanSkip(self):\r
+ if not os.path.exists(self.GetTimeStampPath()):\r
+ return False\r
+ #last creation time of the module\r
+ DstTimeStamp = os.stat(self.GetTimeStampPath())[8]\r
+\r
+ SrcTimeStamp = self.Workspace._SrcTimeStamp\r
+ if SrcTimeStamp > DstTimeStamp:\r
+ return False\r
+\r
+ with open(self.GetTimeStampPath(),'r') as f:\r
+ for source in f:\r
+ source = source.rstrip('\n')\r
+ if not os.path.exists(source):\r
+ return False\r
+ if source not in ModuleAutoGen.TimeDict :\r
+ ModuleAutoGen.TimeDict[source] = os.stat(source)[8]\r
+ if ModuleAutoGen.TimeDict[source] > DstTimeStamp:\r
+ return False\r
+ return True\r
+\r
+ def GetTimeStampPath(self):\r
+ if self._TimeStampPath == None:\r
+ self._TimeStampPath = os.path.join(self.MakeFileDir, 'AutoGenTimeStamp')\r
+ return self._TimeStampPath\r
+ def CreateTimeStamp(self, Makefile):\r
+\r
+ FileSet = set()\r
+\r
+ FileSet.add (self.MetaFile.Path)\r
+\r
+ for SourceFile in self.Module.Sources:\r
+ FileSet.add (SourceFile.Path)\r
+\r
+ for Lib in self.DependentLibraryList:\r
+ FileSet.add (Lib.MetaFile.Path)\r
+\r
+ for f in self.AutoGenDepSet:\r
+ FileSet.add (f.Path)\r
+\r
+ if os.path.exists (self.GetTimeStampPath()):\r
+ os.remove (self.GetTimeStampPath())\r
+ with open(self.GetTimeStampPath(), 'w+') as file:\r
+ for f in FileSet:\r
+ print >> file, f\r
+\r
Module = property(_GetModule)\r
Name = property(_GetBaseName)\r
Guid = property(_GetGuid)\r
IsBinaryModule = property(_IsBinaryModule)\r
BuildDir = property(_GetBuildDir)\r
OutputDir = property(_GetOutputDir)\r
+ FfsOutputDir = property(_GetFfsOutputDir)\r
DebugDir = property(_GetDebugDir)\r
MakeFileDir = property(_GetMakeFileDir)\r
CustomMakefile = property(_GetCustomMakefile)\r
\r
IncludePathList = property(_GetIncludePathList)\r
+ IncludePathLength = property(_GetIncludePathLength)\r
AutoGenFileList = property(_GetAutoGenFileList)\r
UnicodeFileList = property(_GetUnicodeFileList)\r
+ VfrFileList = property(_GetVfrFileList)\r
SourceFileList = property(_GetSourceFileList)\r
BinaryFileList = property(_GetBinaryFiles) # FileType : [File List]\r
Targets = property(_GetTargets)\r
CodaTargetList = property(_GetFinalTargetList)\r
FileTypes = property(_GetFileTypes)\r
BuildRules = property(_GetBuildRules)\r
+ IdfFileList = property(_GetIdfFileList)\r
\r
DependentPackageList = property(_GetDependentPackageList)\r
DependentLibraryList = property(_GetLibraryList)\r